Lean / Reader
Lean readerSharpParity.lean
Lean 4 Web has Mathlib, so it can check files that import only Mathlib. This one also imports PaletteCross, which it does not have: you can read it there, but it will not check. Build the project itself to check it.
import PaletteCrossnamespace ParityPalettestheorem sig_congr {α : Type} (f g : α → Bool) (xs : List α)(h : ∀ x ∈ xs, f x = g x) : sig f xs = sig g xs := byinduction xs with| nil => rfl| cons x xs ih =>simp only [sig]rw [h x (by simp),ih (fun t ht => h t (by simp [ht]))]def eqMask (n w : Nat) (side : Bool) : Nat := sig (sameAt n w side) (crossRows n)theorem eqMask_rename (p : Fin 4 → Fin 4) (hp : Function.Injective p)(n w : Nat) (side : Bool) :eqMask n (rename p ((n+1-side.toNat)/2) w) side = eqMask n w side :=sig_congr _ _ _ (same_rename p hp n w side)def incompatible37 : Bool :=let left := (layer 15).map (fun w => eqMask 37 w false)let right := (layer 14).map (fun w => eqMask 37 w true)left.all fun l => right.all fun r => l &&& r != 0theorem table37 : incompatible37 = true := by native_decidetheorem forcedPair37 (left right : Nat) (hl : legal 19 left = true)(hr : legal 18 right = true) (wl : left < 4^19) (wr : right < 4^18) :∃ row ∈ crossRows 37, sameAt 37 left false row = true ∧ sameAt 37 right true row = true := byobtain ⟨p,hp,lp⟩ := normalize 15 left hl wlobtain ⟨q,hq,rq⟩ := normalize 14 right hr wrhave t := table37unfold incompatible37 at tsimp only [List.all_eq_true,List.mem_map,forall_exists_index,and_imp,forall_apply_eq_imp_iff₂, bne_iff_ne] at thave hx := t _ lp _ rqchange eqMask 37 (rename p ((37+1-Bool.false.toNat)/2) left) false &&&eqMask 37 (rename q ((37+1-Bool.true.toNat)/2) right) true ≠ 0 at hxrw [eqMask_rename p hp, eqMask_rename q hq] at hxby_contra! happly hxexact and_zero_of_avoids _ _ _ (by simpa using h)end ParityPalettes