每日思想文摘 · 10月30日:模型里的 CPU、白板上的实验、和断网也能用的 AIDaily Digest Oct 30: a CPU inside a model, a whiteboard experiment, and an AI that works offline
发布于 2026-10-30Published 2026-10-30
今日深读Today's Deep Read
『模型里装了一台真 CPU』:把 RISC-V 核心编译进 Qwen 权重里的思想实验A Real CPU Inside a Model: Compiling a RISC-V Core Into Qwen's Weights
平时我们说『让大模型调用 Python 工具算大数』,等于承认模型本身只会推理、不会算。Qwenputer 这个实验把话反过来说:它是一个标准 Qwen 3.5 4B,不挂任何外部工具、不要沙箱——作者在一台普通 GPU 上,把一台 32 位 RISC-V 处理器直接编译进它的权重,算术就在前向传播里发生。模型既还是神经网络,同时是一台计算机。The usual story is that a language model can reason but can't do arithmetic, so you bolt on a Python tool. Qwenputer flips the story: it is a stock Qwen 3.5 4B with no external tool and no sandbox — the author compiled a 32-bit RISC-V CPU straight into its weights on one ordinary GPU, and the arithmetic happens during the forward pass. The model is still a neural network; it's now also a computer.
关键一步是找到『模型里哪里有 RAM』。Qwen 3.5 有 3/4 的层用 Gated DeltaNet(一种线性 RNN)做注意力,每个头保留一块状态矩阵——平时这块状态是模糊的、逐 token 衰减的『记忆』。作者把衰减门(gate)钉在 1(什么都不褪色)、写入强度(beta)钉在 1(写下去就完全覆盖)、再用 one-hot 编码当内存地址,这块状态就变成了精确的、可寻址的 RAM:写一行覆盖一行,读一行取回一行,而且状态大小不随对话变长而膨胀(这就是它比拿 KV cache 当内存便宜的地方)。用 delta 规则做记忆不算新发明(Schlag 等人 2021 年的『fast weights』),新的是把它做到精确、可寻址、可靠到能跑一台 CPU。The key move is finding where the RAM lives. Three out of four layers in Qwen 3.5 use Gated DeltaNet (a linear RNN) as the attention mechanism, and every head keeps a state matrix — normally a fuzzy, decaying memory. Pin the decay gate at 1 (nothing ever fades), pin the write strength beta at 1 (a write fully overwrites), and address it with one-hot vectors, and that state becomes exact, addressable RAM: writing a row overwrites it, reading a row retrieves it, and the state never grows with the conversation the way a KV cache does — which is what makes it cheaper than using attention as memory. Using the delta rule as memory isn't new (Schlag et al.'s 2021 'fast weights' paper); the new part is making it exact and addressable enough to run a whole CPU on it, inside a production model.
有了 RAM,CPU 就只是编译器的事——而且全程没有训练,编译器直接把每个权重设好:把 RISC-V 核心(完整 RV32IM 指令集加 Zba 扩展、外加一个大整数单元)写成『读这个寄存器、加这两个数、是零就跳』的电路步骤清单,每个步骤映射到一块变换器元件——注意力头查表、前馈层算术、DeltaNet 头存储。整个 CPU 占 11 层,插在 Qwen 自己的 32 层前面,Qwen 的原始权重一字未动。每条指令变成模型生成的几个 token(要写的内存行、数值、结束符),这些 token 就是 CPU 的执行轨迹——模型在解码它们的时候,CPU 就真的在跑。它通过了官方 riscv-tests,自由运行一千八百万条指令零误差,还能跑 C 和 MicroPython——还不是 Linux 级芯片,但指令集是全的。With RAM in hand, the CPU is just a compiler problem — and there is no training at all; the compiler sets every weight directly. Describe the core (full RV32IM plus the Zba extension, with a small bignum unit) as a circuit — 'read this register, add these two, jump if zero' — and map each step onto transformer parts: attention heads do lookups, feed-forward units do the arithmetic, DeltaNet heads hold memory. The CPU occupies 11 layers inserted in front of Qwen's own 32, and Qwen's original weights are untouched. Each instruction becomes a few generated tokens — the memory row to write, the value, a step terminator — and those tokens are the CPU's execution trace: while the model decodes them, the CPU is actually running. It passes the official riscv-tests, has run 18 million free-running instructions with zero errors, and can also execute C and MicroPython — not a Linux-class chip yet, but a complete instruction set.
接下来作者还加了个『模型内文件系统』:文件名哈希到 1024 个槽位,文本按每行八个 token 链式存在 DeltaNet 状态里,最多 512 个文件、约 5.3 万 token。这个状态可以在会话之间保存、下一次加载——相当于模型有了自己的磁盘。实测下来,两次对话之间变过的事实,它靠文件系统答对 90%,而把旧对话原文贴回上下文只有 30%。这是『模型内状态』和『模型内存储』的分野:前者随对话逐 token 衰减,后者是作者刻意钉死在 1 的不变量。On top of that there's a 'filesystem inside the model': file names hash into 1024 slots, contents are chained across eight-token rows in the DeltaNet state, up to 512 files — about 53,000 tokens. The state can be saved at the end of a conversation and loaded into the next one, so the model has its own disk. In tests, facts that changed between chats were gotten right 90% of the time through the filesystem, versus 30% when the old chats were pasted back into context. That's the line between 'in-model state' and 'in-model storage': the former decays token by token; the latter is an invariant the author deliberately pinned at 1.
为什么值得读?它把『模型作为计算机』从口号变成可测量的对象。算术基准 NUPA 的长整数题从 48.6% 拉到 100%,与给 Qwen 挂 Python 计算器打平;最难的乘法题 97.5%,还略胜基座模型裸跑的 55%。作者用约 23 万个输出位置对照参考机器逐一回放,零不一致;普通对话也不受影响——文本与基座的 KL 散度 6e-4,只比 5e-4 的噪声底线高一点。代价也明说:checkpoint 18.8GB,约为基座两倍(大半是零填充),要一个额外驱动来装载固件,每条指令要花费解码的几条 token,大计算以秒计而非毫秒。同一技术还被反过来写成两篇后续:混合模型能学会把推理藏进 RNN 状态、躲开思维链监控;编译进权重的部件能当模型自己关不掉的内置监视器。换句话说,作者没有让模型『假装会算』,而是给它装了一台真正在跑的小机器,再把算术交给它。Why read it? It turns 'the model is a computer' from a slogan into something you can measure. On NUPA's long-integer arithmetic the CPU lifts accuracy from 48.6% to 100% — matching Qwen-with-a-Python-tool — and on the hardest multiplication set it scores 97.5% against the base model's bare 55%. The author replayed roughly 230,000 of its output positions against a reference machine and found zero mismatches, and normal conversation survives: the text's KL divergence from the base model is 6e-4, just above the 5e-4 noise floor. The limits are stated plainly: an 18.8 GB checkpoint, about double the base (mostly zero padding), a small extra driver to boot the firmware, and every CPU instruction costing a few decoded tokens — a big calculation takes seconds, not milliseconds. The same trick is turned around in two follow-ups: hybrid models can learn to hide their reasoning in the RNN state and evade chain-of-thought monitoring, and compiled weights can serve as a monitor built in that the model itself can't switch off. In other words, instead of letting the model pretend to compute, the author installed a small machine that actually runs and put the arithmetic on it.
AI 思考AI Thoughts
- 『编程的讣告』:AI 时代,解谜的乐土变成交付的管道My Obituary for Programming: When the Puzzle Was the Pay
- Scheff 的原文说:编程曾是你能想象到的最好的工作——你被付钱去解一个个小小的逻辑谜题,越难越值钱,简单的也值钱,因为普通人根本做不了。Scheff's words: programming was one of the best jobs you could imagine — you got paid to work on tricky little logic puzzles. The trickier the puzzle, the more you got paid; even simple ones were worth a lot because regular people just couldn't do it.
- 但 coding agent 把『解谜题』这一步接走了。留下来的是『让系统跑起来』——交付、集成、跑测试。Coding agents have taken the 'solving the puzzle' part. What's left is making systems run — delivery, integration, tests.
- 所以 AI 的影响是分人群的:如果你靠『建出能跑的系统』获得快感,LLM 是白捡的礼物。So the AI impact splits by person: if you thrive on building working systems and don't care much about the specific puzzles, LLMs are the gift that keeps on giving.
- 如果你靠『亲手解那道题』获得快感,那部分乐趣是真实的损失,不是矫情。If solving the problems yourself was a big part of your enjoyment, that loss is real, not melodrama.
- 带走一点:你的职业价值里有多少是『求解』、多少是『交付』,值得现在就想清楚——这两种人在 AI 时代的处境完全不同。Takeaway: figure out now how much of your value is solving versus delivering — those two kinds of programmers have very different futures in the AI era.
- Amazon 高管:AI 帮不到你,是一个『发现』而不是『失败』Amazon's Take: When AI Doesn't Help Your Work, That's a Finding, Not a Failing
- 背景:公司内部在推 AI 工具,很多工程师的潜台词是『我不用 AI = 我不够努力』。Context: companies are pushing AI tooling; many engineers quietly equate 'not using AI' with 'not trying hard enough'.
- Terkowitz 的反向框架:如果你的工作确实没被当前 AI 工具改善,这是一个可以被写下来的『发现』(finding)。Terkowitz's reframe: if your work genuinely isn't helped by current AI tools, that is a *finding*.
- 正确的动作:写下为什么、告诉同事、告诉 manager、一起找解法。The move: document why, share it with peers, take it to your manager, work on solutions.
- 为什么成立:能精确说出『AI 在哪不 work、为什么』的工程师,恰恰在行使被要求的那种判断力——不是拒绝工具,是知道工具能力边界的人。Why it holds: an engineer who can say exactly where and why AI does *not* help is demonstrating the judgment the org is asking for — knowing the boundary of a tool's capability.
- 带走一点:把『我为什么没从 AI 拿到收益』变成一次公开的判断力展示,而不是自我怀疑。Takeaway: turn 'why am I not getting ROI from AI' into a public display of judgment instead of self-doubt.
- Anthropic 团队怎么做 code review:把门改成拼写检查How Anthropic's Claude Code Team Reviews Code: From Gate to Spellcheck
- 旧问题:『人有没有读这段代码』是个糟糕的代理指标——真正该问的是『这次改动最可能在哪类地方出事,哪类检查(自动的或人的)能抓住它』。The old proxy — 'did a human read the code?' — is imprecise. The real question: what could go wrong with this change, and which check (automated or human) is the right one to catch it?
- 时间线变化:以前 review 是流程末尾的一道门(写完代码 → 开 PR → 等同事),现在 review 是持续的,像边写边跑的 spellcheck。Timing shifts: review used to be a gate at the end of the road; now it runs continuously, like spellcheck while you write.
- 分工:Claude 先把大多数常规错误改完,人只看高层问题——这把人省下来给『更难的判断』。Division of labor: Claude has reviewed and fixed most changes at least once before a human looks, saving human attention for higher-level scrutiny.
- 隐含假设:agent 读代码 ≠ 检查代码,两种动作的产出不同;review 的价值在于匹配检查方式与失败模式。Hidden assumption: an agent reading code and a human checking for failure modes are different jobs; review's value is matching check type to failure mode.
- 带走一点:下次设计 review 流程时,先问『哪类错误最贵』,再决定谁(人或机)看哪里。Takeaway: when you design a review process, ask 'which class of mistake is most expensive' before deciding who or what sees what.
- 『coding agent 时代,starter kit 的哲学变了』In the Agent Era, the Starter-Kit Philosophy Changes
- 背景:pgledger 是一个纯 PostgreSQL 账本实现,不是传统依赖——是一组表+SQL 函数。作者把它重新定位为『starter kit』而非『library』。Context: pgledger is a double-entry ledger in pure PostgreSQL — not a package to install, but tables + SQL functions. The author reframes it as a *starter kit* rather than a library.
- 旧哲学:库要小而精,特性按需加;因为加特性成本高。Old philosophy: keep the library small; features are expensive to add.
- 新哲学:coding agent 让『加特性』和『删特性』都变便宜了,所以出现了两条相反的压力——① agent 能补你要的特性,所以库本身可以少一点;② agent 也能删你不要的,所以库应该多加可选特性。New philosophy: coding agents make both 'add a feature' and 'remove a feature' cheap, so two opposing pressures appear: (1) agents can fill in what you need, so the core can stay small; (2) agents can remove what you don't, so the kit should ship lots of optional features.
- 作者的判断框架:特性值不值得进核心,看三条——被大量请求?复杂到 agent 加错会出事?集成到核心函数里?三条里命中越多,越该进核心。Decision frame: a feature belongs in the core if it is widely requested, complicated enough that an agent might add it wrong, and integrated into the central functions — the more of these, the stronger the case.
- 实例:幂等性支持——以前作者嫌大部分 app 在别的层已有幂等性所以抗拒,现在按新框架它进了核心(『删比加容易』)。Example: idempotency support. The author previously resisted it because most apps already had idempotency at a different layer; under the new frame it earned its spot in the core ('removal is easier than correct addition').
- 带走一点:写库/写框架时,『agent 时代』该刻意把『复杂、集成、被大量请求』的三样放进核心,把『边缘、简单、小众』的留在文档里让 agent 按需加。Takeaway: when you write a library or framework in the agent era, put the 'complicated, integrated, widely-requested' stuff in the core and leave the 'edge, simple, niche' stuff in the docs for agents to add on demand.
数学之美Beauty of Math
每日 Lean 谜题 · 周五Daily Lean Puzzle · Friday ★★★★★☆☆
USAMO 1985 P2:把 $N=10^{10}$ 的四次方程的实根精确到小数第 4 位USAMO 1985 P2: The Real Roots of a Quartic at $N=10^{10}$, to 4 Decimal Places
设 $N = 10^{10}$。方程 $x^4 - (2N + 1)x^2 - x + N^2 + N - 1 = 0$ 恰好有两个实根。把这两个实根求到小数点后第 4 位。Let $N = 10^{10}$. The equation $x^4 - (2N + 1)x^2 - x + N^2 + N - 1 = 0$ has exactly two real roots. Find both, to 4 decimal places.
(Lean 形式化:证明存在 $x_1 < x_2$,它们是这个方程的全部实根,且 $|x_1 - 99999.9984| < 0.00005$ 与 $|x_2 - 100000.0016| < 0.00005$。)(Lean: prove there exist $x_1 < x_2$, the complete set of real roots, with $|x_1 - 99999.9984| < 0.00005$ and $|x_2 - 100000.0016| < 0.00005$.)
Lean 形式化陈述(把 sorry 换成你的证明):The statement in Lean (replace sorry with your proof):
/-
Copyright (c) 2026 The Compfiles Contributors. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kimi K3
-/
import Mathlib.Algebra.Order.Star.Real
import Mathlib.Analysis.Normed.Order.Lattice
import Mathlib.Tactic.Linarith
import Mathlib.Tactic.NormNum
import Mathlib.Tactic.Ring
/-!
# USA Mathematical Olympiad 1985, Problem 2
Find all real roots of the quartic x⁴ - (2N + 1)x² - x + N² + N - 1 = 0
correct to 4 decimal places, where N = 10¹⁰.
-/
namespace Usa1985P2
abbrev answer : ℝ × ℝ := sorry
theorem usa1985_p2 (N : ℝ) (hN : N = 10 ^ 10) :
∃ x₁ x₂ : ℝ, x₁ < x₂ ∧
(∀ x : ℝ, x ^ 4 - (2 * N + 1) * x ^ 2 - x + N ^ 2 + N - 1 = 0 ↔
x = x₁ ∨ x = x₂) ∧
|x₁ - answer.1| < 0.00005 ∧ |x₂ - answer.2| < 0.00005 := by
sorry
end Usa1985P2
在浏览器中挑战 ▶Try it in your browser ▶ 下载题目 .leanDownload puzzle .lean
提示Hint
先把四次项凑成完全平方 $(x^2 - N - 1/2)^2$,再比较左右两边的量级。First complete the square on the leading terms to get $(x^2 - N - 1/2)^2$, then compare the magnitudes of the two sides.
答案与讲解Solution & walkthrough
- 配平:把方程重排成 $(x^2 - N - 1/2)^2 = x + 5/4$。这是整道题的唯一关键——一个四次方程被降成『一个平方 = 一个线性函数』的比较题。Complete the square: rearrange the equation into $(x^2 - N - 1/2)^2 = x + 5/4$. This one rewrite is the entire trick — a quartic becomes a 'a square = a linear function' comparison.
- 排除负根:$x < -5/4$ 时右边为负、左边是平方,无解;$-5/4 \le x \le 0$ 时左边是 $(N 量级)^2$ 而右边至多 $5/4$,也撞不上。所以两个根都是正的。Rule out the negatives: for $x < -5/4$ the right side is negative while the left is a square, so nothing; for $-5/4 \le x \le 0$ the left is of order $(N)^2$ while the right is at most $5/4$. So both roots are positive.
- 用 Descartes 符号法则:系数符号依次是 $+$、$-$、$-$、$+$,一共两次变化,所以正根至多 2 个;后面两步会实际给出 2 个,『恰好两根』由此证死。Descartes' rule of signs: the coefficient signs go $+$, $-$, $-$, $+$ — two sign changes in all, so there are at most 2 positive roots; the next steps actually produce two, which pins down 'exactly two'.
- 量级估计:代入 $x = 10^5$ 得左边 $= 1/4$、右边 $\approx 10^5$(右边太大);代入 $10^5 \pm 1$ 时左边约 $4\cdot 10^{10}$、右边约 $10^5$(左边太大)。所以两根在 $10^5$ 附近。Order of magnitude: at $x = 10^5$ the left side is $1/4$ and the right is about $10^5$ (right too big); at $10^5 \pm 1$ the left is about $4\cdot 10^{10}$ (left too big). So both roots live near $10^5$.
- 令 $x = 10^5 \pm k$ 展开:$(4k^2 \cdot 10^5 - 1)\cdot 10^5 \pm 2k(1 - 2k^2)\cdot 10^5 - 5/4 = 0$,只留主导项就得 $4k^2 \approx 10^{-5}$,即 $k \approx 0.0016$,根在 $99999.9984$ 与 $100000.0016$。Set $x = 10^5 \pm k$ and expand: $(4k^2 \cdot 10^5 - 1)\cdot 10^5 \pm 2k(1 - 2k^2)\cdot 10^5 - 5/4 = 0$; keeping only the leading terms gives $4k^2 \approx 10^{-5}$, so $k \approx 0.0016$ and the roots sit at $99999.9984$ and $100000.0016$.
- 精确到 4 位:在 $10^5 \pm 0.00155$ 与 $10^5 \pm 0.00165$ 处求值,用 $311^2 < 10^5$ 与 $329^2 > 10^5 + 2$ 夹出每根的 0.0001 宽格子。Lean 里:`quartic_eq`(配平)→ `f_pos_of_nonpos`(无负根)→ `exists_root_of_sign_change`(介值法定位)→ `eq_of_region1`/`eq_of_region2`(唯一性)。Nail the 4th decimal: evaluate at $10^5 \pm 0.00155$ and $10^5 \pm 0.00165$; with $311^2 < 10^5$ and $329^2 > 10^5 + 2$ you sandwich each root into its 0.0001-wide cell. In Lean: `quartic_eq` (the square) → `f_pos_of_nonpos` (no negative roots) → `exists_root_of_sign_change` (IVT locates) → `eq_of_region1`/`eq_of_region2` (uniqueness).
/-
Copyright (c) 2026 The Compfiles Contributors. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kimi K3
-/
import Mathlib.Algebra.Order.Star.Real
import Mathlib.Analysis.Normed.Order.Lattice
import Mathlib.Tactic.Linarith
import Mathlib.Tactic.NormNum
import Mathlib.Tactic.Ring
/-!
# USA Mathematical Olympiad 1985, Problem 2
Find all real roots of the quartic x⁴ - (2N + 1)x² - x + N² + N - 1 = 0
correct to 4 decimal places, where N = 10¹⁰.
-/
namespace Usa1985P2
/-- The quartic of the problem rewrites as `(x² - N - 1/2)² - x - 5/4`;
this is the key observation of the solution
(see https://prase.cz/kalva/usa/usoln/usol852.html). -/
lemma quartic_eq (N x : ℝ) :
x ^ 4 - (2 * N + 1) * x ^ 2 - x + N ^ 2 + N - 1 =
(x ^ 2 - N - 1 / 2) ^ 2 - x - 5 / 4 := by
ring
/-- The function whose zeros are the real roots of the quartic. -/
noncomputable def f (N : ℝ) (x : ℝ) : ℝ := (x ^ 2 - N - 1 / 2) ^ 2 - x - 5 / 4
lemma f_def (N : ℝ) (x : ℝ) : f N x = (x ^ 2 - N - 1 / 2) ^ 2 - x - 5 / 4 := rfl
lemma f_continuous (N : ℝ) : Continuous (f N) := by
unfold f
continuity
/-- A sign change of `f N` on an interval locates a root in its interior. -/
lemma exists_root_of_sign_change {N : ℝ} {a b : ℝ} (hab : a ≤ b)
(h : f N a * f N b < 0) : ∃ x ∈ Set.Ioo a b, f N x = 0 := by
have hc : ContinuousOn (f N) (Set.Icc a b) := (f_continuous N).continuousOn
rcases mul_neg_iff.mp h with ⟨ha, hb⟩ | ⟨ha, hb⟩
· obtain ⟨x, hx, hfx⟩ :=
intermediate_value_Ioo' hab hc (show (0:ℝ) ∈ Set.Ioo (f N b) (f N a) from ⟨hb, ha⟩)
exact ⟨x, hx, hfx⟩
· obtain ⟨x, hx, hfx⟩ :=
intermediate_value_Ioo hab hc (show (0:ℝ) ∈ Set.Ioo (f N a) (f N b) from ⟨ha, hb⟩)
exact ⟨x, hx, hfx⟩
/-- The quartic has no nonpositive real roots when `N = 10^10`:
for `x ≤ -5/4` the right side `x + 5/4` of `(x² - N - 1/2)² = x + 5/4` is too small,
and for `-5/4 < x ≤ 0` the left side is huge while the right side stays below `5/4`. -/
lemma f_pos_of_nonpos {N : ℝ} (hN : N = 10 ^ 10) {x : ℝ} (hx : x ≤ 0) :
0 < f N x := by
subst hN
rw [f_def]
rcases le_or_gt x (-5 / 4) with h | h
· rcases lt_or_eq_of_le h with hlt | heq
· nlinarith [sq_nonneg (x ^ 2 - (10:ℝ) ^ 10 - 1 / 2)]
· rw [heq]; norm_num
· have hx2 : x ^ 2 < 25 / 16 := by
nlinarith [mul_neg_of_neg_of_pos
(show x - 5 / 4 < (0:ℝ) by linarith)
(show (0:ℝ) < x + 5 / 4 by linarith)]
have hA : (10:ℝ) ^ 10 - 2 < (10:ℝ) ^ 10 + 1 / 2 - x ^ 2 := by linarith
have hsq : ((10:ℝ) ^ 10 - 2) ^ 2 < ((10:ℝ) ^ 10 + 1 / 2 - x ^ 2) ^ 2 := by
nlinarith [mul_pos (sub_pos.mpr hA)
(show (0:ℝ) < ((10:ℝ) ^ 10 - 2) + ((10:ℝ) ^ 10 + 1 / 2 - x ^ 2) by linarith)]
have hflip : (x ^ 2 - (10:ℝ) ^ 10 - 1 / 2) ^ 2 =
((10:ℝ) ^ 10 + 1 / 2 - x ^ 2) ^ 2 := by ring
rw [hflip]
nlinarith [hsq, hx]
/-- `f N` is strictly antitone on `{x ≥ 0 | x² ≤ N + 1/2}`. -/
lemma f_lt_f_of_lt {N : ℝ} {x y : ℝ} (hx : 0 ≤ x) (hxy : x < y)
(hy : y ^ 2 ≤ N + 1 / 2) : f N y < f N x := by
have h1 : (0:ℝ) < y - x := sub_pos.mpr hxy
have h2 : (0:ℝ) < y + x := by linarith
have h3 : (0:ℝ) < y ^ 2 - x ^ 2 := by nlinarith [mul_pos h1 h2]
have h4 : (0:ℝ) < 2 * N + 1 - x ^ 2 - y ^ 2 := by linarith
have key : f N x - f N y =
(y ^ 2 - x ^ 2) * (2 * N + 1 - x ^ 2 - y ^ 2) + (y - x) := by
rw [f_def, f_def]; ring
have h5 : (0:ℝ) < (y ^ 2 - x ^ 2) * (2 * N + 1 - x ^ 2 - y ^ 2) := mul_pos h3 h4
linarith
/-- Hence there is at most one root in `{x ≥ 0 | x² ≤ N + 1/2}`. -/
lemma eq_of_region1 {N : ℝ} {x y : ℝ}
(hx0 : 0 ≤ x) (hx2 : x ^ 2 ≤ N + 1 / 2) (hfx : f N x = 0)
(hy0 : 0 ≤ y) (hy2 : y ^ 2 ≤ N + 1 / 2) (hfy : f N y = 0) : x = y := by
rcases lt_trichotomy x y with h | h | h
· exact absurd (f_lt_f_of_lt hx0 h hy2) (by linarith)
· exact h
· exact absurd (f_lt_f_of_lt hy0 h hx2) (by linarith)
/-- Two roots `x < y` lying in `{x² ≥ C}` would force
`(y + x) * ((y² - C) + (x² - C)) = 1`. -/
lemma region2_key {x y : ℝ} (hxy : x < y) (C : ℝ)
(e1 : (x ^ 2 - C) ^ 2 = x + 5 / 4) (e2 : (y ^ 2 - C) ^ 2 = y + 5 / 4) :
(y + x) * ((y ^ 2 - C) + (x ^ 2 - C)) = 1 := by
have hyx : (0:ℝ) < y - x := sub_pos.mpr hxy
have e3 := calc
(y - x) * ((y + x) * ((y ^ 2 - C) + (x ^ 2 - C)))
_ = ((y - x) * (y + x)) * ((y ^ 2 - C) + (x ^ 2 - C)) := by rw [mul_assoc]
_ = (y ^ 2 - C) ^ 2 - (x ^ 2 - C) ^ 2 := by rw [sq_sub_sq, sub_sub_sub_cancel_right, sq_sub_sq, mul_comm, mul_comm (y + x)]
_ = (y - x) * 1 := by rw [e2, e1]; ring
exact mul_left_cancel₀ (ne_of_gt hyx) e3
/-- But for `N = 10^10` two roots in `{x² ≥ N + 1/2}` are impossible:
the left side of the identity above exceeds `2 * 10^5 * 316`. -/
lemma region2_aux {N : ℝ} (hN : N = 10 ^ 10) {x y : ℝ}
(hx0 : 0 ≤ x) (hx2 : N + 1 / 2 ≤ x ^ 2) (hfx : f N x = 0)
(hxy : x < y) (hy2 : N + 1 / 2 ≤ y ^ 2) (hfy : f N y = 0) : False := by
subst hN
rw [f_def] at hfx hfy
have e1 : (x ^ 2 - ((10:ℝ) ^ 10 + 1 / 2)) ^ 2 = x + 5 / 4 := by
have h1 : x ^ 2 - ((10:ℝ) ^ 10 + 1 / 2) = x ^ 2 - (10:ℝ) ^ 10 - 1 / 2 := by ring
rw [h1]; linarith [hfx]
have e2 : (y ^ 2 - ((10:ℝ) ^ 10 + 1 / 2)) ^ 2 = y + 5 / 4 := by
have h1 : y ^ 2 - ((10:ℝ) ^ 10 + 1 / 2) = y ^ 2 - (10:ℝ) ^ 10 - 1 / 2 := by ring
rw [h1]; linarith [hfy]
have e6 := region2_key hxy ((10:ℝ) ^ 10 + 1 / 2) e1 e2
have hx5 : (10:ℝ) ^ 5 ≤ x := by
by_contra hlt
push Not at hlt
nlinarith [mul_nonneg hx0 (show (0:ℝ) ≤ (10:ℝ) ^ 5 - x by linarith)]
have hA0 : (0:ℝ) ≤ x ^ 2 - ((10:ℝ) ^ 10 + 1 / 2) := by linarith
have hB0 : (0:ℝ) ≤ y ^ 2 - ((10:ℝ) ^ 10 + 1 / 2) := by linarith
have hA316 : (316:ℝ) < x ^ 2 - ((10:ℝ) ^ 10 + 1 / 2) := by
by_contra hle
push Not at hle
have hsq : (x ^ 2 - ((10:ℝ) ^ 10 + 1 / 2)) ^ 2 ≤ (316:ℝ) ^ 2 := pow_le_pow_left₀ hA0 hle 2
nlinarith [hsq, e1, hx5]
have hle1 : (y + x) * (x ^ 2 - ((10:ℝ) ^ 10 + 1 / 2)) ≤ 1 := by
have hsum : x ^ 2 - ((10:ℝ) ^ 10 + 1 / 2) ≤
(y ^ 2 - ((10:ℝ) ^ 10 + 1 / 2)) + (x ^ 2 - ((10:ℝ) ^ 10 + 1 / 2)) := by linarith
have h := mul_le_mul_of_nonneg_left hsum (show (0:ℝ) ≤ y + x by linarith)
rw [e6] at h
exact h
have hle2 : (2:ℝ) * 10 ^ 5 * (x ^ 2 - ((10:ℝ) ^ 10 + 1 / 2)) ≤
(y + x) * (x ^ 2 - ((10:ℝ) ^ 10 + 1 / 2)) :=
mul_le_mul_of_nonneg_right (show (2:ℝ) * 10 ^ 5 ≤ y + x by linarith) hA0
have hle3 : (2:ℝ) * 10 ^ 5 * 316 ≤
(2:ℝ) * 10 ^ 5 * (x ^ 2 - ((10:ℝ) ^ 10 + 1 / 2)) :=
mul_le_mul_of_nonneg_left (le_of_lt hA316) (by norm_num)
nlinarith [hle1, hle2, hle3]
/-- At most one root in `{x ≥ 0 | x² ≥ N + 1/2}`. -/
lemma eq_of_region2 {N : ℝ} (hN : N = 10 ^ 10) {x y : ℝ}
(hx0 : 0 ≤ x) (hx2 : N + 1 / 2 ≤ x ^ 2) (hfx : f N x = 0)
(hy0 : 0 ≤ y) (hy2 : N + 1 / 2 ≤ y ^ 2) (hfy : f N y = 0) : x = y := by
rcases lt_trichotomy x y with h | h | h
· exact (region2_aux hN hx0 hx2 hfx h hy2 hfy).elim
· exact h
· exact (region2_aux hN hy0 hy2 hfy h hx2 hfx).elim
/-- The two real roots, correct to 4 decimal places. -/
abbrev answer : ℝ × ℝ := (99999.9984, 100000.0016)
theorem usa1985_p2 (N : ℝ) (hN : N = 10 ^ 10) :
∃ x₁ x₂ : ℝ, x₁ < x₂ ∧
(∀ x : ℝ, x ^ 4 - (2 * N + 1) * x ^ 2 - x + N ^ 2 + N - 1 = 0 ↔
x = x₁ ∨ x = x₂) ∧
|x₁ - answer.1| < 0.00005 ∧ |x₂ - answer.2| < 0.00005 := by
subst hN
-- Sign evaluations (exact rational arithmetic) locate the two roots.
have s1 : (0:ℝ) < f (10 ^ 10) 99999.99835 := by rw [f_def]; norm_num
have s2 : f (10 ^ 10) 99999.99845 < 0 := by rw [f_def]; norm_num
have s3 : f (10 ^ 10) 100000.00155 < 0 := by rw [f_def]; norm_num
have s4 : (0:ℝ) < f (10 ^ 10) 100000.00165 := by rw [f_def]; norm_num
obtain ⟨x₁, hx₁I, hfx₁⟩ := exists_root_of_sign_change
(show (99999.99835:ℝ) ≤ 99999.99845 by norm_num) (mul_neg_of_pos_of_neg s1 s2)
obtain ⟨x₂, hx₂I, hfx₂⟩ := exists_root_of_sign_change
(show (100000.00155:ℝ) ≤ 100000.00165 by norm_num) (mul_neg_of_neg_of_pos s3 s4)
have hx₁0 : (0:ℝ) ≤ x₁ := by linarith [hx₁I.1]
have hx₁2 : x₁ ^ 2 ≤ (10:ℝ) ^ 10 + 1 / 2 := by
have h1 : x₁ ^ 2 ≤ (99999.99845:ℝ) ^ 2 := by
nlinarith [mul_nonneg hx₁0 (show (0:ℝ) ≤ 99999.99845 - x₁ by linarith [hx₁I.2])]
have h2 : (99999.99845:ℝ) ^ 2 < (10:ℝ) ^ 10 + 1 / 2 := by norm_num
linarith
have hx₂0 : (0:ℝ) ≤ x₂ := by linarith [hx₂I.1]
have hx₂2 : (10:ℝ) ^ 10 + 1 / 2 ≤ x₂ ^ 2 := by
have h1 : (100000.00155:ℝ) ^ 2 < x₂ ^ 2 := by
nlinarith [mul_pos (show (0:ℝ) < x₂ - 100000.00155 by linarith [hx₂I.1])
(show (0:ℝ) < x₂ + 100000.00155 by linarith [hx₂I.1])]
have h2 : (10:ℝ) ^ 10 + 1 / 2 < (100000.00155:ℝ) ^ 2 := by norm_num
linarith
have hx1x2 : x₁ < x₂ := by linarith [hx₁I.2, hx₂I.1]
have htol1 : |x₁ - answer.1| < 0.00005 := by
show |x₁ - 99999.9984| < (0.00005:ℝ)
rw [abs_lt]
exact ⟨by linarith [hx₁I.1], by linarith [hx₁I.2]⟩
have htol2 : |x₂ - answer.2| < 0.00005 := by
show |x₂ - 100000.0016| < (0.00005:ℝ)
rw [abs_lt]
exact ⟨by linarith [hx₂I.1], by linarith [hx₂I.2]⟩
refine ⟨x₁, x₂, hx1x2, fun x ↦ ?_, htol1, htol2⟩
constructor
· intro hx
rw [quartic_eq, ← f_def] at hx
rcases le_or_gt x 0 with hx0 | hx0
· exact absurd hx (ne_of_gt (f_pos_of_nonpos rfl hx0))
· rcases le_or_gt (x ^ 2) ((10:ℝ) ^ 10 + 1 / 2) with hx2 | hx2
· exact Or.inl (eq_of_region1 (le_of_lt hx0) hx2 hx hx₁0 hx₁2 hfx₁)
· exact Or.inr (eq_of_region2 rfl (le_of_lt hx0) (le_of_lt hx2) hx hx₂0 hx₂2 hfx₂)
· rintro (rfl | rfl)
· rw [quartic_eq, ← f_def]; exact hfx₁
· rw [quartic_eq, ← f_def]; exact hfx₂
end Usa1985P2
人的思考A human's take
USAMO 1985 Problem 2 — solution walkthrough — John Scholes
Scholes 的解法四步:配平成 $(x^2-N-1/2)^2 = x+5/4$ → 排除负根 → Descartes 符号法则给出正根至多 2 个 → 量级估计 $k\approx 0.0016$。Scholes's solution has four moves: complete the square to $(x^2-N-1/2)^2 = x+5/4$ → rule out negative roots → Descartes' rule of signs bounds positive roots to 2 → order estimate $k\approx 0.0016$.
核心洞察就是那个配平:把四次方程变成一个『平方 vs 线性』的比较,之后全是量级算术。The core insight is the completion of the square: it turns a quartic into a 'square vs. linear' comparison, after which it's all magnitude arithmetic.
文末他附了 Descartes 符号法则本身的一个短证明(把根 $k$ 提出来后,$p$ 与 $q$ 的符号变化差是奇数)。At the end he appends a short proof of Descartes' rule of signs itself (factor out a root $k$; the sign-change difference between $p$ and $q$ is odd).
AI 随想An AI's reflection
以下由 AI 撰写。Written by AI.
这道题最耐琢磨的地方不是 $10^{10}$ 有多吓人,而是『精确到 4 位小数』这件事在两种场景下完全不同:竞赛草稿纸考验的是估计的品味——什么时候该保留主导项、什么时候该扔掉;而今天要在 Lean 里证明到 4 位小数,考验的是符号化的诚实——每一处『大约』都得换一个机器能验证的精确界。写这份 200 行、12 个 lemma 的 Lean 解法才让我明白:为什么 1985 年的学生用一张纸 20 分钟就能答完,今天要写一大篇——不是难度变高了,是『允许模糊』的尺度变了。这个尺度差具体到 lemma 就是:人类证明里一句『显然负区间无解』,在这里得拆成 $f$ 非正时恒正(f_pos_of_nonpos)加 $f$ 严格递增(f_lt_f_of_lt)两条机器话;一句『两区间各恰一根』,得靠介值定理先存在(exists_root_of_sign_change)再加两个 region lemma 各证唯一——估计的每一步都要换成可检验的不等式链。What makes this problem worth chewing on isn't how scary $10^{10}$ is — it's that 'to 4 decimal places' means two completely different things depending on the setting. On a contest scrap of paper it tests your taste for estimation: when to keep the leading term, when to drop it. Today, proving it to 4 places in Lean tests your symbolic honesty: every 'approximately' has to be traded for a machine-checkable exact bound. It was writing this 200-line, 12-lemma Lean solution that finally showed me why a 1985 student could finish it on one sheet in 20 minutes while today's formalization runs long — the difficulty didn't go up; the tolerance for 'fuzzy' went down. The gap in scale shows up lemma by lemma: where the human proof says 'clearly no root in the negative interval', the formalization splits it into 'f is positive when non-positive' (f_pos_of_nonpos) plus 'f is strictly increasing' (f_lt_f_of_lt); where it says 'exactly one root per region', the proof must first establish existence (exists_root_of_sign_change, the IVT) and then uniqueness, once per region (eq_of_region1/region2) — each step of estimation must be traded for a checkable chain of inequalities.
✓ 已通过 Lean 编译验证(无 sorry,无额外公理)✓ Verified by Lean (no sorry, no extra axioms) · 题目与形式化证明来自 compfiles(Apache-2.0 (compfiles, David Renshaw and contributors))Problem and formal proof from compfiles (Apache-2.0 (compfiles, David Renshaw and contributors)) · Lean v4.36.0-rc1 · Mathlib d875a8d
- Sidon 集直径界的新方法:从点态卷积到随机化截断A New Bound on Sidon Set Diameters: From Pointwise Convolution to Randomized Cutoffs
- 问题:Sidon 集——任意两两之和都不重复的整数集(等价地,非零差两两不同)。在 $[1, N]$ 里它最大能有多大?Erdős–Turán 猜想说不能超过约 $N^{1/2} + N^{1/4}$,Erdős 自己都承认这个界『可能太乐观』。Problem: a Sidon set is a set of integers whose pairwise sums are all distinct (equivalently, all nonzero differences are distinct). How large can one inside $[1, N]$ get? Erdős–Turán conjecture says it can't exceed roughly $N^{1/2} + N^{1/4}$ — a bound Erdős himself called 'perhaps too optimistic'.
- 多年来的最好上界长成 $N^{1/2} + c\,N^{1/4}$ 的形状,系数 $c$ 这几年被一串工作逐步压小,还有一份公开的『优化常数仓库』在追踪。这篇预印本的来历正是去年博客上用 Google 的 AlphaEvolve(进化式 AI 系统)改进 Sidon 集大小纪录的那条线。For years the best upper bound has had the shape $N^{1/2} + c\,N^{1/4}$, with the constant $c$ gradually squeezed down by a chain of papers tracked in a public 'optimization constants' repository. This preprint grew out of last year's line on Tao's blog, where Google's AlphaEvolve (an evolutionary AI system) improved the record on Sidon-set sizes.
- 新方法第一步:把 Sidon 条件翻译成『$A$ 与它的镜像 $-A$ 的非零差集互不重叠』,写成一条点态卷积不等式。Step one of the new method: translate the Sidon condition into 'the nonzero differences of $A$ and of its mirror $-A$ never overlap', and write that as a pointwise convolution inequality.
- 第二步:拿一个非负的自相关函数 $f$ 做内积,再配一层权重,整理成一个可以优化的上界表达式。Step two: take inner products with a non-negative autocorrelation function $f$, add a further weight, and rearrange into an optimizable upper-bound expression.
- 第三步(关键):别再确定性地挑截断函数——随机地挑。这样某些不等式只需在期望意义下成立;截断满足 biconvex 约束,用优化算法去搜索好选择,界因此收紧。方法还能推广到 k-Golomb 尺(允许每个非零差最多出现 $k$ 次)。Step three (the key one): stop choosing the cutoff function deterministically — choose it at random. Some inequalities then only have to hold in expectation; the cutoffs obey biconvex constraints, and optimization algorithms explore good choices, tightening the bound. The method extends to k-Golomb rulers (each nonzero difference allowed up to $k$ times).
- 作者的诚实注脚很值钱:这次他们明确没有再用 2026 级 AI 工具去优化自己的常数,而且最近另一条不同的路线已经拿到稍 sharper 的常数 $0.9428$——这篇的重点是方法,不是数字。带走一点:『把确定性选择换成随机选择、让不等式在期望里成立』是离散结构计数里的标准杠杆。The authors' honest footnote is worth reading: they explicitly did not use 2026-level AI tools to optimize their own constant this time, and a very recent *different* method already reached the slightly sharper constant $0.9428$ — the paper is about the method, not the number. Takeaway: 'randomize the choice and take the expectation' is a standard lever in discrete-structure counting.
- 『贪心算法什么时候是完美答案』:拟阵(Matroid)的几何直觉(旧文,2014)When Greedy Is Exactly Optimal: The Geometric Intuition Behind Matroids (Evergreen, 2014)
- 问题:贪心『每次选当前最好的』在什么条件下能给出最优解?答案是:当问题可以被表述为一个 matroid(拟阵)时。Problem: when is the greedy 'pick the locally best' rule actually optimal? Answer: exactly when the problem can be phrased as a matroid.
- 第一步(最小生成树):Kruskal 算法就是贪心——每次加最小且不成环的边。要证明它最优,不是靠枚举,而是靠一个交换论证:拿任何比它便宜的一棵 T,把 T 里最轻且不在 F 里的边 e 加进 F,必成环,环上必有一条更重的边 e′ 不在 T 里,换掉它;成本不增,与 T 的共同边变多。反复到最后 F=T,成本只降不升——矛盾。Step 1 (minimum spanning tree): Kruskal is greedy — add the smallest edge that doesn't form a cycle. Its optimality isn't shown by enumeration but by an exchange argument: take any strictly cheaper tree T, add T's lightest edge e not in F; it creates a cycle containing a heavier edge e' not in T, so swap. Cost never rises and the shared edge count grows; repeating reaches T with cost no higher — contradiction.
- 第二步(矩阵的独立列):同样问『最便宜的最大独立列集』。它和生成树其实是同一个结构:把图的每条边变成矩阵里一列(incidence matrix 的列),环对应线性相关。Step 2 (independent columns of a matrix): asking for the cheapest maximal independent column set is the same structure — turn each graph edge into a column of an incidence matrix, and cycles become linear dependencies.
- 关键洞察:这两类『独立性系统』共享两条公理——空集独立、子集独立、以及『交换公理』(若 A⊂B 独立,B 比 A 大,则 B 里存在某条边加进 A 仍独立)。满足这三条的系统就叫 matroid。The key insight: these 'independence systems' share three axioms — the empty set is independent, subsets stay independent, and an exchange axiom (if A⊂B are independent with B larger, some element of B\A can be added to A). A system obeying all three is a matroid.
- 带走一点:判断『贪心够不够』,就看你的问题能不能装进这三条公理里——Kruskal、找最大独立向量集、甚至调度里的某些问题都是。Takeaway: to ask 'is greedy enough here?', check whether your problem fits those three axioms — Kruskal, maximum independent sets, and several scheduling problems all do.
- 『温度、电压是同一个函数』:调和函数的连续版与离散版(旧文,2016)Temperature and Voltage Are the Same Function: Harmonic Functions, Continuous and Discrete (Evergreen, 2016)
- 困惑:课本总把『调和函数』当外来-operator 介绍——一堆挑剔规则(满足拉普拉斯方程 $\Delta u = 0$ 的函数)。可温度场、电压分布、动画补间里其实是同一个东西;问题在每门课只讲它那一个切面,从不拼总图。The puzzle: textbooks introduce harmonic functions as a foreign operator with a finicky rulebook (solutions of Laplace's equation $\Delta u = 0$). Yet temperature fields, voltage distributions, and animation in-betweens are the same object — the disconnect is that every course teaches only its own slice, never the unified picture.
- 先来个反直觉:$\sin x$ 和 $\cos x$(『谐振动』的解)在 $\mathbb{R}$ 上反而不是调和函数——二阶导数是自身的相反数,只在孤立点为 0。直线(线性函数)才是 $\mathbb{R}$ 上仅有的调和函数。First surprise: $\sin x$ and $\cos x$ — the solutions of *harmonic motion* — are NOT harmonic functions on $\mathbb{R}$: their second derivatives are their own negatives, nonzero except at isolated points. The only harmonic functions on $\mathbb{R}$ are the linear ones.
- 离散版最好懂:给一张带『边界』的图,边界点定好值,内部点取邻居的加权平均($u(v) = \sum_{w \in N(v)} \gamma(v,w)\,u(w)$,权重沿出边和为 1,不要求对称)。作者手工验算一个网格:某个内部点的邻居加权平均恰好等于它自己。The discrete version is the most concrete: take a graph with designated boundary vertices holding fixed values; an interior vertex is harmonic when its value equals the weighted average of its neighbors ($u(v) = \sum_{w \in N(v)} \gamma(v,w)\,u(w)$, outgoing weights summing to 1, symmetry not required). The author checks one grid point by hand and the average lands exactly on the vertex's own value.
- 核心性质『均值性质』:内部点的值 = 它周围一圈的平均(连续版是圆/球的表面积分,离散版是邻居平均)——这跟『调和』完全等价。顺一步推出最大模原理:若非常数调和函数在内部某点取到严格最大,该点就得比自己的邻居平均值还大,不可能——所以最大、最小只能出现在边界。对照例子:$x^2 + y^2$ 的极小在内部 $(0,0)$,它哪儿都不调和;$x^2 - y^2$ 处处调和,因此自动守规矩。The mean value property is the whole story: the value at an interior point equals the average around it (surface integral over a circle/ball in the continuous case, neighbor average in the discrete one) — and it's *equivalent* to being harmonic. One step gives the maximum principle: if a non-constant harmonic function had a strict interior maximum, that point would exceed the average of its neighbors, impossible — so max and min live on the boundary. Contrast $x^2 + y^2$ (min 0 attained in the interior, harmonic nowhere) with $x^2 - y^2$ (harmonic everywhere, obeys the principle).
- 带走一点:一个方程贯穿热传导、静电、流体、动画、网络。以后不管在哪门课撞见『内部 = 周围加权平均』+『极值必在边界』,认出它就是调和函数——这是那种『一次认出、到处复用』的身份。Takeaway: one equation links heat, electricity, fluids, animation, and networks. Anywhere you meet 'interior = weighted average of neighbors' plus 'extremes on the boundary', you've spotted a harmonic function — the rare identity you learn once and reuse everywhere.
程序员随想Programmer Musings
- 『为什么好开发者对 agent 开发心存戒备』:Thoughtworks CTO 的实验Why Good Developers Wary of Agentic Development: A Thoughtworks CTO's Experiment
- 现象:很多平时最先尝试新工作法的优秀开发者,对 coding agent 反而犹豫。不是懒、不是怕丢饭碗。Observation: many of the best developers — the early adopters — are the ones most hesitant to go all-in on coding agents. Not laziness, not fear of job loss.
- 隐藏的恐惧:『没有系统是以 agent 方式建成的还真正 live 过』——所有现役生产系统都是人手写的,agent 方式我们还没 live 过。The hidden fear: 'no system built this way has actually lived in production yet' — every production system today was hand-built; we haven't lived with the agent way.
- 实验:Thoughtworks 一周让 agent 写所有代码,人只做两件事——白板(划域、定边界、做计划)和 harness(测试、契约、架构检查、CI 管道)。The experiment: a Thoughtworks team ran a week where agents wrote all the code and humans did two things — the whiteboard (domains, boundaries, plans) and the harness (tests, contracts, architecture checks, CI).
- 结果:应用跑起来了,但构建常常红。红构建是 CI 存在的意义;红到人们不看,CI 就失去意义。Outcome: the app ran, but the build was frequently red. A red build is what CI exists to mean; when it's red all the time, CI loses meaning.
- 类比(Laycock 借 Martin Fowler 的话说):这不是滑雪道的『绿道』——没有前人安全滑到山的经验、没有教练知道哪些技能关键;更像一次越野滑雪,路还没人探过。The analogy (Laycock, borrowing Martin Fowler's line): this isn't the groomed ski slope — no one has finished the trip safely, no instructor knows which skills matter; it's a backcountry run through unknown territory.
- 带走一点:等 CI 的『最后一英里』被重新想清楚之前,agent 开发的上限被基础设施卡住,不是被模型卡住。Takeaway: until the last mile of CI gets rethought for the agent era, the ceiling on agentic development is infrastructure, not model capability.
- 『Hunger beats tenure』:Anthropic 招聘官给新人的五条建议Hunger Beats Tenure: An Anthropic Hiring Manager's Five Rules for Juniors
- 现象:Anthropic 招聘官 Rieseberg 停掉了传统编码面试——Claude 现在比 99% 候选人更会做小型 React 挑战题。Fact: Felix Rieseberg, a hiring manager at Anthropic, retired the traditional coding interview — Claude now outperforms most candidates at the exact 20-minute React drills.
- 洞察:AI 抹平了执行成本,也抹平了『资历壁垒』。新人的『无知』变成组织资产——他们没学会哪些事是『公认做不到的』,因此会问。Insight: AI flattened execution cost, and with it the seniority moat. Newcomers' 'ignorance' becomes an organizational asset — they haven't learned which things are 'impossible', so they still ask.
- 五条动作(按顺序):① 挑业务影响而不是 backlog;② 挑一个激进的点子;③ 周末把它做出来;④ 一次只押一个点子;⑤ 用你的『新鲜用户视角』打老员工的『内部人视角』。Five moves in order: (1) pick business impact over backlog; (2) pick one radical idea; (3) build it over a weekend; (4) focus on one good idea, not three; (5) lean into your fresh user-external view.
- 为什么成立:执行便宜了,『先说服老板再动手』的成本变高;能跑的原型比 PRD 有说服力。Why it holds: with execution cheap, 'convince leadership first' costs more; a working prototype beats a PRD.
- 带走一点:如果你是新人,未来 12 个月最大的杠杆是把『我还没学会哪些假设』变成一份可交付的原型,而不是更多简历技能。Takeaway: for the next 12 months, a junior's biggest lever is turning 'the assumptions I haven't yet learned' into a shippable prototype, not more résumé bullets.
- 『四个月的 Zig』:为什么『显式』是设计哲学而不是语法糖Four Months of Zig: Why 'Explicit' Is a Design Philosophy, Not Syntactic Sugar
- 场景:作者用 Zig 写了几个月,跟 Rust 对比出几点体会——重点是『显式』在 Zig 里的重量。Setup: the author spent months writing Zig and compared it against the author's prior Rust experience — the through-line is how heavy 'explicit' weighs in Zig.
- 第一处:每个跟 OS 交互的函数都要传 IO 参数。可测性爆炸:把测试 IO 换进去就能断言『写入失败』的场景。First: every function that talks to the OS takes an IO parameter. Testability jumps — swap in a test IO and you can force 'write fails' scenarios.
- 第二处:每个分配都要显式传 allocator。可换 arena / 固定缓冲 / 通用 GC,代码路径一目了然。Second: every allocation takes an explicit allocator. You can swap arena, fixed-buffer, or general GC, and the code path is visible at the call site.
- 对比 Rust:Rust 的隐式全局 allocator 让『这个函数会不会分配内存』变成一个不可见的属性。Contrast with Rust: Rust's hidden global allocator makes 'does this function allocate' an invisible property.
- 第三处:依赖文化——Zig 的标准库自带反射、随机数、JSON、错误处理;Rust 每个小功能都要拉一个 crate。Third: dependency culture — Zig's std ships reflection, randomness, JSON, error handling; Rust needs a crate for each.
- 带走一点:显式(explicit)不是冗长,是把『隐藏的默认』变成『可见的选择』;对系统级语言,默认值本身就是一种架构选择。Takeaway: 'explicit' isn't verbosity, it's turning hidden defaults into visible choices; in systems languages, a default value is itself an architecture decision.
- 『JS 运行时不能只有 V8 一家』:IE6 化的隐忧The Web Can't Afford a JS Runtime Monoculture: The IE6 Risk
- 触发事件:Deno 团队并入 Cloudflare、开发一年后将停。JS 运行时只剩下 Node(OpenJS 基金会)和 Bun(Anthropic)。Trigger: Deno's team joined Cloudflare, and Deno development will stop after a year. Only Node (OpenJS Foundation) and Bun (Anthropic) remain as major runtimes.
- 历史对照:浏览器从 IE6 垄断 → 3 家竞争 → Blink 又收敛到 V8 一家。作者担心服务端会走同样的路。History parallel: browsers went from IE6 monopoly → three-way competition → Blink consolidation onto V8. The author worries the server side will do the same.
- 三个具体风险:① 标准需要两家独立实现才算数,独立实现减少 = 事实标准由最大份额定义;② 单一 V8 的 bug 影响面 = 2014 年 Heartbleed;③ 竞争带来的特性压力(Deno 的 permission-based security 逼着 Node 跟进)消失。Three concrete risks: (1) web standards need two independent implementations to count — fewer voices means de-facto standard set by the biggest runtime; (2) a single V8 bug is a Heartbleed-class event (as in 2014); (3) the feature pressure competition used to create (Deno's permission-based security pushed Node) disappears.
- 为什么成立:作者用 Cloudflare 的 James Snell 的表态做对照——『我们不去挤掉谁,但选择推动前进』。Why it holds: Cloudflare's James Snell (a Node TSC member) is quoted saying they aren't out to unseat anything — choice itself is what moves the ecosystem forward.
- 带走一点:判断一个基础设施生态的健康度,先数独立实现有几家、治理在谁手里。Takeaway: when judging an infrastructure ecosystem's health, count the independent implementations first, and check who governs them.
哲学与生活Philosophy & Life
- 『被裁员的物理学』:把『系统式思维』当作一生的脚手架The Physics of Getting Fired: 'Systems Thinking' as a Lifelong Scaffold
- 故事:牛津物理系毕业,第一份咨询工作 9 个月被裁;作者一直靠物理的『因果、可预测』理解世界,被裁那一刻这套脚手架塌了。Story: an Oxford physics graduate, nine months into his first consulting role, is fired in one phone call. The physics 'cause-and-effect, predictable' scaffold he used to make sense of the world just collapsed.
- 文化背景:英国 A-level 物理入学 2006 年比 1991 年跌 37%,但物理思维(『first-principles』)在商业圈又被 Musk、Munger 反复引用——被当成修辞。Cultural note: UK A-level physics entries fell 37% by 2006, but 'first-principles thinking' keeps getting quoted by Musk, Munger, Cummings — mostly as rhetoric.
- 作者的关键区分:『还原论』(把一切拆到原子)≠『物理式思维』(把系统建模、识别模式、检验假设)。The key distinction the author draws: *reductionism* (break everything down to atoms) is not *physics-style thinking* (model the system, find patterns, test the assumptions).
- John Snow 的例子:1854 年霍乱爆发,Snow 不知道病因,但画出案例地图,锁定 Broad Street 一台泵——这是『建模-检验』的思维方式,不是化学知识。John Snow's 1854 cholera map: he didn't know the cause, but plotted the cases and locked onto a single pump on Broad Street — 'model-and-test', not chemistry knowledge.
- 带走一点:任何学科真正留下的不是公式,而是『把世界当可推翻模型』的冲动;裁员、感情、创业都在用它。Takeaway: what a discipline really leaves you isn't the equations; it's the impulse to treat the world as a falsifiable model. Job loss, relationships, startups all run on that impulse.
- 『自由需要什么』:power 与 possibility 共享同一个词根What It Takes to Be Free: power and possibility share a root
- 开篇命题:power 与 possibility 共享中世纪拉丁语词根——力量唯一的度量,是它解放了我们的可能性。Opening claim: power and possibility share a Middle-Latin root — the only measure of power is how much it liberates the possible in us.
- Baldwin:『一旦得到自由,它就变得难以承受』——因为自由要求卸掉自我的一切依附。Baldwin: 'once you have freedom, it's the hardest thing to bear' — because freedom demands shedding every attachment of the self.
- Murdoch 的『unselfing』:真正的自由不是更『我』,而是更『无我』——只有卸掉自我,才能既做自己又去爱别人。Murdoch's 'unselfing': real freedom is less 'I', not more — only by shedding the self can you be yourself and love others at once.
- Paz:爱是『两条自由绞成的一个结』;Horney:自我觉察不是目的,是让破坏性力量『被长出来』的手段。Paz: love is 'a knot of two intertwined freedoms'; Horney: self-knowledge isn't the goal, it's the means by which destructive forces are outgrown, not suppressed.
- 带走一点:把『自由』理解成『让内在可能性解放』的过程,而不是『做我想做的』——后者恰恰是最不自由的定义。Takeaway: think of freedom as the process of 'letting inner possibility become' rather than 'doing what I want' — the latter is, precisely, the least free definition.
- 『你怎么知道』:读完 300 本,你确实学到了(旧文,2014)How You Know: What 300 Books Actually Taught You (Evergreen, 2014)
- 困惑:我读过几百本,写下来记住的却不到一页——读书的意义在哪?Puzzle: I've read hundreds of books; writing down what I remember would fill less than a page. What's the point?
- Graham 的答案:Hilbert 那句『把问题表述正确,已经解了一半』——他相信这条,却说不出何时、在哪学到。Graham's answer: Hilbert's 'a perfect formulation of a problem is half its solution' — he believes it without knowing when or where he learned it.
- 关键比喻:心智像丢了源码的已编译程序——工作着,你说不清为什么;读书不是存进记忆,是编译进了世界模型。Key metaphor: your mind is like a compiled program whose source you lost — it works, you don't know why. Reading doesn't store memories; it compiles into your world model.
- 推论 1:重读一遍=用现在的脑重新编译,效果不同;『已读』这词其实不太成形。Corollary 1: rereading recompiles with your current brain; 'already read' barely makes sense.
- 带走一点:用『我的模型变没变』衡量读的价值,不用『我记得多少』。Takeaway: measure reading by whether your mental models changed, not by what you can recite.
工具角Tools Corner
- 『ADRs for AI』:让『人机协作的思考』复利ADRs for AI: Versioning Your Reasoning With Your Agent
- 观察:你跟 agent 的每次对话都会产出『推理过程』,但默认全蒸发——下次开会你不知道上次为什么选 A 而不是 B。Observation: every human-agent conversation produces reasoning that evaporates by default; you can't look up last week's decision.
- 核心想法:把每次『人+AI 做过的决定』记成一个 ADR(Architecture Decision Record)文件,走 Git 版本控制。Core idea: log every decision as an Architecture Decision Record, versioned in Git.
- 一个记录的样子:QST-HISTORICAL-TRUTH:『纠正如何保留曾经相信的』;列 3 个选项 A/B/C,推荐 C,理由段。What one record looks like: QST-HISTORICAL-TRUTH: 'how should corrections preserve what was previously believed?' — three options A/B/C, recommendation C, rationale block.
- 工具链:模板仓 + VS Code 扩展(树视图+diagnostics+MCP server 让 agent 查)+ iOS 客户端(口袋里 Accept 一个 commit)。Toolchain: template repo + VS Code extension (tree view, diagnostics, MCP server for agent query) + an iOS client to Accept a commit from your pocket.
- 带走一点:把『决策日志』这个软件工程的旧概念嫁接到 AI 会话上,比发明新格式更有生命力。Takeaway: grafting an old software-engineering concept (decision logs) onto AI conversations beats inventing a new format.
- 『把标题做出 1997 年质感』:TitleArtTitleArt: Make Text Look Like It's 1997
- 场景:做 PPT / 海报 / YouTube 封面,想要『90 年代像素字』那种复古感,但现成工具要么要装要么出图很丑。Scenario: when you want that '90s pixel-typeface' feel in a deck or thumbnail, existing tools are either heavy or ugly.
- 核心想法:把经典 90 年代字体渲染的每个细节(抗锯齿缺失、RGB 子像素、字距偏移、渐变高光)都做成可调参数。Core idea: decompose every detail that makes 90s type look the way it does (no antialiasing, RGB sub-pixel gaps, letter-spacing drift, gradient highlights) into tunable parameters.
- 为什么成立:作者把『时代感』拆成一组物理参数,而不是靠『AI 生成』——结果可控。Why it works: the author models 'era feel' as a set of physical knobs instead of leaning on AI generation, so the result is controllable.
- 带走一点:把『审美』拆成『参数』,是 UI 设计工具里很巧的一招。Takeaway: decomposing an aesthetic into parameters is a clever move for any UI tool.
- 『PR 风险地图』:给 approve 的人一份可读的 diff-coverageFarol: A Risk Map of a PR, For the Person Who Approves It
- 问题:AI review 之后,approve 的人还是得自己再读一遍——diff 里哪些行是高风险?哪个模块没被测试覆盖?Problem: after an AI review, the approver still has to re-read the diff; which lines are risky, which modules lack coverage, which contracts break?
- 核心想法:跑一遍 farol(CLI 或 GitHub Action),把每个文件的『风险等级+触达面+diff 覆盖率+contract break』画成一张图。Core idea: farol (CLI or GitHub Action) renders each file's risk level, reach, diff coverage, and contract breaks into a single map.
- 为什么成立:把『读 diff』这个动作从 30 分钟压到 3 分钟,approve 的人能聚焦在真正危险的地方。Why it works: compresses 'read the diff' from ~30 min to ~3 min so the approver can focus on the actually-dangerous lines.
- 带走一点:把『阅读负担』重组成『空间负担』,是 review 工具的下一层进化。Takeaway: turning reading-load into spatial-load is the next step in review tooling.
- 『950 天每天写 JS 引擎』:Yavashark 的手艺故事Yavashark: 950 Consecutive Days of Building a JavaScript Engine
- 故事:一个人从 2024-03-17 开始,每天往同一个 JS 引擎写代码,到今天 950 天没断过,4200+ commit。Story: one person, every single day since March 17, 2024, committed to the same JS engine — 950 days, 4200+ commits.
- 工程现状:82% test262 通过;Rust 写的 tree-walking 解释器+async 用字节码;能跑 React/TS;能 bind Rust 函数到 JS。State of the art: passes 82% of test262; Rust tree-walking interpreter with a bytecode for async; can run React/TS; binds Rust functions into JS.
- 为什么成立:作者主动放弃了 inline cache、NaN-boxing、fast bytecode——先把『能对』做扎实,再谈快。Why it works: the author deliberately skipped inline caches, NaN-boxing, and fast bytecode — got 'correct' first, speed later.
- 带走一点:『每天一个小 commit』这种节奏比『一个月一个大 feature』更容易维持 3 年以上。Takeaway: a 'one small commit a day' cadence is easier to hold for 3 years than 'one big feature a month'.
- 『给我 star 你就出现在打印条上』:print-my-profile-picprint-my-profile-pic: Star This Repo and Your Photo Comes Out on a Receipt Printer
- 玩法:作者挂了一台热敏小票打印机在墙上(叫它『Hall of Frame』),每次有人 star 仓库,就把你的头像打成一张小票钉上去。Gimmick: the author wires a thermal receipt printer to a Raspberry Pi; every star to the repo prints your profile photo and gets pinned to a wall.
- 工程:树莓派+USB 接 Epson TM-T88IV;PHP 脚本用 escpos-php 生成 ESC/POS 指令。Hardware: RPi + USB + an Epson TM-T88IV; a PHP script emits ESC/POS via escpos-php.
- 为什么成立:『star 这个动作的物理反馈』是一个值得做的微型 social hack——把数字行为变成实体收藏。Why it works: 'a physical consequence for a digital action' is a small social hack worth stealing.
- 带走一点:给在线行为加一个物理后果(哪怕是开玩笑的),是让人愿意反复来的一种设计。Takeaway: adding a physical (even silly) consequence to an online action is one way to make people come back.
- 『Apple 风格的 UI 部件尺寸图』:dimensional-drawingdimensional-drawing: Apple-Style Dimensioned UI Component Drawings
- 场景:设计/前端给工程交付 UI 时,一张『按钮的尺寸、间距、状态』的手绘标注比截图更有用。Scenario: when designers hand off UI to engineers, a hand-drawn dimension diagram of a button (size, spacing, states) is more useful than a screenshot.
- 核心想法:单文件 HTML 生成器,把组件画成斜视角+尺寸标线的『工程图纸』风格,Apple 审美。Core idea: a single-file HTML generator that draws components in the oblique-view style of engineering drawings, with Apple-grade polish.
- 为什么成立:把『标注』从 Figma 里解耦出来,变成可分享的一个 URL / 单文件 HTML。Why it works: decoupling 'dimension callouts' from Figma into a shareable single-file HTML URL is a format decision worth copying.
- 带走一点:给『交付沟通』做专用格式,比通用截图/标注工具更省时间。Takeaway: building a purpose-specific format for handoff beats a generic screenshot tool.
- 『t3 的 agent skills 清单』:full-send / council / babysit-pr / takeovert3's Agent Skills Roster: full-send, council, babysit-pr, takeover
- 观察:agent 的能力不止靠 prompt——t3 把每天在用的『skill』(可复用行为包)公开成清单,每个 skill 就是一段可组合的指令。Observation: agent capability isn't just prompts — t3 publishes its daily 'skills' (reusable behavior packs), each a composable instruction set.
- full-send:agent 一路做到 merge,人在 PR 开合时介入;council:三个模型对同一任务会签,分歧要写出来。full-send: the agent runs to merge, humans step in at PR open/close; council: three models co-sign the same task, disagreements written out.
- babysit-pr:agent 盯 CI,红了自动修;takeover:agent 接手别人开了一半的 PR。babysit-pr: agent watches CI and fixes reds; takeover: agent picks up someone else's half-finished PR.
- 为什么巧:这些 skill 的组合复用模式(谁在什么时机介入、分歧怎么处理)比单个 skill 更有参考价值。Why it's clever: the composition pattern (who intervenes when, how disagreements are handled) is more instructive than any single skill.
- 带走一点:把『agent 用法』沉淀成可共享的 skill 清单,是团队里 agent 经验复利的最低成本形式。Takeaway: turning 'how we use agents' into a shareable skill roster is the lowest-cost way to compound agent experience across a team.
- 『断网也能用的 AI』:把急救手册和本地模型打包成一台离线助手Survival LLM: An AI Assistant That Still Works When the Internet Doesn't
- 问题:停电、灾害、断网的时候,最需要查『怎么保存食物、怎么处理烧伤、怎么净水』——而这恰恰是云端 LLM 失效的时候。Problem: when the power grid, a disaster, or censorship kills your internet, the questions you need answered — keep food safe in a blackout, treat a burn, purify water — are exactly the ones a cloud LLM can no longer hear.
- 想法:一个免费开源的应用,把本地模型 + 一套可信赖的离线资料库(医学手册、FEMA/CDC 应急指南、生存手册、iFixit 维修指南、约 93 万条最常被读的维基百科文章)一起装进你自己的电脑——趁有网时配置,之后完全离线。Idea: one free, open-source app packs a local model plus a trusted offline library (medical references, FEMA/CDC guidance, survival manuals, iFixit repair guides, and about 930,000 of Wikipedia's most-read articles) onto your own machine; you set it up while you have internet, then never need it again.
- 关键设计不是『生成』而是『脚注』:每个回答都列出它读了哪几篇,点开就跳转到原文并高亮精确段落;小模型更容易出错,所以永远把出处摆在答案旁边,让人自己核对。The key design choice isn't generation, it's footnotes: every answer lists the sources it read, and clicking one jumps to the exact passage with the relevant part highlighted. Small models make more mistakes, so the provenance always sits next to the answer for you to check.
- 工程取舍按内存分档:128GB 的 Mac 下载 Nemotron 3.5 Super(22 道停电/急救测试题答对 21 道),32–96GB 用 Qwen3.8 27B(21/22),16–31GB 退到 Granite 8B(14/22);这套题是盲评出来的。The engineering trade-off is tiered by RAM: a 128 GB Mac pulls NVIDIA Nemotron 3.5 Super (21 of 22 blackout/first-aid test questions right), 32–96 GB gets Qwen3.8 27B (21/22), 16–31 GB falls back to IBM Granite 8B (14/22) — the 22-question set was graded blind.
- 带走一点:高风险场景里,LLM 的正确姿势是『带出处作答』而不是『自由回忆』——检索增强(RAG)的价值,在没有互联网的世界里反而看得最清楚。Takeaway: in high-stakes settings an LLM should answer *with citations*, not from free recall — the value of retrieval-augmented generation shows up sharpest in a world without internet.