Lean / AlexWang-AI/ordered-corner-lean4 / CornerRemoval.lean
Lean readerCornerRemoval.lean
Lean 4 Web has Mathlib, so it can check files that import only Mathlib. This one also imports CornerRemoval.Main, CornerRemoval.Packing, CornerRemoval.StripeRemoval, CornerRemoval.IdentityMain, which it does not have: you can read it there, but it will not check. Build the project itself to check it.
import CornerRemoval.Mainimport CornerRemoval.Packingimport CornerRemoval.StripeRemovalimport CornerRemoval.IdentityMainnamespace CornerRemoval.Orbit/-- Explicit bound for all eight patterns having just one zero or just one one. -/theorem corner_orbit_bound {n : ℕ} (hn : 2 ≤ n) (Q : Pattern)(hQ : weight Q = 1 ∨ weight Q = 3) (M : Rect n n) :(((patternDistance Q M : ℝ)/(n:ℝ)^2)/9)^10 ≤((patternCopies Q M).card:ℝ)/(n:ℝ)^4 :=removal_all_corners polynomial_removal hn Q hQ Mdef antiDiagonalRep : Pattern := fun i j => !(i == j)/-- All fourteen non-checkerboard patterns have polynomial removal bounds. -/theorem removal_except_diagonals (Q : Pattern) (hi : Q ≠ diagonalRep)(ha : Q ≠ antiDiagonalRep) : PolynomialRemoval Q := byrcases sixteen_partition Q with hc | ⟨t,b,h | h | h⟩· exact ⟨9, by norm_num, 10, by decide, fun hn M => corner_orbit_bound hn Q hc M⟩· exact h ▸ removal_symm t b constant_removal· exact h ▸ removal_symm t b stripe_removal· have diag_sym : ∀ a b : Bool,transposeComplementPattern a b diagonalRep = diagonalRep ∨transposeComplementPattern a b diagonalRep = antiDiagonalRep := by decideexact ((diag_sym t b).elim (fun e => hi (h.trans e)) (fun e => ha (h.trans e))).elim/-- The remaining external input to the sixteen-pattern classification is preciselypolynomial removal for the ordered identity. -/theorem all_patterns_iff_ordered_identity :(∀ Q : Pattern, PolynomialRemoval Q) ↔ PolynomialRemoval diagonalRep :=⟨fun h => h _, fun h => sixteen_patterns_of_three_representatives polynomial_removalconstant_removal stripe_removal h⟩/-- The two binary checkerboards share the same numerical removal estimate. -/theorem diagonal_orbit_bound {n : ℕ} (hn : 2 ≤ n) (Q : Pattern)(hQ : Q = diagonalRep ∨ Q = antiDiagonalRep) (M : Rect n n) :(((patternDistance Q M : ℝ)/(n:ℝ)^2)/14)^16 ≤((patternCopies Q M).card:ℝ)/(n:ℝ)^4 := byrcases hQ with rfl | rfl· exact Identity.ordered_identity_bound hn M· have e : antiDiagonalRep = transposeComplementPattern false true diagonalRep := by deciderw [e, patternDistance_symm,patternCounts_symm]exact Identity.ordered_identity_bound hn _/-- Polynomial removal for every single ordered binary 2 × 2 pattern. All foursymmetry classes are discharged within this development. -/theorem polynomial_removal_all_patterns (Q : Pattern) : PolynomialRemoval Q :=all_patterns_iff_ordered_identity.mpr⟨14, by norm_num, 16, by decide, fun hn M => Identity.ordered_identity_bound hn M⟩ Qend CornerRemoval.Orbit