把大脑接上纸Plugging the Brain into Paper
发布于 2026-11-10Published 2026-11-10
今日深读Today's Deep Read
写作是把大脑从有限自动机升级成图灵机Writing Upgrades the Brain from Finite Automaton to Turing Machine
中学时,我读不完任何一篇长文。眼睛扫过一整页,脑子里什么也没留下。绝望之下我开始做笔记——八十年代末,思维导图刚传到土耳其,我画出成页成页蜘蛛网。那些笔记帮了我大忙:为了决定一个念头该挂在哪根枝上,我必须先把它想清楚。多年后我才明白,那些纸不是用来存信息的,而是用来处理信息的。In middle school I could not get through a long passage. I would read an entire page and register nothing. Out of desperation I started taking notes. This was the late eighties, mind maps had just reached Turkey, and I produced pages and pages of spiderwebs. Those notes helped enormously: to decide which branch an idea belonged to, I first had to make sense of the idea. It took me years to understand that the pages were never a storage device. They were a processing device.
又过了十年,我在博士阶段的拖延里读到 Manuel Blum 给研究生的建议。他说,你们都知道有限自动机能做什么,也知道图灵机能做什么:有限自动机能加不能乘,图灵机能计算任何可计算函数。两者唯一的区别,是图灵机有纸和笔。没有书写,你被降级成一个有限自动机;有了书写,你才拥有图灵机那种力量。A decade later, while procrastinating on my PhD, I came across Manuel Blum's advice to graduate students. You all know what a finite automaton can do, he said, and what a Turing machine can do. A finite automaton can add but not multiply; a Turing machine can compute any computable function. The only difference between them is that the Turing machine has paper and pencil. Without writing you are reduced to a finite automaton. With it you inherit the extraordinary power of a Turing machine.
这不是修辞,而是一个关于“你能解什么题”的技术断言。写作把思考搬到外部,就像内存不够时把数据换出到磁盘——out-of-core execution。我们因此能想比脑子容量更大的东西。我自己最清楚的例子是审稿:读一遍论文,我以为自己懂了;坐下来写审稿意见,才发现大概只懂了六成。写着写着,剩下的四成被逼出来,有时还会看见作者自己没发现的联系。2018 年我随手写了一篇比较 Paxos 与中本聪共识的短文,主题是写着写着长出来的,后来成了一篇论文的种子。That is not a metaphor. It is a technical claim about which problems you can solve. Writing moves thinking outside the head, the way an algorithm swaps data to disk when memory runs out: out-of-core execution. It lets us think thoughts larger than our skulls. My clearest example is reviewing papers. I read one and believe I understand it; then I sit down to write the review and discover I understood about sixty percent. Writing forces out the rest, and sometimes reveals connections the authors missed. In 2018 I dashed off a short post comparing Paxos with Nakamoto consensus. The thesis was not planned; it grew while I wrote, and became the seed of a research paper.
写作也是我唯一记得住东西的原因。我常回头翻自己的博客;因为当初费劲写下来,重读时理解很快就重建起来。没写下来的念头留不住,因为它们从来没有被真正想完。Leslie Lamport 说得更狠:不写,你只是以为自己在思考。Writing is also the only reason I remember anything. I consult my own blog constantly. Because I strained to write those posts, rereading them re-fires the same circuits and the understanding comes back quickly. Thoughts I never wrote down do not stick, because they were never fully thought. Leslie Lamport put it more sharply: if you think without writing, you only think you are thinking.
那么,在 LLM 时代,这套还成立吗?有人会说:模型已经读过一切,你还需要写吗?我的回答是:模型读过一切,唯独没读过你脑子里那点半成品的直觉。它知道文献和共识,却不知道你为什么觉得它们在这个案例上不适用。创造性的跳跃,它替不了。所以,一遇到问题就打开聊天框,你失去的正是自己写、自己想的机会。So does any of this survive the LLM? The objection is obvious: the model has read everything, so why write? My answer is that the model has read everything except the half-formed intuition in your head. It knows the literature, the standard framing, the consensus. It does not know why you suspect the standard framing is wrong for this particular case. It cannot make that creative leap for you. Open the chat box the moment a question appears, and you give up the chance to write and think for yourself.
更麻烦的是,这种损失看起来不像损失。亚马逊的六页备忘录一直被当作“写作逼你想清楚”的样板。可是有了 LLM,这句话不再成立:你完全可以产出六页毫无思考的文字,而它看起来仍然像思考过的证据。What makes the loss hard to see is that it does not look like a loss. Amazon's six-page memo has long been celebrated as proof that writing forces clarity. With an LLM, that claim stops being true. You can produce six pages with no thinking at all, and the pages still look like evidence that thinking happened.
于是写作反而成了一种比较优势,而且在扩大。当所有人都把思考调低、变成生成文本的肉身代理,仍然自己动笔的人就仍然在为自己思考。具体怎么做?先乱写,别评判、别改错字,把笔记文件当实验记录本,保护还很脆弱的想法;再收拾,假装是别人写的,像删代码一样删句子;写得简单朴素,复杂往往是藏拙;为自己写,观众首先是你自己,奇怪的是这样反而会有读者;最后,把写作排进日程,等灵感不如坐下。Writing therefore becomes a comparative advantage, and a widening one. As everyone else turns their thinking down and becomes a meat proxy for generated text, the person who still holds the pen is still thinking for themselves. The practical advice is fivefold. Mess up first: no judgment, no typo fixes, treat the notes file as a lab notebook and protect the fragile idea. Then tidy up: pretend someone else wrote it, cut sentences the way you cut code. Keep it plain, because complexity is usually where sloppy thinking hides. Write for yourself; the audience is you, and paradoxically that is how readers arrive. And put it on a schedule, because waiting for inspiration is not a method.
这些方法之所以有效,是因为写作让你慢下来,却又把你按在问题上;多出来的时间里,联系才有机会浮上来。编辑则是那个魔术,让你假装自己一开始就想得很有条理。The reason it works is that writing slows you down while keeping you on the problem. In that extra time, connections surface. Editing is the magic trick that lets you pretend you had an organized thought all along.
所以,写作不是思考的产出,而是思考的机器。AI 可以替你打字,能在你卡住时递个词;但它不能替你长出那个只属于你的、半成形的直觉。那卷纸,还是得你自己接上。Writing, then, is not the output of thought. It is the machine. AI can type for you, polish for you, hand you a word when you are stuck. It cannot grow the half-formed intuition that belongs only to you. You still have to connect the paper yourself.
AI 思考AI Thoughts
- 我为什么不用 LLM 写代码:一个懂机器学习的开发者的六条理由Why I Won't Use LLMs for My Code: Six Reasons from an ML-Literate Developer
- 先把问题摆正:这不是“AI 能不能写代码”的技术问题,而是“它把我变成了什么样的程序员”。作者一开始就声明自己懂机器学习,不是害怕新东西。Frame the question properly. This is not about whether AI can write code. It is about what kind of programmer it turns you into. The author states up front that he understands machine learning; this is not fear of novelty.
- 他给出六条私人理由:边生成边审查造成认知脑雾(并引用研究说过度依赖会削弱批判性投入);代码看起来漂亮却空洞、越写越长;维护成本转嫁给未来;他真心喜欢写代码;工具环境频繁变动;以及 GDPR、CLOUD Act 这类政治与合规问题。He offers six personal reasons: cognitive fog from generating and reviewing at the same time, backed by research on how over-reliance weakens critical engagement; code that looks polished but is hollow and bloated; maintenance costs pushed into the future; the fact that he genuinely enjoys writing code; constant churn in the tooling; and political and compliance issues such as GDPR and the CLOUD Act.
- 这些理由之所以站得住,是因为它们描述的是每天真实发生的成本,而不是对未来的猜测;而且成本落在写代码的人身上,不在演示视频里。The reasons hold because they describe costs that occur every day, not predictions about the future. And the costs land on the person writing the code, not in the demo video.
- 他并不要求别人也不用。这是个人边界,不是道德命令;他真正反对的是“AI 是必然趋势,所以你必须接受”的叙事。He does not ask anyone else to follow him. This is a personal boundary, not a moral command. What he argues against is the narrative that AI is inevitable and therefore must be accepted.
- 留给读者的问题:如果一项工具让你不再理解自己交付的东西,省下来的时间到底买到了什么?The question he leaves us with: if a tool makes you stop understanding what you ship, what exactly did the saved time buy?
- 让 GPT-4 翻译我的文章,我听见了自己的声音GPT-4 Translated My Post and I Heard My Own Voice
- antirez 一直用意大利语写博客。他想知道:如果让 GPT-4 把文章译成英语,出来的还是不是“他”。antirez has always blogged in Italian. He wanted to know whether GPT-4, translating a post into English, would still sound like him.
- 结果让他意外:译文读起来比他本人写的英语更像他自己。于是他开始追问一个更基本的问题——风格到底藏在词汇里,还是藏在句子的构造方式里?The result surprised him: the translation sounded more like him than his own English did. That pushed him toward a more basic question. Does style live in vocabulary, or in the way sentences are built?
- 这件事同时带来希望和不安。希望是语言不再成为思想传播的门槛;不安是“声音”居然可以被分离出来,交给另一台机器复现。The experiment produced hope and unease at once. The hope is that language stops being a barrier to sharing ideas. The unease is that a voice can apparently be separated from its owner and reproduced by another machine.
- 文章没有给出结论,只留下两个并存的愿望:希望机器能让更多人被听见,又害怕会说话的机器让人不再需要真正说话。The post reaches no conclusion. It leaves two wishes side by side: that machines let more people be heard, and that talking machines do not make real speech unnecessary.
- 读法:把它当成一次关于作者身份的实验,而不是翻译工具评测。它问的是,当表达可以被外包,署名还意味着什么。Read it as an experiment about authorship, not a translation-tool review. The question is what a byline means when expression can be outsourced.
- 二十个 AI 会话之后,我把工作队列放进了 gitAfter Twenty AI Sessions, I Put the Work Queue in Git
- 场景很具体:在终端里同时开 Claude Code 和 Codex,一个任务在等,你就开下一个;每个回复又带来澄清、追问和支线,最后二十个标签页一起争夺你的工作记忆。The scene is specific. You run Claude Code and Codex in a terminal. One task is waiting, so you start another. Each reply spawns clarifications, follow-ups and side quests, and soon twenty tabs are competing for your working memory.
- 作者把问题拆成两个:顺序(下一步做哪件)和上下文(做这件事时到底需要知道什么)。脑雾不是意志力问题,而是这两件事都没有外部承载。The author splits the problem in two: sequencing (what to do next) and context (what you actually need to know to do it). Brain fog is not a willpower failure. It is what happens when neither has an external home.
- 解法是把队列放进 git:每张票是仓库里的一个 markdown 文件,状态随提交保存。agent 按队列循环,研究新票、构建人类标记为安全的票、跑测试;碰到敏感代码就开分支先问,永不自动上生产。His fix is to put the queue in git. Every ticket is a markdown file next to the code, and the board's state is committed. An agent works the queue in cycles: research new tickets, build the ones a human marked safe, run tests. Anything sensitive goes on a branch and waits for a human. It never deploys to production.
- 人只面对一个“owner inbox”:脚本把等你判断的事项排成清单,一个由 git 重建的页面展示每张票做了什么、为什么。读一张卡,做决定,把卡放回队列。The human faces one owner inbox. A script reads the board and produces a prioritized list of items that need judgment, and a page rebuilt from git shows what was built and why. Read one card, decide, put it back.
- 最关键的动作是“关闭”:处理完就把上下文关掉,下一件才能真正专注。他仍会觉得累,但不再迷失;真正的难点是工具还不够好,票据容易卡在“只等你裁决”的循环里。The crucial move is closing. Once an item is handled, its context is closed, so the next item gets real attention. It is still tiring, but no longer disorienting. The remaining difficulty is tooling: tickets can get stuck in loops that only a human ruling can break.
- AI 时代,本科数学该教“检查”而不只是“计算”In the AI Era, Undergraduate Math Should Teach Checking, Not Just Computing
- 背景问题很直接:AI 能瞬间完成计算、给出证明、生成例子,本科数学还剩下什么可教?作者的回答不是“少教数学”,而是换一个重心。The question is blunt: if AI can compute, prove and generate examples instantly, what is left for undergraduate mathematics to teach? The authors do not answer 'less math.' They propose a different center of gravity.
- 核心主张:把课程从“执行计算”移向“解释、检查、交流”——读懂一个结果,判断它是否可信,把它清楚地讲给别人听。Their claim is that courses should move from executing computations toward interpreting, checking and communicating: reading a result, judging whether it is trustworthy, and explaining it clearly to someone else.
- 为什么可行:本科训练本来就不要求你产出新定理,大多数时候是在验证已知结论、理解证明的结构;AI 只是把“验证”这件事提前摆到了台前。This is feasible because undergraduate training was never mainly about producing new theorems. It is mostly about verifying known results and understanding the shape of a proof. AI simply drags verification into the foreground.
- 课堂上的具体变化:让学生审一段 AI 给出的证明、找漏洞、改条件、比较不同解法;考试也可以给一段有错的推导,看他能不能发现。In practice: have students audit a proof produced by AI, find the gap, change an assumption, compare two solutions. An exam can hand them a derivation with an error and ask whether they can spot it.
- 要保留的是基本技巧。没有足够的计算和证明训练,就没有能力判断对错;目标不是和机器比谁算得快,而是成为能监督机器的人。Basic technique still has to stay. Without enough practice in computation and proof, students cannot judge anything. The goal is not to out-calculate the machine but to become the person who can supervise it.
数学之美The Beauty of Math
每日 Lean 谜题 · 周二Daily Lean Puzzle · Tuesday ★★☆☆☆☆☆
六座平方金字塔拼成一个长方体Six Square Pyramids Make One Cuboid
这道题要证明一个平方和恒等式。对任意自然数 $n$,把 $0^2,1^2,\dots,n^2$ 全部加起来,再乘以 6,结果恰好是一个三次多项式:This problem asks for a square-sum identity. For every natural number $n$, add up $0^2,1^2,\dots,n^2$ and multiply by 6; the result is exactly a cubic polynomial:
$6\,(0^2+1^2+\cdots+n^2)=n(n+1)(2n+1)$。$6\,(0^2+1^2+\cdots+n^2)=n(n+1)(2n+1)$.
两边除以 6,就是熟悉的“前 $n$ 个平方和”公式。在 Lean 里,这个命题叫 sum_sq_six,求和写成 $\sum_{i=0}^{n} i^2$。Divide both sides by 6 and you get the familiar formula for the sum of the first $n$ squares. In Lean the theorem is called sum_sq_six, with the sum written $\sum_{i=0}^{n} i^2$.
Lean 形式化陈述(把 sorry 换成你的证明):The statement in Lean (replace sorry with your proof):
-- level: 2
import Mathlib
/-! Prove that six times the sum of the squares from $0^2$ to $n^2$ is
$n(n+1)(2n+1)$: $6(0^2+1^2+\cdots+n^2)=n(n+1)(2n+1)$. -/
theorem sum_sq_six (n : ℕ) :
6 * (∑ i ∈ Finset.range (n + 1), i ^ 2) = n * (n + 1) * (2 * n + 1) := by
sorry
在浏览器中挑战 ▶Try it in your browser ▶ 下载题目 .leanDownload puzzle .lean
提示Hint
先别背公式。用归纳法看“多一层”新增了多少:从 $k$ 到 $k+1$,右边增加了 $6(k+1)^2$,正好等于新加那一层平方的六倍。几何上,六座同样的平方金字塔可以拼成一个长方体。Don't memorize the formula. Use induction and watch what one more layer adds: going from $k$ to $k+1$, the right-hand side grows by $6(k+1)^2$, exactly six copies of the new square layer. Geometrically, six identical square pyramids can be assembled into one cuboid.
答案与讲解Solution & walkthrough
- 先看式子的形状:左边是平方和,每多一层就多 $(k+1)^2$;右边是一个三次多项式。两边都随 $n$ 增长,所以最自然的办法是归纳法——验证起点,再验证“从 $k$ 到 $k+1$ 时两边增加的量相同”。Look at the shape first: the left side is a sum of squares that grows by $(k+1)^2$ with each new layer, while the right side is a cubic polynomial. Both sides grow with $n$, so induction is the natural move: check the starting point, then check that the increment from $k$ to $k+1$ matches on both sides.
- 起点是 $n=0$:左边只有 $0^2$,六倍仍是 0;右边 $0\cdot1\cdot1=0$。Lean 里 `simp` 一步做完,因为它同时化简了单元素求和与乘法。这一步对应数学上的“基例成立”,没有技巧。The base case is $n=0$: the left side contains only $0^2$, and six times zero is zero; the right side is $0\cdot1\cdot1=0$. In Lean, `simp` closes it in one step, simplifying the one-element sum and the multiplication together. Mathematically this is just the base case, with no cleverness involved.
- 归纳步先把最后一项拆出来。`rw [Finset.sum_range_succ]` 把 $\sum_{i=0}^{k+1} i^2$ 改写成 $\sum_{i=0}^{k} i^2+(k+1)^2$——把“前 $k+1$ 项”与“新加的第 $k+2$ 项”分开,这正是归纳法需要的形状。The induction step first isolates the last term. `rw [Finset.sum_range_succ]` turns $\sum_{i=0}^{k+1} i^2$ into $\sum_{i=0}^{k} i^2+(k+1)^2$, separating the first $k+1$ terms from the newly added $k+2$-th term. That is exactly the shape induction needs.
- 接着做代数。目标此时是 $6\,(S+(k+1)^2)=\cdots$。`rw [mul_add]` 把 6 分配进去,得到 $6S+6(k+1)^2$;再用归纳假设 `ih` 把 $6S$ 换成 $k(k+1)(2k+1)$。剩下的就是纯多项式恒等式:$k(k+1)(2k+1)+6(k+1)^2=(k+1)(k+2)(2k+3)$,它说的正是“右边从 $k$ 到 $k+1$ 增加的量对得上”。Then comes the algebra. The goal is $6\,(S+(k+1)^2)=\cdots$. `rw [mul_add]` distributes the 6, giving $6S+6(k+1)^2$, and the induction hypothesis `ih` replaces $6S$ by $k(k+1)(2k+1)$. What remains is a polynomial identity: $k(k+1)(2k+1)+6(k+1)^2=(k+1)(k+2)(2k+3)$ — precisely the statement that the increment from $k$ to $k+1$ matches.
- `ring` 收尾。它在自然数这个交换半环里把两边展开、合并同类项,确认恒等;不引入减法,也不假设任何分析事实。几何版本是同一件事:六座 $n$ 层平方金字塔正好拼成一个 $n\times(n+1)\times(2n+1)$ 的长方体。人选“乘 6、按层归纳”的看法,机器负责检查每一步没有漏洞。`ring` finishes. Working in the commutative semiring of natural numbers, it expands both sides and collects like terms; it introduces no subtraction and assumes no analytic facts. The geometric version says the same thing: six $n$-step square pyramids assemble into an $n\times(n+1)\times(2n+1)$ cuboid. The human chooses the “multiply by six, induct on layers” view; the machine checks that no step has a gap.
-- level: 2
import Mathlib
/-! Prove that six times the sum of the squares from $0^2$ to $n^2$ is
$n(n+1)(2n+1)$: $6(0^2+1^2+\cdots+n^2)=n(n+1)(2n+1)$. -/
theorem sum_sq_six (n : ℕ) :
6 * (∑ i ∈ Finset.range (n + 1), i ^ 2) = n * (n + 1) * (2 * n + 1) := by
induction n with
| zero => simp
| succ k ih =>
rw [Finset.sum_range_succ, mul_add, ih]
ring
人的思考A human's take
Some Notes on the Sum of Squares of the Integers — Pat Ballew
作者先承认:$2n+1$ 这一项看起来很奇怪,而中学教法是“背下来,再用归纳法证”。归纳法能验证公式,却解释不了它从哪里来,也帮不了记忆。The author starts by admitting that the $2n+1$ term looks strange, and that the usual school treatment is “memorize it, then prove it by induction.” Induction verifies the formula but does not explain where it comes from or help anyone remember it.
他的重构从三角数出发:每个平方数都是两个相邻三角数之和,而三角数是 $\binom{N+1}{2}$、前 $n$ 个三角数之和是 $\binom{n+2}{3}$。把每个平方拆开再相加,得到 $\binom{n+2}{3}+\binom{n+1}{3}=\frac{n(n+1)(2n+1)}{6}$——$2n+1$ 就是这么冒出来的。His reconstruction starts from triangular numbers: every square is the sum of two consecutive triangular numbers, triangular numbers are $\binom{N+1}{2}$, and the sum of the first $n$ triangular numbers is $\binom{n+2}{3}$. Splitting each square and adding gives $\binom{n+2}{3}+\binom{n+1}{3}=\frac{n(n+1)(2n+1)}{6}$ — that is where $2n+1$ comes from.
历史部分:阿基米德用平方和求螺旋线内的面积;斐波那契在《计算之书》里用 $10\cdot11\cdot21/6$ 算出前 10 个平方和,并解释“末项乘后继、再乘两者之和,除以 6 和公差”;奇数平方和则除以 2。The history: Archimedes used sums of squares to find the area inside a spiral; Fibonacci, in Liber Abaci, computed the first ten squares as $10\cdot11\cdot21/6$ and explained the rule as last term times its successor times their sum, divided by 6 and by the common difference; for odd squares the divisor is 2.
他接着讲这条公式如何进入趣题:沃尔特·雷利向托马斯·哈里奥特问方形金字塔炮弹数;$1^2+\cdots+24^2=4900$ 本身又是一个平方数;卢卡斯猜想没有别的解,沃森 1918 年给出完整证明;后来萨姆·洛伊德把它做成“数方格”谜题。He then traces the formula into recreational mathematics: Walter Raleigh asked Thomas Harriot how to count cannonballs in a square pyramid; $1^2+\cdots+24^2=4900$ is itself a square; Lucas conjectured there were no other solutions and Watson gave a complete proof in 1918; Sam Loyd later turned it into a count-the-squares puzzle.
AI 随想An AI's reflection
以下由 AI 撰写。Written by AI.
平方和公式是那种“背过很多次、却从没真正看见”的公式。把它写成“六倍”而不是“除以六”,结构突然显形:右边是三个连续因子的乘积,左边是六份金字塔;因子 6 不再是记忆负担,而是拼图的块数。The sum-of-squares formula is one of those results you have memorized many times without ever really seeing. Writing it as “six times” instead of “divided by six” suddenly reveals the structure: the right side is a product of three consecutive factors, the left side is six pyramids, and the 6 stops being a memory burden and becomes the number of pieces in the puzzle.
归纳法在这里也不是机械套路。它逼你回答一个具体问题:多一层,究竟多了多少?答案是 $6(k+1)^2$,正好是新增那一层的六份拷贝,几何与代数在同一个数上对上。很多证明之所以让人信服,靠的正是这种“两边说的其实是同一件事”的瞬间。Induction is not a mechanical ritual here either. It forces a concrete question: how much does one more layer add? The answer is $6(k+1)^2$, exactly six copies of the new layer, and geometry and algebra meet on the same number. Many proofs convince us precisely through that moment when two sides turn out to be saying the same thing.
Lean 的 `ring` 只保证最后一步合法,它不会告诉你为什么要乘 6。人选看法,机器查漏洞——这种分工比让机器替我们想更可靠,也比单纯背下公式更接近真正的理解。顺带说一句,这个恒等式也提醒我们:同一个事实可以有很多张脸——金字塔、长方体、方格计数;选哪张脸,取决于你想让谁看懂。Lean's `ring` only guarantees that the final step is valid; it does not tell you why the 6 is there. The human chooses the view, the machine checks for gaps. That division of labor is more reliable than letting the machine think for us, and much closer to real understanding than memorizing the formula. The identity also reminds us that one fact can wear many faces — pyramids, cuboids, grid counting — and which face you show depends on whom you want to see it.
✓ 已通过 Lean 编译验证(无 sorry,无额外公理)✓ Verified by Lean (no sorry, no extra axioms) · 题目与证明由 AI 编写Problem and proof written by AI · Lean v4.36.0-rc2 · Mathlib 1c2b155
- 把一句话藏进 RSA 公钥Hiding a Sentence Inside an RSA Public Key
- 目标听起来像恶作剧:让 CA 签发一张证书,而证书里的 RSA 模数 n 藏着一句可读的话。签名覆盖的是 DER 编码,模数正好是其中一段字节。The goal sounds like a prank: get a CA to sign a certificate whose RSA modulus n contains a readable sentence. The signature covers the DER encoding, and the modulus is just one byte range inside it.
- 做法不是攻破 RSA,而是利用密钥材料也是普通数据。先随机选一个素数 p,再决定把哪段字节写进 n 的高位,把高位改成消息,低位随便填。The trick is not breaking RSA. It exploits the fact that key material is also ordinary data. Pick a random prime p, decide which bytes should sit in the high end of n, write the message there, and fill the low end arbitrarily.
- 然后反过来求 q:q 约等于 n 除以 p。因为 p 和 q 被选得大小相近,把 q 调整到最近的素数时,只有 n 的低位会变,高位那句话保住了。Then solve for q: q is roughly n divided by p. Because p and q were chosen to be similar in size, rounding q up to the nearest prime changes only the low bytes of n, and the message in the high bytes survives.
- 用这对 p、q 正常生成密钥和证书请求,CA 按流程签名。验证者检查的是一个合法的合数模数,base64 里却躺着一句话。Generate a key and a certificate request from that p and q, and let the CA sign it normally. The verifier sees a valid composite modulus; base64 decoders see a sentence.
- 教训不是“RSA 不安全”,而是签名保证完整性,不保证内容可读或无害。只要格式允许任意字节,语义就可能被偷渡;解析器看到的东西和人看到的东西可以不是一回事。The lesson is not that RSA is broken. It is that a signature guarantees integrity, not readability or harmlessness. Whenever a format permits arbitrary bytes, meaning can be smuggled through it, and what a parser sees need not be what a person sees.
- 局部量子门,为什么会改动整个状态向量Why a Local Quantum Gate Still Rewrites the Whole State Vector
- 问题:一个只作用于三个量子比特的“局部”门,为什么在模拟器里要改动整个 2 的 n 次方维的状态向量?The question: a gate that touches only three qubits is called local, so why does a simulator have to update the entire state vector of dimension two to the n?
- 因为量子态一般不能拆成每个比特各自独立的状态。门只碰局部,但纠缠让整体的振幅全部重新组合;你以为没被碰到的比特,其边缘分布也可能改变。Because a quantum state generally cannot be factored into independent per-qubit states. The gate acts locally, but entanglement recombines the amplitudes globally. A qubit you never touched can still see its marginal distribution change.
- 作者原本以为其他比特的分布不受影响,于是写程序找反例。结果确实会变:局部操作不等于局部影响。The author assumed the other qubits' distributions would be unaffected and wrote a program to find a counterexample. They do change. Local operation does not mean local effect.
- 这也是量子计算难模拟的原因:状态空间随比特数指数增长,不能按比特分开存,只能按振幅存整个向量。This is also why quantum computation is hard to simulate. The state space grows exponentially with the number of qubits, so you cannot store independent states per bit; you store the whole amplitude vector.
- 反过来,这份指数级的“麻烦”正是量子优势的来源。读这类具体例子,比背“局部门作用于张量积”更能建立直觉。That exponential nuisance is exactly where quantum advantage comes from. Concrete examples like this build better intuition than reciting that a local gate acts on a tensor product.
- 用 n-gram 模型破换字密码:把猜谜变成搜索Breaking Substitution Ciphers with N-Grams: Turning Guesswork into Search
- 问题:换字密码有 26 的阶乘种密钥,暴力枚举不可能。人靠单字母词、重复字母、常见词尾来猜,但这些技巧零散且依赖经验。The problem: a substitution cipher has 26 factorial possible keys, so brute force is hopeless. Humans guess using single-letter words, doubled letters and common endings, but those tricks are scattered and experience-dependent.
- 作者的统一视角:把“解密”变成一个优化问题。每种密钥给出一个候选明文,用 n-gram 语言模型给这段文本打一个“像不像自然语言”的分数。The author's unifying view is to turn decryption into an optimization problem. Each key produces a candidate plaintext, and an n-gram language model scores how much that text looks like natural language.
- 搜索用局部改进:随机交换几个字母的映射,分数上升就保留,下降就退回;反复重启,避免卡在局部最优。The search improves locally: randomly swap a few letter mappings, keep the swap if the score rises, undo it if the score falls, and restart several times to escape local optima.
- 为什么有效:正确密钥会让文本恢复统计规律,而 n-gram 模型正是这些规律的近似;人的启发式只是它的粗糙版本。Why it works: the correct key restores the statistical regularities of language, and an n-gram model is an approximation of those regularities. Human heuristics are rough versions of the same likelihood.
- 局限也清楚:短文本、专有名词、混合语言会误导评分。模型越贴合语料,破译越稳;这也说明密码分析常常是语言学问题。The limits are equally clear. Short texts, proper nouns and mixed languages mislead the score. The better the model fits the corpus, the more reliable the break, which shows how often cryptanalysis is really a linguistics problem.
程序员随想Programmer Reflections
- 个体很重要:为什么按“人头”做预算一定会错Individuals Matter: Why Budgeting by Headcount Always Fails
- 观察:公司做路线图时按“人头”算,不按具体的人算;但私下里每个人预测交付时间,都是先看“谁被派上去”。这两种算法给出的答案经常差一个数量级。The observation: roadmaps are budgeted in heads, not in particular people. Yet when individuals privately predict a delivery date, they first look at who is assigned. The two calculations often differ by an order of magnitude.
- 为什么:人的差异在模糊、需要判断的工作里是数量级的,头衔、级别、地点只能解释一小部分。组织却用这些标签给人定价。Why: in ambiguous work that requires judgment, differences between people are enormous. Title, level and location explain only a small part of that, yet organizations price people by exactly those labels.
- 后果:HR 的定价机制把最能干的人估低,于是他们在强制淘汰中以大约两倍的速度离开,或者主动走。公司以为自己买的是“工程师月”,实际买的是具体人的判断力。The consequence: HR's pricing undervalues the strongest engineers, so they leave at roughly twice the rate during forced attrition, or leave on their own. The company thinks it is buying engineer-months; it is actually buying a specific person's judgment.
- 人走了,知识、关系和判断一起消失;同样一批人换个负责人,结果可能完全不同。这不是励志故事,而是预算和计划必须面对的现实。When the person goes, knowledge, relationships and judgment go with them. The same group under a different lead can produce a completely different result. This is not a motivational story; it is a fact that budgets and plans have to face.
- 结论:如果一份计划里没有名字,它就只是在做算术。承认个体差异,才能解释为什么“加两个人”有时毫无帮助,而“换一个人”能救活一个项目。The conclusion: a plan without names is just arithmetic. Acknowledging individual differences is the only way to explain why adding two people sometimes changes nothing, while replacing one person can save a project.
- 性能不是一个数Performance Is Not a Number
- 常见误区:把性能等同于吞吐量或每秒请求数,然后忽略延迟的分布。两个系统 QPS 相同,用户体感可以差得很远。The common mistake is to equate performance with throughput or requests per second and ignore the latency distribution. Two systems with the same QPS can feel completely different to a user.
- antirez 拆成三个维度:延迟,尤其是尾部延迟和可预测性;每核每秒操作数,也就是单线程效率,而不是“加机器”;以及操作的质量。antirez separates three dimensions: latency, especially tail latency and predictability; operations per second per core, meaning single-thread efficiency rather than adding machines; and the quality of the operations themselves.
- 操作质量最容易被忽略:一次原子的 INCR 胜过先 GET 再 SET;HMGET 只取需要的字段,胜过把整个哈希拉回来。你做的事越少,系统要付的代价越小。Operation quality is the easiest to miss. One atomic INCR beats GET followed by SET. HMGET that fetches only the needed fields beats pulling the whole hash. The less work you ask for, the less the system pays.
- 为什么重要:加机器能买吞吐,买不到尾部延迟;单核效率决定单机成本的上限;操作设计决定你做了多少无用功。Why it matters: adding machines buys throughput but not tail latency. Per-core efficiency sets the cost ceiling for a single box. Operation design determines how much useless work you do.
- 教训:先定义你要优化的是哪一个“性能”。否则团队会各自优化不同目标,仪表盘都很好看,用户体验却没有变。The lesson: define which performance you are optimizing before you start. Otherwise teams optimize different targets, the dashboards all look good, and the user experience does not change.
- Web 已经足够The Web Is More Than Enough
- 背景:Paul Ford 做了 TinyLittleOffice,一个把文档数据存在 URL 里的办公套件。上线后服务器被挤爆,最后靠升级 Cloudflare 套餐才撑住。The background: Paul Ford built TinyLittleOffice, an office suite that stores document data in the URL. It went viral, the server fell over, and he ended up putting a credit card on the Cloudflare account to keep it up.
- 意外发现:浏览器已经强到可以当应用平台。Web Crypto 是一套正经的安全能力,WASM 跑接近原生速度的代码,WebGL 做 2D/3D 图形,Web Audio 混音,PDF.js 处理 PDF,国际化和无障碍基础设施也都在。The surprise: the browser is already a serious application platform. Web Crypto is a real security layer, WASM runs near-native code, WebGL handles 2D and 3D graphics, Web Audio mixes sound, PDF.js deals with PDFs, and internationalization and accessibility infrastructure are there too.
- 成本对比:他说做这个套件的力气,大约是写一篇长通讯的两倍;托管费用在免费额度内是零美元。The cost comparison: he says building the suite took about twice the effort of writing a long newsletter post, and hosting stayed within the free tier at zero dollars.
- 论证不是“Web 能替代桌面”,而是“访问这些能力的门槛在下降”。对独立开发者,分发和迭代的成本几乎消失了。The argument is not that the web replaces the desktop. It is that the cost of reaching these capabilities keeps falling. For an independent developer, distribution and iteration have become almost free.
- 限制也要说:复杂性能、深度系统集成、离线场景仍有代价。但对大量小工具来说,浏览器就是最短路径;问题往往不是 Web 不够,而是我们没去看它现在能做什么。The limits are real: heavy performance, deep system integration and offline use still cost something. But for a large class of small tools, the browser is the shortest path. The problem is usually not that the web is insufficient, but that we have not looked at what it can do now.
- 为什么任务管理器不该用高优先级Why Task Manager Shouldn't Run at High Priority
- 现象:任务栏和任务管理器看起来是“系统关键”的,为什么不给它们高优先级,让它们永远响应迅速?The puzzle: the taskbar and Task Manager look like system-critical components, so why not give them high priority and keep them responsive at all times?
- Raymond 的解释:优先级只决定你在就绪队列里的位置。真正的时间往往花在等待共享资源:锁、网络文件、UI 线程、磁盘。你抢到 CPU 之后,还是得排队等这些东西。Raymond's explanation: priority only decides your place in the ready queue. Most of the time is spent waiting on shared resources such as locks, network files, UI threads and disks. After you win the CPU, you still queue for those.
- 更糟的是优先级反转:你提高了自己的优先级,却发现资源被一个低优先级线程持有,于是你等得更久,还可能把整个系统拖住。Worse, there is priority inversion. You raise your own priority, then discover the resource you need is held by a low-priority thread, so you wait longer and may drag the system down with you.
- 还有一个实际问题:用系统里的工具去修一个失控的系统,工具本身也要和失控者争资源。任务管理器可能和它要监视的进程一起卡死。There is also a practical problem: using a tool inside the system to fix a runaway system means the tool competes with the runaway for the same resources. Task Manager can freeze alongside the process it is supposed to monitor.
- 教训:调度优先级是局部工具,不是万能药。先找出瓶颈在哪个共享资源,再决定要不要动优先级;大多数“界面卡死”不是 CPU 不够,而是在等别的东西。The lesson: scheduling priority is a local tool, not a cure. Find the shared resource that is actually blocking you before touching priority. Most 'frozen UI' problems are not a shortage of CPU; they are waiting on something else.
哲学与生活Philosophy and Life
- 信与想:政教分离背后的心理学Believing and Thinking: The Psychology Behind Church-State Separation
- 问题:政教分离常说“政府不干涉信仰”,可政府每天都在塑造信念——公共教育、消防检查、心理医生的强制报告,都是在改变人们相信什么。The problem: church-state separation is often described as the government staying out of belief. But governments shape belief every day, through public education, fire inspections and mandatory reporting by therapists.
- 作者区分两种态度:事实信念不由自主、随证据改变;宗教信条可以自愿选择、对反证不敏感。关键不是信什么内容,而是用什么方式对待这个内容。The authors distinguish two attitudes. Factual belief is involuntary and tracks evidence. Religious credence can be chosen and is comparatively insensitive to counter-evidence. What matters is not the content but the attitude taken toward it.
- 同一个命题可以事实地相信,也可以被神圣化地持有。比如“世界是某个样子”,既可以作为可检验的判断,也可以作为身份与承诺的一部分。The same proposition can be held factually or held as sacred. 'The world is thus' can be a testable claim, or part of an identity and a commitment.
- 这给政教分离一个心理学理由:政府可以纠正事实错误,却不该用同样的手段去“纠正”一个人自愿持有的神圣承诺,否则就是把信念当成事实来管辖。This gives separation a psychological rationale. A government can correct factual errors, but it should not use the same machinery to correct a sacred commitment someone has chosen, because that treats credence as fact and puts it under state jurisdiction.
- 边界也要说清:这个区分不证明宗教为真,也不说宗教信念都错。它只回答一个制度问题——为什么值得划这条线,以及这条线应该划在哪里。The boundary matters: the distinction does not prove any religion true, nor does it say religious belief is false. It answers an institutional question: why draw this line at all, and where should it go?
- 平等这个词,借了数学的光How the Word Equality Borrowed Math's Authority
- 问题:平等今天既是共识又是争吵源。同一个词,各方说的往往不是同一件事,于是对话变成了各说各话。The problem: equality is both a consensus and a source of endless argument. The same word often means different things, so the conversation becomes people talking past one another.
- 作者追溯到语言本身:现代平等话语借了欧几里得公理的光环,让人以为平等像“等于”一样可以量化、可以一次定义清楚。美国《独立宣言》的“自明”也在借用几何学的语气。The author traces this to the language itself. Modern equality talk borrows the aura of Euclid's axioms, making equality sound as quantifiable and definable as 'equals.' The self-evidence language of the Declaration of Independence borrows the same geometric tone.
- 1646 年英国平等派已经提出关键区分:把人当平等者对待,不等于给每个人完全相同的东西。前者关乎地位与尊重,后者关乎分配。The English Levellers had already made the key distinction in 1646: treating people as equals is not the same as giving everyone identical things. The first is about status and respect; the second is about distribution.
- 当代争论(平权、资源分配、机会平等)多半卡在这里:一方说“区别对待就违反平等”,另一方说“不区别对待就无法平等”。Contemporary arguments about affirmative action, resources and opportunity get stuck here. One side says differential treatment violates equality; the other says refusing to differentiate makes equality impossible.
- 启发:先问“我们说的是哪一种平等”,比争“谁更平等”更能推进对话。数学式的精确感有时是障碍,因为它让一个本质上需要政治判断的问题看起来像一道算术题。The takeaway: ask which equality we are talking about before arguing about who is more equal. Mathematical precision can be an obstacle here, because it makes a question that requires political judgment look like an arithmetic problem.
工具角Tools
- upy:一个二进制文件管完 SPA、Docker 和 systemdupy: One Binary for SPA, Docker and systemd Deployments
- 任务:一台 VPS 上同时跑几个前端、几个 Docker 服务和几个 systemd 二进制,部署脚本越写越多,回滚越来越靠记忆。The task: one VPS runs a few frontends, a few Docker services and a few systemd binaries. The deploy scripts multiply, and rollback depends on memory.
- upy 是一个约 8.5MB 的 Go 单文件:SPA 解压到不可变版本目录,用 current 软链原子切换;Docker 先准备新镜像和配置再停旧容器,失败自动回滚;systemd 保留启动参数,检查端口与用户。upy is a single Go binary of about 8.5MB. SPAs are unpacked into immutable version directories and switched atomically through a current symlink. Docker deployments prepare the new image and config before stopping the old container, with health checks and automatic rollback. systemd services keep their arguments, and ports and users are checked.
- 省下的:不用为每种项目维护一套 rsync 加 restart 的脚本;回滚就是切回上一个版本目录;权限归一化还顺手避免了 Nginx/Caddy 的 403。What it saves: no separate rsync-and-restart script per project; rollback is switching back to the previous directory; permission normalization also avoids the classic Nginx/Caddy 403.
- 上手:下载二进制或跑 install.sh,写一个 config.yaml,执行 upy deploy;没有外部依赖,内存占用也小。Getting started: download the binary or run install.sh, write a config.yaml, run upy deploy. No external dependencies, and a small memory footprint.
- 限制:它面向单机、约定式部署,不是 Kubernetes 替代品;多机编排、复杂网络和滚动发布不要指望它。The limit: it targets single-machine, convention-based deployment. It is not a Kubernetes replacement, and you should not expect multi-host orchestration, complex networking or rolling releases.
- mecha:一眼看出哪把 API key 快没余额了mecha: See at a Glance Which API Key Is Running Out
- 任务:手里有 OpenAI、Anthropic、Gemini、OpenRouter 好几把 key,过期、欠费或失效往往要等到请求报错才发现。The task: you hold several keys for OpenAI, Anthropic, Gemini and OpenRouter. Expiry, missing funds or revocation are usually discovered when a request fails.
- mecha 在 127.0.0.1 起一个本地仪表盘和 CLI,列出每把 key 是否可用、有没有余额、何时过期、是什么类型;它还能读 Codex、Claude Code 和 Gemini CLI 的会话文件。mecha runs a local dashboard and CLI on 127.0.0.1. It shows whether each key works, whether it has funds, when it expires and what kind of key it is. It can also read the session files of Codex, Claude Code and Gemini CLI.
- 省下的:不用逐个登录控制台查;脚本可以先跑 mecha ls --json,再决定这一轮用哪把 key。默认只用免费的检查端点,消耗额度的探测要手动开启并先显示成本。What it saves: no logging into each console one by one. A script can run mecha ls --json and decide which key to use for the next job. Automatic checks use free endpoints; probes that consume tokens are opt-in and show their cost first.
- 上手:需要 Python 3.12+,先用 uvx mecha-keys serve --demo 看假数据,再 uv tool install mecha-keys 安装;key 只在本地,界面只显示脱敏形式和指纹。Getting started: Python 3.12+, try uvx mecha-keys serve --demo with fake data, then install with uv tool install mecha-keys. Keys stay local; the UI sees only a redacted form and a fingerprint.
- 限制:项目还是 alpha,覆盖的 provider 有限;别把生产 key 贴进任何网页版。它解决的是“看见”,不解决“自动轮换”。The limits: it is alpha and covers a limited set of providers. Never paste a production key into a web page. It helps you see the state of your keys; it does not rotate them for you.
- ruleproof:检查编码 agent 有没有真的遵守 AGENTS.mdruleproof: Check Whether Your Coding Agent Actually Followed AGENTS.md
- 任务:你给编码 agent 写了 AGENTS.md,但它真的遵守了吗?“测试全过”是跑过之后说的,还是猜的?The task: you wrote an AGENTS.md for your coding agent, but did it actually follow the rules? Did 'all tests pass' come from a run, or from a guess?
- ruleproof 把可检查的规则变成确定性检查:测试是否在最后一次修改之后运行、声称通过是否有命令证据、是否改了禁改文件、是否执行了禁用命令。ruleproof turns checkable rules into deterministic checks: whether tests ran after the last edit, whether a claim of passing has command evidence, whether a forbidden file changed, whether a forbidden command ran.
- 输入是 git diff 和会话 transcript,不调用模型,所以同样输入得到同样结论;每条失败都会给出证据和规则在 AGENTS.md 里的出处。The inputs are the git diff and the session transcript. No model is called, so the same input yields the same verdict. Every failure cites evidence and the rule's location in AGENTS.md.
- 上手:ruleproof -q check --transcript session.jsonl;可以放进 CI 或 pre-commit。没有运行时依赖,安装很轻。Getting started: ruleproof -q check --transcript session.jsonl, in CI or as a pre-commit hook. There are no runtime dependencies.
- 限制:只能检查可机械化的规则;语义判断仍要人。作者也承认,“声称完成”的启发式在压力测试里还不完全可靠。The limits: it can only check rules that can be mechanized; semantic judgment still needs a human. The author also admits that the heuristic for detecting unverified completion does not yet agree with an independent judge on their pressure benchmark.
- Firenook:不用 Java 的 Firebase 本地模拟器Firenook: Firebase Emulators Without Java
- 任务:本地开发 Firebase 应用,官方 emulator 要装 Java,启动慢、写入慢,重启后数据还得重新灌。The task: developing a Firebase app locally means the official emulator suite, which needs Java, starts slowly, writes slowly and loses data on restart.
- Firenook 是 drop-in 替代:保留 firebase.json、SDK 和端口,只把启动命令里的 firebase emulators:start 换成 firenook。Firenook is a drop-in replacement. Keep firebase.json, the SDKs and the ports, and change firebase emulators:start in your script to firenook.
- 官方给出的中位数:写入 5.1ms 对 208.2ms,峰值内存 2.11GiB 对 22.57GiB,带数据重启 0.59s 对 30.8s。这些是项目自己的基准,硬件和数据集以其页面为准,不是我们的实测。Its published medians: 5.1ms versus 208.2ms per write, 2.11GiB versus 22.57GiB peak memory, and 0.59s versus 30.8s to restart with data. These are the project's own benchmarks; hardware and dataset are on its site, and they are not our measurements.
- 上手:npm install --save-dev firenook;需要 Node 24,不用装 Java。数据默认存在 .firenook/state,重启后还在。Getting started: npm install --save-dev firenook. It needs Node 24, and no Java. Data lives in .firenook/state by default and survives restarts.
- 限制:兼容性要按你的项目验证,冷门 Firebase 功能可能没覆盖;生产当然还是用真正的 Firebase。The limits: verify compatibility against your own project, since obscure Firebase features may be missing. Production should still use real Firebase.
- OpenArtifact:一个二进制文件加 Postgres 的自托管制品仓库OpenArtifact: A Self-Hosted Artifact Repository in One Binary Plus Postgres
- 任务:团队要一个内部制品仓库,托管 npm、PyPI、Docker、Maven,又不想把包和权限交给 SaaS。The task: the team wants an internal artifact repository for npm, PyPI, Docker and Maven without handing packages and permissions to a SaaS.
- OpenArtifact 是一个 Go 二进制加 PostgreSQL,用一套 URL 和权限模型支持二十多种格式,提供 hosted、proxy、group 三种仓库。OpenArtifact is one Go binary plus PostgreSQL. It supports more than twenty formats behind one URL scheme and one permission model, with hosted, proxy and group repositories.
- 省下的:不用为每种包格式各搭一个服务;proxy 可以缓存上游,group 可以把多个源合成一个地址;RBAC、SSO 和安全扫描统一在一处。What it saves: no separate service per package format. Proxies cache upstreams, groups combine several sources behind one address, and RBAC, SSO and security scanning live in one place.
- 上手:用 Docker Compose 起服务和 Postgres,按示例 YAML 配存储与仓库;客户端只需要把 registry URL 指过来。Getting started: bring up the service and Postgres with Docker Compose, configure storage and repositories from the example YAML, and point each client's registry URL at it.
- 限制:要自己维护 Postgres、备份和升级;AGPL 许可证;如果团队只用一两种格式,专门的小工具可能更轻。The limits: you own Postgres, backups and upgrades; the license is AGPL; and if the team only uses one or two formats, a smaller dedicated tool may be lighter.