AFTD Auto-Formalizing Theoretical Domains

five_by_five_sparse_defects_have_good_pair

theoremverified

For a relation between two five-element sets, if every row and column has one or two related entries and no related pair has both row and column degree two, there is an unrelated pair whose row and column degrees are both one.

Statement

theorem five_by_five_sparse_defects_have_good_pair
    {V : Type*} [DecidableEq V] (A C : Finset V) (R : V → V → Prop) [DecidableRel R]
    (hA : A.card=5) (hC : C.card=5)
    (hrow : ∀ a ∈ A, 1 ≤ (C.filter (R a)).card ∧ (C.filter (R a)).card ≤ 2)
    (hcol : ∀ c ∈ C, 1 ≤ (A.filter (fun a => R a c)).card ∧
      (A.filter (fun a => R a c)).card ≤ 2)
    (hno22 : ∀ a ∈ A, ∀ c ∈ C, R a c →
      (C.filter (R a)).card = 2 → (A.filter (fun v => R v c)).card ≠ 2) :
    ∃ a ∈ A, ∃ c ∈ C, ¬ R a c ∧ (C.filter (R a)).card = 1 ∧
      (A.filter (fun v => R v c)).card = 1
Source
OP-1957: finite incidence assembly for the clique-block degree route.
Verified
24 Nov 2026
Axioms
Classical.choiceQuot.soundpropext
Used by 1

The proof, explained

