math / data /lean /OAI /Combinatorics /MatrixRemoval /AnchorPatternFixed.lean
introvoyz045's picture
Migrated from GitHub
4a56cd6 verified
Raw History Blame Contribute Delete
3.08 kB
import OAI.Combinatorics.MatrixRemoval.AnchorPatternBridge
import OAI.Combinatorics.MatrixRemoval.AnchorProperties
namespace OAI
/-!
# Structural anchor bridges for the fixed pattern
The generic bridges are specialized to the explicit `anchor64` definition.
-/
universe uR uC
namespace Problem348.AnchorBridge
/-- The exact anchor realizes every five-bit word on the specified suffix. -/
theorem anchor64_word_block_complete (w : Fin 5 β†’ Bool) :
βˆƒ a : Fin 32, βˆ€ b : Fin 5,
anchor64 (wordRow a) (wordCol b) = w b := by
obtain ⟨a, ha⟩ := anchorWord_bijective.2 w
refine ⟨a, fun b => ?_⟩
have hb := congrFun ha b
simpa only [anchorWord, wordRow, wordCol, Nat.add_comm] using hb
/-- An exact anchor copy has at least 33 anchors on one of its two axes,
provided anchors form prefixes and non-anchor rows do not shatter five
non-anchor columns. -/
theorem anchor64_anchor_majority {R : Type uR} {C : Type uC}
(A : R β†’ C β†’ Bool) (row : Fin 64 β†’ R) (col : Fin 64 β†’ C)
(anchorR : R β†’ Prop) (anchorC : C β†’ Prop)
[DecidablePred anchorR] [DecidablePred anchorC]
(hcopy : βˆ€ i j, A (row i) (col j) = anchor64 i j)
(hcol : Function.Injective col)
(hprefixR : βˆ€ i j, i ≀ j β†’ anchorR (row j) β†’ anchorR (row i))
(hprefixC : βˆ€ i j, i ≀ j β†’ anchorC (col j) β†’ anchorC (col i))
(hnoshatter : βˆ€ cs : Fin 5 β†’ C, Function.Injective cs β†’
(βˆ€ b, Β¬ anchorC (cs b)) β†’ βˆƒ w : Fin 5 β†’ Bool,
βˆ€ r, Β¬ anchorR r β†’ βˆƒ b, A r (cs b) β‰  w b) :
33 ≀ (Finset.univ.filter (fun i => anchorR (row i))).card ∨
33 ≀ (Finset.univ.filter (fun j => anchorC (col j))).card := by
rcases anchor_at_32_or_anchor_at_32 anchor64 A row col anchorR anchorC
hcopy hcol hprefixR hprefixC anchor64_word_block_complete hnoshatter with hr | hc
· exact Or.inl (prefix_card_lower_bound _ ⟨32, by decide⟩ hprefixR hr)
· exact Or.inr (prefix_card_lower_bound _ ⟨32, by decide⟩ hprefixC hc)
/-- A row class of equal host rows occurs at most once in an anchor copy. -/
theorem anchor64_row_class_single_use {R : Type uR} {C : Type uC}
(A : R β†’ C β†’ Bool) (row : Fin 64 β†’ R) (col : Fin 64 β†’ C)
(P : R β†’ Prop) [DecidablePred P]
(hcopy : βˆ€ i j, A (row i) (col j) = anchor64 i j)
(hclass : βˆ€ r s, P r β†’ P s β†’ A r = A s) :
(Finset.univ.filter (fun i => P (row i))).card ≀ 1 :=
card_selected_row_class_le_one anchor64 A row col P hcopy
anchor64_rows_injective hclass
/-- A column class of equal host columns occurs at most once in an anchor copy. -/
theorem anchor64_col_class_single_use {R : Type uR} {C : Type uC}
(A : R β†’ C β†’ Bool) (row : Fin 64 β†’ R) (col : Fin 64 β†’ C)
(P : C β†’ Prop) [DecidablePred P]
(hcopy : βˆ€ i j, A (row i) (col j) = anchor64 i j)
(hclass : βˆ€ c d, P c β†’ P d β†’ βˆ€ r, A r c = A r d) :
(Finset.univ.filter (fun j => P (col j))).card ≀ 1 :=
card_selected_col_class_le_one anchor64 A row col P hcopy
anchor64_columns_injective hclass
end Problem348.AnchorBridge
end OAI