tests+docs: contract fixtures, Lean-backed acceptance suite and executed status

- document_contract: negative path coverage through the real CLI (selection,
  shape errors, formula unsupported/invalid, missing/external links, cycles,
  --unit, upstream static failure, root escape) with exit-code assertions
- e2e: algebra, vector composition (declared == used), program model scope,
  refutation, export+replay, cache reuse, tampered payload rejection
- report fixes: declared/used locator consistency, diagnostic-only exit status,
  unsupported vs invalid formula outcomes
- clippy -D warnings and cargo fmt clean; docs/STATUS records pinned identities,
  executed commands, measured backend limits and known gaps
This commit is contained in:
marqdo-prove committed 2026-11-26 11:10:42 +08:00
1 parent 4e02da95a4
commit bd7e46b208
46 files changed
+390180 -460

No files matched your search

+69 -25
View File
@@ -39,17 +39,15 @@ fn fixture_vector_proposition() {
#[test]
fn fixture_nonnegative_addition_preserves_premises() {
let goal = parse("\\forall a,b\\in\\mathbb{Z},\\quad (a\\geq0\\land b\\geq0)\\Rightarrow a+b\\geq0");
let goal =
parse("\\forall a,b\\in\\mathbb{Z},\\quad (a\\geq0\\land b\\geq0)\\Rightarrow a+b\\geq0");
assert_eq!(goal.vars, vec!["a", "b"]);
assert_eq!(
lean(&goal),
"∀ mqx0 mqx1 : Int, (((mqx0 ≥ (0 : Int)) ∧ (mqx1 ≥ (0 : Int))) → \
((mqx0 + mqx1) ≥ (0 : Int)))"
);
assert_eq!(
goal.normal(),
"∀ a b : ℤ, (a ≥ 0 ∧ b ≥ 0) → a + b ≥ 0"
);
assert_eq!(goal.normal(), "∀ a b : ℤ, (a ≥ 0 ∧ b ≥ 0) → a + b ≥ 0");
assert_eq!(goal.premises(), vec!["a ≥ 0 ∧ b ≥ 0"]);
assert_eq!(goal.evaluate(&[int(-2), int(1)]), Some(true));
}
@@ -98,14 +96,23 @@ fn exponent_rules() {
lean(&goal),
"∀ mqx0 : Int, ((mqx0 ^ (12 : Nat)) ≥ (0 : Int))"
);
let error = formula::parse("\\forall x\\in\\mathbb{Z},\\quad x^12\\geq0", Span::new(0, 1))
.unwrap_err();
let error = formula::parse(
"\\forall x\\in\\mathbb{Z},\\quad x^12\\geq0",
Span::new(0, 1),
)
.unwrap_err();
assert_eq!(error.code(), codes::FORMULA_SYNTAX, "{error:?}");
let error = formula::parse("\\forall x\\in\\mathbb{Z},\\quad x^{17}\\geq0", Span::new(0, 1))
.unwrap_err();
let error = formula::parse(
"\\forall x\\in\\mathbb{Z},\\quad x^{17}\\geq0",
Span::new(0, 1),
)
.unwrap_err();
assert_eq!(error.code(), codes::FORMULA_UNSUPPORTED, "{error:?}");
let error = formula::parse("\\forall x\\in\\mathbb{Z},\\quad x^{999999999}\\geq0", Span::new(0, 1))
.unwrap_err();
let error = formula::parse(
"\\forall x\\in\\mathbb{Z},\\quad x^{999999999}\\geq0",
Span::new(0, 1),
)
.unwrap_err();
assert_eq!(error.code(), codes::FORMULA_UNSUPPORTED, "{error:?}");
}
@@ -113,26 +120,53 @@ fn exponent_rules() {
fn unsupported_and_invalid_inputs_are_rejected() {
let cases: &[(&str, &str)] = &[
("x^2\\geq0", codes::FORMULA_FREE_VARIABLE),
("\\forall x\\in\\mathbb{R}, x^2\\geq0", codes::FORMULA_UNSUPPORTED),
("\\forall x\\in\\mathbb{N}, x^2\\geq0", codes::FORMULA_UNSUPPORTED),
(
"\\forall x\\in\\mathbb{R}, x^2\\geq0",
codes::FORMULA_UNSUPPORTED,
),
(
"\\forall x\\in\\mathbb{N}, x^2\\geq0",
codes::FORMULA_UNSUPPORTED,
),
("\\forall x\\in\\mathbb{Z}, 2x\\geq0", codes::FORMULA_SYNTAX),
("\\forall x\\in\\mathbb{Z}, 0<x<1", codes::FORMULA_SYNTAX),
("\\forall x\\in\\mathbb{Z}, x^2\\geq0\\ \\forall y, y\\geq0", codes::FORMULA_UNSUPPORTED),
("\\forall x\\in\\mathbb{Z}, \\frac{1}{2}\\geq0", codes::FORMULA_UNSUPPORTED),
("\\forall x\\in\\mathbb{Z}, \\exists y, y\\geq0", codes::FORMULA_UNSUPPORTED),
(
"\\forall x\\in\\mathbb{Z}, x^2\\geq0\\ \\forall y, y\\geq0",
codes::FORMULA_UNSUPPORTED,
),
(
"\\forall x\\in\\mathbb{Z}, \\frac{1}{2}\\geq0",
codes::FORMULA_UNSUPPORTED,
),
(
"\\forall x\\in\\mathbb{Z}, \\exists y, y\\geq0",
codes::FORMULA_UNSUPPORTED,
),
("\\forall x\\in\\mathbb{Z}, \\neg x", codes::FORMULA_SYNTAX),
("\\forall x\\in\\mathbb{Z}, x^2", codes::FORMULA_SYNTAX),
("\\forall x\\in\\mathbb{Z} x^2\\geq0", codes::FORMULA_SYNTAX),
("\\forall x,x\\in\\mathbb{Z}, x\\geq0", codes::FORMULA_SYNTAX),
(
"\\forall x,x\\in\\mathbb{Z}, x\\geq0",
codes::FORMULA_SYNTAX,
),
("\\forall x\\in\\mathbb{Z},", codes::FORMULA_SYNTAX),
("", codes::FORMULA_SYNTAX),
(" ", codes::FORMULA_SYNTAX),
("\\forall x\\in\\mathbb{Z}, (x\\geq0", codes::FORMULA_SYNTAX),
("\\forall x\\in\\mathbb{Z}, x\\geq0)", codes::FORMULA_SYNTAX),
("\\forall x\\in\\mathbb{Z}, x\\geq0 y\\geq0", codes::FORMULA_SYNTAX),
("\\forall x\\in\\mathbb{Z}, x\\neq y", codes::FORMULA_FREE_VARIABLE),
(
"\\forall x\\in\\mathbb{Z}, x\\geq0 y\\geq0",
codes::FORMULA_SYNTAX,
),
(
"\\forall x\\in\\mathbb{Z}, x\\neq y",
codes::FORMULA_FREE_VARIABLE,
),
("\\frac{1}{2}\\geq0", codes::FORMULA_UNSUPPORTED),
("\\forall x\\in\\mathbb{Z}, \\operatorname{}(x)\\geq0", codes::FORMULA_SYNTAX),
(
"\\forall x\\in\\mathbb{Z}, \\operatorname{}(x)\\geq0",
codes::FORMULA_SYNTAX,
),
];
for (literal, expected) in cases {
let error = formula::parse(literal, Span::new(0, literal.len())).unwrap_err();
@@ -192,12 +226,12 @@ fn evaluate_is_exact_arbitrary_precision() {
assert_eq!(goal.evaluate(&[int(-123456789)]), Some(true));
let goal = parse("\\forall x\\in\\mathbb{Z},\\quad x^2<0");
assert_eq!(goal.evaluate(&[int(0)]), Some(false));
assert_eq!(goal.evaluate(&["9".repeat(200).parse().unwrap()]), Some(false));
let goal = parse("\\forall a,b\\in\\mathbb{Z},\\quad (a>0\\land b>0)\\Rightarrow a\\cdot b>0");
assert_eq!(
goal.evaluate(&[int(2), int(3)]),
Some(true)
goal.evaluate(&["9".repeat(200).parse().unwrap()]),
Some(false)
);
let goal = parse("\\forall a,b\\in\\mathbb{Z},\\quad (a>0\\land b>0)\\Rightarrow a\\cdot b>0");
assert_eq!(goal.evaluate(&[int(2), int(3)]), Some(true));
// If the antecedent fails, the conditional proposition is vacuously true;
// this is exactly why reports preserve and display the whole premise.
assert_eq!(goal.evaluate(&[int(0), int(3)]), Some(true));
@@ -224,7 +258,17 @@ fn typed_ast_is_public_and_structural() {
fn closed_propositions_are_supported() {
let goal = parse("(2+3)\\cdot4=20");
assert!(goal.vars.is_empty());
assert_eq!(lean(&goal), "((((2 : Int) + (3 : Int)) * (4 : Int)) = (20 : Int))");
assert_eq!(
lean(&goal),
"((((2 : Int) + (3 : Int)) * (4 : Int)) = (20 : Int))"
);
assert_eq!(goal.evaluate(&[]), Some(true));
assert_eq!(goal.normal(), "(2 + 3) · 4 = 20");
}
#[test]
fn unsupported_domain_variant_reports_unsupported() {
let literal = "\\forall x\\in\\mathbb{R},\\quad x^2\\geq0\n";
let error = formula::parse(literal, Span::new(0, 1)).unwrap_err();
assert_eq!(error.code(), codes::FORMULA_UNSUPPORTED, "{error:?}");
}