Primitive-Recursive Signed Integer Arithmetic
DefinitionMonodromy_IntegerPrimrecUses the canonical natural-number encoding of signed integers to define and prove effective integer case analysis, arithmetic, order tests, scaling, and positive-base Euclidean quotients and remainders. These functions provide the arithmetic interface for the integer interpretation of native programs.
-- Generated by Lean-fact skeleton subtraction; original source is frozen in imports/monodromy/source. module public import Mathlib.Computability.Primrec.Basic public import Mathlib.Data.Int.ModEq public import Mathlib.Tactic.Ring @[expose] public section /-! # Effective integer primitives The canonical signed encoding reduces integer arithmetic and positive-base Euclidean division to primitive recursive operations on natural numbers. -/ @[expose] public section namespace Monodromy.IntegerPrimrec def split (value : ℤ) : ℕ ⊕ ℕ := Equiv.intEquivNatSumNat value def join (value : ℕ ⊕ ℕ) : ℤ := Sum.elim Int.ofNat Int.negSucc value def difference (first second : ℕ) : ℤ := if second ≤ first then Int.ofNat (first - second) else Int.negSucc (second - first - 1) end Monodromy.IntegerPrimrec
Read-back
What the Lean code literally says, in plain math · OpenAI Codex (independent agent)
For every integer , split sends a nonnegative integer to the left copy of in , and sends to the right copy of ; join sends those two cases back to and respectively. For all naturals , difference is the integer whose defining formula is the nonnegative constructor applied to the natural subtraction if , and the negative-successor constructor applied to otherwise; thus the latter case represents . The subtractions inside these expressions are natural-number truncated subtraction, and the branch hypotheses ensure the indicated cases include , and with their literal values. These are total definitions and contain no partiality or asserted running-time bound.
Confirmed by the mission captain (proposal self-audit).