test(proof): arithmetic overflow at imported call boundary remains opaque, not misproved by unbounded Lean Int

This commit is contained in:
cflmy committed 2026-11-18 12:50:20 +08:00
1 parent b168e56dd0
commit 8e41337e17
1 file changed
+40
+40
View File
@@ -57,6 +57,46 @@ fn links_bind_to_exact_owner_and_stale_after_source_change() {
fs::remove_dir_all(dir).unwrap();
}
#[test]
fn overflowing_imported_arithmetic_cannot_be_source_inlined_to_lean_int() {
let dir=root("overflow-import");
fs::write(dir.join("numbers.mq.md"),r#"# numbers
## increment
+ `n`
*`n` + 1*
"#).unwrap();
let file=dir.join("main.mq.md");
fs::write(&file,r#"---
import:
numbers: numbers.mq.md
---
# main
## compute
| 定理 | 结论 | 策略 |
|---|---|---|
| bad | 结果 = 0 | auto |
**value = [溢出](numbers.numbers.increment(9223372036854775807))**
*value*
"#).unwrap();
let out=dir.join("prove");
let _=marqdo::prove::prove_path(&file,&marqdo::prove::ProveOptions{
emit_dir:Some(out.clone()),judge:false,..Default::default()
}).unwrap();
let plan:serde_json::Value=serde_json::from_slice(
&fs::read(out.join("plan.json")).unwrap()).unwrap();
let f=plan["functions"].as_array().unwrap().iter()
.find(|x|x["name"]=="main.compute").unwrap();
assert!(!f["ops"].as_array().unwrap().is_empty(),
"i64 overflow must never silently become total unbounded Lean arithmetic");
fs::remove_dir_all(dir).unwrap();
}
#[test]
fn effectful_import_stays_opaque_in_proof_plan() {
let dir=root("effectful-import");