AFTD Auto-Formalizing Theoretical Domains

two_bridge_shore_overlap_with_saturated_twins

theoremverified

Let H have maximum degree seven and adjacent true twins x,y. Let Q₁,Q₂,W₁,W₂ each have four vertices, with x,y outside both Q sets, W₁,W₂ contained in the neighbors of x other than y, and each Qᵢ complete to Wᵢ. Let distinct vertices z₁,z₂, both different from x, be nonneighbors of x, absent from both Q sets, and adjacent to every vertex in Q₁ and Q₂ respectively. Suppose H has no four vertices with identical open neighborhoods and degree seven. Then either both pairs of sets agree, or each pair overlaps in exactly three vertices; in the latter case the common Q vertices all have neighborhood (W₁ ∪ W₂) ∪ {z₁,z₂}, and the common W vertices all have neighborhood (Q₁ ∪ Q₂) ∪ {x,y}.

Statement

theorem two_bridge_shore_overlap_with_saturated_twins
    {n : ℕ} (H : SimpleGraph (Fin n)) [DecidableRel H.Adj]
    (x y z₁ z₂ : Fin n) (Q₁ Q₂ W₁ W₂ : Finset (Fin n))
    (hxy : H.Adj x y) (hz : z₁ ≠ z₂)
    (hz₁x : z₁ ≠ x) (hz₂x : z₂ ≠ x)
    (hxz₁ : ¬ H.Adj x z₁) (hxz₂ : ¬ H.Adj x z₂)
    (hmax : ∀ a, (H.neighborFinset a).card ≤ 7)
    (htwin : ∀ a, a ≠ x → a ≠ y → (H.Adj x a ↔ H.Adj y a))
    (hq₁x : x ∉ Q₁) (hq₂x : x ∉ Q₂)
    (hq₁y : y ∉ Q₁) (hq₂y : y ∉ Q₂)
    (hz₁q₁ : z₁ ∉ Q₁) (hz₁q₂ : z₁ ∉ Q₂)
    (hz₂q₁ : z₂ ∉ Q₁) (hz₂q₂ : z₂ ∉ Q₂)
    (hw₁ : W₁ ⊆ (H.neighborFinset x).erase y)
    (hw₂ : W₂ ⊆ (H.neighborFinset x).erase y)
    (hcross₁ : ∀ q ∈ Q₁, ∀ w ∈ W₁, H.Adj q w)
    (hcross₂ : ∀ q ∈ Q₂, ∀ w ∈ W₂, H.Adj q w)
    (hqz₁ : ∀ q ∈ Q₁, H.Adj q z₁)
    (hqz₂ : ∀ q ∈ Q₂, H.Adj q z₂)
    (hq₁ : Q₁.card = 4) (hq₂ : Q₂.card = 4)
    (hw₁c : W₁.card = 4) (hw₂c : W₂.card = 4)
    (hfour : ∀ T : Finset (Fin n), T.card = 4 →
      (∀ a ∈ T, (H.neighborFinset a).card = 7) →
      ¬ (∀ a ∈ T, ∀ b ∈ T, H.neighborFinset a = H.neighborFinset b)) :
    (Q₁ = Q₂ ∧ W₁ = W₂) ∨
      ((Q₁ ∩ Q₂).card = 3 ∧ (W₁ ∩ W₂).card = 3 ∧
       (∀ q ∈ Q₁ ∩ Q₂, H.neighborFinset q = W₁ ∪ W₂ ∪ {z₁, z₂}) ∧
       (∀ w ∈ W₁ ∩ W₂, H.neighborFinset w = Q₁ ∪ Q₂ ∪ {x, y}))
Source
Two-critical-edge overlap reduction for the saturated-twin branch of OP-1957; finite compatibility tests in experiment 35071.
Verified
20 Nov 2026
Axioms
Classical.choiceQuot.soundpropext

The proof, explained

