Skip to content

Trap i64.MIN remainder overflow in the Lean operator - #170

Open
dcharlot65-openie wants to merge 2 commits into
mainfrom
cursor/lean-rem-overflow-trap-754a
Open

dcharlot65-openie wants to merge 2 commits into
mainfrom
cursor/lean-rem-overflow-trap-754a

Conversation

@dcharlot65-openie

Copy link
Copy Markdown
Contributor

N2 requires i64.MIN % -1 to trap with overflow, the same as i64.MIN / -1. The interpreter and emit/rt.rs already trap. The Lean expression operator returned ok 0 for that case, and the printed MiniRust remainder checked only checked_rem in i128, which holds the quotient 2^63.

  • binop .rem checks the quotient against the static range before the remainder.
  • The printed prelude does the same with checked_div, then checked_rem.
  • binop_ty still says a successful operator result has the result type. The proof cases on the quotient check.
  • Regression vectors: Lean binop and core eval examples, the emit differential (i64_min_div, i64_min_rem), and the interpreter test n2_min.

Checks

  • lake build completed.
  • lake env lean audit/Audit.lean: 5539 RCE theorems, standard axioms only.
  • Emit differential: 3002 cases, 0 mismatches. Both fixed cases expect Trap::Overflow.
  • cargo test --test n2_min and b001_imin_rem_minus_one_traps passed on Rust 1.98.1.

No sorry, no new axioms, and no weakened statement.

Open in Web Open in Cursor 

cursoragent and others added 2 commits November 13, 2026 17:24
N2 requires i64.MIN % -1 to trap with overflow, the same as division.
The expression operator returned 0, and the printed MiniRust remainder
checked only the remainder in i128. Both now check the quotient against
the static range first. Vectors cover the Lean operator, the core
evaluator, the emit differential, and the reference interpreter.

Co-authored-by: David Charlot <dcharlot65-openie@users.noreply.github.com>
Bring in the production acceptance gate and the longer fast-job limit.
Co-authored-by: David Charlot <dcharlot65-openie@users.noreply.github.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants