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
+13
-2
@@ -23,14 +23,17 @@ use crate::load;
|
||||
|
||||
/// 读取文件 + 装载(含 import)后做全量契约互查。
|
||||
pub fn check_path(path: &Path) -> Result<Vec<Diagnostic>> {
|
||||
check_path_opts(path, false)
|
||||
check_path_opts(path, false, false)
|
||||
}
|
||||
|
||||
/// `implicit_labels` enables the fuzzy M5 check (prose above `>` calls).
|
||||
///
|
||||
/// It is **off by default**: describing a call in prose is freeform, so the
|
||||
/// check is inherently ambiguous and would be noisy — opt in when you want it.
|
||||
pub fn check_path_opts(path: &Path, implicit_labels: bool) -> Result<Vec<Diagnostic>> {
|
||||
///
|
||||
/// `proof` enables the theorem-table check (`check --proof`, ADR 0010,
|
||||
/// 默认关):表形、名字、片段、遮蔽。
|
||||
pub fn check_path_opts(path: &Path, implicit_labels: bool, proof: bool) -> Result<Vec<Diagnostic>> {
|
||||
let module = load::load_module(path)?;
|
||||
let mut out = check_module(&module, Some(path));
|
||||
if implicit_labels {
|
||||
@@ -38,6 +41,9 @@ pub fn check_path_opts(path: &Path, implicit_labels: bool) -> Result<Vec<Diagnos
|
||||
out.extend(crate::label::check_implicit(&module, &source, Some(path)));
|
||||
}
|
||||
}
|
||||
if proof {
|
||||
out.extend(crate::prove::proof_check::check_proofs(&module, Some(path)));
|
||||
}
|
||||
Ok(out)
|
||||
}
|
||||
|
||||
@@ -213,6 +219,11 @@ fn edit_distance(a: &str, b: &str) -> usize {
|
||||
prev[b.len()]
|
||||
}
|
||||
|
||||
/// 供 `prove::proof_check` 复用的最近名建议(编辑距离 ≤ 2)。
|
||||
pub fn suggest_closest(name: &str, known: &[String]) -> Option<String> {
|
||||
suggest(name, known)
|
||||
}
|
||||
|
||||
fn suggest(name: &str, known: &[String]) -> Option<String> {
|
||||
let lower = name.to_ascii_lowercase();
|
||||
let mut best: Option<(usize, String)> = None;
|
||||
|
||||
Reference in new issue
Block a user