op861_middle_levels_strong_tail_exists
At the neighboring uniformity m=q+1, a single-tail hypergraph with strong q-domination exists on 2q+1 points.
Statement
theorem op861_middle_levels_strong_tail_exists (q : ℕ) (hq : 1 ≤ q) :
∃ tail : Finset (Fin (2*q+1)) → Fin (2*q+1),
(∀ E : Finset (Fin (2*q+1)), E.card = q+1 → tail E ∈ E) ∧
(∀ R : Finset (Fin (2*q+1)), R.card = q → ∃ v, v ∉ R ∧ tail (insert v R) = v)- Source
- Perfect matching between the equal middle layers of the Boolean lattice; the five-point case was checked in experiment 30755.
- Verified
- 19 Nov 2026
- Axioms
Classical.choiceQuot.soundpropext
The proof, explained
The proof constructs a bijection between the family Y of (q+1)-subsets and the family X of q-subsets of a (2q+1)-element ground set such that each (q+1)-set contains its matched q-set. This matching is found using Hall's Marriage Theorem on the bipartite inclusion graph between Y and X, where Hall's condition is verified by double-counting edges: every vertex in Y has degree q+1 and every vertex in X has degree at most q+1. Because |Y| = |X|, the resulting injection is a bijection, and defining tail(E) as the unique element in E \ f(E) satisfies the strong q-domination property by the surjectivity of f.
Let X and Y be the collections of all q-element and (q+1)-element subsets of {0, ..., 2q}.
We introduce classical logic and define X = powersetCard q (univ) and Y = powersetCard (q+1) (univ). We record the equivalences that R ∈ X if and only if |R| = q, and E ∈ Y if and only if |E| = q + 1.
classical set X : Finset (Finset (Fin (2*q+1))) := Finset.univ.powersetCard q with hX set Y : Finset (Finset (Fin (2*q+1))) := Finset.univ.powersetCard (q+1) with hY have memX : ∀ R : Finset (Fin (2*q+1)), R ∈ X ↔ R.card = q := by intro R; simp [hX] have memY : ∀ E : Finset (Fin (2*q+1)), E ∈ Y ↔ E.card = q+1 := by intro E; simp [hY]
For any finite set T and predicate p, the cardinality of the subtype elements of T satisfying p equals the cardinality of the filtered set T.filter p.
The subtype inclusion map is injective, and its image on the subtype elements satisfying p is precisely T.filter p. By injectivity, the image has the same cardinality as the domain.
uses
Finset.mem_image,Finset.mem_filter,Finset.mem_univ,true_and,Finset.card_image_of_injective,Subtype.val_injectivehave card_sub_filter : ∀ (T : Finset (Finset (Fin (2*q+1)))) (p : Finset (Fin (2*q+1)) → Prop) [DecidablePred p], (Finset.univ.filter (fun R : ↥T => p (R : Finset (Fin (2*q+1))))).card = (T.filter p).card := by intro T p _ have himg : (Finset.univ.filter (fun R : ↥T => p (R : Finset (Fin (2*q+1))))).image (Subtype.val) = T.filter p := by ext R simp only [Finset.mem_image, Finset.mem_filter, Finset.mem_univ, true_and] constructor · rintro ⟨S, hS, rfl⟩ exact ⟨S.2, hS⟩ · rintro ⟨hT, hp⟩ exact ⟨⟨R, hT⟩, hp, rfl⟩ rw [← himg, Finset.card_image_of_injective _ Subtype.val_injective]
Every (q+1)-element subset E ∈ Y contains exactly q+1 subsets of size q.
The q-element subsets of E are precisely the elements of powersetCard q E. There are (|E| choose q) = (q+1 choose q) = q+1 such subsets.
uses
Finset.mem_filter,Finset.mem_powersetCard,Finset.card_powersetCard,Nat.choose_succ_self_righthave hUp : ∀ E : ↥Y, (Finset.univ.filter (fun R : ↥X => (R : Finset (Fin (2*q+1))) ⊆ (E : Finset (Fin (2*q+1))))).card = q+1 := by intro E rw [card_sub_filter X (fun R => R ⊆ (E : Finset (Fin (2*q+1))))] have hEq : X.filter (fun R : Finset (Fin (2*q+1)) => R ⊆ (E : Finset (Fin (2*q+1)))) = (E : Finset (Fin (2*q+1))).powersetCard q := by ext R rw [Finset.mem_filter, memX, Finset.mem_powersetCard] tauto rw [hEq, Finset.card_powersetCard, (memY _).mp E.2, Nat.choose_succ_self_right]
Every q-element subset R ∈ X is contained in at most q+1 subsets of size q+1.
Any extension E of R to a (q+1)-element set is uniquely determined by the difference singleton E \ R, which is a 1-element subset of the complement of R. Since the complement has (2q+1) - q = q+1 elements, there are at most (q+1 choose 1) = q+1 such extensions.
uses
Finset.mem_coe,Finset.mem_filter,Finset.mem_powersetCard,Finset.mem_sdiff,Finset.mem_univ,Finset.card_sdiff_of_subset,Finset.union_sdiff_of_subset,Finset.card_le_card_of_injOn,Finset.card_powersetCard,Finset.subset_univ,Finset.card_univ,Fintype.card_fin,Nat.choose_one_righthave hDown : ∀ R : ↥X, (Finset.univ.filter (fun E : ↥Y => (R : Finset (Fin (2*q+1))) ⊆ (E : Finset (Fin (2*q+1))))).card ≤ q+1 := by intro R rw [card_sub_filter Y (fun E => (R : Finset (Fin (2*q+1))) ⊆ E)] have hRcard : (R : Finset (Fin (2*q+1))).card = q := (memX _).mp R.2 have hmaps : Set.MapsTo (fun E : Finset (Fin (2*q+1)) => E \ (R : Finset (Fin (2*q+1)))) ↑(Y.filter (fun E => (R : Finset (Fin (2*q+1))) ⊆ E)) ↑((Finset.univ \ (R : Finset (Fin (2*q+1)))).powersetCard 1) := by intro E hE simp only [Finset.mem_coe, Finset.mem_filter, Finset.mem_powersetCard] at hE ⊢ obtain ⟨hEY, hRE⟩ := hE refine ⟨?_, ?_⟩ · intro x hx rw [Finset.mem_sdiff] at hx ⊢ exact ⟨Finset.mem_univ x, hx.2⟩ · rw [Finset.card_sdiff_of_subset hRE, (memY _).mp hEY, hRcard] omega have hinj : Set.InjOn (fun E : Finset (Fin (2*q+1)) => E \ (R : Finset (Fin (2*q+1)))) ↑(Y.filter (fun E => (R : Finset (Fin (2*q+1))) ⊆ E)) := by intro E1 hE1 E2 hE2 h have h' : E1 \ (R : Finset (Fin (2*q+1))) = E2 \ (R : Finset (Fin (2*q+1))) := h simp only [Finset.mem_coe, Finset.mem_filter] at hE1 hE2 rw [← Finset.union_sdiff_of_subset hE1.2, ← Finset.union_sdiff_of_subset hE2.2, h'] calc (Y.filter (fun E => (R : Finset (Fin (2*q+1))) ⊆ E)).card ≤ ((Finset.univ \ (R : Finset (Fin (2*q+1)))).powersetCard 1).card := Finset.card_le_card_of_injOn _ hmaps hinj _ = q+1 := by rw [Finset.card_powersetCard, Finset.card_sdiff_of_subset (Finset.subset_univ _), Finset.card_univ, Fintype.card_fin, hRcard, Nat.choose_one_right] omega
Hall's Marriage Condition holds: for any subfamily A ⊆ Y, |A| ≤ |N(A)|, where N(A) ⊆ X is the neighborhood of A under containment.
We double-count the incidence pairs S = {(E, R) ∈ A × X | R ⊆ E}. Since each E ∈ A contains q+1 sets in X, the first projection gives (q+1)|A| ≤ |S|. On the other hand, each R ∈ N(A) is contained in at most q+1 sets in Y, so the second projection gives |S| ≤ (q+1)|N(A)|. Combining these inequalities and dividing by q+1 > 0 yields |A| ≤ |N(A)|.
uses
Finset.mem_filter,Finset.mem_image,Finset.card_image_of_injective,Finset.card_le_card,Finset.filter_subset_filter,Finset.subset_univ,Finset.mul_card_image_le_card_of_maps_to,Finset.card_le_mul_card_image_of_maps_to,Finset.mem_biUnion,Nat.le_of_mul_le_mul_left,le_transhave hall : ∀ A : Finset ↥Y, A.card ≤ (A.biUnion (fun E : ↥Y => Finset.univ.filter (fun R : ↥X => (R : Finset (Fin (2*q+1))) ⊆ (E : Finset (Fin (2*q+1)))))).card := by intro A set N : Finset ↥X := A.biUnion (fun E : ↥Y => Finset.univ.filter (fun R : ↥X => (R : Finset (Fin (2*q+1))) ⊆ (E : Finset (Fin (2*q+1))))) with hN set S : Finset (↥Y × ↥X) := (A ×ˢ Finset.univ).filter (fun p : ↥Y × ↥X => (p.2 : Finset (Fin (2*q+1))) ⊆ (p.1 : Finset (Fin (2*q+1)))) with hS have hS_mem : ∀ p : ↥Y × ↥X, p ∈ S ↔ p.1 ∈ A ∧ (p.2 : Finset (Fin (2*q+1))) ⊆ (p.1 : Finset (Fin (2*q+1))) := by intro p; simp [hS] have hS_fst : ∀ E ∈ A, (S.filter (fun p : ↥Y × ↥X => p.1 = E)).card = q+1 := by intro E hE have hfib : S.filter (fun p : ↥Y × ↥X => p.1 = E) = (Finset.univ.filter (fun R : ↥X => (R : Finset (Fin (2*q+1))) ⊆ (E : Finset (Fin (2*q+1))))).image (fun R => (E, R)) := by ext p rw [Finset.mem_filter, hS_mem, Finset.mem_image] constructor · rintro ⟨⟨hA, hsub⟩, hE1⟩ exact ⟨p.2, by simpa [hE1] using hsub, by rw [← hE1]⟩ · rintro ⟨R, hR, hp⟩ rw [Finset.mem_filter] at hR rw [← hp] exact ⟨⟨hE, hR.2⟩, rfl⟩ rw [hfib, Finset.card_image_of_injective _ (fun a b h => by simpa using h)] exact hUp E have hS_snd : ∀ R ∈ N, (S.filter (fun p : ↥Y × ↥X => p.2 = R)).card ≤ q+1 := by intro R _ have hfib : S.filter (fun p : ↥Y × ↥X => p.2 = R) = (A.filter (fun E : ↥Y => (R : Finset (Fin (2*q+1))) ⊆ (E : Finset (Fin (2*q+1))))).image (fun E => (E, R)) := by ext p simp only [Finset.mem_filter, Finset.mem_image, hS_mem] constructor · rintro ⟨⟨hA, hsub⟩, hR2⟩ exact ⟨p.1, ⟨hA, by simpa [hR2] using hsub⟩, by rw [← hR2]⟩ · rintro ⟨E, ⟨hA, hRE⟩, hp⟩ rw [← hp] exact ⟨⟨hA, hRE⟩, rfl⟩ rw [hfib, Finset.card_image_of_injective _ (fun a b h => by simpa using h)] calc (A.filter (fun E : ↥Y => (R : Finset (Fin (2*q+1))) ⊆ (E : Finset (Fin (2*q+1))))).card ≤ (Finset.univ.filter (fun E : ↥Y => (R : Finset (Fin (2*q+1))) ⊆ (E : Finset (Fin (2*q+1))))).card := Finset.card_le_card (Finset.filter_subset_filter _ (Finset.subset_univ A)) _ ≤ q+1 := hDown R have h1 : (q+1) * A.card ≤ S.card := by refine Finset.mul_card_image_le_card_of_maps_to (f := Prod.fst) (s := S) (t := A) ?_ (q+1) ?_ · intro p hp exact (hS_mem p).mp hp |>.1 · intro E hE exact (hS_fst E hE).ge have h2 : S.card ≤ (q+1) * N.card := by refine Finset.card_le_mul_card_image_of_maps_to (f := Prod.snd) (s := S) (t := N) ?_ (q+1) ?_ · intro p hp obtain ⟨hA, hsub⟩ := (hS_mem p).mp hp rw [hN] refine Finset.mem_biUnion.mpr ⟨p.1, hA, ?_⟩ simpa using hsub · intro R hR exact hS_snd R hR exact Nat.le_of_mul_le_mul_left (le_trans h1 h2) (by omega : 0 < q+1)
There exists a bijection f : Y → X such that f(E) ⊆ E for all E ∈ Y.
By Hall's Marriage Theorem, Hall's condition provides an injective map f : Y → X with f(E) ⊆ E. Since |Y| = (2q+1 choose q+1) = (2q+1 choose q) = |X| by symmetry of binomial coefficients, any injection between these two finite sets of equal cardinality is automatically a bijection.
uses
Finset.all_card_le_biUnion_card_iff_exists_injective,Fintype.card_coe,Finset.card_powersetCard,Finset.card_univ,Fintype.card_fin,Nat.choose_symm,Fintype.bijective_iff_injective_and_cardobtain ⟨f, hf_inj, hf_mem⟩ := (Finset.all_card_le_biUnion_card_iff_exists_injective (fun E : ↥Y => Finset.univ.filter (fun R : ↥X => (R : Finset (Fin (2*q+1))) ⊆ (E : Finset (Fin (2*q+1)))))).mp hall have hf_sub : ∀ E : ↥Y, (f E : Finset (Fin (2*q+1))) ⊆ (E : Finset (Fin (2*q+1))) := by intro E have h := hf_mem E simpa using h have hcardXY : Fintype.card ↥Y = Fintype.card ↥X := by rw [Fintype.card_coe, Fintype.card_coe] have hXc : X.card = Nat.choose (2*q+1) q := by rw [hX, Finset.card_powersetCard, Finset.card_univ, Fintype.card_fin] have hYc : Y.card = Nat.choose (2*q+1) (q+1) := by rw [hY, Finset.card_powersetCard, Finset.card_univ, Fintype.card_fin] rw [hXc, hYc] have hk : 2*q+1 - (q+1) = q := by omega have h := Nat.choose_symm (n := 2*q+1) (k := q+1) (by omega) rw [hk] at h exact h.symm have hsurj : Function.Surjective f := ((Fintype.bijective_iff_injective_and_card f).mpr ⟨hf_inj, hcardXY⟩).2
Define tail(E) as the unique element of E \ f(E) when |E| = q+1, and a default element 0 otherwise.
For each E ∈ Y, f(E) is a q-element subset of E, so the difference E \ f(E) has cardinality (q+1) - q = 1 and is nonempty. We define tail(E) to be its unique element, chosen via the minimum of the nonempty set.
uses
Finset.card_sdiff_of_subset,Finset.card_poshave hne : ∀ E : ↥Y, ((E : Finset (Fin (2*q+1))) \ (f E : Finset (Fin (2*q+1)))).Nonempty := by intro E have hsub := hf_sub E have hc : ((E : Finset (Fin (2*q+1))) \ (f E : Finset (Fin (2*q+1)))).card = 1 := by rw [Finset.card_sdiff_of_subset hsub, (memY _).mp E.2, (memX _).mp (f E).2] omega exact Finset.card_pos.mp (by rw [hc]; norm_num) let tail : Finset (Fin (2*q+1)) → Fin (2*q+1) := fun E => if h : E.card = q+1 then (E \ ((f ⟨E, (memY E).mpr h⟩ : ↥X) : Finset (Fin (2*q+1)))).min' (hne ⟨E, (memY E).mpr h⟩) else ⟨0, by omega⟩
For every (q+1)-element set E, tail(E) ∈ E.
By construction, tail(E) is chosen from the difference E \ f(E), which is a subset of E.
uses
dif_pos,Finset.mem_sdiff,Finset.min'_memrefine ⟨tail, ?_, ?_⟩ · intro E hE have h1 : tail E = (E \ ((f ⟨E, (memY E).mpr hE⟩ : ↥X) : Finset (Fin (2*q+1)))).min' (hne ⟨E, (memY E).mpr hE⟩) := by simp only [tail] exact dif_pos hE rw [h1] exact (Finset.mem_sdiff.mp (Finset.min'_mem _ _)).1
For every q-element set R, there exists v ∉ R such that tail(R ∪ {v}) = v.
By surjectivity of f, there exists E ∈ Y such that f(E) = R. Let v = tail(E) ∈ E \ R. Then v ∉ R and E = R ∪ {v}, which implies that tail(R ∪ {v}) = tail(E) = v.
uses
Subtype.ext,Finset.min'_mem,Finset.mem_sdiff,Finset.eq_of_subset_of_card_le,Finset.mem_insert,Finset.card_insert_of_notMem,dif_pos· intro R hR have hRX : R ∈ X := (memX R).mpr hR obtain ⟨E, hE⟩ := hsurj ⟨R, hRX⟩ have hcardE : (E : Finset (Fin (2*q+1))).card = q+1 := (memY _).mp E.2 have hsub : R ⊆ (E : Finset (Fin (2*q+1))) := by have h1 := hf_sub E rw [hE] at h1 simpa using h1 set v : Fin (2*q+1) := ((E : Finset (Fin (2*q+1))) \ ((f ⟨(E : Finset (Fin (2*q+1))), (memY _).mpr hcardE⟩ : ↥X) : Finset (Fin (2*q+1)))).min' (hne ⟨(E : Finset (Fin (2*q+1))), (memY _).mpr hcardE⟩) with hv have hfE : f ⟨(E : Finset (Fin (2*q+1))), (memY _).mpr hcardE⟩ = ⟨R, hRX⟩ := by rw [show (⟨(E : Finset (Fin (2*q+1))), (memY _).mpr hcardE⟩ : ↥Y) = E from Subtype.ext rfl, hE] have hvmem : v ∈ (E : Finset (Fin (2*q+1))) \ ((f ⟨(E : Finset (Fin (2*q+1))), (memY _).mpr hcardE⟩ : ↥X) : Finset (Fin (2*q+1))) := Finset.min'_mem _ _ have hvR : v ∉ R := by have h2 := (Finset.mem_sdiff.mp hvmem).2 rw [hfE] at h2 exact h2 have hvE : v ∈ (E : Finset (Fin (2*q+1))) := (Finset.mem_sdiff.mp hvmem).1 have hins : insert v R = (E : Finset (Fin (2*q+1))) := by refine Finset.eq_of_subset_of_card_le ?_ ?_ · intro x hx rw [Finset.mem_insert] at hx rcases hx with rfl | hx · exact hvE · exact hsub hx · rw [hcardE, Finset.card_insert_of_notMem hvR, hR] refine ⟨v, hvR, ?_⟩ rw [hins] have htv : tail (E : Finset (Fin (2*q+1))) = v := by simp only [tail] exact dif_pos hcardE exact htv
Finset.all_card_le_biUnion_card_iff_exists_injective- Hall's Marriage Theorem for finite sets: a family admits an injective system of distinct representatives if and only if every subfamily s satisfies |s| ≤ |⋃_{x ∈ s} t(x)|.
Finset.card_image_of_injective- An injective function preserves the cardinality of a finite set: |f(s)| = |s|.
Finset.card_insert_of_notMem- If a ∉ s, then |s ∪ {a}| = |s| + 1.
Finset.card_le_card- If s ⊆ t, then |s| ≤ |t|.
Finset.card_le_card_of_injOn- If a function maps s to t and is injective on s, then |s| ≤ |t|.
Finset.card_le_mul_card_image_of_maps_to- If a function maps s to t and each fiber has at most n elements, then |s| ≤ n * |t|.
Finset.card_pos- A finite set is nonempty if and only if its cardinality is strictly greater than 0.
Finset.card_powersetCard- The number of size-n subsets of a finite set s is (card s choose n).
Finset.card_sdiff_of_subset- If s ⊆ t, then |t \ s| = |t| - |s|.
Finset.card_univ- The cardinality of Finset.univ on a finite type equals the type's cardinality.
Finset.eq_of_subset_of_card_le- If s ⊆ t and |t| ≤ |s|, then s = t.
Finset.filter_subset_filter- If s ⊆ t, then filtering both sets by the same predicate preserves the inclusion.
Finset.mem_biUnion- An element x belongs to ⋃_{a ∈ s} t(a) if and only if there is some a ∈ s such that x ∈ t(a).
Finset.mem_coe- Membership in a coerced finset equals membership in the finset.
Finset.mem_filter- An element x belongs to {y ∈ s | p(y)} if and only if x ∈ s and p(x) holds.
Finset.mem_image- An element y is in f(s) if and only if there exists x ∈ s with f(x) = y.
Finset.mem_insert- An element x belongs to insert a s if and only if x = a or x ∈ s.
Finset.mem_powersetCard- A set s belongs to the size-n powerset of t if and only if s ⊆ t and |s| = n.
Finset.mem_sdiff- An element x belongs to s \ t if and only if x ∈ s and x ∉ t.
Finset.mem_univ- Every element of a finite type belongs to Finset.univ.
Finset.min'_mem- The minimum element of a nonempty finite set in a linear order belongs to the set.
Finset.mul_card_image_le_card_of_maps_to- If a function maps s to t and each fiber has at least n elements, then n * |t| ≤ |s|.
Finset.subset_univ- Every finite set of elements of a type is a subset of Finset.univ.
Finset.union_sdiff_of_subset- If s ⊆ t, then s ∪ (t \ s) = t.
Fintype.bijective_iff_injective_and_card- A function between finite types of equal cardinality is bijective if and only if it is injective.
Fintype.card_coe- The cardinality of the subtype corresponding to a finset equals the finset's cardinality.
Fintype.card_fin- The finite type Fin n has cardinality n.
Nat.choose_one_right- For any natural number n, (n choose 1) = n.
Nat.choose_succ_self_right- For any natural number n, (n + 1 choose n) = n + 1.
Nat.choose_symm- Symmetry of binomial coefficients: if k ≤ n, then (n choose n - k) = (n choose k).
Nat.le_of_mul_le_mul_left- If c * a ≤ c * b and 0 < c, then a ≤ b for natural numbers.
Subtype.ext- Subtype elements with equal underlying values are equal.
Subtype.val_injective- The inclusion map from a subtype into the ambient type is injective.
dif_pos- A dependent if-then-else expression evaluates to the then-branch when the condition holds.
le_trans- Inequality is transitive: if a ≤ b and b ≤ c, then a ≤ c.
true_and- The conjunction True ∧ p simplifies to p.
- The lemma `card_sub_filter` (lines 12–23) is a formal bridge between subtype-level filtering and ambient finset filtering, which requires no counterpart in mathematical prose.
- The bipartite degree bounds and Hall's condition are resolved via double-counting incidence pairs, with linear integer arithmetic handled by the `omega` tactic.
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
Choose a tactic — a marked line — to see the goals Lean had before and after it, as in Lean’s infoview. Step with ← → or j k.
theorem op861_middle_levels_strong_tail_exists (q : ℕ) (hq : 1 ≤ q) : ∃ tail : Finset (Fin (2*q+1)) → Fin (2*q+1), (∀ E : Finset (Fin (2*q+1)), E.card = q+1 → tail E ∈ E) ∧ (∀ R : Finset (Fin (2*q+1)), R.card = q → ∃ v, v ∉ R ∧ tail (insert v R) = v) := by classical set X : Finset (Finset (Fin (2*q+1))) := Finset.univ.powersetCard q with hX set Y : Finset (Finset (Fin (2*q+1))) := Finset.univ.powersetCard (q+1) with hY have memX : ∀ R : Finset (Fin (2*q+1)), R ∈ X ↔ R.card = q := by intro R; simp [hX] have memY : ∀ E : Finset (Fin (2*q+1)), E ∈ Y ↔ E.card = q+1 := by intro E; simp [hY] have card_sub_filter : ∀ (T : Finset (Finset (Fin (2*q+1)))) (p : Finset (Fin (2*q+1)) → Prop) [DecidablePred p], (Finset.univ.filter (fun R : ↥T => p (R : Finset (Fin (2*q+1))))).card = (T.filter p).card := by intro T p _ have himg : (Finset.univ.filter (fun R : ↥T => p (R : Finset (Fin (2*q+1))))).image (Subtype.val) = T.filter p := by ext R simp only [Finset.mem_image, Finset.mem_filter, Finset.mem_univ, true_and] constructor · rintro ⟨S, hS, rfl⟩ exact ⟨S.2, hS⟩ · rintro ⟨hT, hp⟩ exact ⟨⟨R, hT⟩, hp, rfl⟩ rw [← himg, Finset.card_image_of_injective _ Subtype.val_injective] have hUp : ∀ E : ↥Y, (Finset.univ.filter (fun R : ↥X => (R : Finset (Fin (2*q+1))) ⊆ (E : Finset (Fin (2*q+1))))).card = q+1 := by intro E rw [card_sub_filter X (fun R => R ⊆ (E : Finset (Fin (2*q+1))))] have hEq : X.filter (fun R : Finset (Fin (2*q+1)) => R ⊆ (E : Finset (Fin (2*q+1)))) = (E : Finset (Fin (2*q+1))).powersetCard q := by ext R rw [Finset.mem_filter, memX, Finset.mem_powersetCard] tauto rw [hEq, Finset.card_powersetCard, (memY _).mp E.2, Nat.choose_succ_self_right] have hDown : ∀ R : ↥X, (Finset.univ.filter (fun E : ↥Y => (R : Finset (Fin (2*q+1))) ⊆ (E : Finset (Fin (2*q+1))))).card ≤ q+1 := by intro R rw [card_sub_filter Y (fun E => (R : Finset (Fin (2*q+1))) ⊆ E)] have hRcard : (R : Finset (Fin (2*q+1))).card = q := (memX _).mp R.2 have hmaps : Set.MapsTo (fun E : Finset (Fin (2*q+1)) => E \ (R : Finset (Fin (2*q+1)))) ↑(Y.filter (fun E => (R : Finset (Fin (2*q+1))) ⊆ E)) ↑((Finset.univ \ (R : Finset (Fin (2*q+1)))).powersetCard 1) := by intro E hE simp only [Finset.mem_coe, Finset.mem_filter, Finset.mem_powersetCard] at hE ⊢ obtain ⟨hEY, hRE⟩ := hE refine ⟨?_, ?_⟩ · intro x hx rw [Finset.mem_sdiff] at hx ⊢ exact ⟨Finset.mem_univ x, hx.2⟩ · rw [Finset.card_sdiff_of_subset hRE, (memY _).mp hEY, hRcard] omega have hinj : Set.InjOn (fun E : Finset (Fin (2*q+1)) => E \ (R : Finset (Fin (2*q+1)))) ↑(Y.filter (fun E => (R : Finset (Fin (2*q+1))) ⊆ E)) := by intro E1 hE1 E2 hE2 h have h' : E1 \ (R : Finset (Fin (2*q+1))) = E2 \ (R : Finset (Fin (2*q+1))) := h simp only [Finset.mem_coe, Finset.mem_filter] at hE1 hE2 rw [← Finset.union_sdiff_of_subset hE1.2, ← Finset.union_sdiff_of_subset hE2.2, h'] calc (Y.filter (fun E => (R : Finset (Fin (2*q+1))) ⊆ E)).card ≤ ((Finset.univ \ (R : Finset (Fin (2*q+1)))).powersetCard 1).card := Finset.card_le_card_of_injOn _ hmaps hinj _ = q+1 := by rw [Finset.card_powersetCard, Finset.card_sdiff_of_subset (Finset.subset_univ _), Finset.card_univ, Fintype.card_fin, hRcard, Nat.choose_one_right] omega have hall : ∀ A : Finset ↥Y, A.card ≤ (A.biUnion (fun E : ↥Y => Finset.univ.filter (fun R : ↥X => (R : Finset (Fin (2*q+1))) ⊆ (E : Finset (Fin (2*q+1)))))).card := by intro A set N : Finset ↥X := A.biUnion (fun E : ↥Y => Finset.univ.filter (fun R : ↥X => (R : Finset (Fin (2*q+1))) ⊆ (E : Finset (Fin (2*q+1))))) with hN set S : Finset (↥Y × ↥X) := (A ×ˢ Finset.univ).filter (fun p : ↥Y × ↥X => (p.2 : Finset (Fin (2*q+1))) ⊆ (p.1 : Finset (Fin (2*q+1)))) with hS have hS_mem : ∀ p : ↥Y × ↥X, p ∈ S ↔ p.1 ∈ A ∧ (p.2 : Finset (Fin (2*q+1))) ⊆ (p.1 : Finset (Fin (2*q+1))) := by intro p; simp [hS] have hS_fst : ∀ E ∈ A, (S.filter (fun p : ↥Y × ↥X => p.1 = E)).card = q+1 := by intro E hE have hfib : S.filter (fun p : ↥Y × ↥X => p.1 = E) = (Finset.univ.filter (fun R : ↥X => (R : Finset (Fin (2*q+1))) ⊆ (E : Finset (Fin (2*q+1))))).image (fun R => (E, R)) := by ext p rw [Finset.mem_filter, hS_mem, Finset.mem_image] constructor · rintro ⟨⟨hA, hsub⟩, hE1⟩ exact ⟨p.2, by simpa [hE1] using hsub, by rw [← hE1]⟩ · rintro ⟨R, hR, hp⟩ rw [Finset.mem_filter] at hR rw [← hp] exact ⟨⟨hE, hR.2⟩, rfl⟩ rw [hfib, Finset.card_image_of_injective _ (fun a b h => by simpa using h)] exact hUp E have hS_snd : ∀ R ∈ N, (S.filter (fun p : ↥Y × ↥X => p.2 = R)).card ≤ q+1 := by intro R _ have hfib : S.filter (fun p : ↥Y × ↥X => p.2 = R) = (A.filter (fun E : ↥Y => (R : Finset (Fin (2*q+1))) ⊆ (E : Finset (Fin (2*q+1))))).image (fun E => (E, R)) := by ext p simp only [Finset.mem_filter, Finset.mem_image, hS_mem] constructor · rintro ⟨⟨hA, hsub⟩, hR2⟩ exact ⟨p.1, ⟨hA, by simpa [hR2] using hsub⟩, by rw [← hR2]⟩ · rintro ⟨E, ⟨hA, hRE⟩, hp⟩ rw [← hp] exact ⟨⟨hA, hRE⟩, rfl⟩ rw [hfib, Finset.card_image_of_injective _ (fun a b h => by simpa using h)] calc (A.filter (fun E : ↥Y => (R : Finset (Fin (2*q+1))) ⊆ (E : Finset (Fin (2*q+1))))).card ≤ (Finset.univ.filter (fun E : ↥Y => (R : Finset (Fin (2*q+1))) ⊆ (E : Finset (Fin (2*q+1))))).card := Finset.card_le_card (Finset.filter_subset_filter _ (Finset.subset_univ A)) _ ≤ q+1 := hDown R have h1 : (q+1) * A.card ≤ S.card := by refine Finset.mul_card_image_le_card_of_maps_to (f := Prod.fst) (s := S) (t := A) ?_ (q+1) ?_ · intro p hp exact (hS_mem p).mp hp |>.1 · intro E hE exact (hS_fst E hE).ge have h2 : S.card ≤ (q+1) * N.card := by refine Finset.card_le_mul_card_image_of_maps_to (f := Prod.snd) (s := S) (t := N) ?_ (q+1) ?_ · intro p hp obtain ⟨hA, hsub⟩ := (hS_mem p).mp hp rw [hN] refine Finset.mem_biUnion.mpr ⟨p.1, hA, ?_⟩ simpa using hsub · intro R hR exact hS_snd R hR exact Nat.le_of_mul_le_mul_left (le_trans h1 h2) (by omega : 0 < q+1) obtain ⟨f, hf_inj, hf_mem⟩ := (Finset.all_card_le_biUnion_card_iff_exists_injective (fun E : ↥Y => Finset.univ.filter (fun R : ↥X => (R : Finset (Fin (2*q+1))) ⊆ (E : Finset (Fin (2*q+1)))))).mp hall have hf_sub : ∀ E : ↥Y, (f E : Finset (Fin (2*q+1))) ⊆ (E : Finset (Fin (2*q+1))) := by intro E have h := hf_mem E simpa using h have hcardXY : Fintype.card ↥Y = Fintype.card ↥X := by rw [Fintype.card_coe, Fintype.card_coe] have hXc : X.card = Nat.choose (2*q+1) q := by rw [hX, Finset.card_powersetCard, Finset.card_univ, Fintype.card_fin] have hYc : Y.card = Nat.choose (2*q+1) (q+1) := by rw [hY, Finset.card_powersetCard, Finset.card_univ, Fintype.card_fin] rw [hXc, hYc] have hk : 2*q+1 - (q+1) = q := by omega have h := Nat.choose_symm (n := 2*q+1) (k := q+1) (by omega) rw [hk] at h exact h.symm have hsurj : Function.Surjective f := ((Fintype.bijective_iff_injective_and_card f).mpr ⟨hf_inj, hcardXY⟩).2 have hne : ∀ E : ↥Y, ((E : Finset (Fin (2*q+1))) \ (f E : Finset (Fin (2*q+1)))).Nonempty := by intro E have hsub := hf_sub E have hc : ((E : Finset (Fin (2*q+1))) \ (f E : Finset (Fin (2*q+1)))).card = 1 := by rw [Finset.card_sdiff_of_subset hsub, (memY _).mp E.2, (memX _).mp (f E).2] omega exact Finset.card_pos.mp (by rw [hc]; norm_num) let tail : Finset (Fin (2*q+1)) → Fin (2*q+1) := fun E => if h : E.card = q+1 then (E \ ((f ⟨E, (memY E).mpr h⟩ : ↥X) : Finset (Fin (2*q+1)))).min' (hne ⟨E, (memY E).mpr h⟩) else ⟨0, by omega⟩ refine ⟨tail, ?_, ?_⟩ · intro E hE have h1 : tail E = (E \ ((f ⟨E, (memY E).mpr hE⟩ : ↥X) : Finset (Fin (2*q+1)))).min' (hne ⟨E, (memY E).mpr hE⟩) := by simp only [tail] exact dif_pos hE rw [h1] exact (Finset.mem_sdiff.mp (Finset.min'_mem _ _)).1 · intro R hR have hRX : R ∈ X := (memX R).mpr hR obtain ⟨E, hE⟩ := hsurj ⟨R, hRX⟩ have hcardE : (E : Finset (Fin (2*q+1))).card = q+1 := (memY _).mp E.2 have hsub : R ⊆ (E : Finset (Fin (2*q+1))) := by have h1 := hf_sub E rw [hE] at h1 simpa using h1 set v : Fin (2*q+1) := ((E : Finset (Fin (2*q+1))) \ ((f ⟨(E : Finset (Fin (2*q+1))), (memY _).mpr hcardE⟩ : ↥X) : Finset (Fin (2*q+1)))).min' (hne ⟨(E : Finset (Fin (2*q+1))), (memY _).mpr hcardE⟩) with hv have hfE : f ⟨(E : Finset (Fin (2*q+1))), (memY _).mpr hcardE⟩ = ⟨R, hRX⟩ := by rw [show (⟨(E : Finset (Fin (2*q+1))), (memY _).mpr hcardE⟩ : ↥Y) = E from Subtype.ext rfl, hE] have hvmem : v ∈ (E : Finset (Fin (2*q+1))) \ ((f ⟨(E : Finset (Fin (2*q+1))), (memY _).mpr hcardE⟩ : ↥X) : Finset (Fin (2*q+1))) := Finset.min'_mem _ _ have hvR : v ∉ R := by have h2 := (Finset.mem_sdiff.mp hvmem).2 rw [hfE] at h2 exact h2 have hvE : v ∈ (E : Finset (Fin (2*q+1))) := (Finset.mem_sdiff.mp hvmem).1 have hins : insert v R = (E : Finset (Fin (2*q+1))) := by refine Finset.eq_of_subset_of_card_le ?_ ?_ · intro x hx rw [Finset.mem_insert] at hx rcases hx with rfl | hx · exact hvE · exact hsub hx · rw [hcardE, Finset.card_insert_of_notMem hvR, hR] refine ⟨v, hvR, ?_⟩ rw [hins] have htv : tail (E : Finset (Fin (2*q+1))) = v := by simp only [tail] exact dif_pos hcardE exact htv