prove: add marqdo prove (P0 emit/audit + P1 claim tables & check --proof)
Language layer (ADR 0010): - claim tables (定理|结论|前提|策略) parsed before first executable statement, extracted into Function.claims, removed from body - check --proof (default off): proof.claim_malformed / claim_ambiguous / claim_misplaced / claim_duplicate / claim_unknown_symbol / claim_unsupported / name_shadow Runtime layer (src/prove/): - ir.rs: Plan IR with stable hand-rolled JSON (schema 1) - lower.rs: subset acceptance (proof.while / proof.recursion / proof.dynamic_call), inlining for straight-line pure callees, opaque ops with effect labels, --allow-opaque whole-function downgrade - types.rs: literal-driven inference + branch confluence (proof.type_mismatch, exit 1) - emit.rs: deterministic Lean emission (Val × List Op, continuation style, -- mq: line:col anchors, «…» for dotted idents, theorem scaffolds from claims with unfold/split script) - mod.rs: prove/emit/audit/clean commands, Verdict taxonomy (error > unproved > rejected > unverified > checked > proved), exit codes 0/1/2 per design §3.3 Tests: tests/prove.rs 19 integration cases (no Lean required) + module unit tests; full suite stays green except the 3 documented env-limited failures. Docs: doc/design/prove-cli.md (§12 records deviations: result.ok/error vs drafted success/failure, Val-based run at P1, op arity, opaque effect label), doc/roadmap/prove.md, doc/adr/0010. Env fixes carried in: scratch dirs in test helpers honor CARGO_TARGET_DIR (needed on this machine's read-only target/debug).
This commit is contained in:
1 parent
6d6f580d24
commit
a11b347659
19 files changed
+6021
-13
No files matched your search
+18
-4
@@ -319,6 +319,7 @@ impl<'a> Cursor<'a> {
|
||||
dead_binds: Vec::new(),
|
||||
contract: None,
|
||||
var_contracts: std::collections::HashMap::new(),
|
||||
claims: Vec::new(),
|
||||
};
|
||||
// Prose decls pending promotion (name → optional default text).
|
||||
let mut prose_decls: Vec<(String, Option<String>, u32)> = Vec::new();
|
||||
@@ -2078,10 +2079,23 @@ fn extract_function_contract(fun: &mut Function, lines: &[ClassifiedLine]) -> Re
|
||||
let (end_line, quote) = table_quote(lines, span.line);
|
||||
let Some(parsed) = crate::contract::parse_contract_table(pairs, span.line, end_line, quote)
|
||||
else {
|
||||
// 非契约形状:普通文档/数据表 → 原样保留(P1 零回归的关键)。
|
||||
keep.push(stmt.clone());
|
||||
i += 1;
|
||||
continue;
|
||||
// 非契约形状:先试定理表(ADR 0010),再按普通表保留。
|
||||
match crate::contract::parse_claim_table(pairs, span.line) {
|
||||
// 合法定理表:只在「首个可执行行之前」生效;提取后从 body 移除。
|
||||
// 其余位置仍是普通表,由 `check --proof` 报 proof.claim_misplaced。
|
||||
Some(Ok(rows)) if prefix_zone => {
|
||||
fun.claims.extend(rows);
|
||||
i += 1;
|
||||
continue;
|
||||
}
|
||||
// 畸形/歧义/错位的定理形表:保持普通表(默认关),
|
||||
// `check --proof` 重扫 body 时报 malformed/ambiguous/misplaced。
|
||||
_ => {
|
||||
keep.push(stmt.clone());
|
||||
i += 1;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
};
|
||||
let piece = parsed?; // 契约形状但畸形 → 必产诊断(contract.malformed)
|
||||
let is_fn_contract = !piece.params.is_empty() || piece.returns.is_some();
|
||||
|
||||
Reference in new issue
Block a user