The proof double counts the edges incident to degree-2 rows. Because no edge connects two vertices of degree 2, every neighbor of a degree-2 row is a degree-1 column, implying 2 * |D2A| ≤ |D1C| and symmetrically 2 * |D2C| ≤ |D1A|. Since each 5-element set partitions into vertices of degree 1 and 2, this forces at most two vertices of degree 2 in each set, so there are at least three rows of degree 1. Choosing a degree-1 row leaves 4 unrelated columns, which cannot all have degree 2; any remaining column of degree 1 forms the desired unrelated pair.

  1. The number of pairs in a Cartesian product s × t satisfying a relation r equals the sum over a ∈ s of the number of elements in t related to a.

    Rewriting the filtered product using Finset.card_filter represents the cardinality as a sum of 0-1 indicators, and Finset.sum_product converts this into an iterated sum over s and t. Applying Finset.sum_congr with Finset.card_filter then identifies the inner sum over t as the cardinality of the fiber {b ∈ t | r a b}.

    lines 5–8

    uses Finset.card_filter, Finset.sum_product, Finset.sum_congr

      rw [Finset.card_filter, Finset.sum_product]
      apply Finset.sum_congr rfl
      intro a ha
      rw [Finset.card_filter]
  2. For any edge (a, c) with row a having degree 2, the column c must have degree 1.

    Let D2A be the rows of degree 2 and P the set of pairs (a, c) ∈ D2A × C satisfying R a c. For any such pair, the row degree of a is 2, so the hypothesis hno22 prohibits the column degree of c from being 2. Since column degrees are bounded between 1 and 2 by hcol, the degree of c must be 1, placing c in D1C.

    lines 18–30

    uses Finset.mem_filter.mp, Finset.mem_product.mp, Finset.filter_subset, Finset.mem_filter.mpr

      classical
      let D2A := A.filter (fun a => (C.filter (R a)).card = 2)
      let D1C := C.filter (fun c => (A.filter (fun v => R v c)).card = 1)
      let P := (D2A ×ˢ C).filter (fun p : V × V => R p.1 p.2)
      have memC : ∀ p ∈ P, p.2 ∈ D1C := by
        intro p hp
        obtain ⟨hpprod, hpR⟩ := Finset.mem_filter.mp hp
        obtain ⟨hp1, hp2⟩ := Finset.mem_product.mp hpprod
        have hp1A : p.1 ∈ A := Finset.filter_subset _ _ hp1
        have hp1d : (C.filter (R p.1)).card = 2 := (Finset.mem_filter.mp hp1).2
        have hcolp := hcol p.2 hp2
        have hne := hno22 p.1 hp1A p.2 hp2 hpR hp1d
        exact Finset.mem_filter.mpr ⟨hp2, by omega⟩
  3. The number of edges originating from degree-2 rows is 2 * |D2A|.

    By five_by_five_sparse_defects_have_good_pair_card_prod_filter, |P| equals the sum over a ∈ D2A of the row degree of a in C. Since every a ∈ D2A has degree 2 by definition, this is a sum of constant terms 2, which evaluates by Finset.sum_const and Nat.nsmul_eq_mul to 2 * |D2A|.

    lines 31–40

    uses five_by_five_sparse_defects_have_good_pair_card_prod_filter, Finset.sum_congr, Finset.mem_filter.mp, Finset.sum_const, Nat.nsmul_eq_mul

      have hPcard : P.card = 2 * D2A.card := by
        have hprod : P.card = ∑ a ∈ D2A, (C.filter (R a)).card :=
          five_by_five_sparse_defects_have_good_pair_card_prod_filter D2A C R
        rw [hprod]
        have hconst : ∑ a ∈ D2A, (C.filter (R a)).card = ∑ a ∈ D2A, 2 := by
          apply Finset.sum_congr rfl
          intro a ha
          exact (Finset.mem_filter.mp ha).2
        rw [hconst, Finset.sum_const, Nat.nsmul_eq_mul]
        omega
  4. The number of edges originating from degree-2 rows is at most the number of degree-1 columns: |P| ≤ |D1C|.

    The second projection map (a, c) ↦ c maps P injectively into D1C, whence |P| ≤ |D1C| by Finset.card_le_card_of_injOn. Target membership in D1C was proven in memC. For injectivity, if two pairs p, q ∈ P have the same second component p.2 = q.2 = c, then both p.1 and q.1 belong to {v ∈ A | R v c}. Since c ∈ D1C, this fiber has cardinality 1, so p.1 = q.1 by Finset.card_le_one.mp, and thus p = q by Prod.ext.

    lines 41–58

    uses Finset.card_le_card_of_injOn, Finset.mem_filter.mp, Finset.mem_product.mp, Finset.filter_subset, Finset.mem_filter.mpr, Finset.card_le_one.mp, Prod.ext

      have hbound : P.card ≤ D1C.card := by
        apply Finset.card_le_card_of_injOn (fun p : V × V => p.2)
        · intro p hp
          exact memC p hp
        · intro p hp q hq hpq
          have hpc := memC p hp
          have hp1d : (A.filter (fun v => R v p.2)).card = 1 := (Finset.mem_filter.mp hpc).2
          obtain ⟨hpprod, hpR⟩ := Finset.mem_filter.mp hp
          have hpq2 : p.2 = q.2 := hpq
          obtain ⟨hqprod, hqR⟩ := Finset.mem_filter.mp hq
          have hp1A : p.1 ∈ A := Finset.filter_subset _ _ (Finset.mem_product.mp hpprod).1
          have hq1A : q.1 ∈ A := Finset.filter_subset _ _ (Finset.mem_product.mp hqprod).1
          have hmem1 : p.1 ∈ A.filter (fun v => R v p.2) := Finset.mem_filter.mpr ⟨hp1A, hpR⟩
          have hmem2 : q.1 ∈ A.filter (fun v => R v p.2) := by
            rw [← hpq2] at hqR
            exact Finset.mem_filter.mpr ⟨hq1A, hqR⟩
          have heq1 : p.1 = q.1 := Finset.card_le_one.mp (by omega) p.1 hmem1 q.1 hmem2
          exact Prod.ext heq1 hpq2
  5. Twice the number of degree-2 rows is at most the number of degree-1 columns: 2 * |D2A| ≤ |D1C|.

    Chaining 2 * |D2A| = |P| and |P| ≤ |D1C| in a calculation directly establishes the inequality.

    lines 59–63

      calc 2 * (A.filter (fun a => (C.filter (R a)).card = 2)).card
          = 2 * D2A.card := by rfl
        _ = P.card := hPcard.symm
        _ ≤ D1C.card := hbound
        _ = (C.filter (fun c => (A.filter (fun v => R v c)).card = 1)).card := by rfl
  6. The bounds 2 * |D2A| ≤ |D1C| and 2 * |D2C| ≤ |D1A| both hold.

    Applying the helper lemma five_by_five_sparse_defects_have_good_pair_rows_le_cols to R gives 2 * |D2A| ≤ |D1C|. Symmetrically, after checking that the condition prohibiting edges between degree-2 vertices is symmetric (hno'), applying the helper lemma to the transpose relation yields 2 * |D2C| ≤ |D1A|.

    lines 75–87

    uses five_by_five_sparse_defects_have_good_pair_rows_le_cols

      classical
      let D2A := A.filter (fun a => (C.filter (R a)).card = 2)
      let D1A := A.filter (fun a => (C.filter (R a)).card = 1)
      let D2C := C.filter (fun c => (A.filter (fun v => R v c)).card = 2)
      let D1C := C.filter (fun c => (A.filter (fun v => R v c)).card = 1)
      have h1 : 2 * D2A.card ≤ D1C.card :=
        five_by_five_sparse_defects_have_good_pair_rows_le_cols A C R hcol hno22
      have hno' : ∀ c ∈ C, ∀ a ∈ A, R a c → (A.filter (fun v => R v c)).card = 2 →
          (C.filter (fun v => R a v)).card ≠ 2 := by
        intro c hc a ha hR hcd hrd
        exact hno22 a ha c hc hR hrd hcd
      have h2 : 2 * D2C.card ≤ D1A.card :=
        five_by_five_sparse_defects_have_good_pair_rows_le_cols C A (fun c a => R a c) hrow hno'
  7. The rows partition into degree-2 and degree-1 vertices (|D2A| + |D1A| = |A|), and the columns partition similarly (|D2C| + |D1C| = |C|).

    By Finset.card_filter_add_card_filter_not, |A| is the sum of the number of rows with degree 2 and those with degree not equal to 2. Since all row degrees lie in {1, 2} by hrow, not having degree 2 is equivalent to having degree 1, so the non-degree-2 rows are precisely D1A. An identical argument applies to C using the column degree bounds hcol.

    lines 88–113

    uses Finset.card_filter_add_card_filter_not, Finset.mem_filter

      have hpartA : D2A.card + D1A.card = A.card := by
        have key := Finset.card_filter_add_card_filter_not (s := A) (p := fun a : V => (C.filter (R a)).card = 2)
        have heq : A.filter (fun a => ¬ (C.filter (R a)).card = 2) = D1A := by
          ext a
          simp only [D1A, Finset.mem_filter]
          constructor
          · rintro ⟨ha, hne⟩
            have := hrow a ha
            exact ⟨ha, by omega⟩
          · rintro ⟨ha, h1⟩
            exact ⟨ha, by omega⟩
        rw [heq] at key
        simpa [D2A] using key
      have hpartC : D2C.card + D1C.card = C.card := by
        have key := Finset.card_filter_add_card_filter_not (s := C) (p := fun c : V => (A.filter (fun a => R a c)).card = 2)
        have heq : C.filter (fun c => ¬ (A.filter (fun a => R a c)).card = 2) = D1C := by
          ext c
          simp only [D1C, Finset.mem_filter]
          constructor
          · rintro ⟨hc, hne⟩
            have := hcol c hc
            exact ⟨hc, by omega⟩
          · rintro ⟨hc, h1⟩
            exact ⟨hc, by omega⟩
        rw [heq] at key
        simpa [D2C] using key
  8. There are at most two rows of degree 2 and at most two columns of degree 2: |D2A| ≤ 2 and |D2C| ≤ 2.

    Since D1C ⊆ C and |C| = 5 (via Finset.card_le_card and Finset.filter_subset), the inequality 2 * |D2A| ≤ |D1C| implies 2 * |D2A| ≤ 5, forcing |D2A| ≤ 2. Symmetrically, 2 * |D2C| ≤ |D1A| ≤ |A| = 5 forces |D2C| ≤ 2.

    lines 114–121

    uses Finset.card_le_card, Finset.filter_subset

      have hD1Cle : D1C.card ≤ C.card := Finset.card_le_card (Finset.filter_subset _ _)
      have hD1Ale : D1A.card ≤ A.card := Finset.card_le_card (Finset.filter_subset _ _)
      have ht : D2A.card ≤ 2 := by
        rw [hC] at hD1Cle
        omega
      have hs : D2C.card ≤ 2 := by
        rw [hA] at hD1Ale
        omega
  9. The set D1A of degree-1 rows is nonempty, so there exists a row a ∈ A with degree 1.

    From |D2A| + |D1A| = 5 and |D2A| ≤ 2, we have |D1A| ≥ 3 > 0. By Finset.card_pos.mp, D1A is nonempty, allowing us to choose a witness a ∈ D1A, which has row degree 1.

    lines 122–129

    uses Finset.card_pos.mp, Finset.mem_filter.mp

      have hD1A_nonempty : D1A.Nonempty := by
        have hpos : 0 < D1A.card := by
          rw [hA] at hpartA
          omega
        exact Finset.card_pos.mp hpos
      obtain ⟨a, haD1A⟩ := hD1A_nonempty
      have haA : a ∈ A := (Finset.mem_filter.mp haD1A).1
      have hrd_a : (C.filter (R a)).card = 1 := (Finset.mem_filter.mp haD1A).2
  10. The set U of columns unrelated to a contains 4 elements and cannot be a subset of D2C.

    Let U = C \\ {c ∈ C | R a c}. Because |C| = 5 and the row degree of a is 1, Finset.card_sdiff_add_card_eq_card gives |U| = 5 - 1 = 4. If U ⊆ D2C held, Finset.card_le_card would imply 4 = |U| ≤ |D2C|, contradicting |D2C| ≤ 2. Thus U is not a subset of D2C.

    lines 130–142

    uses Finset.filter_subset, Finset.card_sdiff_add_card_eq_card, Finset.card_le_card

      let U := C \ C.filter (R a)
      have hUcard : U.card = 4 := by
        show (C \ C.filter (R a)).card = 4
        have hsub : C.filter (R a) ⊆ C := Finset.filter_subset _ _
        have hcd := Finset.card_sdiff_add_card_eq_card hsub
        rw [hC, hrd_a] at hcd
        omega
      have hnotsub : ¬ U ⊆ D2C := by
        intro hsub
        have hle := Finset.card_le_card hsub
        rw [hUcard] at hle
        omega
      obtain ⟨c, hcU, hcD2C⟩ := Finset.not_subset.mp hnotsub
  11. There exists a column c ∈ C such that ¬ R a c and the column degree of c is 1, completing the proof.

    Because U is not a subset of D2C, Finset.not_subset.mp yields a column c ∈ U with c ∉ D2C. By definition of U, c ∈ C and ¬ R a c. Since c ∉ D2C, its column degree cannot be 2, and since column degrees are restricted to {1, 2}, it must be 1. Thus (a, c) is an unrelated pair with both row and column degree equal to 1.

    lines 143–153

    uses Finset.not_subset.mp, Finset.mem_sdiff.mp, Finset.mem_filter.mpr

      obtain ⟨hcC, hcnot⟩ := Finset.mem_sdiff.mp hcU
      have hncR : ¬ R a c := by
        intro hR
        exact hcnot (Finset.mem_filter.mpr ⟨hcC, hR⟩)
      have hcd_c : (A.filter (fun v => R v c)).card = 1 := by
        have hne : (A.filter (fun v => R v c)).card ≠ 2 := by
          intro h2eq
          exact hcD2C (Finset.mem_filter.mpr ⟨hcC, h2eq⟩)
        have := hcol c hcC
        omega
      exact ⟨a, haA, c, hcC, hncR, hrd_a, hcd_c⟩
Finset.card_filter
The cardinality of a filtered finset equals the sum over the finset of the indicator function of the predicate.
Finset.sum_product
A sum over a Cartesian product of two finite sets equals the iterated sum over each set.
Finset.sum_congr
Two sums are equal if their index sets are equal and their summands agree on every element.
Finset.mem_filter.mp
If an element belongs to a filtered set, then it belongs to the base set and satisfies the predicate.
Finset.mem_product.mp
If a pair belongs to a Cartesian product, its first element is in the first set and its second element is in the second set.
Finset.filter_subset
A filtered finset is a subset of the original finset.
Finset.mem_filter.mpr
An element of a finset that satisfies a predicate belongs to the filtered finset.
five_by_five_sparse_defects_have_good_pair_card_prod_filter
The number of pairs in a product of two finsets satisfying a relation equals the sum of the neighborhood sizes over the first set.
Finset.sum_const
The sum of a constant value over a finite set equals the cardinality of the set multiplied by the constant.
Nat.nsmul_eq_mul
Scalar multiplication of a natural number by a natural number equals ordinary multiplication.
Finset.card_le_card_of_injOn
If a map between finite sets sends elements of s to t and is injective on s, then |s| ≤ |t|.
Finset.card_le_one.mp
In a finite set with cardinality at most 1, any two elements are equal.
Prod.ext
Two ordered pairs are equal if their corresponding components are equal.
five_by_five_sparse_defects_have_good_pair_rows_le_cols
Under the degree bounds and the condition prohibiting degree-2 neighbors, twice the number of degree-2 rows is at most the number of degree-1 columns.
Finset.card_filter_add_card_filter_not
The cardinality of a finite set is the sum of the number of elements satisfying a predicate and the number satisfying its negation.
Finset.mem_filter
An element is in a filtered set if and only if it belongs to the base set and satisfies the predicate.
Finset.card_le_card
If one finite set is a subset of another, its cardinality is less than or equal to the other's.
Finset.card_pos.mp
A finite set with strictly positive cardinality is nonempty.
Finset.card_sdiff_add_card_eq_card
For a subset s of t, the cardinality of the set difference t \\ s plus |s| equals |t|.
Finset.not_subset.mp
If a set is not a subset of another, there is an element in the first that is not in the second.
Finset.mem_sdiff.mp
An element in the set difference s \\ t belongs to s and does not belong to t.

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

private lemma five_by_five_sparse_defects_have_good_pair_card_prod_filter    {α β : Type*} [DecidableEq α] [DecidableEq β]    (s : Finset α) (t : Finset β) (r : α → β → Prop) [DecidableRel r] :    ((s ×ˢ t).filter (fun p => r p.1 p.2)).card = ∑ a ∈ s, (t.filter (r a)).card := by  rw [Finset.card_filter, Finset.sum_product]  apply Finset.sum_congr rfl  intro a ha  rw [Finset.card_filter]private lemma five_by_five_sparse_defects_have_good_pair_rows_le_cols    {V : Type*} [DecidableEq V] (A C : Finset V) (R : V → V → Prop) [DecidableRel R]    (hcol : ∀ c ∈ C, 1 ≤ (A.filter (fun a => R a c)).card ∧      (A.filter (fun a => R a c)).card ≤ 2)    (hno22 : ∀ a ∈ A, ∀ c ∈ C, R a c →      (C.filter (R a)).card = 2 → (A.filter (fun v => R v c)).card ≠ 2) :    2 * (A.filter (fun a => (C.filter (R a)).card = 2)).card ≤      (C.filter (fun c => (A.filter (fun v => R v c)).card = 1)).card := by  classical  let D2A := A.filter (fun a => (C.filter (R a)).card = 2)  let D1C := C.filter (fun c => (A.filter (fun v => R v c)).card = 1)  let P := (D2A ×ˢ C).filter (fun p : V × V => R p.1 p.2)  have memC : ∀ p ∈ P, p.2 ∈ D1C := by    intro p hp    obtain ⟨hpprod, hpR⟩ := Finset.mem_filter.mp hp    obtain ⟨hp1, hp2⟩ := Finset.mem_product.mp hpprod    have hp1A : p.1 ∈ A := Finset.filter_subset _ _ hp1    have hp1d : (C.filter (R p.1)).card = 2 := (Finset.mem_filter.mp hp1).2    have hcolp := hcol p.2 hp2    have hne := hno22 p.1 hp1A p.2 hp2 hpR hp1d    exact Finset.mem_filter.mpr ⟨hp2, by omega⟩  have hPcard : P.card = 2 * D2A.card := by    have hprod : P.card = ∑ a ∈ D2A, (C.filter (R a)).card :=      five_by_five_sparse_defects_have_good_pair_card_prod_filter D2A C R    rw [hprod]    have hconst : ∑ a ∈ D2A, (C.filter (R a)).card = ∑ a ∈ D2A, 2 := by      apply Finset.sum_congr rfl      intro a ha      exact (Finset.mem_filter.mp ha).2    rw [hconst, Finset.sum_const, Nat.nsmul_eq_mul]    omega  have hbound : P.card ≤ D1C.card := by    apply Finset.card_le_card_of_injOn (fun p : V × V => p.2)    · intro p hp      exact memC p hp    · intro p hp q hq hpq      have hpc := memC p hp      have hp1d : (A.filter (fun v => R v p.2)).card = 1 := (Finset.mem_filter.mp hpc).2      obtain ⟨hpprod, hpR⟩ := Finset.mem_filter.mp hp      have hpq2 : p.2 = q.2 := hpq      obtain ⟨hqprod, hqR⟩ := Finset.mem_filter.mp hq      have hp1A : p.1 ∈ A := Finset.filter_subset _ _ (Finset.mem_product.mp hpprod).1      have hq1A : q.1 ∈ A := Finset.filter_subset _ _ (Finset.mem_product.mp hqprod).1      have hmem1 : p.1 ∈ A.filter (fun v => R v p.2) := Finset.mem_filter.mpr ⟨hp1A, hpR⟩      have hmem2 : q.1 ∈ A.filter (fun v => R v p.2) := by        rw [← hpq2] at hqR        exact Finset.mem_filter.mpr ⟨hq1A, hqR⟩      have heq1 : p.1 = q.1 := Finset.card_le_one.mp (by omega) p.1 hmem1 q.1 hmem2      exact Prod.ext heq1 hpq2  calc 2 * (A.filter (fun a => (C.filter (R a)).card = 2)).card      = 2 * D2A.card := by rfl    _ = P.card := hPcard.symm    _ ≤ D1C.card := hbound    _ = (C.filter (fun c => (A.filter (fun v => R v c)).card = 1)).card := by rfltheorem five_by_five_sparse_defects_have_good_pair    {V : Type*} [DecidableEq V] (A C : Finset V) (R : V → V → Prop) [DecidableRel R]    (hA : A.card=5) (hC : C.card=5)    (hrow : ∀ a ∈ A, 1 ≤ (C.filter (R a)).card ∧ (C.filter (R a)).card ≤ 2)    (hcol : ∀ c ∈ C, 1 ≤ (A.filter (fun a => R a c)).card ∧      (A.filter (fun a => R a c)).card ≤ 2)    (hno22 : ∀ a ∈ A, ∀ c ∈ C, R a c →      (C.filter (R a)).card = 2 → (A.filter (fun v => R v c)).card ≠ 2) :    ∃ a ∈ A, ∃ c ∈ C, ¬ R a c ∧ (C.filter (R a)).card = 1 ∧      (A.filter (fun v => R v c)).card = 1 := by  classical  let D2A := A.filter (fun a => (C.filter (R a)).card = 2)  let D1A := A.filter (fun a => (C.filter (R a)).card = 1)  let D2C := C.filter (fun c => (A.filter (fun v => R v c)).card = 2)  let D1C := C.filter (fun c => (A.filter (fun v => R v c)).card = 1)  have h1 : 2 * D2A.card ≤ D1C.card :=    five_by_five_sparse_defects_have_good_pair_rows_le_cols A C R hcol hno22  have hno' : ∀ c ∈ C, ∀ a ∈ A, R a c → (A.filter (fun v => R v c)).card = 2 →      (C.filter (fun v => R a v)).card ≠ 2 := by    intro c hc a ha hR hcd hrd    exact hno22 a ha c hc hR hrd hcd  have h2 : 2 * D2C.card ≤ D1A.card :=    five_by_five_sparse_defects_have_good_pair_rows_le_cols C A (fun c a => R a c) hrow hno'  have hpartA : D2A.card + D1A.card = A.card := by    have key := Finset.card_filter_add_card_filter_not (s := A) (p := fun a : V => (C.filter (R a)).card = 2)    have heq : A.filter (fun a => ¬ (C.filter (R a)).card = 2) = D1A := by      ext a      simp only [D1A, Finset.mem_filter]      constructor      · rintro ⟨ha, hne⟩        have := hrow a ha        exact ⟨ha, by omega⟩      · rintro ⟨ha, h1⟩        exact ⟨ha, by omega⟩    rw [heq] at key    simpa [D2A] using key  have hpartC : D2C.card + D1C.card = C.card := by    have key := Finset.card_filter_add_card_filter_not (s := C) (p := fun c : V => (A.filter (fun a => R a c)).card = 2)    have heq : C.filter (fun c => ¬ (A.filter (fun a => R a c)).card = 2) = D1C := by      ext c      simp only [D1C, Finset.mem_filter]      constructor      · rintro ⟨hc, hne⟩        have := hcol c hc        exact ⟨hc, by omega⟩      · rintro ⟨hc, h1⟩        exact ⟨hc, by omega⟩    rw [heq] at key    simpa [D2C] using key  have hD1Cle : D1C.card ≤ C.card := Finset.card_le_card (Finset.filter_subset _ _)  have hD1Ale : D1A.card ≤ A.card := Finset.card_le_card (Finset.filter_subset _ _)  have ht : D2A.card ≤ 2 := by    rw [hC] at hD1Cle    omega  have hs : D2C.card ≤ 2 := by    rw [hA] at hD1Ale    omega  have hD1A_nonempty : D1A.Nonempty := by    have hpos : 0 < D1A.card := by      rw [hA] at hpartA      omega    exact Finset.card_pos.mp hpos  obtain ⟨a, haD1A⟩ := hD1A_nonempty  have haA : a ∈ A := (Finset.mem_filter.mp haD1A).1  have hrd_a : (C.filter (R a)).card = 1 := (Finset.mem_filter.mp haD1A).2  let U := C \ C.filter (R a)  have hUcard : U.card = 4 := by    show (C \ C.filter (R a)).card = 4    have hsub : C.filter (R a) ⊆ C := Finset.filter_subset _ _    have hcd := Finset.card_sdiff_add_card_eq_card hsub    rw [hC, hrd_a] at hcd    omega  have hnotsub : ¬ U ⊆ D2C := by    intro hsub    have hle := Finset.card_le_card hsub    rw [hUcard] at hle    omega  obtain ⟨c, hcU, hcD2C⟩ := Finset.not_subset.mp hnotsub  obtain ⟨hcC, hcnot⟩ := Finset.mem_sdiff.mp hcU  have hncR : ¬ R a c := by    intro hR    exact hcnot (Finset.mem_filter.mpr ⟨hcC, hR⟩)  have hcd_c : (A.filter (fun v => R v c)).card = 1 := by    have hne : (A.filter (fun v => R v c)).card ≠ 2 := by      intro h2eq      exact hcD2C (Finset.mem_filter.mpr ⟨hcC, h2eq⟩)    have := hcol c hcC    omega  exact ⟨a, haA, c, hcC, hncR, hrd_a, hcd_c⟩
See it in the graphDiscuss this resultChallenge it