import CornerRemoval.Main import CornerRemoval.Packing import CornerRemoval.StripeRemoval import CornerRemoval.IdentityMain namespace 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 M def 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 := by rcases 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 decide exact ((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 precisely polynomial 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_removal constant_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 := by rcases hQ with rfl | rfl · exact Identity.ordered_identity_bound hn M · have e : antiDiagonalRep = transposeComplementPattern false true diagonalRep := by decide rw [e, patternDistance_symm,patternCounts_symm] exact Identity.ordered_identity_bound hn _ /-- Polynomial removal for every single ordered binary 2 × 2 pattern. All four symmetry 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⟩ Q end CornerRemoval.Orbit