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
+16
@@ -95,6 +95,22 @@ pub struct Function {
|
||||
pub contract: Option<crate::contract::Contract>,
|
||||
/// 集合契约(T2.1):变量名 → 字段契约(紧邻 `` `名` = `` 绑定之前的文档表)。
|
||||
pub var_contracts: HashMap<String, crate::contract::Contract>,
|
||||
/// 定理表(ADR 0010):函数级命题声明;首条可执行语句之前提取,不参与运行。
|
||||
pub claims: Vec<Claim>,
|
||||
}
|
||||
|
||||
/// 一条定理声明(设计 §7.1):`| 定理 | 结论 | 前提 | 策略 |` 的一行。
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Claim {
|
||||
/// 定理 id(函数内唯一;重复由 `check --proof` 报 `proof.claim_duplicate`)。
|
||||
pub id: String,
|
||||
/// 受限表达式文本(参数、`结果`、`轨迹`、三个谓词、算术/比较/布尔)。
|
||||
pub conclusion: String,
|
||||
pub premise: Option<String>,
|
||||
/// `auto`(默认)或 `none`;其他值由 `check --proof` 报 unsupported。
|
||||
pub tactic: Option<String>,
|
||||
/// 表行所在行号(锚定漂移检测)。
|
||||
pub line: u32,
|
||||
}
|
||||
|
||||
impl Function {
|
||||
|
||||
Reference in new issue
Block a user