math / data /lean /OAI /Combinatorics /MatrixRemoval /HostNonshattering.lean
introvoyz045's picture
Migrated from GitHub
4a56cd6 verified
Raw History Blame Contribute Delete
7 kB

The two kinds of non-anchor positions, without their outer sum tag.

23
abbrev NonanchorPosition (h : ℕ) := VariablePosition h ⊕ Fin (2 ^ h)

Column-class labels for the non-anchor induced submatrix. The dummy label is irrelevant because dummy columns are treated separately.

27
def nonanchorClass {h : ℕ} : NonanchorPosition h → ℕ
body · 2 lines
  | Sum.inl v => v.1.val
  | Sum.inr _ => 0
31
def nonanchorKey {h : ℕ} : NonanchorPosition h → ℕ
body · 2 lines
  | Sum.inl v => node v
  | Sum.inr _ => 0
35
def nonanchorDummy {h : ℕ} : NonanchorPosition h → Prop
body · 2 lines
  | Sum.inl _ => False
  | Sum.inr _ => True
39
instance {h : ℕ} (x : NonanchorPosition h) : Decidable (nonanchorDummy x) := by
body · 1 line
  cases x <;> simp only [nonanchorDummy] <;> infer_instance

The three class labels that can contain ones in a variable row.

43
def variableSupportLabels {h : ℕ} (r : VariablePosition h) : Finset ℕ :=
body · 1 line
  {r.1.val, 2 * (depth r - 1), 2 * (depth r - 1) + 1}
46
theorem variableSupportLabels_card_le {h : ℕ} (r : VariablePosition h) :
    (variableSupportLabels r).card ≤ 3 := by
proof · 1 line
  exact Finset.card_le_three

The constant-class suffix property, stated for the actual host kernel.

51
theorem variableEntry_mono_class {h : ℕ} (r c d : VariablePosition h)
    (hclass : c.1.val = d.1.val) (hnode : node c ≤ node d)
    (hc : variableEntry r c = true) : variableEntry r d = true := by
proof · 5 lines
  have hd : depth c = depth d := by simp only [depth, hclass]
  have hp : plus c = plus d := by simp only [plus, hclass]
  unfold variableEntry at hc ⊢
  simp only [hd, hp] at hc
  split_ifs at hc ⊢ <;> simp_all <;> omega

A true variable entry has one of the three possible column-class labels.

61
theorem variableEntry_mem_support {h : ℕ} (r c : VariablePosition h)
    (hc : variableEntry r c = true) : c.1.val ∈ variableSupportLabels r := by
proof · 6 lines
  have hr := r.1.isLt
  have hcv := c.1.isLt
  simp only [variableSupportLabels, Finset.mem_insert, Finset.mem_singleton]
  unfold variableEntry at hc
  simp only [depth, plus, decide_eq_true_eq] at hc ⊢
  split_ifs at hc <;> simp_all <;> omega

The induced matrix on all non-anchor positions misses a five-bit word.

71
theorem nonanchor_host_not_surjective (h : ℕ)
    (selected : Fin 5 → NonanchorPosition h) :
    ¬ Function.Surjective
      (fun r : NonanchorPosition h =>
        fun i => host (Sum.inr r) (Sum.inr (selected i))) := by
proof · 32 lines
  apply DirectNonshattering.not_surjective_selected_columns
    (fun r c : NonanchorPosition h => host (Sum.inr r) (Sum.inr c))
    nonanchorDummy nonanchorDummy nonanchorClass nonanchorKey
  · intro r hr c
    cases r with
    | inl r => exact False.elim hr
    | inr r => cases c <;> rfl
  · intro c hc r
    cases c with
    | inl c => exact False.elim hc
    | inr c => cases r <;> rfl
  · intro r hr c d hc hd hclass hnode he
    cases r with
    | inr r => exact False.elim (hr trivial)
    | inl r =>
      cases c with
      | inr c => exact False.elim (hc trivial)
      | inl c =>
        cases d with
        | inr d => exact False.elim (hd trivial)
        | inl d => exact variableEntry_mono_class r c d hclass hnode he
  · intro r hr
    cases r with
    | inr r => exact False.elim (hr trivial)
    | inl r =>
      apply (Finset.card_le_card ?_).trans (variableSupportLabels_card_le r)
      intro a ha
      obtain ⟨c, hc, rfl⟩ := Finset.mem_image.mp ha
      obtain ⟨_, hnd, he⟩ := Finset.mem_filter.mp hc
      cases c with
      | inr c => exact False.elim (hnd trivial)
      | inl c => exact variableEntry_mem_support r c he

