Prove what a page claims: theorem tables judged by Lean 4ok
文档
怎样读这份可执行文档
正文说明意图,标记指出哪些片段会执行。遮蔽只在正文显示动作说明,实际逻辑放在侧注;阅读、展开与定位都不会运行代码。
| 标记 | 阅读含义 |
|---|---|
无标记文字 | 作者的解释,按普通 Markdown 阅读。 |
空行 | 分隔叙述与结构,不是计算步骤。 |
# / ## | 一级标题声明对象或入口,更深标题声明函数;说明按钮可查看输入、返回与依据。 |
> | 调用函数;实际执行结果另有标注。 |
1. 递增 | 按条件选择分支,不是普通编号说明。 |
- | 重复或遍历结构;迭代选择器只切换已有运行记录。 |
+ `名` | 兼容的显式形参;新库优先在叙述中声明参数,标题下的表格解释契约。 |
GFM 表 | 未绑定的契约表是说明;绑定表按列、行和 @ 形态构成数据。 |
```lang | 代码块;绑定的外语代码与普通示例区分展示,数学公式另有公式卡片。 |
--- / *** | 分隔内容,不能把分隔线当作函数返回。 |
<!-- marqdo-out --> | 程序写回的结果,区别于作者原始正文。 |
`名` | 叙述中的参数或变量;默认值跟在名称之后。 |
**…** | 执行语句:赋值、调用或计算;不是打印,也不是返回。 |
*…* | 返回表达式;句中以返回、Return 等明确引出。 |
*None* / **** | 显式返回空值或结束当前函数。 |
[键](集合) | 正文显示描述,侧注按函数与参数、可跳转链接、结构化内容展示括号内的细节;空括号表示待补充实际逻辑。阅读不会执行调用。classic 模式保留旧链接取元。 |
修饰… [函数] … | 兼容的带修饰调用;不能把任意普通链接当作执行授权。 |
集合[^键] | 兼容的脚注取元;当前库优先用 access 读取集合。 |
*仅* / **说明** | 普通强调仍属于文字;界面按真实解析结果区分强调、语句与返回。 |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | any | None; execute this page's documented steps in order and observe their output or stated effects |
v2.8.0 adds one command: marqdo prove. A theorem table in a knowledge file is compiled to Lean 4 and judged automatically. The claim stops being prose that a reader agrees with and becomes a statement a proof assistant checks.
marqdo prove examples/approval.mq.md --json
The pipeline has six stages: load, lower to an intermediate representation, type the claim, generate a Lean module, judge it, and issue a certificate. Judging has two layers. Offline symbolic execution runs first — path enumeration over the pure fragment, milliseconds, no toolchain required. When a Lean toolchain is available it re-checks the emitted module and upgrades the verdict.
The status ladder is honest by construction: proved > checked > unverified > rejected > unproved > error. Offline checked is a decided trace for the explored paths, never a proof; proved exists only when Lean says so. Without a toolchain the verdict stays at checked or unverified and the process exits zero — advisory, not silent. --require-lean flips unjudged states into failures for CI.
A false theorem does not get a shrug. The judge produces a counterexample witness — concrete input values that walk the function down a path where the conclusion fails — and points back at the theorem-table row.
The boundary that makes this trustworthy is monotonicity: whatever the offline layer claims, Lean must be able to confirm. If the offline verdict says checked and Lean cannot prove it, or a counterexample is proven away, the command fails with proof.divergence and exits non-zero. A judger defect fails loudly; a green light is never defended.
The fragment is deliberately small: pure functions, branch comparisons, call-trace shapes, constructor structure, interval restatements. Loops report proof.foreach_pending instead of pretending. Cross-module calls stay opaque until assumption tables arrive. Every simplification is recorded in the design docs, because a proof system that hides its boundaries is marketing, not verification.
This page runs — the theorems below live in the same file that explains them. 轨迹 is the implicit call trace of the function: the big-amount path must pass through 复核, opaque calls append to it, and inlined result.ok constructors do not.
| 参数 | 类型 | 说明 |
|---|---|---|
| 金额 | int | 记账金额(元) |
| 定理 | 结论 | 前提 | 策略 |
|---|---|---|---|
| 大额必经复核 | 包含(轨迹, "复核") | 金额 > 10000 | auto |
| 大额单次外呼 | 长度(轨迹) = 1 | 金额 > 10000 | auto |
| 必有回执 | 结果.ok = True | auto |
- 当金额小于等于10000时回执 =
函数调用直接记账
源码说明 · 不是运行结果result.ok- value
- 记
原始写法
result.ok(value="记") - else复核结论 =
函数调用转复核
源码说明 · 不是运行结果复核- 金额
`金额`
原始写法
复核(金额=`金额`)回执 =函数调用采纳
源码说明 · 不是运行结果result.ok- value
`复核结论`
原始写法
result.ok(value=`复核结论`)
函数调用复核通过
result.ok- value
- 复核
原始写法
result.ok(value="复核")Variables
-
description textv2.8.0 marqdo prove compiles theorem tables to Lean 4 and judges them. Offline symbolic execution works without a toolchain and never outruns Lean.v2.8.0 marqdo prove compiles theorem tables to Lean 4 and judges them. Offline symbolic execution works without a toolchain and never outruns Lean.
-
markup textocclusionocclusion
-
title textProve what a page claims: theorem tables judged by Lean 4Prove what a page claims: theorem tables judged by Lean 4
可执行知识 · 输入、返回与依据
这份文档怎样成为可调用的知识
4 个知识单元 · 4 个结构步骤。先读输入、返回与调用边界,再按需查看依赖和依据。
以下来自静态分析,不代表程序已经运行、测试通过或内容已获领域确认。实际运行见正文标注与“运行与结果”。
main程序入口
这是程序入口或对象声明。成员函数的输入输出在各自说明中列出。
源码中的返回契约
any · None; execute this page's documented steps in order and observe their output or stated effects
调用边界
无已知宿主副作用。权限由实际运行入口授予;静态副作用信息不等于运行许可。
当前有哪些依据
- 语法与引用
- 检查通过;检查通过
- 契约检查
- 尚未检查
- 测试记录
- 没有可用记录
- 内容来源
- 尚无已核验证据
- 领域审阅
- 尚未进行领域审阅
技术详情:身份、摘要与原始状态
- 目标标识
mq://public/features%2F23-prove/type/main- 制品摘要(未检查锁定状态)
sha256:2839b0a3cf2c13e0d83cff6a9cae1807187aff52086ff61672e5cb3ed857912e- 依赖标识
- 原始验证状态
parse: passed; resolve: passed; contract: unchecked; execution: not_run; tests: unknown; evidence: unverified; domain: unreviewed
台账对象
这是程序入口或对象声明。成员函数的输入输出在各自说明中列出。
调用边界
无已知宿主副作用。权限由实际运行入口授予;静态副作用信息不等于运行许可。
当前有哪些依据
- 语法与引用
- 检查通过;检查通过
- 契约检查
- 尚未检查
- 测试记录
- 没有可用记录
- 内容来源
- 尚无已核验证据
- 领域审阅
- 尚未进行领域审阅
技术详情:身份、摘要与原始状态
- 目标标识
mq://public/features%2F23-prove/type/%E5%8F%B0%E8%B4%A6- 制品摘要(未检查锁定状态)
sha256:2839b0a3cf2c13e0d83cff6a9cae1807187aff52086ff61672e5cb3ed857912e- 依赖标识
- 原始验证状态
parse: passed; resolve: passed; contract: unchecked; execution: not_run; tests: unknown; evidence: unverified; domain: unreviewed
台账.记一笔函数
需要什么输入
| 参数 | 类型 | 提供方式 | 含义 |
|---|---|---|---|
金额 | number | 必填 | 记账金额(元) |
返回什么
any · 源码未提供返回值说明;请结合正文实现阅读。
调用边界
无已知宿主副作用。权限由实际运行入口授予;静态副作用信息不等于运行许可。
依赖哪些知识
当前有哪些依据
- 语法与引用
- 检查通过;检查通过
- 契约检查
- 尚未检查
- 测试记录
- 没有可用记录
- 内容来源
- 尚无已核验证据
- 领域审阅
- 尚未进行领域审阅
技术详情:身份、摘要与原始状态
- 目标标识
mq://public/features%2F23-prove/function/%E5%8F%B0%E8%B4%A6/%E8%AE%B0%E4%B8%80%E7%AC%94- 制品摘要(未检查锁定状态)
sha256:c73571755b1a8ba3f47f037e05cd2b99c2a6efd1d3925b112cec50edb57739fa- 依赖标识
mq://public/features%2F23-prove/function/%E5%8F%B0%E8%B4%A6/%E5%A4%8D%E6%A0%B8- 原始验证状态
parse: passed; resolve: passed; contract: unchecked; execution: not_run; tests: unknown; evidence: unverified; domain: unreviewed
台账.复核函数
需要什么输入
| 参数 | 类型 | 提供方式 | 含义 |
|---|---|---|---|
金额 | any | 必填 | 源码未提供参数说明 |
返回什么
any · 源码未提供返回值说明;请结合正文实现阅读。
调用边界
无已知宿主副作用。权限由实际运行入口授予;静态副作用信息不等于运行许可。
当前有哪些依据
- 语法与引用
- 检查通过;检查通过
- 契约检查
- 尚未检查
- 测试记录
- 没有可用记录
- 内容来源
- 尚无已核验证据
- 领域审阅
- 尚未进行领域审阅
技术详情:身份、摘要与原始状态
- 目标标识
mq://public/features%2F23-prove/function/%E5%8F%B0%E8%B4%A6/%E5%A4%8D%E6%A0%B8- 制品摘要(未检查锁定状态)
sha256:d39ef6634c33379081896e70907d5d99e5d3bb3ed11cc1952106bae401869399- 依赖标识
- 原始验证状态
parse: passed; resolve: passed; contract: unchecked; execution: not_run; tests: unknown; evidence: unverified; domain: unreviewed
运行与结果
完整源码
--- markup: occlusion import: result: ../../lib/result.mq.md title: Prove what a page claims: theorem tables judged by Lean 4 description: v2.8.0 marqdo prove compiles theorem tables to Lean 4 and judges them. Offline symbolic execution works without a toolchain and never outruns Lean. --- # main | 返回 | 类型 | 说明 | |---|---|---| | result | any | None; execute this page's documented steps in order and observe their output or stated effects | v2.8.0 adds one command: `marqdo prove`. A theorem table in a knowledge file is compiled to Lean 4 and judged automatically. The claim stops being prose that a reader agrees with and becomes a statement a proof assistant checks. ```text marqdo prove examples/approval.mq.md --json ``` The pipeline has six stages: load, lower to an intermediate representation, type the claim, generate a Lean module, judge it, and issue a certificate. Judging has two layers. Offline symbolic execution runs first — path enumeration over the pure fragment, milliseconds, no toolchain required. When a Lean toolchain is available it re-checks the emitted module and upgrades the verdict. The status ladder is honest by construction: `proved > checked > unverified > rejected > unproved > error`. Offline `checked` is a decided trace for the explored paths, never a proof; `proved` exists only when Lean says so. Without a toolchain the verdict stays at `checked` or `unverified` and the process exits zero — advisory, not silent. `--require-lean` flips unjudged states into failures for CI. A false theorem does not get a shrug. The judge produces a counterexample witness — concrete input values that walk the function down a path where the conclusion fails — and points back at the theorem-table row. The boundary that makes this trustworthy is monotonicity: whatever the offline layer claims, Lean must be able to confirm. If the offline verdict says checked and Lean cannot prove it, or a counterexample is proven away, the command fails with `proof.divergence` and exits non-zero. A judger defect fails loudly; a green light is never defended. The fragment is deliberately small: pure functions, branch comparisons, call-trace shapes, constructor structure, interval restatements. Loops report `proof.foreach_pending` instead of pretending. Cross-module calls stay opaque until assumption tables arrive. Every simplification is recorded in the design docs, because a proof system that hides its boundaries is marketing, not verification. This page runs — the theorems below live in the same file that explains them. `轨迹` is the implicit call trace of the function: the big-amount path must pass through 复核, opaque calls append to it, and inlined `result.ok` constructors do not. # 台账 ## 记一笔 + `金额` | 参数 | 类型 | 说明 | |---|---|---| | 金额 | int | 记账金额(元) | | 定理 | 结论 | 前提 | 策略 | |---|---|---|---| | 大额必经复核 | 包含(轨迹, "复核") | 金额 > 10000 | auto | | 大额单次外呼 | 长度(轨迹) = 1 | 金额 > 10000 | auto | | 必有回执 | 结果.ok = True | | auto | 1. 当`金额`小于等于10000时 **回执 = [直接记账](result.ok(value="记"))** 2. * **复核结论 = [转复核](复核(金额=`金额`))** **回执 = [采纳](result.ok(value=`复核结论`))** *回执* ## 复核 + `金额` **复核回执 = [复核通过](result.ok(value="复核"))** *复核回执*