@[inline, extern lean_hex_word_mod_add]
Full-range modular addition of two residues below m.
Equations
Instances For
@[inline, extern lean_hex_word_mod_sub]
Full-range modular subtraction of two residues below m.
Equations
Instances For
theorem
Hex.addModWord_lt
(m a b : UInt64)
(hm : 0 < m.toNat)
(hmw : m.toNat ≤ UInt64.word)
(ha : a.toNat < m.toNat)
(hb : b.toNat < m.toNat)
:
addModWord stays below m.
Residues modulo an odd m < 2^64, stored in Montgomery form. val is the
Montgomery representative; the represented residue is ctx.fromMont val.
The packed native polynomial kernels rely on proof erasure leaving val as
the sole runtime constructor field. Any new data-bearing field requires a
matching FFI update and native cross-check.
- val : UInt64
Montgomery-form representative.
The representative is reduced.
Instances For
@[instance_reducible]
@[instance_reducible]
Equations
- Hex.WordMod.instZero = { zero := Hex.WordMod.ofNat 0 }
@[instance_reducible]
Equations
- Hex.WordMod.instOne = { one := Hex.WordMod.ofNat 1 }
@[instance_reducible]
Equations
- Hex.WordMod.instNatCast = { natCast := Hex.WordMod.ofNat }
@[inline]
Division, defined only where it is used: by the leading coefficient of a
monic divisor, which is 1. Dividing by 1 is the identity (div_one);
other divisors return 0 and are never exercised by monic divMod.
Instances For
@[instance_reducible]
Equations
- Hex.WordMod.instDiv = { div := Hex.WordMod.div }
@[instance_reducible]
Equations
- Hex.WordMod.instMul = { mul := Hex.WordMod.mul }
@[instance_reducible]
Equations
- Hex.WordMod.instAdd = { add := Hex.WordMod.add }
@[instance_reducible]
Equations
- Hex.WordMod.instSub = { sub := Hex.WordMod.sub }
@[instance_reducible]
Equations
- Hex.WordMod.instNeg = { neg := Hex.WordMod.neg }
@[instance_reducible]
Equations
- Hex.WordMod.instPowNat = { pow := Hex.WordMod.pow }
@[instance_reducible]
Equations
- Hex.WordMod.instOfNat n = { ofNat := Hex.WordMod.ofNat n }
@[instance_reducible]
Equations
- Hex.WordMod.instSMulNat = { smul := fun (n : Nat) (a : Hex.WordMod ctx) => ↑n * a }
@[instance_reducible]
Equations
- Hex.WordMod.instIntCast = { intCast := fun (i : Int) => match i with | Int.ofNat n => ↑n | Int.negSucc n => -↑(n + 1) }
@[instance_reducible]
Equations
- Hex.WordMod.instSMulInt = { smul := fun (i : Int) (a : Hex.WordMod ctx) => ↑i * a }