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:
1 parent
4e02da95a4
commit
bd7e46b208
46 files changed
+390180
-460
No files matched your search
@@ -52,7 +52,10 @@ fn real_cli_extracts_vector_fixture() {
|
||||
);
|
||||
assert_eq!(unit.dependencies.links.len(), 2);
|
||||
assert_eq!(unit.dependencies.links[0].text, "整数平方非负性");
|
||||
assert_eq!(unit.dependencies.links[0].url, "algebra.mq.md#整数平方非负性");
|
||||
assert_eq!(
|
||||
unit.dependencies.links[0].url,
|
||||
"algebra.mq.md#整数平方非负性"
|
||||
);
|
||||
assert!(unit.goal.payload_span.is_some());
|
||||
let source = &snapshot.entry().source;
|
||||
assert_eq!(
|
||||
|
||||
@@ -0,0 +1,238 @@
|
||||
//! Negative/contract tests through the real CLI without requiring the Lean
|
||||
//! backend: selection, document shape, formulas and link closure.
|
||||
//!
|
||||
//! The tests skip (and say so) when `MARQDO_BIN` is not set. Each assertion is
|
||||
//! about a reported diagnostic code and the process exit code, never about
|
||||
//! presentation text.
|
||||
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::process::Command;
|
||||
|
||||
fn cli() -> Option<PathBuf> {
|
||||
std::env::var_os("MARQDO_BIN").map(PathBuf::from)
|
||||
}
|
||||
|
||||
fn fixtures() -> PathBuf {
|
||||
PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("tests/fixtures")
|
||||
}
|
||||
|
||||
fn run(entry: &str, extra: &[&str]) -> Option<(i32, serde_json::Value)> {
|
||||
let marqdo = cli()?;
|
||||
let binary = env!("CARGO_BIN_EXE_marqdo-prove");
|
||||
let work = PathBuf::from(env!("CARGO_MANIFEST_DIR"))
|
||||
.join(".tmp")
|
||||
.join("tests/document_contract");
|
||||
std::fs::create_dir_all(&work).expect("work dir");
|
||||
let output = Command::new(binary)
|
||||
.arg("check")
|
||||
.arg(fixtures().join(entry))
|
||||
.args(extra)
|
||||
.arg("--json")
|
||||
.env("MARQDO_BIN", &marqdo)
|
||||
.env(
|
||||
"MARQDO_PROVE_LEAN_ROOT",
|
||||
PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("lean"),
|
||||
)
|
||||
.output()
|
||||
.expect("run marqdo-prove");
|
||||
let code = output.status.code().unwrap_or(-1);
|
||||
let stdout = String::from_utf8_lossy(&output.stdout);
|
||||
let parsed: serde_json::Value = serde_json::from_str(stdout.trim()).unwrap_or_else(|error| {
|
||||
panic!(
|
||||
"expected one JSON object on stdout, got `{stdout}` ({error}); stderr: {}",
|
||||
String::from_utf8_lossy(&output.stderr)
|
||||
)
|
||||
});
|
||||
Some((code, parsed))
|
||||
}
|
||||
|
||||
fn codes(report: &serde_json::Value) -> Vec<String> {
|
||||
let mut out = Vec::new();
|
||||
if let Some(targets) = report["targets"].as_array() {
|
||||
for target in targets {
|
||||
for diagnostic in target["diagnostics"]
|
||||
.as_array()
|
||||
.cloned()
|
||||
.unwrap_or_default()
|
||||
{
|
||||
if let Some(code) = diagnostic["code"].as_str() {
|
||||
out.push(code.to_string());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for diagnostic in report["diagnostics"]
|
||||
.as_array()
|
||||
.cloned()
|
||||
.unwrap_or_default()
|
||||
{
|
||||
if let Some(code) = diagnostic["code"].as_str() {
|
||||
out.push(code.to_string());
|
||||
}
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn no_target_document_succeeds_without_targets() {
|
||||
let Some((code, report)) = run("no-target.mq.md", &[]) else {
|
||||
eprintln!("skipping: MARQDO_BIN is not set");
|
||||
return;
|
||||
};
|
||||
assert_eq!(code, 0, "{report}");
|
||||
assert_eq!(report["targets"].as_array().map(Vec::len), Some(0));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn two_goals_are_invalid() {
|
||||
let Some((code, report)) = run("two-goals.mq.md", &[]) else {
|
||||
eprintln!("skipping: MARQDO_BIN is not set");
|
||||
return;
|
||||
};
|
||||
assert_eq!(code, 1, "{report}");
|
||||
assert!(
|
||||
codes(&report).contains(&"document.goal_count".to_string()),
|
||||
"{report}"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn dependency_list_shape_is_rejected() {
|
||||
let Some((code, report)) = run("bad-dependencies.mq.md", &[]) else {
|
||||
eprintln!("skipping: MARQDO_BIN is not set");
|
||||
return;
|
||||
};
|
||||
assert_eq!(code, 1, "{report}");
|
||||
assert!(
|
||||
codes(&report).contains(&"document.dependencies_shape".to_string()),
|
||||
"{report}"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn unsupported_domain_is_unsupported_not_invalid() {
|
||||
let Some((code, report)) = run("unsupported-domain.mq.md", &[]) else {
|
||||
eprintln!("skipping: MARQDO_BIN is not set");
|
||||
return;
|
||||
};
|
||||
assert_eq!(code, 1, "{report}");
|
||||
assert_eq!(report["targets"][0]["outcome"], "unsupported");
|
||||
assert!(
|
||||
codes(&report).contains(&"formula.unsupported".to_string()),
|
||||
"{report}"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn free_variable_is_invalid() {
|
||||
let Some((code, report)) = run("free-variable.mq.md", &[]) else {
|
||||
eprintln!("skipping: MARQDO_BIN is not set");
|
||||
return;
|
||||
};
|
||||
assert_eq!(code, 1, "{report}");
|
||||
assert!(
|
||||
codes(&report).contains(&"formula.free_variable".to_string()),
|
||||
"{report}"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn missing_link_is_reported() {
|
||||
let Some((code, report)) = run("missing-link.mq.md", &[]) else {
|
||||
eprintln!("skipping: MARQDO_BIN is not set");
|
||||
return;
|
||||
};
|
||||
assert_eq!(code, 1, "{report}");
|
||||
assert!(
|
||||
codes(&report).contains(&"link.missing".to_string()),
|
||||
"{report}"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn external_link_is_rejected() {
|
||||
let Some((code, report)) = run("external-link.mq.md", &[]) else {
|
||||
eprintln!("skipping: MARQDO_BIN is not set");
|
||||
return;
|
||||
};
|
||||
assert_eq!(code, 1, "{report}");
|
||||
assert!(
|
||||
codes(&report).contains(&"link.invalid".to_string()),
|
||||
"{report}"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn dependency_cycle_is_rejected_with_a_chain() {
|
||||
let Some((code, report)) = run("cycle-a.mq.md", &[]) else {
|
||||
eprintln!("skipping: MARQDO_BIN is not set");
|
||||
return;
|
||||
};
|
||||
assert_eq!(code, 1, "{report}");
|
||||
assert!(
|
||||
codes(&report).contains(&"link.cycle".to_string()),
|
||||
"{report}"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn unknown_unit_selection_fails() {
|
||||
let Some((code, report)) = run("no-target.mq.md", &["--unit", "不存在的标题"]) else {
|
||||
eprintln!("skipping: MARQDO_BIN is not set");
|
||||
return;
|
||||
};
|
||||
assert_eq!(code, 1, "{report}");
|
||||
assert!(
|
||||
codes(&report).contains(&"document.unit".to_string()),
|
||||
"{report}"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn upstream_static_failure_is_a_contract_failure() {
|
||||
let Some(marqdo) = cli() else {
|
||||
eprintln!("skipping: MARQDO_BIN is not set");
|
||||
return;
|
||||
};
|
||||
let binary = env!("CARGO_BIN_EXE_marqdo-prove");
|
||||
let output = Command::new(binary)
|
||||
.arg("check")
|
||||
.arg(fixtures().join("static-error.mq.md"))
|
||||
.arg("--json")
|
||||
.env("MARQDO_BIN", marqdo)
|
||||
.output()
|
||||
.expect("run marqdo-prove");
|
||||
assert_eq!(
|
||||
output.status.code(),
|
||||
Some(2),
|
||||
"{}",
|
||||
String::from_utf8_lossy(&output.stderr)
|
||||
);
|
||||
let report: serde_json::Value =
|
||||
serde_json::from_str(String::from_utf8_lossy(&output.stdout).trim()).expect("json");
|
||||
assert_eq!(report["status"], "failure");
|
||||
assert_eq!(report["diagnostics"][0]["code"], "upstream.contract");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn root_must_contain_the_entry() {
|
||||
let Some(marqdo) = cli() else {
|
||||
eprintln!("skipping: MARQDO_BIN is not set");
|
||||
return;
|
||||
};
|
||||
let binary = env!("CARGO_BIN_EXE_marqdo-prove");
|
||||
let outside = Path::new("/tmp");
|
||||
let output = Command::new(binary)
|
||||
.arg("check")
|
||||
.arg(fixtures().join("no-target.mq.md"))
|
||||
.arg("--root")
|
||||
.arg(outside)
|
||||
.arg("--json")
|
||||
.env("MARQDO_BIN", marqdo)
|
||||
.output()
|
||||
.expect("run marqdo-prove");
|
||||
assert_eq!(output.status.code(), Some(2));
|
||||
let report: serde_json::Value =
|
||||
serde_json::from_str(String::from_utf8_lossy(&output.stdout).trim()).expect("json");
|
||||
assert_eq!(report["diagnostics"][0]["code"], "link.outside_root");
|
||||
}
|
||||
+214
@@ -0,0 +1,214 @@
|
||||
//! Lean-backed end-to-end acceptance tests.
|
||||
//!
|
||||
//! These tests exercise the real CLI, the pinned Lean + Mathlib backend, the
|
||||
//! independent kernel replay and the certificate path. They are `#[ignore]`d
|
||||
//! because they require the fixed backend and take ~20-30s per target; CI runs
|
||||
//! them explicitly:
|
||||
//!
|
||||
//! ```sh
|
||||
//! MARQDO_BIN=/abs/marqdo cargo test --test e2e -- --ignored --test-threads=1
|
||||
//! ```
|
||||
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::process::Command;
|
||||
|
||||
use serde_json::Value;
|
||||
|
||||
fn marqdo() -> Option<PathBuf> {
|
||||
std::env::var_os("MARQDO_BIN").map(PathBuf::from)
|
||||
}
|
||||
|
||||
fn repo() -> PathBuf {
|
||||
PathBuf::from(env!("CARGO_MANIFEST_DIR"))
|
||||
}
|
||||
|
||||
fn work(tag: &str) -> PathBuf {
|
||||
let directory = repo().join(".tmp").join("e2e").join(tag);
|
||||
let _ = std::fs::remove_dir_all(&directory);
|
||||
std::fs::create_dir_all(&directory).expect("work dir");
|
||||
directory
|
||||
}
|
||||
|
||||
fn run(arguments: &[&str]) -> (i32, Value) {
|
||||
let output = Command::new(env!("CARGO_BIN_EXE_marqdo-prove"))
|
||||
.args(arguments)
|
||||
.env("MARQDO_BIN", marqdo().expect("MARQDO_BIN"))
|
||||
.env("MARQDO_PROVE_LEAN_ROOT", repo().join("lean"))
|
||||
.output()
|
||||
.expect("run marqdo-prove");
|
||||
let code = output.status.code().unwrap_or(-1);
|
||||
let stdout = String::from_utf8_lossy(&output.stdout);
|
||||
let report: Value = serde_json::from_str(stdout.trim()).unwrap_or_else(|error| {
|
||||
panic!(
|
||||
"expected one JSON object, got `{stdout}` ({error}); stderr: {}",
|
||||
String::from_utf8_lossy(&output.stderr)
|
||||
)
|
||||
});
|
||||
(code, report)
|
||||
}
|
||||
|
||||
fn check(entry: &Path, extra: &[&str]) -> (i32, Value) {
|
||||
let mut arguments = vec!["check", entry.to_str().expect("utf8 path"), "--json"];
|
||||
arguments.extend_from_slice(extra);
|
||||
run(&arguments)
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn algebra_fixture_verifies_and_publishes_certificates() {
|
||||
let (code, report) = check(&repo().join("examples/algebra.mq.md"), &[]);
|
||||
assert_eq!(code, 0, "{report}");
|
||||
let targets = report["targets"].as_array().expect("targets");
|
||||
assert_eq!(targets.len(), 2);
|
||||
for target in targets {
|
||||
assert_eq!(target["outcome"], "verified", "{target}");
|
||||
assert_eq!(target["freshness"], "current");
|
||||
assert_eq!(target["scope"], "mathematical");
|
||||
assert!(target["certificate"]["cache_key"].as_str().is_some());
|
||||
let axioms = target["axioms"].as_array().expect("axioms");
|
||||
for axiom in axioms {
|
||||
assert!(
|
||||
["propext", "Classical.choice", "Quot.sound"]
|
||||
.contains(&axiom.as_str().unwrap_or("")),
|
||||
"{axiom}"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn vector_composition_uses_both_linked_theorems() {
|
||||
let (code, report) = check(&repo().join("examples/vector.mq.md"), &[]);
|
||||
assert_eq!(code, 0, "{report}");
|
||||
let target = &report["targets"][0];
|
||||
assert_eq!(target["outcome"], "verified", "{target}");
|
||||
let declared = target["declared_dependencies"]
|
||||
.as_array()
|
||||
.expect("declared");
|
||||
let used = target["used_dependencies"].as_array().expect("used");
|
||||
assert_eq!(declared.len(), 2);
|
||||
// Actual proof-term dependencies, not merely declared links.
|
||||
assert_eq!(used.len(), 2, "{target}");
|
||||
for dependency in declared {
|
||||
assert!(
|
||||
used.iter().any(|used| used == &dependency["locator"]),
|
||||
"declared {} was not used: {target}",
|
||||
dependency["locator"]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn program_model_bridge_is_exact_integer_scope() {
|
||||
let (code, report) = check(&repo().join("examples/arithmetic.mq.md"), &[]);
|
||||
assert_eq!(code, 0, "{report}");
|
||||
let target = &report["targets"][0];
|
||||
assert_eq!(target["outcome"], "verified", "{target}");
|
||||
assert_eq!(target["scope"], "program_model");
|
||||
let declared = target["declared_dependencies"]
|
||||
.as_array()
|
||||
.expect("declared");
|
||||
assert!(declared
|
||||
.iter()
|
||||
.any(|dependency| dependency["kind"] == "model"));
|
||||
assert!(declared
|
||||
.iter()
|
||||
.any(|dependency| dependency["kind"] == "theorem"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn false_propositions_are_refuted_by_proven_negations() {
|
||||
let (code, report) = check(&repo().join("tests/fixtures/false.mq.md"), &[]);
|
||||
assert_eq!(code, 1, "{report}");
|
||||
let targets = report["targets"].as_array().expect("targets");
|
||||
assert_eq!(targets.len(), 2);
|
||||
for target in targets {
|
||||
assert_eq!(target["outcome"], "refuted", "{target}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn exported_bundle_replays_without_search() {
|
||||
let directory = work("replay");
|
||||
let bundle = directory.join("vector-proof");
|
||||
let (code, report) = check(
|
||||
&repo().join("examples/vector.mq.md"),
|
||||
&["--out", bundle.to_str().expect("utf8")],
|
||||
);
|
||||
assert_eq!(code, 0, "{report}");
|
||||
assert!(bundle.join("manifest.json").is_file());
|
||||
assert!(bundle.join("proof.ndjson").is_file());
|
||||
let (code, replayed) = run(&[
|
||||
"replay",
|
||||
repo().join("examples/vector.mq.md").to_str().expect("utf8"),
|
||||
bundle.to_str().expect("utf8"),
|
||||
"--json",
|
||||
]);
|
||||
assert_eq!(code, 0, "{replayed}");
|
||||
assert_eq!(replayed["targets"][0]["outcome"], "verified", "{replayed}");
|
||||
assert_eq!(replayed["targets"][0]["freshness"], "current");
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn repeated_check_reuses_and_replays_the_certificate() {
|
||||
let entry = repo().join("examples/algebra.mq.md");
|
||||
let (_, first) = check(&entry, &[]);
|
||||
let key = first["targets"][0]["certificate"]["cache_key"]
|
||||
.as_str()
|
||||
.expect("cache key")
|
||||
.to_string();
|
||||
let (code, second) = check(&entry, &[]);
|
||||
assert_eq!(code, 0, "{second}");
|
||||
assert_eq!(second["targets"][0]["outcome"], "verified");
|
||||
assert_eq!(second["targets"][0]["freshness"], "current");
|
||||
assert_eq!(
|
||||
second["targets"][0]["certificate"]["cache_key"],
|
||||
Value::String(key),
|
||||
"a cache hit must keep the same content address"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn tampered_payload_is_rejected() {
|
||||
let directory = work("tamper");
|
||||
let bundle = directory.join("algebra-proof");
|
||||
let (code, report) = check(
|
||||
&repo().join("examples/algebra.mq.md"),
|
||||
&[
|
||||
"--unit",
|
||||
"整数平方非负性",
|
||||
"--out",
|
||||
bundle.to_str().expect("utf8"),
|
||||
],
|
||||
);
|
||||
assert_eq!(code, 0, "{report}");
|
||||
let payload = bundle.join("proof.ndjson");
|
||||
let mut bytes = std::fs::read(&payload).expect("payload");
|
||||
let last = bytes.len() - 2;
|
||||
bytes[last] ^= 0x01;
|
||||
std::fs::write(&payload, &bytes).expect("tamper");
|
||||
let output = Command::new(env!("CARGO_BIN_EXE_marqdo-prove"))
|
||||
.args([
|
||||
"replay",
|
||||
repo()
|
||||
.join("examples/algebra.mq.md")
|
||||
.to_str()
|
||||
.expect("utf8"),
|
||||
bundle.to_str().expect("utf8"),
|
||||
"--json",
|
||||
])
|
||||
.env("MARQDO_BIN", marqdo().expect("MARQDO_BIN"))
|
||||
.env("MARQDO_PROVE_LEAN_ROOT", repo().join("lean"))
|
||||
.output()
|
||||
.expect("run replay");
|
||||
assert_ne!(output.status.code(), Some(0));
|
||||
let report: Value =
|
||||
serde_json::from_str(String::from_utf8_lossy(&output.stdout).trim()).expect("json");
|
||||
assert_eq!(report["status"], "failure", "{report}");
|
||||
}
|
||||
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
+70
@@ -0,0 +1,70 @@
|
||||
{
|
||||
"schema": "marqdo.proof",
|
||||
"schema_version": 1,
|
||||
"tool": {
|
||||
"name": "marqdo-prove",
|
||||
"version": "0.1.0"
|
||||
},
|
||||
"target": {
|
||||
"unit_id": "root:default::false.mq.md#反例/平方总是负",
|
||||
"unit_path": [
|
||||
"反例",
|
||||
"平方总是负"
|
||||
],
|
||||
"locator": "false.mq.md",
|
||||
"scope": "mathematical",
|
||||
"outcome": "refuted",
|
||||
"statement_literal": "\\forall x\\in\\mathbb{Z},\\quad x^2<0\n",
|
||||
"statement_normalized": "∀ x : ℤ, x^2 < 0",
|
||||
"statement_lean": "∀ mqx0 : Int, ((mqx0 ^ (2 : Nat)) < (0 : Int))",
|
||||
"goal_span": {
|
||||
"start": 41,
|
||||
"end": 81
|
||||
},
|
||||
"goal_payload_span": {
|
||||
"start": 44,
|
||||
"end": 79
|
||||
},
|
||||
"goal_digest": "07b45c4054327cb560709dd7142d81bc2b39428b9dab088d035f2e15c5d3040d",
|
||||
"premises": [],
|
||||
"theorem_name": "marqdoTarget_a9f1eee0314c784457f9",
|
||||
"expected_name": "marqdoExpected_a9f1eee0314c784457f9",
|
||||
"model_definitions": []
|
||||
},
|
||||
"sources": [
|
||||
{
|
||||
"locator": "false.mq.md",
|
||||
"module_id": "root:default::false.mq.md",
|
||||
"source_digest": "88e2eef4fe81a1287b5596daf7aba0b5e8725ef668012ccc193702685f610543",
|
||||
"analysis_digest": "e987323e501121c1a21709e50720746bd891c989a0b25f79ca37c81e3196e87b"
|
||||
}
|
||||
],
|
||||
"environment": {
|
||||
"lean_toolchain": "leanprover/lean4:v4.36.0",
|
||||
"lean_version": "86_64",
|
||||
"mathlib_rev": "fc4f59e577feb1a4956671bc04ac18aaaf8cd842",
|
||||
"lake_manifest_digest": "bb82472009ad8aba44b75c1a1095dfe290dd87319421d55039e02fe57f2e0022",
|
||||
"replay_verifier_digest": "02cbc2c8b00dbdac2c5bcf359b25a62f896372b9964f7578caca4d4346d544c1",
|
||||
"con_leche_version": "con-leche-a6380d68b4fb3641",
|
||||
"formula_compiler": "marqdo-prove-0.1.0",
|
||||
"semantic_mapping": "marqdo-int-exact-v1",
|
||||
"environment_id": "9622d44bfc5540616117b8e4b60b3e06a84122535d4495925739a08acc14877a"
|
||||
},
|
||||
"declared_dependencies": [],
|
||||
"used_dependencies": [],
|
||||
"transitive_dependencies": [
|
||||
"false.mq.md#反例/平方总是负"
|
||||
],
|
||||
"axioms": [
|
||||
"propext"
|
||||
],
|
||||
"proof": {
|
||||
"file": "proof.ndjson",
|
||||
"bytes": 1493702,
|
||||
"sha256": "21bfd1a3d53438e8521379ddc1fb806e5ba5121f9d6bc8485dc0bb05a28942bc",
|
||||
"export_format": "lean4export-3.1.0",
|
||||
"target_decl": "marqdoTarget_a9f1eee0314c784457f9",
|
||||
"expected_decl": "marqdoExpected_a9f1eee0314c784457f9"
|
||||
},
|
||||
"cache_key": "364469fffce1d2c9810883f6df462a3fc6655ee2de4c65684aa6d77ae8e6efd0"
|
||||
}
|
||||
+28062
File diff suppressed because it is too large.
Load diff
+68
@@ -0,0 +1,68 @@
|
||||
{
|
||||
"schema": "marqdo.proof",
|
||||
"schema_version": 1,
|
||||
"tool": {
|
||||
"name": "marqdo-prove",
|
||||
"version": "0.1.0"
|
||||
},
|
||||
"target": {
|
||||
"unit_id": "root:default::false.mq.md#反例/封闭错误等式",
|
||||
"unit_path": [
|
||||
"反例",
|
||||
"封闭错误等式"
|
||||
],
|
||||
"locator": "false.mq.md",
|
||||
"scope": "mathematical",
|
||||
"outcome": "refuted",
|
||||
"statement_literal": "3+4=8\n",
|
||||
"statement_normalized": "3 + 4 = 8",
|
||||
"statement_lean": "(((3 : Int) + (4 : Int)) = (8 : Int))",
|
||||
"goal_span": {
|
||||
"start": 135,
|
||||
"end": 146
|
||||
},
|
||||
"goal_payload_span": {
|
||||
"start": 138,
|
||||
"end": 144
|
||||
},
|
||||
"goal_digest": "1511e16776c3dedbc83717b7809f26ef859cb24a0980c34f5186efab40b751f3",
|
||||
"premises": [],
|
||||
"theorem_name": "marqdoTarget_c1a66f9163cb21940c3e",
|
||||
"expected_name": "marqdoExpected_c1a66f9163cb21940c3e",
|
||||
"model_definitions": []
|
||||
},
|
||||
"sources": [
|
||||
{
|
||||
"locator": "false.mq.md",
|
||||
"module_id": "root:default::false.mq.md",
|
||||
"source_digest": "88e2eef4fe81a1287b5596daf7aba0b5e8725ef668012ccc193702685f610543",
|
||||
"analysis_digest": "e987323e501121c1a21709e50720746bd891c989a0b25f79ca37c81e3196e87b"
|
||||
}
|
||||
],
|
||||
"environment": {
|
||||
"lean_toolchain": "leanprover/lean4:v4.36.0",
|
||||
"lean_version": "86_64",
|
||||
"mathlib_rev": "fc4f59e577feb1a4956671bc04ac18aaaf8cd842",
|
||||
"lake_manifest_digest": "bb82472009ad8aba44b75c1a1095dfe290dd87319421d55039e02fe57f2e0022",
|
||||
"replay_verifier_digest": "02cbc2c8b00dbdac2c5bcf359b25a62f896372b9964f7578caca4d4346d544c1",
|
||||
"con_leche_version": "con-leche-a6380d68b4fb3641",
|
||||
"formula_compiler": "marqdo-prove-0.1.0",
|
||||
"semantic_mapping": "marqdo-int-exact-v1",
|
||||
"environment_id": "9622d44bfc5540616117b8e4b60b3e06a84122535d4495925739a08acc14877a"
|
||||
},
|
||||
"declared_dependencies": [],
|
||||
"used_dependencies": [],
|
||||
"transitive_dependencies": [
|
||||
"false.mq.md#反例/封闭错误等式"
|
||||
],
|
||||
"axioms": [],
|
||||
"proof": {
|
||||
"file": "proof.ndjson",
|
||||
"bytes": 174123,
|
||||
"sha256": "b802f214ce34fabcf6e88750c87965d0e7a53e809098cb51006e2d483d3f4501",
|
||||
"export_format": "lean4export-3.1.0",
|
||||
"target_decl": "marqdoTarget_c1a66f9163cb21940c3e",
|
||||
"expected_decl": "marqdoExpected_c1a66f9163cb21940c3e"
|
||||
},
|
||||
"cache_key": "c5f87c70f553453cf28e79fe129cf80e94a38912d1bc9e466e916d43e876b4d3"
|
||||
}
|
||||
+3166
File diff suppressed because it is too large.
Load diff
+11
@@ -0,0 +1,11 @@
|
||||
# 依赖形状错误
|
||||
|
||||
## @knowledge 目标
|
||||
|
||||
$$
|
||||
1 = 1
|
||||
$$
|
||||
|
||||
### 证明依赖
|
||||
|
||||
- [目标](other.mq.md#目标) 多余文字
|
||||
Vendored
+11
@@ -0,0 +1,11 @@
|
||||
# 环形 A
|
||||
|
||||
## @knowledge A
|
||||
|
||||
$$
|
||||
1 = 1
|
||||
$$
|
||||
|
||||
### 证明依赖
|
||||
|
||||
- [B](cycle-b.mq.md#B)
|
||||
Vendored
+11
@@ -0,0 +1,11 @@
|
||||
# 环形 B
|
||||
|
||||
## @knowledge B
|
||||
|
||||
$$
|
||||
1 = 1
|
||||
$$
|
||||
|
||||
### 证明依赖
|
||||
|
||||
- [A](cycle-a.mq.md#A)
|
||||
Vendored
+11
@@ -0,0 +1,11 @@
|
||||
# 外部链接
|
||||
|
||||
## @knowledge 目标
|
||||
|
||||
$$
|
||||
1 = 1
|
||||
$$
|
||||
|
||||
### 证明依赖
|
||||
|
||||
- [外部知识](https://example.com/theory)
|
||||
Vendored
+17
@@ -0,0 +1,17 @@
|
||||
# 反例
|
||||
|
||||
## @knowledge 平方总是负
|
||||
|
||||
$$
|
||||
\forall x\in\mathbb{Z},\quad x^2<0
|
||||
$$
|
||||
|
||||
### 证明依赖
|
||||
|
||||
## @knowledge 封闭错误等式
|
||||
|
||||
$$
|
||||
3+4=8
|
||||
$$
|
||||
|
||||
### 证明依赖
|
||||
Vendored
+9
@@ -0,0 +1,9 @@
|
||||
# 自由变量
|
||||
|
||||
## @knowledge 没有定义域
|
||||
|
||||
$$
|
||||
x^2\geq0
|
||||
$$
|
||||
|
||||
### 证明依赖
|
||||
Vendored
+11
@@ -0,0 +1,11 @@
|
||||
# 断链
|
||||
|
||||
## @knowledge 目标
|
||||
|
||||
$$
|
||||
1 = 1
|
||||
$$
|
||||
|
||||
### 证明依赖
|
||||
|
||||
- [缺失定理](does-not-exist.mq.md#定理)
|
||||
Vendored
+9
@@ -0,0 +1,9 @@
|
||||
# 普通知识
|
||||
|
||||
## @knowledge 仅解释
|
||||
|
||||
这里有一个公式,但没有 `证明依赖` 标题,因此不是证明目标。
|
||||
|
||||
$$
|
||||
\forall x\in\mathbb{Z},\quad x^2\geq0
|
||||
$$
|
||||
Vendored
+5
@@ -0,0 +1,5 @@
|
||||
# bad
|
||||
|
||||
## @exec broken
|
||||
|
||||
`return +`
|
||||
Vendored
+13
@@ -0,0 +1,13 @@
|
||||
# 双目标
|
||||
|
||||
## @knowledge 两个公式
|
||||
|
||||
$$
|
||||
x = 1
|
||||
$$
|
||||
|
||||
$$
|
||||
y = 2
|
||||
$$
|
||||
|
||||
### 证明依赖
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
# 不支持的域
|
||||
|
||||
## @knowledge 实数平方
|
||||
|
||||
$$
|
||||
\forall x\in\mathbb{R},\quad x^2\geq0
|
||||
$$
|
||||
|
||||
### 证明依赖
|
||||
+69
-25
@@ -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:?}");
|
||||
}
|
||||
Reference in new issue
Block a user