Searching for irreducible polynomials over GF(2)
Polynomial
TheoremMonic irreducible binary polynomials exist in every degree#✓fully proved
Over ZMod 2, there is a monic irreducible polynomial of every positive degree.
theorem exists_monic_irreducible_zmod_two (s : Nat) (hs : 0 < s) :
∃ f : Polynomial (ZMod 2), f.Monic ∧ Irreducible f ∧ f.natDegree = s
Used by 1
Bit Vec
DefinitionExhaustive inverse test for a binary polynomial modulus#✓fully proved
Test exhaustively whether every nonzero word has a multiplicative inverse modulo
g.monicModulus.
def passesInverseTest {s : Nat} (g : BitVec s) : Bool :=
let words := (List.range (2 ^ s)).map (BitVec.ofNat s)
words.all fun x =>
decide (x = 0#s) ||
words.any fun y => decide (g.mulMod x y = 1#s)
Uses 1 · Used by 4
TheoremInverse test succeeds exactly for irreducible moduli#✓fully proved
At positive width, the exhaustive inverse test succeeds exactly for irreducible monic moduli.
theorem passesInverseTest_iff_irreducible {s : Nat} (g : BitVec s) (hs : 0 < s) :
g.passesInverseTest = true ↔ Irreducible g.monicModulus
Uses 8 · Used by 2
DefinitionExhaustive search for an irreducible binary modulus#✓fully proved
Search the lower coefficient words in ascending order for the first word passing the exhaustive inverse test. Width zero is deliberately reported as failure.
def findIrreducibleModulus (s : Nat) : Option (BitVec s) :=
if 0 < s then
((List.range (2 ^ s)).map (BitVec.ofNat s)).find? passesInverseTest
else
none
def passesInverseTest {s : Nat} (g : BitVec s) : Bool :=
let words := (List.range (2 ^ s)).map (BitVec.ofNat s)
words.all fun x =>
decide (x = 0#s) ||
words.any fun y => decide (g.mulMod x y = 1#s)
MathlibExt/FieldTheory/Finite/BinaryModulusSearch.lean:47
Uses 1 · Used by 2
TheoremExhaustive search returns an irreducible binary modulus#✓fully proved
At every positive width, exhaustive search returns an irreducible binary modulus.
theorem findIrreducibleModulus_spec (s : Nat) (hs : 0 < s) :
∃ g : BitVec s, findIrreducibleModulus s = some g ∧
Irreducible g.monicModulus
def findIrreducibleModulus (s : Nat) : Option (BitVec s) :=
if 0 < s then
((List.range (2 ^ s)).map (BitVec.ofNat s)).find? passesInverseTest
else
none
MathlibExt/FieldTheory/Finite/BinaryModulusSearch.lean:182
Uses 8
TheoremMinimality of the binary modulus found by exhaustive search#✓fully proved
The returned modulus is no larger than any lower coefficient word whose monic modulus is irreducible.
theorem findIrreducibleModulus_minimal {s : Nat} (g : BitVec s)
(h : findIrreducibleModulus s = some g) :
∀ g' : BitVec s, Irreducible g'.monicModulus → g.toNat ≤ g'.toNat
def findIrreducibleModulus (s : Nat) : Option (BitVec s) :=
if 0 < s then
((List.range (2 ^ s)).map (BitVec.ofNat s)).find? passesInverseTest
else
none
MathlibExt/FieldTheory/Finite/BinaryModulusSearch.lean:182
Loading dependency explorer…
The dependency explorer needs JavaScript and its graph data.