The actual host, stated using its outer position type. This avoids any choice of a separate non-anchor enumeration in anchor-rigidity applications.

111
theorem host_nonanchor_missing_word {h : ℕ} (columns : Fin 5 → Position h)
    (hcolumns : ∀ i, ∃ c : NonanchorPosition h, columns i = Sum.inr c) :
    ∃ w : Fin 5 → Bool, ∀ r : Position h,
      (∃ a : NonanchorPosition h, r = Sum.inr a) →
      (fun i => host r (columns i)) ≠ w := by
proof · 9 lines
  classical
  choose selected hselected using hcolumns
  obtain ⟨w, hw⟩ : ∃ w : Fin 5 → Bool, ∀ r : NonanchorPosition h,
      (fun i => host (Sum.inr r) (Sum.inr (selected i))) ≠ w := by
    simpa only [Function.Surjective, not_forall, not_exists] using
      nonanchor_host_not_surjective h selected
  refine ⟨w, ?_⟩
  rintro r ⟨a, rfl⟩
  simpa only [hselected] using hw a

Restricting to any collection of non-anchor rows still misses a word. This is the form used for the final 32 rows of an alleged anchor copy.

128
theorem host_nonanchor_submatrix_not_surjective {h : ℕ} {R : Type uR}
    (rows : R → Position h) (columns : Fin 5 → Position h)
    (hrows : ∀ r, ∃ a : NonanchorPosition h, rows r = Sum.inr a)
    (hcolumns : ∀ i, ∃ c : NonanchorPosition h, columns i = Sum.inr c) :
    ¬ Function.Surjective (fun r i => host (rows r) (columns i)) := by
proof · 4 lines
  obtain ⟨w, hw⟩ := host_nonanchor_missing_word columns hcolumns
  intro hsurj
  obtain ⟨r, hr⟩ := hsurj w
  exact hw (rows r) (hrows r) hr

The outer sum tag gives a convenient intrinsic non-anchor predicate.

139
@[simp] theorem exists_nonanchor_iff_not_isLeft {h : ℕ} (x : Position h) :
    (∃ a : NonanchorPosition h, x = Sum.inr a) ↔ ¬ x.isLeft := by
proof · 1 line
  cases x <;> simp

Pointwise missing-word property for concrete anchor rigidity.

144
theorem host_nonanchor_missing_entry {h : ℕ} (columns : Fin 5 → Position h)
    (hcolumns : ∀ i, ¬ (columns i).isLeft) :
    ∃ w : Fin 5 → Bool, ∀ r : Position h, ¬ r.isLeft →
      ∃ i, host r (columns i) ≠ w i := by
proof · 6 lines
  obtain ⟨w, hw⟩ := host_nonanchor_missing_word columns
    (fun i => (exists_nonanchor_iff_not_isLeft (columns i)).mpr (hcolumns i))
  refine ⟨w, ?_⟩
  intro r hr
  have hne := hw r ((exists_nonanchor_iff_not_isLeft r).mpr hr)
  exact not_forall.mp (fun he => hne (funext he))

The subtype formulation also avoids making any non-anchor choices.

156
theorem host_nonanchor_subtype_not_surjective {h : ℕ}
    (columns : Fin 5 → Position h) (hcolumns : ∀ i, ¬ (columns i).isLeft) :
    ¬ Function.Surjective
      (fun r : {x : Position h // ¬ x.isLeft} => fun i => host r.val (columns i)) := by
proof · 6 lines
  apply host_nonanchor_submatrix_not_surjective
    (fun r : {x : Position h // ¬ x.isLeft} => r.val) columns
  · intro r
    exact (exists_nonanchor_iff_not_isLeft r.val).mpr r.property
  · intro i
    exact (exists_nonanchor_iff_not_isLeft (columns i)).mpr (hcolumns i)