theoremirrW_eq_true {g : ListBool} : irrW g = true↔∀x : ListBool, x.length = g.length → x = zeroW g ∨∃y : ListBool, y.length = g.length ∧ mulW g x y = oneW g :=by
proof · 1
line
simp only [irrW, List.all_eq_true, List.any_eq_true, Bool.or_eq_true, decide_eq_true_eq, mem_wordsL]
For a word g of s ≥ 1 bits, the test holds exactly if X^s + g is irreducible.
rw [irrW_eq_true]
constructor
· intro h
refine irreducible_of_inv g hg fun z hz => ?_
obtain ⟨x, hx, rfl⟩ := decW_surj g z
rcases h x hx with rfl | ⟨y, _, hy⟩
· exact absurd (decW_zeroW g) hz
· exact ⟨decW g y, by rw [← decW_mulW g hx, hy, decW_oneW]⟩
· intro h x hx
have : Fact (Irreducible (modP g)) := ⟨h⟩
by_cases h0 : x = zeroW g
· exact Or.inl h0
· right
havehne : decW g x ≠0:=fun e => h0 (decW_inj g hx (length_zeroW g) (by rw [e, decW_zeroW]))
obtain ⟨y, hy, hyz⟩ := decW_surj g (decW g x)⁻¹
refine ⟨y, hy, decW_inj g (length_mulW hx y) (length_oneW hg) ?_⟩
rw [decW_mulW g hx, hyz, decW_oneW, mul_inv_cancel₀ hne]
For s ≥ 1 the search succeeds: modW s is a word of s bits, and X^s + modW s is irreducible.