Blaine Hansen:构建主流可形式化验证语言抵御LLM风险
The need for a formally verifiable mainstream programming language
To save software engineering from LLMs, we need a mainstream verifiable language
为了将软件工程从大语言模型中拯救出来,我们需要一种主流的可验证编程语言
The culture of software engineering has to change, and that will take many different projects to achieve.
软件工程的文化和实践必须改变,这需要多个不同的项目共同努力才能实现。
published: June 21, 2026 - last updated: November 27, 2026
发布时间:2026年6月21日 - 最后更新时间:2026年11月27日
Because of LLMs, the discipline of software engineering is in crisis. Quality is nose-diving (opens new window), and I see no reason why it won't keep getting worse. Software engineering was struggling before LLMs (opens new window). The default was to be sloppy and poorly considered, and now everyone is frantically accelerating those same terrible practices to LLM speed.
由于大语言模型(LLMs)的出现,软件工程这一学科正陷入危机。代码质量正在断崖式下跌(opens new window),而我看不到任何理由相信情况不会继续恶化。在大语言模型出现之前,软件工程就已经步履维艰(opens new window)。当时的默认做法往往是草率且缺乏深思熟虑的,而现在,每个人都在以惊人的速度将这些糟糕的实践加速到大语言模型的级别。
Something has to change. I've been preoccupied with this for a while (opens new window), but much more qualified people finally fully agree with me (opens new window). The only way forward is to fully embrace formal verification (opens new window), all the way down to the foundations of our civilizational software stack. We have to post-hoc verify the things we can, and rewrite the rest.
必须做出改变。我对此已经关注了一段时间(opens new window),但如今更多具备资质的人终于完全认同我的观点(opens new window)。唯一的出路是全面拥抱形式化验证(opens new window),一直深入到我们文明软件栈的基础层面。我们必须对能够验证的部分进行事后验证,并重写其余部分。
But that's easier said than done. Existing formal verification tools suffer from massive usability (opens new window) and understandability (opens new window) problems, and have failed to make any kind of noticeable impact on the broader culture of software engineering.
但这说起来容易做起来难。现有的形式化验证工具在可用性(opens new window)和理解性(opens new window)方面存在巨大问题,并且未能对更广泛的软件工程文化产生任何显著影响。
It might be tempting to say that LLMs will actually save us in this regard, by allowing humans to create formally verified code without needing to understand its fundamentals in any way. This is pure cope. Merely having excellent proof assistants and LLMs will never be good enough. Even in a world where something like Lean is extremely scalable and LLMs can write all proofs, it doesn't matter if they aren't adopted by actual industry engineers as they build the real apps we actually use. For provably correct code to defend us from the LLM future:
人们可能会觉得,大语言模型实际上能在这方面拯救我们,因为它们允许人类无需理解其基本原理就能创建经过形式化验证的代码。这纯属自我安慰。仅仅拥有优秀的证明助手和大语言模型是远远不够的。即使在一个像 Lean 这样极其可扩展、且大语言模型能够编写所有证明的世界中,如果这些工具没有被实际构建我们所用真实应用程序的行业工程师所采用,那也是毫无意义的。为了让可证明正确的代码能够抵御大语言模型带来的未来风险:
- It needs to be possible to formally verify code that runs in any environment, from web browsers down to embedded systems.
- Industry engineers need to know provably correct code is even possible and be comfortable enough with it to at least tell their LLMs to write it.
- Those industry engineers must be able to reason about formal correctness properties enough to even know the right things are being proven. In the words of Leonardo de Moura (opens new window):
- Proof assistants guarantee that proofs are correct, but correctness alone is not enough. Someone has to read the theorem statements and confirm they capture the intended mathematics. This is the human contract that no amount of automation can eliminate.
- 必须能够对运行在任何环境中的代码进行形式化验证,范围从 Web 浏览器一直到嵌入式系统。
- 行业工程师需要知道可证明正确的代码是可能存在的,并且对其感到足够舒适,至少能够指示他们的大语言模型去编写这类代码。
- 这些行业工程师必须具备足够的推理能力,以理解形式化正确性属性,从而知道哪些内容是被证明的关键点。正如 Leonardo de Moura(opens new window)所言:
- 证明助手能够保证证明的正确性,但仅有正确性是不够的。必须有人阅读定理陈述并确认它们准确捕捉了预期的数学内容。这是任何自动化手段都无法消除的人类契约。
This is what most voices are missing in this discussion: a safe future isn't going to be delivered by a small priestly class of formal methods researchers, too much code must be produced in too many contexts. The entire discipline of software engineering has to grow up and demand that all code we produce is at minimum provably safe. This requires many different projects and bets that attack this imperative of cultural change from different directions.
这场讨论中大多数声音所缺失的正是这一点:一个安全的未来不会由一小撮形式化方法研究人员的神职阶层来交付,因为必须在众多情境下生成大量代码。软件工程整个领域都必须成熟起来,要求我们生成的所有代码至少是可证明安全的。这需要许多不同的项目和赌注,从不同方向应对这种文化变革的迫切需求。
§ The long winding road of Magmide
§ Magmide 漫长而曲折的道路
My chosen angle is Magmide, a project whose goal is to create a new formally verifiable programming language intended for immediate adoption by practitioners. However when I first had this idea my specific plan was woefully over-ambitious and unrealistic, since I wanted to make a whole new proof assistant and an assembly-level base language so the system could be verified all the way down to the metal.
我选择的切入点是 Magmide,这是一个旨在创建一种新的、可供从业者立即采用的形式化验证编程语言的项目。然而,当我最初产生这个想法时,我的具体计划过于雄心勃勃且不切实际,因为我希望构建一个全新的证明助手和一个汇编级别的基础语言,以便系统能够一直验证到硬件层面。
I pursued it for a time as a startup, and I met with some investors and was applying for an SBIR grant. Then I realized some obvious problems with my approach (opens new window):
我曾将其作为初创项目进行了一段时间的探索,会见了一些投资者,并正在申请 SBIR 资助。随后我意识到我的方法存在一些显而易见的问题(opens new window):
- It didn't make sense to build a new proof assistant when Lean has been making such rapid progress.
- An assembly-level language was insanely difficult and wasn't necessary to gain adoption from practitioners.
- I didn't have the appetite to pursue some strained business model for a project that ultimately makes most sense as a pure public good.
- 当 Lean 正在取得如此快速进展时,构建一个新的证明助手是没有意义的。
- 汇编级语言极其困难,而且对于获得从业者的采用来说并非必要。
- 我没有动力去追求某种勉强的商业模式,因为该项目最终作为纯粹的公共产品才最有意义。
So now after a few years pursuing other projects and letting all these ideas marinate, I've arrived at a much simpler and more pragmatic vision of what Magmide could be. If I started working on it today, it would:
因此,在 pursuit 其他项目并让这些想法沉淀几年后,我现在对 Magmide 可能是什么有了更为简单和务实的愿景。如果我今天开始着手开发它,它将:
- Compile to WebAssembly using the Garbage Collection (opens new window) features.
- Have a Rust-inspired type system but without the difficulties of the borrow-checker.
- Start with basic and more easily learnable SMT powered (opens new window) Liquid Types (opens new window) and Flow Effects (opens new window).
- Over time integrate Lean as the proof layer, and use some separation logic paradigm like Iris (opens new window) to bootstrap the language and verify its own implementation.
- 使用垃圾回收功能(opens new window)编译为 WebAssembly。
- 拥有受 Rust 启发的类型系统,但不具备借用检查器的困难。
- 从基本的、更易学习的 SMT 驱动(opens new window)的 Liquid Types(opens new window)和 Flow Effects(opens new window)开始。
- 随着时间的推移集成 Lean 作为证明层,并使用类似 Iris(opens new window)的分离逻辑范式来引导该语言并验证其自身实现。
This design is specifically intended to appeal to actual engineers and "meet them where they are". The roadmap would start from a simpler more mainstream design and go "bottom up" by adding more and more proving capabilities, rather than going "top down" by starting with the most formally powerful system and then seeking to make it more usable.
该设计专门旨在吸引真正的工程师,并"在他们所处的位置与他们对接"。路线图将从一个更简单、更主流的设计开始,通过逐步增加证明能力来"自底向上"推进,而不是从最形式化的强大系统开始再试图使其更易用(即"自顶向下")。
A possible analogue for the adoption of Magmide is Deno (opens new window): Deno is "just javascript/typescript", but it adds a runtime layer of permissions checking. Engineers who care about sandbox safety have enthusiastically adopted Deno, and Flow Effects would offer strictly more security.
Magmide 的采用可能有一个类比:Deno (opens new window)。Deno "只是 JavaScript/TypeScript",但它添加了一层运行时权限检查。关心沙箱安全的工程师热情地采用了 Deno,而 Flow Effects 将提供严格更多的安全性。
§ Nothing will save us but us
§ 唯有我们自己能拯救自己
I continue to stand behind basically all the arguments I made in the Magmide repo (opens new window) (aside from the specific architecture). Formal verification must become the mainstream of software engineering, and we have to embrace a wide diversity of approaches to make that happen. Software engineers aren't a monolith, and not every cultural pocket will respond to the same new tools and resources.
我依然基本支持我在 Magmide 仓库 (opens new window) 中提出的所有论点(除了具体的架构)。形式化验证必须成为软件工程的主流,我们必须拥抱多样化的方法来实现这一目标。软件工程师并非铁板一块,不同的文化群体不会对相同的新工具和资源产生相同的反应。
And you know what, LLMs will probably help a lot! But we can't just wait around for an all-knowing machine god to save us from ourselves. If we bet our whole future on ASI making all our problems go away and then that doesn't happen (opens new window), history will look back on us even more foolish and disastrous than all the millennialists (opens new window) who merely wasted their own time and resources.
而且你知道吗,LLM 可能会帮上大忙!但我们不能只是坐等全知全能的神机来拯救我们免于自身之害。如果我们把整个未来都押注在 ASI 会让所有问题消失上,而结果并未如此 (opens new window),历史将会把我们看得比那些仅仅浪费了自己时间和资源的千禧年主义者 (opens new window) 更加愚蠢和灾难性。
It is our responsibility to meet the challenges of our age with full agency and responsibility, and treat the emergence of a beneficent super-intelligence as an improbable jackpot.
我们有责任以充分的自主性和责任感应对时代的挑战,并将仁慈超级智能的出现视为一个极不可能中的大奖。
更进一步:量化金融体系
看懂新闻只是起点——沿量化金融路径,把它变成能交付的工程能力