Documentation

Transfer.Examples.ZModDecide

decide_zmod: deciding ground ring identities over ZMod m by bounded residue computation #

HexDecide transfers a single ZMod m multiplication to an integer multiply-then-%m (residueMulReal). A ground ring identity — one built from +, *, -, neg, ^ over concrete ZMod m numerals — is a whole expression tree. This module lifts that single-op transfer to the tree (the ReprTransferExpr.OpExpr.denote_commutes idea, for the full ring signature), and reduces mod m after every node so intermediates stay in [0, m). That bounded-residue discipline keeps the final check on the GMP Int fast path, so decide_zmod closes by kernel decide — axiom-free ([propext, Classical.choice, Quot.sound], no Lean.ofReduceBool) — where computing inside ZMod/Fin, or over unreduced ℤ, either stalls the kernel or blows the coefficients up.

Main results #

Scope and extensions #

Ground ring expressions over integer-numeral leaves.

Instances For
    Equations
    • One or more equations did not get rendered due to their size.
    Instances For
      theorem Transfer.ZModDecide.RingExpr.denoteR_cast (m : ℕ) [NeZero m] (e : RingExpr) :
      ↑(denoteR (↑m) e) = denoteA m e

      The abstraction theorem. The residue computation, cast back into ZMod m, equals the abstract value: the single-op commuting square (% m invisible under Int.cast, ZMod.intCast_mod) lifted over the tree by induction.

      theorem Transfer.ZModDecide.RingExpr.decide_transfer (m : ℕ) [NeZero m] (e₁ e₂ : RingExpr) (h : denoteR (↑m) e₁ = denoteR (↑m) e₂) :
      denoteA m e₁ = denoteA m e₂

      The backward transfer. A decidable equality of the two bounded residue computations proves the abstract ZMod m identity — decide on the residues, underwritten by denoteR_cast rather than trusted.

      The decide_zmod tactic #

      Reify a ground ZMod m expression into a RingExpr term. Fails on any leaf that is not a numeral (e.g. a free variable), keeping the tactic total on the ground fragment it is sound for.

      Close a ground ring identity over ZMod m by bounded residue computation: reify both sides, then discharge via RingExpr.decide_transfer and a kernel decide on the reduced integer residues. Axiom-free (no Lean.ofReduceBool). Every leaf must be a numeral; a free ZMod m variable is rejected.

      Equations
      Instances For

        Examples #

        Axiom audit #

        theorem Transfer.ZModDecide.zmod_example_audit :
        7 ^ 4 + 2 * 9 - 3 = 7 ^ 4 + 2 * 9 - 3