prove: P1 — Lean 判定接入 CLI(driver + 证书缓存 + CI)

- driver.rs:工具链发现(--lean → MARQDO_PROOF_LEAN → PATH;显式坏路径
  error[proof.lean_missing] 不回退);MarqdoProof 库内嵌进二进制,按内容
  哈希缓存、lean -o 直接构建(运行时零 lake/elan 依赖);lean 调用带超时
  (--timeout/--heartbeats);unsolved→unproved、error→error、
  sorry→unverified;-- mq: 注释 + 定理头注释 → 证据映射指回源行
- cache.rs:复合键证书(源码⊕plan⊕库sha256⊕lean版本⊕版本),
  命中跳判定(lean.cache: hit),--no-cache/MARQDO_PROOF_NO_CACHE 绕过
- mod.rs:per-claim 判定面(status/decided_by/evidence/source_line)、
  lean JSON 对象、proof.claim_failed 诊断;文件状态只聚合有定理与被拒函数
- main.rs:--lean/--timeout/--no-cache/--heartbeats 旗标;prove emit
  子命令只生成不判定;策略 none → sorry(绝不冒充 proved)
- tests/prove_lean.rs:A1/E1/E4/F2/F3/F4/G1/G2/G2b 矩阵,无工具链 SKIP、
  MARQDO_PROOF_REQUIRE_LEAN=1 硬性要求;实测抓出并修复错误行/列解析、
  逐定理记录缺失、含点函数名归因三处判定缺陷
- CI proof.yml:装 Lean 4.35.0 → 底座校验 → 判定矩阵(CI 不许静默降级)
- 设计文档 §12 记录 P1 落地与偏差(直接 lean -o,不经 lake)

实测:业务样例 3 定理 proved;假定理 unproved 退 1 指回定理表行;
缓存命中后跳判定(假 lean 计数器验证);全量 Rust 测试 508 通过
(仅剩 2 个已记录环境基线失败)。
This commit is contained in:
cflmy committed 2026-11-18 10:28:18 +08:00
1 parent fa832268b3
commit 44d2928c06
11 files changed
+1776 -27

No files matched your search

+28
View File
@@ -536,6 +536,22 @@ enum Commands {
/// CI strict mode: unjudged statuses exit 2 (P1+)
#[arg(long)]
require_lean: bool,
/// Explicit lean binary (else MARQDO_PROOF_LEAN, else PATH)
#[arg(long, value_name = "PATH")]
lean: Option<PathBuf>,
/// Per-lean-call timeout in seconds (default 120)
#[arg(long, value_name = "SEC", default_value_t = 120)]
timeout: u64,
/// Bypass the certificate cache (also MARQDO_PROOF_NO_CACHE)
#[arg(long)]
no_cache: bool,
/// maxHeartbeats for lean (default: lean's own)
#[arg(long, value_name = "N")]
heartbeats: Option<u64>,
},
}
@@ -1081,6 +1097,10 @@ fn try_main(cli: Cli) -> Result<i32> {
allow_opaque,
no_strict_types,
require_lean,
lean,
timeout,
no_cache,
heartbeats,
} => {
// 子命令参数覆盖顶层默认;默认动作 = emit + 报告。
let (file, action_json, action_emit, action_only, action_opaque, action_relax) =
@@ -1131,6 +1151,9 @@ fn try_main(cli: Cli) -> Result<i32> {
let emit_target = action_emit.flatten();
let report_only = matches!(action, Some(ProveAction::Audit { .. }))
|| (action.is_none() && report_only);
// emit 子命令只生成不判定(§8.2)。
let judge = !matches!(action, Some(ProveAction::Emit { .. }));
let no_cache = no_cache || std::env::var_os("MARQDO_PROOF_NO_CACHE").is_some();
let opts = marqdo::prove::ProveOptions {
entry: None,
only: action_only,
@@ -1139,6 +1162,11 @@ fn try_main(cli: Cli) -> Result<i32> {
strict_types: !action_relax,
require_lean,
report_only,
judge,
no_cache,
lean,
timeout: std::time::Duration::from_secs(timeout),
max_heartbeats: heartbeats,
};
let report = marqdo::prove::prove_path(&file, &opts)?;
for d in &report.diagnostics {