Because W₁ ∪ W₂ is contained in the neighbors of x other than its adjacent true twin y, and the maximum degree is at most 7, |W₁ ∪ W₂| ≤ 6, which forces W₁ and W₂ to share a vertex w₀. The vertex w₀ must be adjacent to both twins {x, y} and complete to Q₁ ∪ Q₂, which bounds |Q₁ ∪ Q₂| ≤ 5 by the degree bound on w₀; symmetrically, an overlapping vertex q₀ ∈ Q₁ ∩ Q₂ adjacent to {z₁, z₂} forces |W₁ ∪ W₂| ≤ 5. Since each 4-element set pair has union size 4 or 5, the mixed cases (4, 5) and (5, 4) would each produce four vertices with degree 7 and identical open neighborhoods, violating the hypothesis. This leaves only the case (4, 4), where both pairs coincide, and (5, 5), where both pairs overlap in 3 vertices and have the claimed neighborhoods.

  1. The union W₁ ∪ W₂ has cardinality at most 6, so W₁ ∩ W₂ is nonempty; we choose a common vertex w₀ ∈ W₁ ∩ W₂.

    Both W₁ and W₂ are subsets of N(x) \\ {y}, so their union is also contained in N(x) \\ {y}. Since y is a neighbor of x and the maximum degree of H is at most 7, removing y leaves at most 6 neighbors, so |W₁ ∪ W₂| ≤ 6. By inclusion-exclusion, |W₁ ∩ W₂| = |W₁| + |W₂| - |W₁ ∪ W₂| = 4 + 4 - |W₁ ∪ W₂| ≥ 2 > 0, so the intersection is nonempty and contains some vertex w₀.

    lines 29–43

    uses H.mem_neighborFinset, Finset.union_subset, Finset.card_le_card, Finset.card_erase_of_mem, Finset.card_pos, Finset.card_inter, Finset.mem_inter

      have hyNx : y ∈ H.neighborFinset x := by rw [H.mem_neighborFinset]; exact hxy
      have hWsub : W₁ ∪ W₂ ⊆ (H.neighborFinset x).erase y := Finset.union_subset hw₁ hw₂
      have hb6 : (W₁ ∪ W₂).card ≤ 6 := by
        have h1 := Finset.card_le_card hWsub
        rw [Finset.card_erase_of_mem hyNx] at h1
        have h2 := hmax x
        omega
      have hWinter : (W₁ ∩ W₂).Nonempty := by
        rw [← Finset.card_pos]
        have hcard := Finset.card_inter W₁ W₂
        rw [hw₁c, hw₂c] at hcard
        omega
      obtain ⟨w₀, hw₀mem⟩ := hWinter
      rw [Finset.mem_inter] at hw₀mem
      obtain ⟨hw₀₁, hw₀₂⟩ := hw₀mem
  2. The union Q₁ ∪ Q₂ has cardinality at most 5.

    The common vertex w₀ lies in N(x) \\ {y}, meaning w₀ is adjacent to x and distinct from both x and y. Because x and y are true twins, w₀ is also adjacent to y. Furthermore, w₀ ∈ W₁ implies w₀ is adjacent to every vertex in Q₁, and w₀ ∈ W₂ implies w₀ is adjacent to every vertex in Q₂. Hence N(w₀) contains {x, y} ∪ (Q₁ ∪ Q₂). Since x, y ∉ Q₁ ∪ Q₂, this union is disjoint and has cardinality 2 + |Q₁ ∪ Q₂|. Because the degree of w₀ is at most 7, 2 + |Q₁ ∪ Q₂| ≤ 7, which gives |Q₁ ∪ Q₂| ≤ 5.

    lines 44–79

    uses Finset.mem_erase, H.mem_neighborFinset, Finset.mem_union, Finset.mem_insert, Finset.mem_singleton, not_or, Finset.disjoint_left, Finset.card_union_of_disjoint, Finset.card_pair, Finset.card_le_card

      -- ===== a <= 5 =====
      have ha5 : (Q₁ ∪ Q₂).card ≤ 5 := by
        have hw₀erase : w₀ ∈ (H.neighborFinset x).erase y := hw₁ hw₀₁
        rw [Finset.mem_erase] at hw₀erase
        obtain ⟨hw₀ne_y, hw₀N⟩ := hw₀erase
        have hAdjxw : H.Adj x w₀ := (H.mem_neighborFinset x w₀).mp hw₀N
        have hw₀ne_x : w₀ ≠ x := by intro h; exact hAdjxw.ne h.symm
        have hAdjw₀x : H.Adj w₀ x := hAdjxw.symm
        have hAdjw₀y : H.Adj w₀ y := ((htwin w₀ hw₀ne_x hw₀ne_y).mp hAdjxw).symm
        have hSsub : ({x, y} : Finset (Fin n)) ∪ (Q₁ ∪ Q₂) ⊆ H.neighborFinset w₀ := by
          intro a ha'
          rw [Finset.mem_union] at ha'
          rcases ha' with ha' | ha'
          · rw [Finset.mem_insert, Finset.mem_singleton] at ha'
            rcases ha' with rfl | rfl
            · rw [H.mem_neighborFinset]; exact hAdjw₀x
            · rw [H.mem_neighborFinset]; exact hAdjw₀y
          · rw [Finset.mem_union] at ha'
            rcases ha' with ha' | ha'
            · rw [H.mem_neighborFinset]; exact (hcross₁ a ha' w₀ hw₀₁).symm
            · rw [H.mem_neighborFinset]; exact (hcross₂ a ha' w₀ hw₀₂).symm
        have hxnot : x ∉ Q₁ ∪ Q₂ := by simp only [Finset.mem_union, not_or]; exact ⟨hq₁x, hq₂x⟩
        have hynot : y ∉ Q₁ ∪ Q₂ := by simp only [Finset.mem_union, not_or]; exact ⟨hq₁y, hq₂y⟩
        have hdisj : Disjoint ({x, y} : Finset (Fin n)) (Q₁ ∪ Q₂) := by
          rw [Finset.disjoint_left]
          intro a ha' haq
          rw [Finset.mem_insert, Finset.mem_singleton] at ha'
          rcases ha' with rfl | rfl
          · exact hxnot haq
          · exact hynot haq
        have hSc : (({x, y} : Finset (Fin n)) ∪ (Q₁ ∪ Q₂)).card = 2 + (Q₁ ∪ Q₂).card := by
          rw [Finset.card_union_of_disjoint hdisj, Finset.card_pair hxy.ne]
        have hc := Finset.card_le_card hSsub
        rw [hSc] at hc
        have := hmax w₀
        omega
  3. The intersection Q₁ ∩ Q₂ is nonempty; we choose a common vertex q₀ ∈ Q₁ ∩ Q₂.

    By inclusion-exclusion, |Q₁ ∩ Q₂| = |Q₁| + |Q₂| - |Q₁ ∪ Q₂| = 4 + 4 - |Q₁ ∪ Q₂| ≥ 8 - 5 = 3 > 0. Thus Q₁ ∩ Q₂ is nonempty, and we pick an element q₀ ∈ Q₁ ∩ Q₂.

    lines 80–88

    uses Finset.card_pos, Finset.card_inter, Finset.mem_inter

      -- ===== Q intersection nonempty =====
      have hQinter : (Q₁ ∩ Q₂).Nonempty := by
        rw [← Finset.card_pos]
        have hcard := Finset.card_inter Q₁ Q₂
        rw [hq₁, hq₂] at hcard
        omega
      obtain ⟨q₀, hq₀mem⟩ := hQinter
      rw [Finset.mem_inter] at hq₀mem
      obtain ⟨hq₀₁, hq₀₂⟩ := hq₀mem
  4. The union W₁ ∪ W₂ has cardinality at most 5.

    Vertices z₁ and z₂ are nonneighbors of x, while W₁ ∪ W₂ ⊆ N(x), so {z₁, z₂} is disjoint from W₁ ∪ W₂. The vertex q₀ ∈ Q₁ ∩ Q₂ is adjacent to z₁ (since q₀ ∈ Q₁), to z₂ (since q₀ ∈ Q₂), and to every vertex in W₁ ∪ W₂ (from the complete bipartite connections). Hence N(q₀) contains {z₁, z₂} ∪ (W₁ ∪ W₂), which has cardinality 2 + |W₁ ∪ W₂| because z₁ ≠ z₂. As the degree of q₀ is at most 7, 2 + |W₁ ∪ W₂| ≤ 7, proving |W₁ ∪ W₂| ≤ 5.

    lines 89–137

    uses Finset.mem_erase, H.mem_neighborFinset, Finset.mem_union, not_or, Finset.mem_insert, Finset.mem_singleton, Finset.disjoint_left, Finset.card_union_of_disjoint, Finset.card_pair, Finset.card_le_card

      -- ===== b <= 5 =====
      have hb5 : (W₁ ∪ W₂).card ≤ 5 := by
        have hz₁W1 : z₁ ∉ W₁ := by
          intro h
          have := hw₁ h
          rw [Finset.mem_erase] at this
          exact hxz₁ ((H.mem_neighborFinset x z₁).mp this.2)
        have hz₁W2 : z₁ ∉ W₂ := by
          intro h
          have := hw₂ h
          rw [Finset.mem_erase] at this
          exact hxz₁ ((H.mem_neighborFinset x z₁).mp this.2)
        have hz₂W1 : z₂ ∉ W₁ := by
          intro h
          have := hw₁ h
          rw [Finset.mem_erase] at this
          exact hxz₂ ((H.mem_neighborFinset x z₂).mp this.2)
        have hz₂W2 : z₂ ∉ W₂ := by
          intro h
          have := hw₂ h
          rw [Finset.mem_erase] at this
          exact hxz₂ ((H.mem_neighborFinset x z₂).mp this.2)
        have hz₁not : z₁ ∉ W₁ ∪ W₂ := by simp only [Finset.mem_union, not_or]; exact ⟨hz₁W1, hz₁W2⟩
        have hz₂not : z₂ ∉ W₁ ∪ W₂ := by simp only [Finset.mem_union, not_or]; exact ⟨hz₂W1, hz₂W2⟩
        have hSsub : ({z₁, z₂} : Finset (Fin n)) ∪ (W₁ ∪ W₂) ⊆ H.neighborFinset q₀ := by
          intro a ha'
          rw [Finset.mem_union] at ha'
          rcases ha' with ha' | ha'
          · rw [Finset.mem_insert, Finset.mem_singleton] at ha'
            rcases ha' with rfl | rfl
            · rw [H.mem_neighborFinset]; exact hqz₁ q₀ hq₀₁
            · rw [H.mem_neighborFinset]; exact hqz₂ q₀ hq₀₂
          · rw [Finset.mem_union] at ha'
            rcases ha' with ha' | ha'
            · rw [H.mem_neighborFinset]; exact hcross₁ q₀ hq₀₁ a ha'
            · rw [H.mem_neighborFinset]; exact hcross₂ q₀ hq₀₂ a ha'
        have hdisj : Disjoint ({z₁, z₂} : Finset (Fin n)) (W₁ ∪ W₂) := by
          rw [Finset.disjoint_left]
          intro a ha' haq
          rw [Finset.mem_insert, Finset.mem_singleton] at ha'
          rcases ha' with rfl | rfl
          · exact hz₁not haq
          · exact hz₂not haq
        have hSc : (({z₁, z₂} : Finset (Fin n)) ∪ (W₁ ∪ W₂)).card = 2 + (W₁ ∪ W₂).card := by
          rw [Finset.card_union_of_disjoint hdisj, Finset.card_pair hz]
        have hc := Finset.card_le_card hSsub
        rw [hSc] at hc
        have := hmax q₀
        omega
  5. Both |Q₁ ∪ Q₂| and |W₁ ∪ W₂| must be either 4 or 5, setting up a case analysis over the four possible combinations.

    Since Q₁ ⊆ Q₁ ∪ Q₂ and |Q₁| = 4, we have |Q₁ ∪ Q₂| ≥ 4. Coupled with the upper bound |Q₁ ∪ Q₂| ≤ 5, this restricts |Q₁ ∪ Q₂| to 4 or 5. Symmetrically, |W₁ ∪ W₂| is 4 or 5. We proceed by case analysis on these four combinations.

    lines 138–146

    uses Finset.card_le_card, Finset.subset_union_left

      have ha4 : 4 ≤ (Q₁ ∪ Q₂).card := by
        have := Finset.card_le_card (Finset.subset_union_left : Q₁ ⊆ Q₁ ∪ Q₂)
        omega
      have hb4 : 4 ≤ (W₁ ∪ W₂).card := by
        have := Finset.card_le_card (Finset.subset_union_left : W₁ ⊆ W₁ ∪ W₂)
        omega
      have ha_cases : (Q₁ ∪ Q₂).card = 4 ∨ (Q₁ ∪ Q₂).card = 5 := by omega
      have hb_cases : (W₁ ∪ W₂).card = 4 ∨ (W₁ ∪ W₂).card = 5 := by omega
      rcases ha_cases with ha | ha <;> rcases hb_cases with hb | hb
  6. In the case |Q₁ ∪ Q₂| = 4 and |W₁ ∪ W₂| = 4, both pairs of sets agree: Q₁ = Q₂ and W₁ = W₂.

    Since Q₁ ⊆ Q₁ ∪ Q₂ and |Q₁| = 4 = |Q₁ ∪ Q₂|, we have Q₁ = Q₁ ∪ Q₂. Similarly Q₂ = Q₁ ∪ Q₂, so Q₁ = Q₂. The identical reasoning applied to W₁, W₂ yields W₁ = W₂.

    lines 147–155

    uses Finset.eq_of_subset_of_card_le, Finset.subset_union_left, Finset.subset_union_right

      · -- a = 4, b = 4
        left
        refine ⟨?_, ?_⟩
        · have h1 : Q₁ = Q₁ ∪ Q₂ := Finset.eq_of_subset_of_card_le Finset.subset_union_left (by rw [ha, hq₁])
          have h2 : Q₂ = Q₁ ∪ Q₂ := Finset.eq_of_subset_of_card_le Finset.subset_union_right (by rw [ha, hq₂])
          exact h1.trans h2.symm
        · have h1 : W₁ = W₁ ∪ W₂ := Finset.eq_of_subset_of_card_le Finset.subset_union_left (by rw [hb, hw₁c])
          have h2 : W₂ = W₁ ∪ W₂ := Finset.eq_of_subset_of_card_le Finset.subset_union_right (by rw [hb, hw₂c])
          exact h1.trans h2.symm
  7. The case |Q₁ ∪ Q₂| = 4 and |W₁ ∪ W₂| = 5 is impossible.

    If |Q₁ ∪ Q₂| = 4, then Q₁ = Q₂. Every vertex q ∈ Q₁ also belongs to Q₂, so q is adjacent to both z₁ and z₂, as well as to all 5 vertices of W₁ ∪ W₂. Since z₁, z₂ are nonneighbors of x while W₁ ∪ W₂ consists of neighbors of x, {z₁, z₂} is disjoint from W₁ ∪ W₂, so {z₁, z₂} ∪ (W₁ ∪ W₂) has cardinality 2 + 5 = 7. Because the maximum degree is 7, the open neighborhood of every vertex in Q₁ must equal {z₁, z₂} ∪ (W₁ ∪ W₂). This gives 4 vertices in Q₁ all having degree 7 and identical open neighborhoods, contradicting the hypothesis hfour.

    lines 156–200

    uses Finset.eq_of_subset_of_card_le, Finset.subset_union_left, Finset.subset_union_right, Finset.mem_union, Finset.mem_erase, H.mem_neighborFinset, Finset.disjoint_left, Finset.mem_insert, Finset.mem_singleton, Finset.card_union_of_disjoint, Finset.card_pair

      · -- a = 4, b = 5 : contradiction
        exfalso
        have hQeq : Q₁ = Q₂ := by
          have h1 : Q₁ = Q₁ ∪ Q₂ := Finset.eq_of_subset_of_card_le Finset.subset_union_left (by rw [ha, hq₁])
          have h2 : Q₂ = Q₁ ∪ Q₂ := Finset.eq_of_subset_of_card_le Finset.subset_union_right (by rw [ha, hq₂])
          exact h1.trans h2.symm
        have hz₁not : z₁ ∉ W₁ ∪ W₂ := by
          rw [Finset.mem_union]; intro h; rcases h with h | h
          · have := hw₁ h; rw [Finset.mem_erase] at this
            exact hxz₁ ((H.mem_neighborFinset x z₁).mp this.2)
          · have := hw₂ h; rw [Finset.mem_erase] at this
            exact hxz₁ ((H.mem_neighborFinset x z₁).mp this.2)
        have hz₂not : z₂ ∉ W₁ ∪ W₂ := by
          rw [Finset.mem_union]; intro h; rcases h with h | h
          · have := hw₁ h; rw [Finset.mem_erase] at this
            exact hxz₂ ((H.mem_neighborFinset x z₂).mp this.2)
          · have := hw₂ h; rw [Finset.mem_erase] at this
            exact hxz₂ ((H.mem_neighborFinset x z₂).mp this.2)
        have hdisj : Disjoint ({z₁, z₂} : Finset (Fin n)) (W₁ ∪ W₂) := by
          rw [Finset.disjoint_left]
          intro a ha' haq
          rw [Finset.mem_insert, Finset.mem_singleton] at ha'
          rcases ha' with rfl | rfl
          · exact hz₁not haq
          · exact hz₂not haq
        have hScard' : (({z₁, z₂} : Finset (Fin n)) ∪ (W₁ ∪ W₂)).card = 7 := by
          rw [Finset.card_union_of_disjoint hdisj, Finset.card_pair hz, hb]
        have keyeq : ∀ q ∈ Q₁, H.neighborFinset q = ({z₁, z₂} : Finset (Fin n)) ∪ (W₁ ∪ W₂) := by
          intro q hq
          have hq₂' : q ∈ Q₂ := by rw [← hQeq]; exact hq
          have hSsub : ({z₁, z₂} : Finset (Fin n)) ∪ (W₁ ∪ W₂) ⊆ H.neighborFinset q := by
            intro a ha'
            rw [Finset.mem_union] at ha'
            rcases ha' with ha' | ha'
            · rw [Finset.mem_insert, Finset.mem_singleton] at ha'
              rcases ha' with rfl | rfl
              · rw [H.mem_neighborFinset]; exact hqz₁ q hq
              · rw [H.mem_neighborFinset]; exact hqz₂ q hq₂'
            · rw [Finset.mem_union] at ha'
              rcases ha' with ha' | ha'
              · rw [H.mem_neighborFinset]; exact hcross₁ q hq a ha'
              · rw [H.mem_neighborFinset]; exact hcross₂ q hq₂' a ha'
          exact (Finset.eq_of_subset_of_card_le hSsub (by rw [hScard']; exact hmax q)).symm
        exact hfour Q₁ hq₁ (fun a ha' => by rw [keyeq a ha', hScard'])
          (fun a ha' b hb' => by rw [keyeq a ha', keyeq b hb'])
  8. The case |Q₁ ∪ Q₂| = 5 and |W₁ ∪ W₂| = 4 is impossible.

    If |W₁ ∪ W₂| = 4, then W₁ = W₂. Every vertex w ∈ W₁ is adjacent to x, to the true twin y, and to all 5 vertices of Q₁ ∪ Q₂. Because x, y ∉ Q₁ ∪ Q₂, {x, y} is disjoint from Q₁ ∪ Q₂, so {x, y} ∪ (Q₁ ∪ Q₂) has cardinality 2 + 5 = 7. Since the maximum degree is 7, the neighborhood of every vertex in W₁ must equal {x, y} ∪ (Q₁ ∪ Q₂). This gives 4 vertices in W₁ all having degree 7 and identical open neighborhoods, contradicting hfour.

    lines 201–242

    uses Finset.eq_of_subset_of_card_le, Finset.subset_union_left, Finset.subset_union_right, Finset.mem_union, not_or, Finset.disjoint_left, Finset.mem_insert, Finset.mem_singleton, Finset.card_union_of_disjoint, Finset.card_pair, Finset.mem_erase, H.mem_neighborFinset

      · -- a = 5, b = 4 : contradiction
        exfalso
        have hWeq : W₁ = W₂ := by
          have h1 : W₁ = W₁ ∪ W₂ := Finset.eq_of_subset_of_card_le Finset.subset_union_left (by rw [hb, hw₁c])
          have h2 : W₂ = W₁ ∪ W₂ := Finset.eq_of_subset_of_card_le Finset.subset_union_right (by rw [hb, hw₂c])
          exact h1.trans h2.symm
        have hxnot : x ∉ Q₁ ∪ Q₂ := by simp only [Finset.mem_union, not_or]; exact ⟨hq₁x, hq₂x⟩
        have hynot : y ∉ Q₁ ∪ Q₂ := by simp only [Finset.mem_union, not_or]; exact ⟨hq₁y, hq₂y⟩
        have hdisjX : Disjoint ({x, y} : Finset (Fin n)) (Q₁ ∪ Q₂) := by
          rw [Finset.disjoint_left]
          intro a ha' haq
          rw [Finset.mem_insert, Finset.mem_singleton] at ha'
          rcases ha' with rfl | rfl
          · exact hxnot haq
          · exact hynot haq
        have hScardX : (({x, y} : Finset (Fin n)) ∪ (Q₁ ∪ Q₂)).card = 7 := by
          rw [Finset.card_union_of_disjoint hdisjX, Finset.card_pair hxy.ne, ha]
        have keyeq : ∀ w ∈ W₁, H.neighborFinset w = ({x, y} : Finset (Fin n)) ∪ (Q₁ ∪ Q₂) := by
          intro w hw
          have hw₂' : w ∈ W₂ := by rw [← hWeq]; exact hw
          have hw₁erase : w ∈ (H.neighborFinset x).erase y := hw₁ hw
          rw [Finset.mem_erase] at hw₁erase
          obtain ⟨hwne_y, hwN⟩ := hw₁erase
          have hAdjxw : H.Adj x w := (H.mem_neighborFinset x w).mp hwN
          have hwne_x : w ≠ x := by intro h; exact hAdjxw.ne h.symm
          have hAdjwx : H.Adj w x := hAdjxw.symm
          have hAdjwy : H.Adj w y := ((htwin w hwne_x hwne_y).mp hAdjxw).symm
          have hSsub : ({x, y} : Finset (Fin n)) ∪ (Q₁ ∪ Q₂) ⊆ H.neighborFinset w := by
            intro a ha'
            rw [Finset.mem_union] at ha'
            rcases ha' with ha' | ha'
            · rw [Finset.mem_insert, Finset.mem_singleton] at ha'
              rcases ha' with rfl | rfl
              · rw [H.mem_neighborFinset]; exact hAdjwx
              · rw [H.mem_neighborFinset]; exact hAdjwy
            · rw [Finset.mem_union] at ha'
              rcases ha' with ha' | ha'
              · rw [H.mem_neighborFinset]; exact (hcross₁ a ha' w hw).symm
              · rw [H.mem_neighborFinset]; exact (hcross₂ a ha' w hw₂').symm
          exact (Finset.eq_of_subset_of_card_le hSsub (by rw [hScardX]; exact hmax w)).symm
        exact hfour W₁ hw₁c (fun a ha' => by rw [keyeq a ha', hScardX])
          (fun a ha' b hb' => by rw [keyeq a ha', keyeq b hb'])
  9. In the case |Q₁ ∪ Q₂| = 5 and |W₁ ∪ W₂| = 5, each pair of sets overlaps in exactly 3 vertices, and their common vertices have the specified neighborhoods.

    By inclusion-exclusion, |Q₁ ∩ Q₂| = 4 + 4 - 5 = 3 and |W₁ ∩ W₂| = 4 + 4 - 5 = 3. For any q ∈ Q₁ ∩ Q₂, q is adjacent to both z₁, z₂ and to all vertices of W₁ ∪ W₂. As {z₁, z₂} and W₁ ∪ W₂ are disjoint, this accounts for 2 + 5 = 7 neighbors, so the neighborhood of q must be (W₁ ∪ W₂) ∪ {z₁, z₂}. Symmetrically, for any w ∈ W₁ ∩ W₂, w is adjacent to both true twins x, y and to all vertices of Q₁ ∪ Q₂, which gives 2 + 5 = 7 neighbors, so the neighborhood of w must be (Q₁ ∪ Q₂) ∪ {x, y}.

    lines 243–328

    uses Finset.mem_union, Finset.mem_erase, H.mem_neighborFinset, Finset.disjoint_left, Finset.mem_insert, Finset.mem_singleton, Finset.card_union_of_disjoint, Finset.card_pair, Finset.card_inter, Finset.mem_inter, Finset.eq_of_subset_of_card_le, Finset.union_comm, not_or

      · -- a = 5, b = 5 : conclusion
        right
        have hz₁not : z₁ ∉ W₁ ∪ W₂ := by
          rw [Finset.mem_union]; intro h; rcases h with h | h
          · have := hw₁ h; rw [Finset.mem_erase] at this
            exact hxz₁ ((H.mem_neighborFinset x z₁).mp this.2)
          · have := hw₂ h; rw [Finset.mem_erase] at this
            exact hxz₁ ((H.mem_neighborFinset x z₁).mp this.2)
        have hz₂not : z₂ ∉ W₁ ∪ W₂ := by
          rw [Finset.mem_union]; intro h; rcases h with h | h
          · have := hw₁ h; rw [Finset.mem_erase] at this
            exact hxz₂ ((H.mem_neighborFinset x z₂).mp this.2)
          · have := hw₂ h; rw [Finset.mem_erase] at this
            exact hxz₂ ((H.mem_neighborFinset x z₂).mp this.2)
        have hdisjZ : Disjoint ({z₁, z₂} : Finset (Fin n)) (W₁ ∪ W₂) := by
          rw [Finset.disjoint_left]
          intro a ha' haq
          rw [Finset.mem_insert, Finset.mem_singleton] at ha'
          rcases ha' with rfl | rfl
          · exact hz₁not haq
          · exact hz₂not haq
        have hScardW : (({z₁, z₂} : Finset (Fin n)) ∪ (W₁ ∪ W₂)).card = 7 := by
          rw [Finset.card_union_of_disjoint hdisjZ, Finset.card_pair hz, hb]
        have hQcard3 : (Q₁ ∩ Q₂).card = 3 := by
          have h := Finset.card_inter Q₁ Q₂
          rw [hq₁, hq₂, ha] at h; omega
        have hWcard3 : (W₁ ∩ W₂).card = 3 := by
          have h := Finset.card_inter W₁ W₂
          rw [hw₁c, hw₂c, hb] at h; omega
        have hNq : ∀ q ∈ Q₁ ∩ Q₂, H.neighborFinset q = W₁ ∪ W₂ ∪ {z₁, z₂} := by
          intro q hq'
          rw [Finset.mem_inter] at hq'
          obtain ⟨hq₁', hq₂'⟩ := hq'
          have hSsub : ({z₁, z₂} : Finset (Fin n)) ∪ (W₁ ∪ W₂) ⊆ H.neighborFinset q := by
            intro a ha'
            rw [Finset.mem_union] at ha'
            rcases ha' with ha' | ha'
            · rw [Finset.mem_insert, Finset.mem_singleton] at ha'
              rcases ha' with rfl | rfl
              · rw [H.mem_neighborFinset]; exact hqz₁ q hq₁'
              · rw [H.mem_neighborFinset]; exact hqz₂ q hq₂'
            · rw [Finset.mem_union] at ha'
              rcases ha' with ha' | ha'
              · rw [H.mem_neighborFinset]; exact hcross₁ q hq₁' a ha'
              · rw [H.mem_neighborFinset]; exact hcross₂ q hq₂' a ha'
          have heq : ({z₁, z₂} : Finset (Fin n)) ∪ (W₁ ∪ W₂) = H.neighborFinset q :=
            Finset.eq_of_subset_of_card_le hSsub (by rw [hScardW]; exact hmax q)
          rw [← heq, Finset.union_comm]
        have hxnot : x ∉ Q₁ ∪ Q₂ := by simp only [Finset.mem_union, not_or]; exact ⟨hq₁x, hq₂x⟩
        have hynot : y ∉ Q₁ ∪ Q₂ := by simp only [Finset.mem_union, not_or]; exact ⟨hq₁y, hq₂y⟩
        have hNw : ∀ w ∈ W₁ ∩ W₂, H.neighborFinset w = Q₁ ∪ Q₂ ∪ {x, y} := by
          intro w hw'
          rw [Finset.mem_inter] at hw'
          obtain ⟨hw₁', hw₂'⟩ := hw'
          have hw₁erase : w ∈ (H.neighborFinset x).erase y := hw₁ hw₁'
          rw [Finset.mem_erase] at hw₁erase
          obtain ⟨hwne_y, hwN⟩ := hw₁erase
          have hAdjxw : H.Adj x w := (H.mem_neighborFinset x w).mp hwN
          have hwne_x : w ≠ x := by intro h; exact hAdjxw.ne h.symm
          have hAdjwx : H.Adj w x := hAdjxw.symm
          have hAdjwy : H.Adj w y := ((htwin w hwne_x hwne_y).mp hAdjxw).symm
          have hSsub : ({x, y} : Finset (Fin n)) ∪ (Q₁ ∪ Q₂) ⊆ H.neighborFinset w := by
            intro a ha'
            rw [Finset.mem_union] at ha'
            rcases ha' with ha' | ha'
            · rw [Finset.mem_insert, Finset.mem_singleton] at ha'
              rcases ha' with rfl | rfl
              · rw [H.mem_neighborFinset]; exact hAdjwx
              · rw [H.mem_neighborFinset]; exact hAdjwy
            · rw [Finset.mem_union] at ha'
              rcases ha' with ha' | ha'
              · rw [H.mem_neighborFinset]; exact (hcross₁ a ha' w hw₁').symm
              · rw [H.mem_neighborFinset]; exact (hcross₂ a ha' w hw₂').symm
          have hdisjX : Disjoint ({x, y} : Finset (Fin n)) (Q₁ ∪ Q₂) := by
            rw [Finset.disjoint_left]
            intro a ha' haq
            rw [Finset.mem_insert, Finset.mem_singleton] at ha'
            rcases ha' with rfl | rfl
            · exact hxnot haq
            · exact hynot haq
          have hScardX : (({x, y} : Finset (Fin n)) ∪ (Q₁ ∪ Q₂)).card = 7 := by
            rw [Finset.card_union_of_disjoint hdisjX, Finset.card_pair hxy.ne, ha]
          have heq : ({x, y} : Finset (Fin n)) ∪ (Q₁ ∪ Q₂) = H.neighborFinset w :=
            Finset.eq_of_subset_of_card_le hSsub (by rw [hScardX]; exact hmax w)
          rw [← heq, Finset.union_comm]
        exact ⟨hQcard3, hWcard3, hNq, hNw⟩
H.mem_neighborFinset
A vertex w belongs to the neighbor finset of v in H if and only if v and w are adjacent in H.
Finset.union_subset
The union of two finite sets is a subset of u if and only if both sets are subsets of u.
Finset.card_le_card
If a finite set s is a subset of t, then |s| ≤ |t|.
Finset.card_erase_of_mem
Removing an element a that belongs to s decreases the cardinality of s by one: |s \\ {a}| = |s| - 1.
Finset.card_pos
A finite set has strictly positive cardinality if and only if it is nonempty.
Finset.card_inter
Principle of inclusion-exclusion for two finite sets: |s ∩ t| = |s| + |t| - |s ∪ t|.
Finset.mem_inter
An element belongs to the intersection of two finite sets if and only if it belongs to both sets.
Finset.mem_erase
An element belongs to s \\ {b} if and only if it is in s and not equal to b.
Finset.mem_union
An element belongs to the union of two finite sets if and only if it belongs to at least one of them.
Finset.mem_insert
An element belongs to {b} ∪ s if and only if it equals b or belongs to s.
Finset.mem_singleton
An element belongs to the singleton {a} if and only if it equals a.
not_or
De Morgan's law: ¬(p ∨ q) is equivalent to ¬p ∧ ¬q.
Finset.disjoint_left
Two finite sets are disjoint if and only if no element of the first set belongs to the second set.
Finset.card_union_of_disjoint
If two finite sets s and t are disjoint, then |s ∪ t| = |s| + |t|.
Finset.card_pair
A pair set of two distinct elements {a, b} has cardinality two.
Finset.subset_union_left
A set is always a subset of its union with another set: s₁ ⊆ s₁ ∪ s₂.
Finset.subset_union_right
A set is always a subset of another set's union with it: s₂ ⊆ s₁ ∪ s₂.
Finset.eq_of_subset_of_card_le
If s ⊆ t and |t| ≤ |s|, then s = t.
Finset.union_comm
Union of finite sets is commutative: s₁ ∪ s₂ = s₂ ∪ s₁.

Written by a model (gemini-3.8-flash) from the Lean proof and the goal states Lean reported at each step. Lean verified the proof; this explanation is a reading aid and is not itself machine-checked.

Lean source view module on GitHub

theorem two_bridge_shore_overlap_with_saturated_twins    {n : ℕ} (H : SimpleGraph (Fin n)) [DecidableRel H.Adj]    (x y z₁ z₂ : Fin n) (Q₁ Q₂ W₁ W₂ : Finset (Fin n))    (hxy : H.Adj x y) (hz : z₁ ≠ z₂)    (hz₁x : z₁ ≠ x) (hz₂x : z₂ ≠ x)    (hxz₁ : ¬ H.Adj x z₁) (hxz₂ : ¬ H.Adj x z₂)    (hmax : ∀ a, (H.neighborFinset a).card ≤ 7)    (htwin : ∀ a, a ≠ x → a ≠ y → (H.Adj x a ↔ H.Adj y a))    (hq₁x : x ∉ Q₁) (hq₂x : x ∉ Q₂)    (hq₁y : y ∉ Q₁) (hq₂y : y ∉ Q₂)    (hz₁q₁ : z₁ ∉ Q₁) (hz₁q₂ : z₁ ∉ Q₂)    (hz₂q₁ : z₂ ∉ Q₁) (hz₂q₂ : z₂ ∉ Q₂)    (hw₁ : W₁ ⊆ (H.neighborFinset x).erase y)    (hw₂ : W₂ ⊆ (H.neighborFinset x).erase y)    (hcross₁ : ∀ q ∈ Q₁, ∀ w ∈ W₁, H.Adj q w)    (hcross₂ : ∀ q ∈ Q₂, ∀ w ∈ W₂, H.Adj q w)    (hqz₁ : ∀ q ∈ Q₁, H.Adj q z₁)    (hqz₂ : ∀ q ∈ Q₂, H.Adj q z₂)    (hq₁ : Q₁.card = 4) (hq₂ : Q₂.card = 4)    (hw₁c : W₁.card = 4) (hw₂c : W₂.card = 4)    (hfour : ∀ T : Finset (Fin n), T.card = 4 →      (∀ a ∈ T, (H.neighborFinset a).card = 7) →      ¬ (∀ a ∈ T, ∀ b ∈ T, H.neighborFinset a = H.neighborFinset b)) :    (Q₁ = Q₂ ∧ W₁ = W₂) ∨      ((Q₁ ∩ Q₂).card = 3 ∧ (W₁ ∩ W₂).card = 3 ∧       (∀ q ∈ Q₁ ∩ Q₂, H.neighborFinset q = W₁ ∪ W₂ ∪ {z₁, z₂}) ∧       (∀ w ∈ W₁ ∩ W₂, H.neighborFinset w = Q₁ ∪ Q₂ ∪ {x, y})) := by  -- ===== basic =====  have hyNx : y ∈ H.neighborFinset x := by rw [H.mem_neighborFinset]; exact hxy  have hWsub : W₁ ∪ W₂ ⊆ (H.neighborFinset x).erase y := Finset.union_subset hw₁ hw₂  have hb6 : (W₁ ∪ W₂).card ≤ 6 := by    have h1 := Finset.card_le_card hWsub    rw [Finset.card_erase_of_mem hyNx] at h1    have h2 := hmax x    omega  have hWinter : (W₁ ∩ W₂).Nonempty := by    rw [← Finset.card_pos]    have hcard := Finset.card_inter W₁ W₂    rw [hw₁c, hw₂c] at hcard    omega  obtain ⟨w₀, hw₀mem⟩ := hWinter  rw [Finset.mem_inter] at hw₀mem  obtain ⟨hw₀₁, hw₀₂⟩ := hw₀mem  -- ===== a <= 5 =====  have ha5 : (Q₁ ∪ Q₂).card ≤ 5 := by    have hw₀erase : w₀ ∈ (H.neighborFinset x).erase y := hw₁ hw₀₁    rw [Finset.mem_erase] at hw₀erase    obtain ⟨hw₀ne_y, hw₀N⟩ := hw₀erase    have hAdjxw : H.Adj x w₀ := (H.mem_neighborFinset x w₀).mp hw₀N    have hw₀ne_x : w₀ ≠ x := by intro h; exact hAdjxw.ne h.symm    have hAdjw₀x : H.Adj w₀ x := hAdjxw.symm    have hAdjw₀y : H.Adj w₀ y := ((htwin w₀ hw₀ne_x hw₀ne_y).mp hAdjxw).symm    have hSsub : ({x, y} : Finset (Fin n)) ∪ (Q₁ ∪ Q₂) ⊆ H.neighborFinset w₀ := by      intro a ha'      rw [Finset.mem_union] at ha'      rcases ha' with ha' | ha'      · rw [Finset.mem_insert, Finset.mem_singleton] at ha'        rcases ha' with rfl | rfl        · rw [H.mem_neighborFinset]; exact hAdjw₀x        · rw [H.mem_neighborFinset]; exact hAdjw₀y      · rw [Finset.mem_union] at ha'        rcases ha' with ha' | ha'        · rw [H.mem_neighborFinset]; exact (hcross₁ a ha' w₀ hw₀₁).symm        · rw [H.mem_neighborFinset]; exact (hcross₂ a ha' w₀ hw₀₂).symm    have hxnot : x ∉ Q₁ ∪ Q₂ := by simp only [Finset.mem_union, not_or]; exact ⟨hq₁x, hq₂x⟩    have hynot : y ∉ Q₁ ∪ Q₂ := by simp only [Finset.mem_union, not_or]; exact ⟨hq₁y, hq₂y⟩    have hdisj : Disjoint ({x, y} : Finset (Fin n)) (Q₁ ∪ Q₂) := by      rw [Finset.disjoint_left]      intro a ha' haq      rw [Finset.mem_insert, Finset.mem_singleton] at ha'      rcases ha' with rfl | rfl      · exact hxnot haq      · exact hynot haq    have hSc : (({x, y} : Finset (Fin n)) ∪ (Q₁ ∪ Q₂)).card = 2 + (Q₁ ∪ Q₂).card := by      rw [Finset.card_union_of_disjoint hdisj, Finset.card_pair hxy.ne]    have hc := Finset.card_le_card hSsub    rw [hSc] at hc    have := hmax w₀    omega  -- ===== Q intersection nonempty =====  have hQinter : (Q₁ ∩ Q₂).Nonempty := by    rw [← Finset.card_pos]    have hcard := Finset.card_inter Q₁ Q₂    rw [hq₁, hq₂] at hcard    omega  obtain ⟨q₀, hq₀mem⟩ := hQinter  rw [Finset.mem_inter] at hq₀mem  obtain ⟨hq₀₁, hq₀₂⟩ := hq₀mem  -- ===== b <= 5 =====  have hb5 : (W₁ ∪ W₂).card ≤ 5 := by    have hz₁W1 : z₁ ∉ W₁ := by      intro h      have := hw₁ h      rw [Finset.mem_erase] at this      exact hxz₁ ((H.mem_neighborFinset x z₁).mp this.2)    have hz₁W2 : z₁ ∉ W₂ := by      intro h      have := hw₂ h      rw [Finset.mem_erase] at this      exact hxz₁ ((H.mem_neighborFinset x z₁).mp this.2)    have hz₂W1 : z₂ ∉ W₁ := by      intro h      have := hw₁ h      rw [Finset.mem_erase] at this      exact hxz₂ ((H.mem_neighborFinset x z₂).mp this.2)    have hz₂W2 : z₂ ∉ W₂ := by      intro h      have := hw₂ h      rw [Finset.mem_erase] at this      exact hxz₂ ((H.mem_neighborFinset x z₂).mp this.2)    have hz₁not : z₁ ∉ W₁ ∪ W₂ := by simp only [Finset.mem_union, not_or]; exact ⟨hz₁W1, hz₁W2⟩    have hz₂not : z₂ ∉ W₁ ∪ W₂ := by simp only [Finset.mem_union, not_or]; exact ⟨hz₂W1, hz₂W2⟩    have hSsub : ({z₁, z₂} : Finset (Fin n)) ∪ (W₁ ∪ W₂) ⊆ H.neighborFinset q₀ := by      intro a ha'      rw [Finset.mem_union] at ha'      rcases ha' with ha' | ha'      · rw [Finset.mem_insert, Finset.mem_singleton] at ha'        rcases ha' with rfl | rfl        · rw [H.mem_neighborFinset]; exact hqz₁ q₀ hq₀₁        · rw [H.mem_neighborFinset]; exact hqz₂ q₀ hq₀₂      · rw [Finset.mem_union] at ha'        rcases ha' with ha' | ha'        · rw [H.mem_neighborFinset]; exact hcross₁ q₀ hq₀₁ a ha'        · rw [H.mem_neighborFinset]; exact hcross₂ q₀ hq₀₂ a ha'    have hdisj : Disjoint ({z₁, z₂} : Finset (Fin n)) (W₁ ∪ W₂) := by      rw [Finset.disjoint_left]      intro a ha' haq      rw [Finset.mem_insert, Finset.mem_singleton] at ha'      rcases ha' with rfl | rfl      · exact hz₁not haq      · exact hz₂not haq    have hSc : (({z₁, z₂} : Finset (Fin n)) ∪ (W₁ ∪ W₂)).card = 2 + (W₁ ∪ W₂).card := by      rw [Finset.card_union_of_disjoint hdisj, Finset.card_pair hz]    have hc := Finset.card_le_card hSsub    rw [hSc] at hc    have := hmax q₀    omega  have ha4 : 4 ≤ (Q₁ ∪ Q₂).card := by    have := Finset.card_le_card (Finset.subset_union_left : Q₁ ⊆ Q₁ ∪ Q₂)    omega  have hb4 : 4 ≤ (W₁ ∪ W₂).card := by    have := Finset.card_le_card (Finset.subset_union_left : W₁ ⊆ W₁ ∪ W₂)    omega  have ha_cases : (Q₁ ∪ Q₂).card = 4 ∨ (Q₁ ∪ Q₂).card = 5 := by omega  have hb_cases : (W₁ ∪ W₂).card = 4 ∨ (W₁ ∪ W₂).card = 5 := by omega  rcases ha_cases with ha | ha <;> rcases hb_cases with hb | hb  · -- a = 4, b = 4    left    refine ⟨?_, ?_⟩    · have h1 : Q₁ = Q₁ ∪ Q₂ := Finset.eq_of_subset_of_card_le Finset.subset_union_left (by rw [ha, hq₁])      have h2 : Q₂ = Q₁ ∪ Q₂ := Finset.eq_of_subset_of_card_le Finset.subset_union_right (by rw [ha, hq₂])      exact h1.trans h2.symm    · have h1 : W₁ = W₁ ∪ W₂ := Finset.eq_of_subset_of_card_le Finset.subset_union_left (by rw [hb, hw₁c])      have h2 : W₂ = W₁ ∪ W₂ := Finset.eq_of_subset_of_card_le Finset.subset_union_right (by rw [hb, hw₂c])      exact h1.trans h2.symm  · -- a = 4, b = 5 : contradiction    exfalso    have hQeq : Q₁ = Q₂ := by      have h1 : Q₁ = Q₁ ∪ Q₂ := Finset.eq_of_subset_of_card_le Finset.subset_union_left (by rw [ha, hq₁])      have h2 : Q₂ = Q₁ ∪ Q₂ := Finset.eq_of_subset_of_card_le Finset.subset_union_right (by rw [ha, hq₂])      exact h1.trans h2.symm    have hz₁not : z₁ ∉ W₁ ∪ W₂ := by      rw [Finset.mem_union]; intro h; rcases h with h | h      · have := hw₁ h; rw [Finset.mem_erase] at this        exact hxz₁ ((H.mem_neighborFinset x z₁).mp this.2)      · have := hw₂ h; rw [Finset.mem_erase] at this        exact hxz₁ ((H.mem_neighborFinset x z₁).mp this.2)    have hz₂not : z₂ ∉ W₁ ∪ W₂ := by      rw [Finset.mem_union]; intro h; rcases h with h | h      · have := hw₁ h; rw [Finset.mem_erase] at this        exact hxz₂ ((H.mem_neighborFinset x z₂).mp this.2)      · have := hw₂ h; rw [Finset.mem_erase] at this        exact hxz₂ ((H.mem_neighborFinset x z₂).mp this.2)    have hdisj : Disjoint ({z₁, z₂} : Finset (Fin n)) (W₁ ∪ W₂) := by      rw [Finset.disjoint_left]      intro a ha' haq      rw [Finset.mem_insert, Finset.mem_singleton] at ha'      rcases ha' with rfl | rfl      · exact hz₁not haq      · exact hz₂not haq    have hScard' : (({z₁, z₂} : Finset (Fin n)) ∪ (W₁ ∪ W₂)).card = 7 := by      rw [Finset.card_union_of_disjoint hdisj, Finset.card_pair hz, hb]    have keyeq : ∀ q ∈ Q₁, H.neighborFinset q = ({z₁, z₂} : Finset (Fin n)) ∪ (W₁ ∪ W₂) := by      intro q hq      have hq₂' : q ∈ Q₂ := by rw [← hQeq]; exact hq      have hSsub : ({z₁, z₂} : Finset (Fin n)) ∪ (W₁ ∪ W₂) ⊆ H.neighborFinset q := by        intro a ha'        rw [Finset.mem_union] at ha'        rcases ha' with ha' | ha'        · rw [Finset.mem_insert, Finset.mem_singleton] at ha'          rcases ha' with rfl | rfl          · rw [H.mem_neighborFinset]; exact hqz₁ q hq          · rw [H.mem_neighborFinset]; exact hqz₂ q hq₂'        · rw [Finset.mem_union] at ha'          rcases ha' with ha' | ha'          · rw [H.mem_neighborFinset]; exact hcross₁ q hq a ha'          · rw [H.mem_neighborFinset]; exact hcross₂ q hq₂' a ha'      exact (Finset.eq_of_subset_of_card_le hSsub (by rw [hScard']; exact hmax q)).symm    exact hfour Q₁ hq₁ (fun a ha' => by rw [keyeq a ha', hScard'])      (fun a ha' b hb' => by rw [keyeq a ha', keyeq b hb'])  · -- a = 5, b = 4 : contradiction    exfalso    have hWeq : W₁ = W₂ := by      have h1 : W₁ = W₁ ∪ W₂ := Finset.eq_of_subset_of_card_le Finset.subset_union_left (by rw [hb, hw₁c])      have h2 : W₂ = W₁ ∪ W₂ := Finset.eq_of_subset_of_card_le Finset.subset_union_right (by rw [hb, hw₂c])      exact h1.trans h2.symm    have hxnot : x ∉ Q₁ ∪ Q₂ := by simp only [Finset.mem_union, not_or]; exact ⟨hq₁x, hq₂x⟩    have hynot : y ∉ Q₁ ∪ Q₂ := by simp only [Finset.mem_union, not_or]; exact ⟨hq₁y, hq₂y⟩    have hdisjX : Disjoint ({x, y} : Finset (Fin n)) (Q₁ ∪ Q₂) := by      rw [Finset.disjoint_left]      intro a ha' haq      rw [Finset.mem_insert, Finset.mem_singleton] at ha'      rcases ha' with rfl | rfl      · exact hxnot haq      · exact hynot haq    have hScardX : (({x, y} : Finset (Fin n)) ∪ (Q₁ ∪ Q₂)).card = 7 := by      rw [Finset.card_union_of_disjoint hdisjX, Finset.card_pair hxy.ne, ha]    have keyeq : ∀ w ∈ W₁, H.neighborFinset w = ({x, y} : Finset (Fin n)) ∪ (Q₁ ∪ Q₂) := by      intro w hw      have hw₂' : w ∈ W₂ := by rw [← hWeq]; exact hw      have hw₁erase : w ∈ (H.neighborFinset x).erase y := hw₁ hw      rw [Finset.mem_erase] at hw₁erase      obtain ⟨hwne_y, hwN⟩ := hw₁erase      have hAdjxw : H.Adj x w := (H.mem_neighborFinset x w).mp hwN      have hwne_x : w ≠ x := by intro h; exact hAdjxw.ne h.symm      have hAdjwx : H.Adj w x := hAdjxw.symm      have hAdjwy : H.Adj w y := ((htwin w hwne_x hwne_y).mp hAdjxw).symm      have hSsub : ({x, y} : Finset (Fin n)) ∪ (Q₁ ∪ Q₂) ⊆ H.neighborFinset w := by        intro a ha'        rw [Finset.mem_union] at ha'        rcases ha' with ha' | ha'        · rw [Finset.mem_insert, Finset.mem_singleton] at ha'          rcases ha' with rfl | rfl          · rw [H.mem_neighborFinset]; exact hAdjwx          · rw [H.mem_neighborFinset]; exact hAdjwy        · rw [Finset.mem_union] at ha'          rcases ha' with ha' | ha'          · rw [H.mem_neighborFinset]; exact (hcross₁ a ha' w hw).symm          · rw [H.mem_neighborFinset]; exact (hcross₂ a ha' w hw₂').symm      exact (Finset.eq_of_subset_of_card_le hSsub (by rw [hScardX]; exact hmax w)).symm    exact hfour W₁ hw₁c (fun a ha' => by rw [keyeq a ha', hScardX])      (fun a ha' b hb' => by rw [keyeq a ha', keyeq b hb'])  · -- a = 5, b = 5 : conclusion    right    have hz₁not : z₁ ∉ W₁ ∪ W₂ := by      rw [Finset.mem_union]; intro h; rcases h with h | h      · have := hw₁ h; rw [Finset.mem_erase] at this        exact hxz₁ ((H.mem_neighborFinset x z₁).mp this.2)      · have := hw₂ h; rw [Finset.mem_erase] at this        exact hxz₁ ((H.mem_neighborFinset x z₁).mp this.2)    have hz₂not : z₂ ∉ W₁ ∪ W₂ := by      rw [Finset.mem_union]; intro h; rcases h with h | h      · have := hw₁ h; rw [Finset.mem_erase] at this        exact hxz₂ ((H.mem_neighborFinset x z₂).mp this.2)      · have := hw₂ h; rw [Finset.mem_erase] at this        exact hxz₂ ((H.mem_neighborFinset x z₂).mp this.2)    have hdisjZ : Disjoint ({z₁, z₂} : Finset (Fin n)) (W₁ ∪ W₂) := by      rw [Finset.disjoint_left]      intro a ha' haq      rw [Finset.mem_insert, Finset.mem_singleton] at ha'      rcases ha' with rfl | rfl      · exact hz₁not haq      · exact hz₂not haq    have hScardW : (({z₁, z₂} : Finset (Fin n)) ∪ (W₁ ∪ W₂)).card = 7 := by      rw [Finset.card_union_of_disjoint hdisjZ, Finset.card_pair hz, hb]    have hQcard3 : (Q₁ ∩ Q₂).card = 3 := by      have h := Finset.card_inter Q₁ Q₂      rw [hq₁, hq₂, ha] at h; omega    have hWcard3 : (W₁ ∩ W₂).card = 3 := by      have h := Finset.card_inter W₁ W₂      rw [hw₁c, hw₂c, hb] at h; omega    have hNq : ∀ q ∈ Q₁ ∩ Q₂, H.neighborFinset q = W₁ ∪ W₂ ∪ {z₁, z₂} := by      intro q hq'      rw [Finset.mem_inter] at hq'      obtain ⟨hq₁', hq₂'⟩ := hq'      have hSsub : ({z₁, z₂} : Finset (Fin n)) ∪ (W₁ ∪ W₂) ⊆ H.neighborFinset q := by        intro a ha'        rw [Finset.mem_union] at ha'        rcases ha' with ha' | ha'        · rw [Finset.mem_insert, Finset.mem_singleton] at ha'          rcases ha' with rfl | rfl          · rw [H.mem_neighborFinset]; exact hqz₁ q hq₁'          · rw [H.mem_neighborFinset]; exact hqz₂ q hq₂'        · rw [Finset.mem_union] at ha'          rcases ha' with ha' | ha'          · rw [H.mem_neighborFinset]; exact hcross₁ q hq₁' a ha'          · rw [H.mem_neighborFinset]; exact hcross₂ q hq₂' a ha'      have heq : ({z₁, z₂} : Finset (Fin n)) ∪ (W₁ ∪ W₂) = H.neighborFinset q :=        Finset.eq_of_subset_of_card_le hSsub (by rw [hScardW]; exact hmax q)      rw [← heq, Finset.union_comm]    have hxnot : x ∉ Q₁ ∪ Q₂ := by simp only [Finset.mem_union, not_or]; exact ⟨hq₁x, hq₂x⟩    have hynot : y ∉ Q₁ ∪ Q₂ := by simp only [Finset.mem_union, not_or]; exact ⟨hq₁y, hq₂y⟩    have hNw : ∀ w ∈ W₁ ∩ W₂, H.neighborFinset w = Q₁ ∪ Q₂ ∪ {x, y} := by      intro w hw'      rw [Finset.mem_inter] at hw'      obtain ⟨hw₁', hw₂'⟩ := hw'      have hw₁erase : w ∈ (H.neighborFinset x).erase y := hw₁ hw₁'      rw [Finset.mem_erase] at hw₁erase      obtain ⟨hwne_y, hwN⟩ := hw₁erase      have hAdjxw : H.Adj x w := (H.mem_neighborFinset x w).mp hwN      have hwne_x : w ≠ x := by intro h; exact hAdjxw.ne h.symm      have hAdjwx : H.Adj w x := hAdjxw.symm      have hAdjwy : H.Adj w y := ((htwin w hwne_x hwne_y).mp hAdjxw).symm      have hSsub : ({x, y} : Finset (Fin n)) ∪ (Q₁ ∪ Q₂) ⊆ H.neighborFinset w := by        intro a ha'        rw [Finset.mem_union] at ha'        rcases ha' with ha' | ha'        · rw [Finset.mem_insert, Finset.mem_singleton] at ha'          rcases ha' with rfl | rfl          · rw [H.mem_neighborFinset]; exact hAdjwx          · rw [H.mem_neighborFinset]; exact hAdjwy        · rw [Finset.mem_union] at ha'          rcases ha' with ha' | ha'          · rw [H.mem_neighborFinset]; exact (hcross₁ a ha' w hw₁').symm          · rw [H.mem_neighborFinset]; exact (hcross₂ a ha' w hw₂').symm      have hdisjX : Disjoint ({x, y} : Finset (Fin n)) (Q₁ ∪ Q₂) := by        rw [Finset.disjoint_left]        intro a ha' haq        rw [Finset.mem_insert, Finset.mem_singleton] at ha'        rcases ha' with rfl | rfl        · exact hxnot haq        · exact hynot haq      have hScardX : (({x, y} : Finset (Fin n)) ∪ (Q₁ ∪ Q₂)).card = 7 := by        rw [Finset.card_union_of_disjoint hdisjX, Finset.card_pair hxy.ne, ha]      have heq : ({x, y} : Finset (Fin n)) ∪ (Q₁ ∪ Q₂) = H.neighborFinset w :=        Finset.eq_of_subset_of_card_le hSsub (by rw [hScardX]; exact hmax w)      rw [← heq, Finset.union_comm]    exact ⟨hQcard3, hWcard3, hNq, hNw⟩
See it in the graphDiscuss this resultChallenge it