import Mathlib /-! # Kruskal–Katona Cascade Theorem, Shifting, and Lovász's Real Binomial Shadow Bound This module develops the complete numerical shadow theory for uniform finite set families, complementing Mathlib's colex initial-segment formulation (`Finset.kruskal_katona`) with: 1. **Exact `k`-Cascade Binomial Representation (`IsKCascade`, `toCascade`, `cascadeVal`)**: Every natural number `m` has a unique representation `m = C(a_k, k) + C(a_{k-1}, k-1) + ... + C(a_t, t)` with `a_k > a_{k-1} > ... > a_t ≥ t ≥ 1`. We prove both constructive existence (via greedy selection `toCascade`) and full uniqueness (`exists_unique_kCascade`), together with the equivalence to the classical indexed formulation. 2. **Explicit Colex Initial Segments (`cascadeFamily`)**: For any valid `k`-cascade `a` bounded by `n`, we construct the explicit colex initial segment `cascadeFamily n k a : Finset (Finset (Fin n))` recursively matching the cascade, and prove: - exact uniformity (`sized_cascadeFamily`), - exact cardinality `#(cascadeFamily n k a) = cascadeVal k a`, - exact colex initial-segment property (`isInitSeg_cascadeFamily`), - exact shadow formula `#(∂ (cascadeFamily n k a)) = cascadeShadow k a`, and - exact iterated shadow formula `#(∂^[r] (cascadeFamily n k a)) = cascadeIterShadow r k a`. 3. **Full Numerical & Iterated Kruskal–Katona Cascade Theorems**: - `kruskal_katona_cascade`: For every `k`-uniform family `𝒜` (`k ≥ 1`), `cascadeShadow k (toCascade k #𝒜) ≤ #(∂ 𝒜)`, with sharpness attained by `cascadeFamily`. - `kruskal_katona_iterated_cascade`: For every `r ≤ k`, `cascadeIterShadow r k (toCascade k #𝒜) ≤ #(∂^[r] 𝒜)`, with exact sharpness. 4. **Left-Shifting Operators (`shiftFamily`)**: Standalone formalization of `(i, j)`-left-shifting on `Finset (Finset (Fin n))`: preserves cardinality and `k`-uniformity, does not increase shadow size (`card_shadow_shiftFamily_le`), strictly decreases the total element-sum weight when nontrivial, and terminates in a fully left-shifted family (`exists_shifted_shadow_le`). 5. **Lovász's Real Binomial Shadow Theorem (1979) (`lovasz_real_binomial_shadow`)**: Using the real generalized binomial coefficient `realBinom (x : ℝ) k = ∏_{j True | x :: xs => match k with | 0 => False | k' + 1 => k' + 1 ≤ x ∧ (∀ y ∈ xs, y < x) ∧ IsKCascade k' xs /-- The `k`-cascade value `∑_j C(a_j, k - j)`. -/ def cascadeVal : ℕ → List ℕ → ℕ | _, [] => 0 | k, x :: xs => x.choose k + cascadeVal (k - 1) xs /-- The single-step Kruskal–Katona lower shadow `∂_k(a) = ∑_j C(a_j, k - 1 - j)`. -/ def cascadeShadow : ℕ → List ℕ → ℕ | _, [] => 0 | k, x :: xs => x.choose (k - 1) + cascadeShadow (k - 1) xs /-- The `r`-times iterated Kruskal–Katona lower shadow `∂_k^(r)(a)`. -/ def cascadeIterShadow (r : ℕ) : ℕ → List ℕ → ℕ | _, [] => 0 | k, x :: xs => if r ≤ k then x.choose (k - r) + cascadeIterShadow r (k - 1) xs else 0 lemma isKCascade_nil (k : ℕ) : IsKCascade k [] := by simp [IsKCascade] lemma isKCascade_zero_iff (a : List ℕ) : IsKCascade 0 a ↔ a = [] := by cases a with | nil => simp [IsKCascade] | cons x xs => simp [IsKCascade] lemma isKCascade_length_le : ∀ {k : ℕ} {a : List ℕ}, IsKCascade k a → a.length ≤ k | _, [], _ => Nat.zero_le _ | 0, _ :: _, h => False.elim h | _ + 1, _ :: _, ⟨_, _, hxs⟩ => Nat.succ_le_succ (isKCascade_length_le hxs) lemma isKCascade_pairwise : ∀ {k : ℕ} {a : List ℕ}, IsKCascade k a → a.Pairwise (· > ·) | _, [], _ => List.Pairwise.nil | 0, _ :: _, h => False.elim h | _ + 1, _ :: _, ⟨_, hlt, hxs⟩ => List.Pairwise.cons (fun _ hy => hlt _ hy) (isKCascade_pairwise hxs) lemma isKCascade_getElem_ge : ∀ {k : ℕ} {a : List ℕ}, IsKCascade k a → ∀ (j : ℕ) (hj : j < a.length), k - j ≤ a[j] | _, [], _, _, hj => absurd hj (Nat.not_lt_zero _) | 0, _ :: _, h, _, _ => False.elim h | _ + 1, _ :: _, ⟨hx, _, _⟩, 0, _ => by simpa using hx | _ + 1, _ :: _, ⟨_, _, hxs⟩, j + 1, hj => by have hj' : j < _ := Nat.lt_of_succ_lt_succ hj simpa [Nat.succ_sub_succ] using isKCascade_getElem_ge hxs j hj' /-- Equivalence between the recursive `IsKCascade` predicate and the classical indexed definition. -/ theorem isKCascade_iff_classical (k : ℕ) (a : List ℕ) : IsKCascade k a ↔ a.length ≤ k ∧ a.Pairwise (· > ·) ∧ ∀ (j : ℕ) (hj : j < a.length), k - j ≤ a[j] := by constructor · intro h exact ⟨isKCascade_length_le h, isKCascade_pairwise h, isKCascade_getElem_ge h⟩ · induction a generalizing k with | nil => intro _; exact isKCascade_nil k | cons x xs ih => rintro ⟨hlen, hpair, hge⟩ cases k with | zero => simp at hlen | succ k => rw [List.pairwise_cons] at hpair refine ⟨?_, fun y hy => hpair.1 y hy, ih k ⟨Nat.le_of_succ_le_succ hlen, hpair.2, ?_⟩⟩ · exact hge 0 (by simp) · intro j hj have h := hge (j + 1) (Nat.succ_lt_succ hj) simpa [Nat.succ_sub_succ] using h /-- Sharp bound: if `IsKCascade k a`, `k ≤ b`, and `∀ y ∈ a, y < b`, then `cascadeVal k a < b.choose k`. -/ theorem cascadeVal_lt_choose_of_le : ∀ {k b : ℕ} {a : List ℕ}, k ≤ b → IsKCascade k a → (∀ y ∈ a, y < b) → cascadeVal k a < b.choose k | 0, b, [], _, _, _ => by simp [cascadeVal] | 0, _, _ :: _, _, h, _ => False.elim h | k + 1, b, [], hkb, _, _ => by simp only [cascadeVal] exact Nat.choose_pos hkb | k + 1, b, x :: xs, _, ⟨hx, hlt, hxs⟩, hb => by have hxb : x < b := hb x (by simp) have hxs_lt : cascadeVal k xs < x.choose k := by apply cascadeVal_lt_choose_of_le (Nat.le_of_succ_le hx) hxs intro y hy exact hlt y hy have hstep : x.choose (k + 1) + cascadeVal k xs < (x + 1).choose (k + 1) := by rw [Nat.choose_succ_succ, Nat.succ_eq_add_one] omega have hmono : (x + 1).choose (k + 1) ≤ b.choose (k + 1) := Nat.choose_le_choose (k + 1) (Nat.succ_le_of_lt hxb) simpa [cascadeVal] using lt_of_lt_of_le hstep hmono /-- Any nonempty `k`-cascade has positive `cascadeVal`. -/ lemma cascadeVal_pos_of_ne_nil {k : ℕ} {a : List ℕ} (ha : IsKCascade k a) (hne : a ≠ []) : 0 < cascadeVal k a := by cases a with | nil => exact absurd rfl hne | cons x xs => cases k with | zero => exact False.elim ha | succ k => simp only [cascadeVal] exact Nat.add_pos_left (Nat.choose_pos ha.1) _ lemma cascadeVal_eq_zero_iff {k : ℕ} {a : List ℕ} (ha : IsKCascade k a) : cascadeVal k a = 0 ↔ a = [] := by constructor · intro h by_contra hne exact absurd h (Nat.ne_of_gt (cascadeVal_pos_of_ne_nil ha hne)) · rintro rfl; rfl /-- Monotonicity of `a ↦ a.choose k` for `k ≤ a` is strict for `k ≥ 1`. -/ lemma choose_lt_choose_of_lt {k a b : ℕ} (hk : 1 ≤ k) (hka : k ≤ a) (hab : a < b) : a.choose k < b.choose k := by cases k with | zero => omega | succ k => have h1 : a.choose (k + 1) < (a + 1).choose (k + 1) := by rw [Nat.choose_succ_succ, Nat.succ_eq_add_one] have hpos : 0 < a.choose k := Nat.choose_pos (by omega) omega exact lt_of_lt_of_le h1 (Nat.choose_le_choose (k + 1) (Nat.succ_le_of_lt hab)) /-- **Uniqueness of the `k`-cascade representation**: two valid `k`-cascades with the same `cascadeVal` must be identical lists. -/ theorem isKCascade_unique : ∀ {k : ℕ} {a b : List ℕ}, IsKCascade k a → IsKCascade k b → cascadeVal k a = cascadeVal k b → a = b | 0, a, b, ha, hb, _ => by rw [(isKCascade_zero_iff a).mp ha, (isKCascade_zero_iff b).mp hb] | k + 1, [], [], _, _, _ => rfl | k + 1, [], y :: ys, _, hb, hval => by have hpos := cascadeVal_pos_of_ne_nil hb (List.cons_ne_nil y ys) rw [← hval] at hpos; simp [cascadeVal] at hpos | k + 1, x :: xs, [], ha, _, hval => by have hpos := cascadeVal_pos_of_ne_nil ha (List.cons_ne_nil x xs) rw [hval] at hpos; simp [cascadeVal] at hpos | k + 1, x :: xs, y :: ys, ⟨hx, hxl, hxs⟩, ⟨hy, hyl, hys⟩, hval => by have hxy : x = y := by rcases lt_trichotomy x y with hlt | heq | hgt · exfalso have h1 : cascadeVal (k + 1) (x :: xs) < y.choose (k + 1) := by have hxs_lt : cascadeVal k xs < x.choose k := cascadeVal_lt_choose_of_le (Nat.le_of_succ_le hx) hxs hxl have hstep : x.choose (k + 1) + cascadeVal k xs < (x + 1).choose (k + 1) := by rw [Nat.choose_succ_succ, Nat.succ_eq_add_one]; omega exact lt_of_lt_of_le hstep (Nat.choose_le_choose (k + 1) (Nat.succ_le_of_lt hlt)) have h2 : y.choose (k + 1) ≤ cascadeVal (k + 1) (y :: ys) := by simp only [cascadeVal]; omega omega · exact heq · exfalso have h1 : cascadeVal (k + 1) (y :: ys) < x.choose (k + 1) := by have hys_lt : cascadeVal k ys < y.choose k := cascadeVal_lt_choose_of_le (Nat.le_of_succ_le hy) hys hyl have hstep : y.choose (k + 1) + cascadeVal k ys < (y + 1).choose (k + 1) := by rw [Nat.choose_succ_succ, Nat.succ_eq_add_one]; omega exact lt_of_lt_of_le hstep (Nat.choose_le_choose (k + 1) (Nat.succ_le_of_lt hgt)) have h2 : x.choose (k + 1) ≤ cascadeVal (k + 1) (x :: xs) := by simp only [cascadeVal]; omega omega subst hxy simp only [cascadeVal, Nat.add_sub_cancel] at hval have htail : cascadeVal k xs = cascadeVal k ys := Nat.add_left_cancel hval rw [isKCascade_unique hxs hys htail] /-- For `k ≥ 1` and `m ≥ 1`, there exists a unique maximal `a ≥ k` such that `a.choose k ≤ m`. We construct it cleanly via bounded search up to `m + k`. -/ lemma le_choose_add (k m : ℕ) (hk : 1 ≤ k) : m < (m + k).choose k := by cases k with | zero => omega | succ k => clear hk have hge : m + 1 ≤ (m + (k + 1)).choose (k + 1) := by induction k with | zero => simp | succ j ih => calc m + 1 ≤ (m + (j + 1)).choose (j + 1) := ih _ ≤ (m + (j + 1)).choose (j + 1) + (m + (j + 1)).choose (j + 2) := Nat.le_add_right _ _ _ = (m + (j + 1) + 1).choose (j + 2) := (Nat.choose_succ_succ _ _).symm _ = (m + (j + 1 + 1)).choose (j + 2) := by ring_nf omega /-- Auxiliary: the largest `a ≤ bound` with `a.choose k ≤ m`. -/ def maxChooseAux (k m : ℕ) : ℕ → ℕ | 0 => 0 | b + 1 => if (b + 1).choose k ≤ m then b + 1 else maxChooseAux k m b lemma maxChooseAux_le (k m b : ℕ) : maxChooseAux k m b ≤ b := by induction b with | zero => simp [maxChooseAux] | succ b ih => unfold maxChooseAux split_ifs · exact le_rfl · exact Nat.le_succ_of_le ih lemma maxChooseAux_spec (k m b : ℕ) (h0 : (0 : ℕ).choose k ≤ m) : (maxChooseAux k m b).choose k ≤ m := by induction b with | zero => simpa [maxChooseAux] using h0 | succ b ih => unfold maxChooseAux split_ifs with h · exact h · exact ih lemma maxChooseAux_maximal (k m b : ℕ) : ∀ c ≤ b, c.choose k ≤ m → c ≤ maxChooseAux k m b := by induction b with | zero => intro c hc _ simp [maxChooseAux]; omega | succ b ih => intro c hc hcm unfold maxChooseAux split_ifs with h · exact hc · have hne : c ≠ b + 1 := by intro heq; subst heq; exact h hcm exact ih c (by omega) hcm /-- The greedy top term `a_k` for `k ≥ 1, m ≥ 1`: largest `a` with `a.choose k ≤ m`. -/ def topCascadeTerm (k m : ℕ) : ℕ := maxChooseAux k m (m + k) lemma topCascadeTerm_ge {k m : ℕ} (hm : 1 ≤ m) : k ≤ topCascadeTerm k m := by apply maxChooseAux_maximal k m (m + k) k (by omega) simpa using hm lemma topCascadeTerm_choose_le {k m : ℕ} (hk : 1 ≤ k) : (topCascadeTerm k m).choose k ≤ m := by apply maxChooseAux_spec cases k with | zero => omega | succ k => simp lemma lt_choose_succ_topCascadeTerm {k m : ℕ} (hk : 1 ≤ k) : m < (topCascadeTerm k m + 1).choose k := by by_contra h push Not at h have hle_bound : topCascadeTerm k m + 1 ≤ m + k := by have hlt_mk : m < (m + k).choose k := le_choose_add k m hk have hne : topCascadeTerm k m ≠ m + k := by intro heq have h1 := topCascadeTerm_choose_le (m := m) hk rw [heq] at h1 omega have hle := maxChooseAux_le k m (m + k) change topCascadeTerm k m ≤ m + k at hle omega have hmax := maxChooseAux_maximal k m (m + k) (topCascadeTerm k m + 1) hle_bound h change topCascadeTerm k m + 1 ≤ topCascadeTerm k m at hmax omega /-- Constructive greedy algorithm computing the unique `k`-cascade of `m`. -/ def toCascade : ℕ → ℕ → List ℕ | 0, _ => [] | _, 0 => [] | k + 1, m + 1 => let a := topCascadeTerm (k + 1) (m + 1) a :: toCascade k (m + 1 - a.choose (k + 1)) lemma toCascade_zero_right (k : ℕ) : toCascade k 0 = [] := by cases k <;> rfl lemma toCascade_lt_of_lt : ∀ {k m b : ℕ}, m < b.choose k → ∀ y ∈ toCascade k m, y < b | 0, _, _, _, _, hy => by simp [toCascade] at hy | _ + 1, 0, _, _, _, hy => by simp [toCascade] at hy | k + 1, m + 1, b, hmb, y, hy => by simp only [toCascade, List.mem_cons] at hy set a := topCascadeTerm (k + 1) (m + 1) have ha_le : a.choose (k + 1) ≤ m + 1 := topCascadeTerm_choose_le (by omega) have hab : a < b := by by_contra hba push Not at hba have hch : b.choose (k + 1) ≤ a.choose (k + 1) := Nat.choose_le_choose (k + 1) hba omega rcases hy with rfl | hy' · exact hab · have hrem : m + 1 - a.choose (k + 1) < a.choose k := by have hsucc : m + 1 < (a + 1).choose (k + 1) := lt_choose_succ_topCascadeTerm (by omega) rw [Nat.choose_succ_succ, Nat.succ_eq_add_one] at hsucc omega exact lt_trans (toCascade_lt_of_lt hrem y hy') hab /-- `toCascade k m` is always a valid `k`-cascade. -/ theorem toCascade_isKCascade : ∀ (k m : ℕ), IsKCascade k (toCascade k m) | 0, _ => isKCascade_nil 0 | k + 1, 0 => isKCascade_nil (k + 1) | k + 1, m + 1 => by simp only [toCascade, IsKCascade] set a := topCascadeTerm (k + 1) (m + 1) have ha_le : a.choose (k + 1) ≤ m + 1 := topCascadeTerm_choose_le (by omega) have ha_ge : k + 1 ≤ a := topCascadeTerm_ge (by omega) have hrem : m + 1 - a.choose (k + 1) < a.choose k := by have hsucc : m + 1 < (a + 1).choose (k + 1) := lt_choose_succ_topCascadeTerm (by omega) rw [Nat.choose_succ_succ, Nat.succ_eq_add_one] at hsucc omega exact ⟨ha_ge, toCascade_lt_of_lt hrem, toCascade_isKCascade k _⟩ /-- For `k ≥ 1`, `toCascade k m` represents `m` exactly. -/ theorem cascadeVal_toCascade : ∀ {k : ℕ} (_hk : 1 ≤ k) (m : ℕ), cascadeVal k (toCascade k m) = m | 0, hk, _ => absurd hk (by decide) | _ + 1, _, 0 => rfl | 1, _, m + 1 => by simp only [toCascade, cascadeVal] set a := topCascadeTerm 1 (m + 1) have ha_le : a.choose 1 ≤ m + 1 := topCascadeTerm_choose_le (by omega) have hsucc : m + 1 < (a + 1).choose 1 := lt_choose_succ_topCascadeTerm (by omega) simp only [Nat.choose_one_right] at ha_le hsucc ⊢ have : a = m + 1 := by omega simp [this] | k + 2, _, m + 1 => by simp only [toCascade, cascadeVal] set a := topCascadeTerm (k + 2) (m + 1) have ha_le : a.choose (k + 2) ≤ m + 1 := topCascadeTerm_choose_le (by omega) have ih := cascadeVal_toCascade (k := k + 1) (by omega) (m + 1 - a.choose (k + 2)) change a.choose (k + 2) + cascadeVal (k + 1) (toCascade (k + 1) (m + 1 - a.choose (k + 2))) = m + 1 rw [ih] omega /-- **Existence and Uniqueness of the `k`-Cascade Representation**: for every `k ≥ 1` and `m : ℕ`, there exists a unique valid `k`-cascade `a` with `cascadeVal k a = m`. -/ theorem exists_unique_kCascade {k : ℕ} (hk : 1 ≤ k) (m : ℕ) : ∃! a : List ℕ, IsKCascade k a ∧ cascadeVal k a = m := by refine ⟨toCascade k m, ⟨toCascade_isKCascade k m, cascadeVal_toCascade hk m⟩, ?_⟩ rintro a ⟨ha, hval⟩ exact isKCascade_unique ha (toCascade_isKCascade k m) (hval.trans (cascadeVal_toCascade hk m).symm) lemma toCascade_cascadeVal {k : ℕ} (hk : 1 ≤ k) {a : List ℕ} (ha : IsKCascade k a) : toCascade k (cascadeVal k a) = a := isKCascade_unique (toCascade_isKCascade k _) ha (cascadeVal_toCascade hk _) lemma toCascade_lt_n {n k m : ℕ} (hm : m < n.choose k) : ∀ y ∈ toCascade k m, y < n := toCascade_lt_of_lt hm /-! ## Section 2: Explicit Colex Initial Segments Matching Cascades -/ /-- The initial prefix `{i : Fin n | i.1 < x}` of `Fin n`. -/ def finPrefix (n x : ℕ) : Finset (Fin n) := Finset.univ.filter (fun i : Fin n => i.1 < x) lemma card_finPrefix {n x : ℕ} (hxn : x ≤ n) : (finPrefix n x).card = x := by have hbij : (finPrefix n x).card = (Finset.range x).card := by refine Finset.card_bij (fun i _ => i.1) ?_ ?_ ?_ · intro i hi simp only [finPrefix, mem_filter, mem_univ, true_and] at hi exact mem_range.mpr hi · intro i₁ _ i₂ _ heq exact Fin.ext heq · intro a ha rw [mem_range] at ha refine ⟨⟨a, lt_of_lt_of_le ha hxn⟩, ?_, rfl⟩ simp [finPrefix, ha] rw [hbij, card_range] lemma mem_finPrefix {n x : ℕ} {i : Fin n} : i ∈ finPrefix n x ↔ i.1 < x := by simp [finPrefix] /-- Explicit colex initial segment in `Finset (Finset (Fin n))` associated to a `k`-cascade `a`: - `[]` maps to `∅`; - `x :: xs` maps to all `k`-subsets of `{0, ..., x - 1}` together with `{x} ∪ t` for every `t ∈ cascadeFamily n (k - 1) xs`. -/ def cascadeFamily (n : ℕ) : ℕ → List ℕ → Finset (Finset (Fin n)) | _, [] => ∅ | k, x :: xs => (finPrefix n x).powersetCard k ∪ if hx : x < n then (cascadeFamily n (k - 1) xs).image (insert ⟨x, hx⟩) else ∅ lemma cascadeFamily_subset_finPrefix : ∀ {n k B : ℕ} {a : List ℕ}, (∀ y ∈ a, y < B) → ∀ s ∈ cascadeFamily n k a, ∀ i ∈ s, i.1 < B | _, _, _, [], _, _, hs, _, _ => by simp [cascadeFamily] at hs | n, k, B, x :: xs, hB, s, hs, i, hi => by simp only [cascadeFamily, mem_union] at hs have hxB : x < B := hB x (by simp) rcases hs with htop | hrest · rw [mem_powersetCard] at htop exact lt_trans (mem_finPrefix.mp (htop.1 hi)) hxB · split_ifs at hrest with hx · rw [mem_image] at hrest rcases hrest with ⟨t, ht, rfl⟩ rw [mem_insert] at hi rcases hi with rfl | hit · exact hxB · exact cascadeFamily_subset_finPrefix (fun y hy => hB y (by simp [hy])) t ht i hit · simp at hrest lemma cascadeFamily_sized : ∀ {n k : ℕ} {a : List ℕ}, IsKCascade k a → (∀ y ∈ a, y < n) → (cascadeFamily n k a : Set (Finset (Fin n))).Sized k | _, _, [], _, _, s, hs => by simp [cascadeFamily] at hs | _, 0, _ :: _, h, _, _, _ => False.elim h | n, k + 1, x :: xs, ⟨_, hlt, hxs⟩, hn, s, hs => by simp only [SetLike.mem_coe, cascadeFamily, mem_union] at hs have hx : x < n := hn x (by simp) rw [dif_pos hx] at hs rcases hs with htop | hrest · exact (mem_powersetCard.mp htop).2 · rw [mem_image] at hrest rcases hrest with ⟨t, ht, rfl⟩ have hnotmem : (⟨x, hx⟩ : Fin n) ∉ t := by intro hmem have hlt' := cascadeFamily_subset_finPrefix hlt t ht ⟨x, hx⟩ hmem exact Nat.lt_irrefl x hlt' have htcard : t.card = k := cascadeFamily_sized hxs (fun y hy => hn y (by simp [hy])) ht rw [card_insert_of_notMem hnotmem, htcard] /-- Exact cardinality of `cascadeFamily n k a` equals `cascadeVal k a`. -/ theorem card_cascadeFamily : ∀ {n k : ℕ} {a : List ℕ}, IsKCascade k a → (∀ y ∈ a, y < n) → (cascadeFamily n k a).card = cascadeVal k a | _, _, [], _, _ => rfl | _, 0, _ :: _, h, _ => False.elim h | n, k + 1, x :: xs, ⟨_, hlt, hxs⟩, hn => by have hx : x < n := hn x (by simp) simp only [cascadeFamily, dif_pos hx, cascadeVal, Nat.add_sub_cancel] have hdisj : Disjoint ((finPrefix n x).powersetCard (k + 1)) ((cascadeFamily n k xs).image (insert ⟨x, hx⟩)) := by rw [disjoint_left] intro s hs1 hs2 rw [mem_powersetCard] at hs1 rw [mem_image] at hs2 rcases hs2 with ⟨t, _, rfl⟩ have hxmem : (⟨x, hx⟩ : Fin n) ∈ insert ⟨x, hx⟩ t := mem_insert_self _ _ have hxlt := mem_finPrefix.mp (hs1.1 hxmem) exact Nat.lt_irrefl x hxlt have hinj : Set.InjOn (insert (⟨x, hx⟩ : Fin n)) (cascadeFamily n k xs : Set (Finset (Fin n))) := by intro t₁ ht₁ t₂ ht₂ heq have h1 : (⟨x, hx⟩ : Fin n) ∉ t₁ := fun hm => Nat.lt_irrefl x (cascadeFamily_subset_finPrefix hlt t₁ ht₁ ⟨x, hx⟩ hm) have h2 : (⟨x, hx⟩ : Fin n) ∉ t₂ := fun hm => Nat.lt_irrefl x (cascadeFamily_subset_finPrefix hlt t₂ ht₂ ⟨x, hx⟩ hm) ext z by_cases hz : z = ⟨x, hx⟩ · subst hz; simp [h1, h2] · have := Finset.ext_iff.mp heq z simpa [mem_insert, hz] using this rw [card_union_of_disjoint hdisj, card_powersetCard, card_finPrefix (Nat.le_of_lt hx), card_image_of_injOn hinj, card_cascadeFamily hxs (fun y hy => hn y (by simp [hy]))] /-- `cascadeFamily n k a` is an initial segment of the colexicographic order on `k`-subsets. -/ theorem isInitSeg_cascadeFamily : ∀ {n k : ℕ} {a : List ℕ}, IsKCascade k a → (∀ y ∈ a, y < n) → Finset.Colex.IsInitSeg (cascadeFamily n k a) k | _, _, [], _, _ => by refine ⟨fun s hs => by simp [cascadeFamily] at hs, fun A B hA _ => by simp [cascadeFamily] at hA⟩ | _, 0, _ :: _, h, _ => False.elim h | n, k + 1, x :: xs, ha@⟨_, hlt, hxs⟩, hn => by have hx : x < n := hn x (by simp) refine ⟨cascadeFamily_sized ha hn, ?_⟩ rintro A B hA ⟨hBA, hcard⟩ have hcardB : B.card = k + 1 := hcard rw [Finset.Colex.toColex_lt_toColex] at hBA rcases hBA with ⟨hBA_ne, hBA_le⟩ simp only [cascadeFamily, dif_pos hx, mem_union] at hA ⊢ rcases hA with hAtop | hArest · left rw [mem_powersetCard] at hAtop ⊢ refine ⟨fun z hzB => ?_, hcardB⟩ rw [mem_finPrefix] by_cases hzA : z ∈ A · exact mem_finPrefix.mp (hAtop.1 hzA) · rcases hBA_le hzB hzA with ⟨b, hbA, _, hzb⟩ exact lt_of_le_of_lt (Fin.le_def.mp hzb) (mem_finPrefix.mp (hAtop.1 hbA)) · rw [mem_image] at hArest rcases hArest with ⟨t, ht, rfl⟩ have hp_not_t : (⟨x, hx⟩ : Fin n) ∉ t := fun hm => Nat.lt_irrefl x (cascadeFamily_subset_finPrefix hlt t ht ⟨x, hx⟩ hm) have hA_le : ∀ z ∈ insert (⟨x, hx⟩ : Fin n) t, z.1 ≤ x := by intro z hz rw [mem_insert] at hz rcases hz with rfl | hzt · exact le_rfl · exact Nat.le_of_lt (cascadeFamily_subset_finPrefix hlt t ht z hzt) by_cases hpB : (⟨x, hx⟩ : Fin n) ∈ B · right rw [mem_image] have ht'_card : (B.erase ⟨x, hx⟩).card = k := by rw [card_erase_of_mem hpB, hcardB]; simp have ht_card : t.card = k := cascadeFamily_sized hxs (fun y hy => hn y (by simp [hy])) ht have ht'_lt : toColex (B.erase ⟨x, hx⟩) < toColex t := by rw [Finset.Colex.toColex_lt_toColex] refine ⟨fun heq => hBA_ne (by rw [← insert_erase hpB, heq]), fun z hz' hzt => ?_⟩ have hzp : z ≠ ⟨x, hx⟩ := (mem_erase.mp hz').1 have hzB : z ∈ B := mem_of_mem_erase hz' have hzA : z ∉ insert (⟨x, hx⟩ : Fin n) t := fun hm => hzt ((mem_insert.mp hm).resolve_left hzp) rcases hBA_le hzB hzA with ⟨b, hbA, hbB, hzb⟩ have hbp : b ≠ ⟨x, hx⟩ := fun h => hbB (h ▸ hpB) exact ⟨b, (mem_insert.mp hbA).resolve_left hbp, fun h => hbB (mem_of_mem_erase h), hzb⟩ have hseg := isInitSeg_cascadeFamily hxs (fun y hy => hn y (by simp [hy])) refine ⟨B.erase ⟨x, hx⟩, hseg.2 ht ⟨ht'_lt, ht'_card⟩, ?_⟩ exact insert_erase hpB · left rw [mem_powersetCard] refine ⟨fun z hzB => ?_, hcardB⟩ rw [mem_finPrefix] have hzp : z ≠ ⟨x, hx⟩ := fun heq => hpB (heq ▸ hzB) have hzne : z.1 ≠ x := fun heq => hzp (Fin.ext heq) by_cases hzA : z ∈ insert (⟨x, hx⟩ : Fin n) t · have hzt : z ∈ t := (mem_insert.mp hzA).resolve_left hzp exact cascadeFamily_subset_finPrefix hlt t ht z hzt · rcases hBA_le hzB hzA with ⟨b, hbA, _, hzb⟩ have hzle : z.1 ≤ x := le_trans (Fin.le_def.mp hzb) (hA_le b hbA) omega /-- Shadow of `powersetCard (k + 1) s` equals `powersetCard k s` whenever `k + 1 ≤ s.card`. -/ lemma shadow_powersetCard {α : Type*} [DecidableEq α] {s : Finset α} {k : ℕ} (hk : k + 1 ≤ s.card) : ∂ (s.powersetCard (k + 1)) = s.powersetCard k := by ext t rw [mem_shadow_iff_insert_mem, mem_powersetCard] constructor · rintro ⟨a, ha, hat⟩ rw [mem_powersetCard] at hat refine ⟨(subset_insert a t).trans hat.1, ?_⟩ rw [card_insert_of_notMem ha] at hat omega · rintro ⟨hts, htcard⟩ have hne : (s \ t).Nonempty := by rw [← card_pos, card_sdiff_of_subset hts, htcard] omega rcases hne with ⟨a, ha⟩ rw [mem_sdiff] at ha refine ⟨a, ha.2, mem_powersetCard.mpr ⟨insert_subset ha.1 hts, ?_⟩⟩ rw [card_insert_of_notMem ha.2, htcard] /-- Elements of `∂ (cascadeFamily n k a)` inherit the strict upper bound of `a`. -/ lemma shadow_cascadeFamily_subset_finPrefix {n k B : ℕ} {a : List ℕ} (hB : ∀ y ∈ a, y < B) : ∀ t ∈ ∂ (cascadeFamily n k a), ∀ i ∈ t, i.1 < B := by intro t ht i hi rw [mem_shadow_iff_insert_mem] at ht rcases ht with ⟨w, _, hwt⟩ exact cascadeFamily_subset_finPrefix hB (insert w t) hwt i (mem_insert_of_mem hi) /-- Iterated shadow of a set family inherits any element upper bound. -/ lemma iterShadow_subset_finPrefix {n B : ℕ} : ∀ (r : ℕ) (ℱ : Finset (Finset (Fin n))), (∀ s ∈ ℱ, ∀ i ∈ s, i.1 < B) → ∀ t ∈ ∂^[r] ℱ, ∀ i ∈ t, i.1 < B | 0, _, hF, t, ht, i, hi => hF t ht i hi | r + 1, ℱ, hF, t, ht, i, hi => by rw [Function.iterate_succ_apply'] at ht rw [mem_shadow_iff_insert_mem] at ht rcases ht with ⟨w, _, hwt⟩ exact iterShadow_subset_finPrefix r ℱ hF (insert w t) hwt i (mem_insert_of_mem hi) private lemma shadow_union_eq {α : Type*} [DecidableEq α] (𝒜 ℬ : Finset (Finset α)) : ∂ (𝒜 ∪ ℬ) = ∂ 𝒜 ∪ ∂ ℬ := by ext t simp only [mem_union, mem_shadow_iff_insert_mem] constructor · rintro ⟨a, ha, h | h⟩ · exact Or.inl ⟨a, ha, h⟩ · exact Or.inr ⟨a, ha, h⟩ · rintro (⟨a, ha, h⟩ | ⟨a, ha, h⟩) · exact ⟨a, ha, Or.inl h⟩ · exact ⟨a, ha, Or.inr h⟩ /-- Exact structural recursion for the shadow of `cascadeFamily n (k + 1) (x :: xs)`. -/ lemma shadow_cascadeFamily_cons {n k x : ℕ} {xs : List ℕ} (ha : IsKCascade (k + 1) (x :: xs)) (hn : ∀ y ∈ x :: xs, y < n) : ∂ (cascadeFamily n (k + 1) (x :: xs)) = (finPrefix n x).powersetCard k ∪ (∂ (cascadeFamily n k xs)).image (insert ⟨x, hn x (by simp)⟩) := by have hx : x < n := hn x (by simp) set p : Fin n := ⟨x, hx⟩ simp only [cascadeFamily, dif_pos hx] have htop : ∂ ((finPrefix n x).powersetCard (k + 1)) = (finPrefix n x).powersetCard k := shadow_powersetCard (by rw [card_finPrefix (Nat.le_of_lt hx)]; exact ha.1) rw [shadow_union_eq, htop] ext t simp only [mem_union, mem_shadow_iff_insert_mem, mem_image, Nat.add_sub_cancel] constructor · rintro (ht | ⟨w, hw, ⟨u, hu, heq⟩⟩) · exact Or.inl ht · by_cases hwp : w = p · left have htu : t = u := by have hp_not_u : p ∉ u := fun hm => Nat.lt_irrefl x (cascadeFamily_subset_finPrefix ha.2.1 u hu p hm) ext z by_cases hz : z = p · subst hz; simp [hwp ▸ hw, hp_not_u] · have hzp' : z ≠ ⟨x, hx⟩ := hz have := Finset.ext_iff.mp heq z simpa [mem_insert, hwp, hz, hzp'] using this.symm subst htu rw [mem_powersetCard] refine ⟨fun z hz => mem_finPrefix.mpr (cascadeFamily_subset_finPrefix ha.2.1 t hu z hz), cascadeFamily_sized ha.2.2 (fun y hy => hn y (by simp [hy])) hu⟩ · right have hp_mem_t : p ∈ t := by have : p ∈ insert w t := by rw [← heq]; exact mem_insert_self p u exact (mem_insert.mp this).resolve_left (Ne.symm hwp) refine ⟨t.erase p, ⟨w, fun hwm => hw (mem_of_mem_erase hwm), ?_⟩, insert_erase hp_mem_t⟩ have htu : insert w (t.erase p) = u := by have hp_not_u : p ∉ u := fun hm => Nat.lt_irrefl x (cascadeFamily_subset_finPrefix ha.2.1 u hu p hm) ext z by_cases hz : z = p · subst hz; simp [Ne.symm hwp, hp_not_u] · have hzp' : z ≠ ⟨x, hx⟩ := hz have := Finset.ext_iff.mp heq z simpa [mem_insert, mem_erase, hz, hzp'] using this.symm rwa [htu] · rintro (ht | ⟨u, ⟨w, hw, hwu⟩, rfl⟩) · exact Or.inl ht · right have hwp : w ≠ p := by intro heq subst heq have := cascadeFamily_subset_finPrefix ha.2.1 (insert p u) hwu p (mem_insert_self p u) exact Nat.lt_irrefl x this refine ⟨w, fun hmem => ?_, insert w u, hwu, (insert_comm w p u).symm⟩ rw [mem_insert] at hmem exact hw (hmem.resolve_left hwp) /-- **Exact Shadow Formula for `cascadeFamily`**: `#(∂ (cascadeFamily n k a)) = cascadeShadow k a`. -/ theorem card_shadow_cascadeFamily : ∀ {n k : ℕ} {a : List ℕ}, IsKCascade k a → (∀ y ∈ a, y < n) → (∂ (cascadeFamily n k a)).card = cascadeShadow k a | _, _, [], _, _ => by simp [cascadeFamily, cascadeShadow] | _, 0, _ :: _, h, _ => False.elim h | n, k + 1, x :: xs, ha@⟨_, hlt, hxs⟩, hn => by have hx : x < n := hn x (by simp) set p : Fin n := ⟨x, hx⟩ rw [shadow_cascadeFamily_cons ha hn] have hdisj : Disjoint ((finPrefix n x).powersetCard k) ((∂ (cascadeFamily n k xs)).image (insert p)) := by rw [disjoint_left] intro t ht1 ht2 rw [mem_powersetCard] at ht1 rw [mem_image] at ht2 rcases ht2 with ⟨u, _, rfl⟩ exact Nat.lt_irrefl x (mem_finPrefix.mp (ht1.1 (mem_insert_self p u))) have hinj : Set.InjOn (insert p) (∂ (cascadeFamily n k xs) : Set (Finset (Fin n))) := by intro u₁ hu₁ u₂ hu₂ heq have h1 : p ∉ u₁ := fun hm => Nat.lt_irrefl x (shadow_cascadeFamily_subset_finPrefix hlt u₁ hu₁ p hm) have h2 : p ∉ u₂ := fun hm => Nat.lt_irrefl x (shadow_cascadeFamily_subset_finPrefix hlt u₂ hu₂ p hm) ext z by_cases hz : z = p · subst hz; simp [h1, h2] · have := Finset.ext_iff.mp heq z simpa [mem_insert, hz] using this rw [card_union_of_disjoint hdisj, card_powersetCard, card_finPrefix (Nat.le_of_lt hx), card_image_of_injOn hinj, card_shadow_cascadeFamily hxs (fun y hy => hn y (by simp [hy]))] simp [cascadeShadow] /-- Exact structural recursion for the `r`-th iterated shadow of `cascadeFamily n k (x :: xs)` for `r ≤ k`. -/ lemma iterShadow_cascadeFamily_cons : ∀ (r : ℕ) {n k x : ℕ} {xs : List ℕ}, r ≤ k → IsKCascade k (x :: xs) → (hn : ∀ y ∈ x :: xs, y < n) → ∂^[r] (cascadeFamily n k (x :: xs)) = (finPrefix n x).powersetCard (k - r) ∪ (∂^[r] (cascadeFamily n (k - 1) xs)).image (insert ⟨x, hn x (by simp)⟩) | 0, n, k, x, xs, _, _, hn => by simp [cascadeFamily, dif_pos (hn x (by simp))] | r + 1, n, k, x, xs, hrk, ha, hn => by cases k with | zero => omega | succ k => have hx : x < n := hn x (by simp) set p : Fin n := ⟨x, hx⟩ have hrk' : r ≤ k := Nat.le_of_succ_le_succ hrk rw [Function.iterate_succ_apply'] have hih := iterShadow_cascadeFamily_cons r (Nat.le_succ_of_le hrk') ha hn rw [hih] have hkr : k + 1 - r = (k - r) + 1 := by omega rw [hkr] have htop : ∂ ((finPrefix n x).powersetCard (k - r + 1)) = (finPrefix n x).powersetCard (k - r) := by apply shadow_powersetCard rw [card_finPrefix (Nat.le_of_lt hx)] have := ha.1; omega have hbound : ∀ u ∈ ∂^[r] (cascadeFamily n k xs), ∀ i ∈ u, i.1 < x := iterShadow_subset_finPrefix r _ (cascadeFamily_subset_finPrefix ha.2.1) have hsized_r : ∀ u ∈ ∂^[r] (cascadeFamily n k xs), u.card = k - r := by have h0 : (cascadeFamily n k xs : Set (Finset (Fin n))).Sized k := cascadeFamily_sized ha.2.2 (fun y hy => hn y (by simp [hy])) intro u hu have hiter : (∂^[r] (cascadeFamily n k xs) : Set (Finset (Fin n))).Sized (k - r) := by clear hu hrk hrk' hih hkr htop hbound induction r with | zero => simpa using h0 | succ j ihj => rw [Function.iterate_succ_apply'] simpa [Nat.sub_sub] using ihj.shadow exact hiter hu rw [shadow_union_eq, htop] ext t simp only [Nat.succ_sub_succ, mem_union, mem_shadow_iff_insert_mem, mem_image, Function.iterate_succ_apply'] constructor · rintro (ht | ⟨w, hw, ⟨u, hu, heq⟩⟩) · exact Or.inl ht · by_cases hwp : w = p · left have htu : t = u := by have hp_not_u : p ∉ u := fun hm => Nat.lt_irrefl x (hbound u hu p hm) ext z by_cases hz : z = p · subst hz; simp [hwp ▸ hw, hp_not_u] · have hzp' : z ≠ ⟨x, hx⟩ := hz have := Finset.ext_iff.mp heq z simpa [mem_insert, hwp, hz, hzp'] using this.symm subst htu exact mem_powersetCard.mpr ⟨fun z hz => mem_finPrefix.mpr (hbound t hu z hz), hsized_r t hu⟩ · right have hp_mem_t : p ∈ t := by have : p ∈ insert w t := by rw [← heq]; exact mem_insert_self p u exact (mem_insert.mp this).resolve_left (Ne.symm hwp) refine ⟨t.erase p, ⟨w, fun hwm => hw (mem_of_mem_erase hwm), ?_⟩, insert_erase hp_mem_t⟩ have htu : insert w (t.erase p) = u := by have hp_not_u : p ∉ u := fun hm => Nat.lt_irrefl x (hbound u hu p hm) ext z by_cases hz : z = p · subst hz; simp [Ne.symm hwp, hp_not_u] · have hzp' : z ≠ ⟨x, hx⟩ := hz have := Finset.ext_iff.mp heq z simpa [mem_insert, mem_erase, hz, hzp'] using this.symm rwa [htu] · rintro (ht | ⟨u, ⟨w, hw, hwu⟩, rfl⟩) · exact Or.inl ht · right have hwp : w ≠ p := by intro heq; subst heq exact Nat.lt_irrefl x (hbound (insert p u) hwu p (mem_insert_self p u)) refine ⟨w, fun hmem => hw ((mem_insert.mp hmem).resolve_left hwp), insert w u, hwu, (insert_comm w p u).symm⟩ /-- The `r`-th iterated shadow of a `k`-sized family vanishes when `k < r`. -/ lemma iterShadow_eq_empty_of_lt {α : Type*} [DecidableEq α] : ∀ {r k : ℕ} {ℱ : Finset (Finset α)}, k < r → (ℱ : Set (Finset α)).Sized k → ∂^[r] ℱ = ∅ | 0, _, _, hlt, _ => absurd hlt (Nat.not_lt_zero _) | r + 1, 0, ℱ, _, hsz => by have hsub : ℱ ⊆ {∅} := by intro s hs rw [mem_singleton, ← card_eq_zero] exact hsz hs have h1 : ∂ ℱ = ∅ := by rw [← subset_empty] exact (shadow_monotone hsub).trans (by simp) rw [Function.iterate_succ_apply, h1] clear hsz hsub h1 have : ∀ j : ℕ, ∂^[j] (∅ : Finset (Finset α)) = ∅ := by intro j induction j with | zero => rfl | succ j ih => rw [Function.iterate_succ_apply', ih]; simp exact this r | r + 1, k + 1, ℱ, hlt, hsz => by rw [Function.iterate_succ_apply] exact iterShadow_eq_empty_of_lt (Nat.lt_of_succ_lt_succ hlt) hsz.shadow /-- **Exact Iterated Shadow Formula for `cascadeFamily`**: for every `r : ℕ`, `#(∂^[r] (cascadeFamily n k a)) = cascadeIterShadow r k a`. -/ theorem card_iterShadow_cascadeFamily (r : ℕ) : ∀ {n k : ℕ} {a : List ℕ}, IsKCascade k a → (∀ y ∈ a, y < n) → (∂^[r] (cascadeFamily n k a)).card = cascadeIterShadow r k a | n, _, [], _, _ => by simp only [cascadeFamily, cascadeIterShadow] have : ∂^[r] (∅ : Finset (Finset (Fin n))) = ∅ := by induction r with | zero => rfl | succ j ih => rw [Function.iterate_succ_apply', ih]; simp simp [this] | _, 0, _ :: _, h, _ => False.elim h | n, k + 1, x :: xs, ha@⟨_, hlt, hxs⟩, hn => by by_cases hrk : r ≤ k + 1 · have hx : x < n := hn x (by simp) set p : Fin n := ⟨x, hx⟩ rw [iterShadow_cascadeFamily_cons r hrk ha hn] have hbound : ∀ u ∈ ∂^[r] (cascadeFamily n k xs), ∀ i ∈ u, i.1 < x := iterShadow_subset_finPrefix r _ (cascadeFamily_subset_finPrefix hlt) have hdisj : Disjoint ((finPrefix n x).powersetCard (k + 1 - r)) ((∂^[r] (cascadeFamily n k xs)).image (insert p)) := by rw [disjoint_left] intro t ht1 ht2 rw [mem_powersetCard] at ht1 rw [mem_image] at ht2 rcases ht2 with ⟨u, _, rfl⟩ exact Nat.lt_irrefl x (mem_finPrefix.mp (ht1.1 (mem_insert_self p u))) have hinj : Set.InjOn (insert p) (∂^[r] (cascadeFamily n k xs) : Set (Finset (Fin n))) := by intro u₁ hu₁ u₂ hu₂ heq have h1 : p ∉ u₁ := fun hm => Nat.lt_irrefl x (hbound u₁ hu₁ p hm) have h2 : p ∉ u₂ := fun hm => Nat.lt_irrefl x (hbound u₂ hu₂ p hm) ext z by_cases hz : z = p · subst hz; simp [h1, h2] · have := Finset.ext_iff.mp heq z simpa [mem_insert, hz] using this change ((finPrefix n x).powersetCard (k + 1 - r) ∪ (∂^[r] (cascadeFamily n k xs)).image (insert p)).card = cascadeIterShadow r (k + 1) (x :: xs) rw [card_union_of_disjoint hdisj, card_powersetCard, card_finPrefix (Nat.le_of_lt hx), card_image_of_injOn hinj, card_iterShadow_cascadeFamily r hxs (fun y hy => hn y (by simp [hy]))] simp [cascadeIterShadow, hrk] · push Not at hrk have hempty := iterShadow_eq_empty_of_lt hrk (cascadeFamily_sized ha hn) simp [hempty, cascadeIterShadow, Nat.not_le.mpr hrk] /-! ## Section 3: Full Numerical & Iterated Kruskal–Katona Cascade Theorems -/ /-- Exact `m`-element colex initial segment of `k`-subsets of `Fin n` (for `m ≤ n.choose k`). -/ def colexInitSeg (n k m : ℕ) : Finset (Finset (Fin n)) := if m = n.choose k then (Finset.univ : Finset (Fin n)).powersetCard k else cascadeFamily n k (toCascade k m) lemma card_colexInitSeg {n k m : ℕ} (hk : 1 ≤ k) (hm : m ≤ n.choose k) : (colexInitSeg n k m).card = m := by unfold colexInitSeg split_ifs with heq · rw [card_powersetCard, card_univ, Fintype.card_fin, heq] · have hlt : m < n.choose k := lt_of_le_of_ne hm heq rw [card_cascadeFamily (toCascade_isKCascade k m) (toCascade_lt_n hlt), cascadeVal_toCascade hk m] lemma isInitSeg_colexInitSeg {n k m : ℕ} (hm : m ≤ n.choose k) : Finset.Colex.IsInitSeg (colexInitSeg n k m) k := by unfold colexInitSeg split_ifs with heq · refine ⟨Set.sized_powersetCard _ _, ?_⟩ rintro A B _ ⟨_, hcard⟩ exact mem_powersetCard.mpr ⟨subset_univ _, hcard⟩ · have hlt : m < n.choose k := lt_of_le_of_ne hm heq exact isInitSeg_cascadeFamily (toCascade_isKCascade k m) (toCascade_lt_n hlt) lemma card_shadow_colexInitSeg {n k m : ℕ} (hk : 1 ≤ k) (hm : m ≤ n.choose k) : (∂ (colexInitSeg n k m)).card = cascadeShadow k (toCascade k m) := by unfold colexInitSeg split_ifs with heq · subst heq cases k with | zero => omega | succ k => by_cases hkn : k + 1 ≤ n · have hto : toCascade (k + 1) (n.choose (k + 1)) = [n] := by have hcas : IsKCascade (k + 1) [n] := ⟨hkn, fun _ hy => by simp at hy, isKCascade_nil k⟩ have hval : cascadeVal (k + 1) [n] = n.choose (k + 1) := by simp [cascadeVal] exact isKCascade_unique (toCascade_isKCascade _ _) hcas ((cascadeVal_toCascade (by omega) _).trans hval.symm) rw [hto, shadow_powersetCard (by simpa using hkn), card_powersetCard, card_univ, Fintype.card_fin] simp [cascadeShadow] · have hz : n.choose (k + 1) = 0 := Nat.choose_eq_zero_of_lt (by omega) rw [hz, toCascade_zero_right] have hempty : (Finset.univ : Finset (Fin n)).powersetCard (k + 1) = ∅ := by rw [← card_eq_zero, card_powersetCard, card_univ, Fintype.card_fin, hz] simp [hempty, cascadeShadow] · have hlt : m < n.choose k := lt_of_le_of_ne hm heq exact card_shadow_cascadeFamily (toCascade_isKCascade k m) (toCascade_lt_n hlt) lemma card_iterShadow_colexInitSeg {n k m r : ℕ} (hk : 1 ≤ k) (hm : m ≤ n.choose k) : (∂^[r] (colexInitSeg n k m)).card = cascadeIterShadow r k (toCascade k m) := by unfold colexInitSeg split_ifs with heq · subst heq cases k with | zero => omega | succ k => by_cases hkn : k + 1 ≤ n · have hto : toCascade (k + 1) (n.choose (k + 1)) = [n] := by have hcas : IsKCascade (k + 1) [n] := ⟨hkn, fun _ hy => by simp at hy, isKCascade_nil k⟩ have hval : cascadeVal (k + 1) [n] = n.choose (k + 1) := by simp [cascadeVal] exact isKCascade_unique (toCascade_isKCascade _ _) hcas ((cascadeVal_toCascade (by omega) _).trans hval.symm) rw [hto] by_cases hrk : r ≤ k + 1 · have hiter : ∂^[r] ((Finset.univ : Finset (Fin n)).powersetCard (k + 1)) = (Finset.univ : Finset (Fin n)).powersetCard (k + 1 - r) := by clear hto induction r with | zero => simp | succ j ih => rw [Function.iterate_succ_apply', ih (Nat.le_of_succ_le hrk)] have hsub : k + 1 - j = (k + 1 - (j + 1)) + 1 := by omega rw [hsub] exact shadow_powersetCard (by rw [card_univ, Fintype.card_fin]; omega) rw [hiter, card_powersetCard, card_univ, Fintype.card_fin] simp [cascadeIterShadow, hrk] · push Not at hrk have hempty := iterShadow_eq_empty_of_lt hrk (Set.sized_powersetCard (Finset.univ : Finset (Fin n)) (k + 1)) simp [hempty, cascadeIterShadow, Nat.not_le.mpr hrk] · have hz : n.choose (k + 1) = 0 := Nat.choose_eq_zero_of_lt (by omega) rw [hz, toCascade_zero_right] have hempty : (Finset.univ : Finset (Fin n)).powersetCard (k + 1) = ∅ := by rw [← card_eq_zero, card_powersetCard, card_univ, Fintype.card_fin, hz] have hiter : ∂^[r] (∅ : Finset (Finset (Fin n))) = ∅ := by induction r with | zero => rfl | succ j ih => rw [Function.iterate_succ_apply', ih]; simp simp [hempty, hiter, cascadeIterShadow] · have hlt : m < n.choose k := lt_of_le_of_ne hm heq exact card_iterShadow_cascadeFamily r (toCascade_isKCascade k m) (toCascade_lt_n hlt) /-- **Full Numerical Kruskal–Katona Cascade Theorem**: for every `k`-uniform family `𝒜` of subsets of `Fin n` (`k ≥ 1`), `#(∂ 𝒜) ≥ cascadeShadow k (toCascade k #𝒜)`. -/ theorem kruskal_katona_cascade {n k : ℕ} (hk : 1 ≤ k) {𝒜 : Finset (Finset (Fin n))} (h𝒜 : (𝒜 : Set (Finset (Fin n))).Sized k) : cascadeShadow k (toCascade k 𝒜.card) ≤ (∂ 𝒜).card := by have hm : 𝒜.card ≤ n.choose k := by have hsub : 𝒜 ⊆ (Finset.univ : Finset (Fin n)).powersetCard k := by intro s hs exact mem_powersetCard.mpr ⟨subset_univ _, h𝒜 hs⟩ calc 𝒜.card ≤ ((Finset.univ : Finset (Fin n)).powersetCard k).card := card_le_card hsub _ = n.choose k := by rw [card_powersetCard, card_univ, Fintype.card_fin] have hcard : (colexInitSeg n k 𝒜.card).card ≤ 𝒜.card := by rw [card_colexInitSeg hk hm] have hkk := Finset.kruskal_katona h𝒜 hcard (isInitSeg_colexInitSeg hm) rwa [card_shadow_colexInitSeg hk hm] at hkk /-- **Sharpness of the Kruskal–Katona Cascade Bound**: for every `k ≥ 1` and `m ≤ n.choose k`, `colexInitSeg n k m` is a `k`-uniform family of size `m` achieving equality `#(∂ 𝒞) = cascadeShadow k (toCascade k m)`. -/ theorem kruskal_katona_cascade_sharp {n k m : ℕ} (hk : 1 ≤ k) (hm : m ≤ n.choose k) : ∃ 𝒞 : Finset (Finset (Fin n)), (𝒞 : Set (Finset (Fin n))).Sized k ∧ 𝒞.card = m ∧ (∂ 𝒞).card = cascadeShadow k (toCascade k m) := ⟨colexInitSeg n k m, (isInitSeg_colexInitSeg hm).1, card_colexInitSeg hk hm, card_shadow_colexInitSeg hk hm⟩ /-- **Full Iterated Kruskal–Katona Cascade Theorem**: for every `k ≥ 1`, every `r : ℕ`, and every `k`-uniform family `𝒜` on `Fin n`, `#(∂^[r] 𝒜) ≥ cascadeIterShadow r k (toCascade k #𝒜)`, with sharpness attained by `colexInitSeg`. -/ theorem kruskal_katona_iterated_cascade {n k r : ℕ} (hk : 1 ≤ k) {𝒜 : Finset (Finset (Fin n))} (h𝒜 : (𝒜 : Set (Finset (Fin n))).Sized k) : cascadeIterShadow r k (toCascade k 𝒜.card) ≤ (∂^[r] 𝒜).card := by have hm : 𝒜.card ≤ n.choose k := by have hsub : 𝒜 ⊆ (Finset.univ : Finset (Fin n)).powersetCard k := fun s hs => mem_powersetCard.mpr ⟨subset_univ _, h𝒜 hs⟩ calc 𝒜.card ≤ ((Finset.univ : Finset (Fin n)).powersetCard k).card := card_le_card hsub _ = n.choose k := by rw [card_powersetCard, card_univ, Fintype.card_fin] have hcard : (colexInitSeg n k 𝒜.card).card ≤ 𝒜.card := by rw [card_colexInitSeg hk hm] have hkk := Finset.iterated_kk (k := r) h𝒜 hcard (isInitSeg_colexInitSeg hm) rwa [card_iterShadow_colexInitSeg hk hm] at hkk /-! ## Section 4: Left-Shifting Operators and Shadow Non-Expansion -/ /-- Element-level `(i, j)`-shift: replaces `j` by `i` when `j ∈ s` and `i ∉ s`. -/ def shiftSet {n : ℕ} (i j : Fin n) (s : Finset (Fin n)) : Finset (Fin n) := if j ∈ s ∧ i ∉ s then insert i (s.erase j) else s /-- Family-level `(i, j)`-left-shift: shifts each `s ∈ 𝒜` to `shiftSet i j s` unless that shifted set is already in `𝒜`. -/ def shiftFamily {n : ℕ} (i j : Fin n) (𝒜 : Finset (Finset (Fin n))) : Finset (Finset (Fin n)) := 𝒜.image (fun s => if shiftSet i j s ∈ 𝒜 then s else shiftSet i j s) /-- A family `𝒜` is `(i, j)`-shifted if `shiftFamily i j 𝒜 = 𝒜`. -/ def IsShiftedAt {n : ℕ} (i j : Fin n) (𝒜 : Finset (Finset (Fin n))) : Prop := ∀ s ∈ 𝒜, shiftSet i j s ∈ 𝒜 /-- A family `𝒜` is left-shifted if it is `(i, j)`-shifted for all `i < j`. -/ def IsLeftShifted {n : ℕ} (𝒜 : Finset (Finset (Fin n))) : Prop := ∀ i j : Fin n, i < j → IsShiftedAt i j 𝒜 lemma card_shiftSet {n : ℕ} (i j : Fin n) (s : Finset (Fin n)) : (shiftSet i j s).card = s.card := by unfold shiftSet split_ifs with h · have hi : i ∉ s.erase j := fun hm => h.2 (mem_of_mem_erase hm) rw [card_insert_of_notMem hi, card_erase_of_mem h.1] have hpos : 0 < s.card := card_pos.mpr ⟨j, h.1⟩ omega · rfl lemma shiftSet_idem {n : ℕ} (i j : Fin n) (s : Finset (Fin n)) : shiftSet i j (shiftSet i j s) = shiftSet i j s := by unfold shiftSet split_ifs with h1 h2 · exfalso have hij : i ≠ j := fun heq => h1.2 (heq ▸ h1.1) have hjm : j ∈ insert i (s.erase j) := h2.1 rw [mem_insert] at hjm exact notMem_erase j s (hjm.resolve_left (Ne.symm hij)) · rfl · simp lemma shiftSet_injOn_changed {n : ℕ} (i j : Fin n) {s₁ s₂ : Finset (Fin n)} (h1 : j ∈ s₁ ∧ i ∉ s₁) (h2 : j ∈ s₂ ∧ i ∉ s₂) (heq : shiftSet i j s₁ = shiftSet i j s₂) : s₁ = s₂ := by simp only [shiftSet, if_pos h1, if_pos h2] at heq have hij : i ≠ j := fun h => h1.2 (h ▸ h1.1) ext x by_cases hxi : x = i · subst hxi; simp [h1.2, h2.2] · by_cases hxj : x = j · subst hxj; simp [h1.1, h2.1] · have := Finset.ext_iff.mp heq x simpa [mem_insert, mem_erase, hxi, hxj] using this /-- Left-shifting preserves cardinality. -/ theorem card_shiftFamily {n : ℕ} (i j : Fin n) (𝒜 : Finset (Finset (Fin n))) : (shiftFamily i j 𝒜).card = 𝒜.card := by unfold shiftFamily apply card_image_of_injOn intro s₁ hs₁ s₂ hs₂ heq rw [SetLike.mem_coe] at hs₁ hs₂ dsimp only at heq split_ifs at heq with h1 h2 h2 · exact heq · exfalso; exact h2 (heq ▸ hs₁) · exfalso; exact h1 (heq.symm ▸ hs₂) · have hc1 : j ∈ s₁ ∧ i ∉ s₁ := by by_contra h; exact h1 (by simp [shiftSet, h, hs₁]) have hc2 : j ∈ s₂ ∧ i ∉ s₂ := by by_contra h; exact h2 (by simp [shiftSet, h, hs₂]) exact shiftSet_injOn_changed i j hc1 hc2 heq /-- Left-shifting preserves `k`-uniformity. -/ theorem sized_shiftFamily {n k : ℕ} (i j : Fin n) {𝒜 : Finset (Finset (Fin n))} (h𝒜 : (𝒜 : Set (Finset (Fin n))).Sized k) : (shiftFamily i j 𝒜 : Set (Finset (Fin n))).Sized k := by intro t ht rw [SetLike.mem_coe, shiftFamily, mem_image] at ht rcases ht with ⟨s, hs, rfl⟩ split_ifs · exact h𝒜 hs · rw [card_shiftSet]; exact h𝒜 hs lemma mem_shiftFamily_iff {n : ℕ} {i j : Fin n} {𝒜 : Finset (Finset (Fin n))} {t : Finset (Fin n)} : t ∈ shiftFamily i j 𝒜 ↔ (t ∈ 𝒜 ∧ shiftSet i j t ∈ 𝒜) ∨ (t ∉ 𝒜 ∧ ∃ s ∈ 𝒜, shiftSet i j s = t) := by unfold shiftFamily rw [mem_image] constructor · rintro ⟨s, hs, hst⟩ split_ifs at hst with h · subst hst; exact Or.inl ⟨hs, h⟩ · subst hst; exact Or.inr ⟨h, s, hs, rfl⟩ · rintro (⟨ht, hst⟩ | ⟨ht, s, hs, rfl⟩) · exact ⟨t, ht, by simp [hst]⟩ · exact ⟨s, hs, by simp [ht]⟩ /-- **Shadow Non-Expansion under Left-Shifting**: `#(∂ (shiftFamily i j 𝒜)) ≤ #(∂ 𝒜)` for all `i, j : Fin n`. -/ theorem card_shadow_shiftFamily_le {n : ℕ} (i j : Fin n) (𝒜 : Finset (Finset (Fin n))) : (∂ (shiftFamily i j 𝒜)).card ≤ (∂ 𝒜).card := by by_cases hij : i = j · subst hij have hEq : shiftFamily i i 𝒜 = 𝒜 := by ext t simp only [mem_shiftFamily_iff, shiftSet, and_not_self, ↓reduceIte, exists_eq_right] tauto rw [hEq] -- Partition `∂ (shiftFamily i j 𝒜)` into elements already in `∂ 𝒜` and those outside `∂ 𝒜`. -- Every `t ∈ ∂ (shiftFamily i j 𝒜) \ ∂ 𝒜` must contain `i` and not `j`, and the inverse shift -- `insert j (t.erase i)` lands injectively in `∂ 𝒜 \ ∂ (shiftFamily i j 𝒜)`! set ℬ := shiftFamily i j 𝒜 have hmap : ∀ t ∈ ∂ ℬ \ ∂ 𝒜, i ∈ t ∧ j ∉ t ∧ insert j (t.erase i) ∈ ∂ 𝒜 \ ∂ ℬ := by intro t ht rw [mem_sdiff] at ht rcases ht with ⟨htℬ, ht𝒜⟩ rw [mem_shadow_iff_insert_mem] at htℬ rcases htℬ with ⟨w, hw, hwtℬ⟩ rw [mem_shiftFamily_iff] at hwtℬ rcases hwtℬ with ⟨hwt𝒜, _⟩ | ⟨hwtnot𝒜, s, hs𝒜, hs_eq⟩ · exact absurd (mem_shadow_iff_insert_mem.mpr ⟨w, hw, hwt𝒜⟩) ht𝒜 · have hsc : j ∈ s ∧ i ∉ s := by by_contra h have : shiftSet i j s = s := by simp [shiftSet, h] rw [this] at hs_eq exact hwtnot𝒜 (hs_eq ▸ hs𝒜) simp only [shiftSet, if_pos hsc] at hs_eq -- `insert i (s.erase j) = insert w t`, with `w ∉ t` have hw_ne_i : w ≠ i := by intro hwi; subst w -- Then `t = s.erase j`, so `insert j t = s ∈ 𝒜`, contradicting `t ∉ ∂ 𝒜`! have hjt : j ∉ t := by intro hjm have : j ∈ insert i t := mem_insert_of_mem hjm rw [← hs_eq, mem_insert] at this exact notMem_erase j s (this.resolve_left (Ne.symm hij)) have hst : insert j t = s := by ext z by_cases hzj : z = j · subst z; simp [hsc.1] · by_cases hzi : z = i · subst z; simp [hw, hsc.2, hij] · have := Finset.ext_iff.mp hs_eq z simpa [mem_insert, mem_erase, hzi, hzj] using this.symm exact ht𝒜 (mem_shadow_iff_insert_mem.mpr ⟨j, hjt, hst ▸ hs𝒜⟩) have hi_mem_t : i ∈ t := by have : i ∈ insert w t := hs_eq ▸ mem_insert_self i (s.erase j) exact (mem_insert.mp this).resolve_left (Ne.symm hw_ne_i) have hj_not_t : j ∉ t := by intro hjm have : j ∈ insert i (s.erase j) := hs_eq.symm ▸ mem_insert_of_mem hjm rw [mem_insert] at this exact notMem_erase j s (this.resolve_left (Ne.symm hij)) have hw_ne_j : w ≠ j := by intro hwj; subst w have : j ∈ insert i (s.erase j) := hs_eq.symm ▸ mem_insert_self j t rw [mem_insert] at this exact notMem_erase j s (this.resolve_left (Ne.symm hij)) -- Show `insert w (insert j (t.erase i)) = s` and `w ∉ insert j (t.erase i)` have hwinv : insert w (insert j (t.erase i)) = s := by ext z by_cases hzj : z = j · subst z; simp [hsc.1] · by_cases hzi : z = i · subst z; simp [Ne.symm hw_ne_i, hsc.2, hij] · have := Finset.ext_iff.mp hs_eq z simpa [mem_insert, mem_erase, hzi, hzj] using this.symm have hw_not_inv : w ∉ insert j (t.erase i) := by simp [mem_insert, mem_erase, hw_ne_j, hw] have hinv_in_shadA : insert j (t.erase i) ∈ ∂ 𝒜 := mem_shadow_iff_insert_mem.mpr ⟨w, hw_not_inv, hwinv ▸ hs𝒜⟩ have hinv_not_shadB : insert j (t.erase i) ∉ ∂ ℬ := by intro hmem rw [mem_shadow_iff_insert_mem] at hmem rcases hmem with ⟨u, hu_not, huℬ⟩ rw [mem_shiftFamily_iff] at huℬ rcases huℬ with ⟨hu𝒜, hushift𝒜⟩ | ⟨_, s', hs'𝒜, hs'_eq⟩ · by_cases hui : u = i · subst u have heq' : insert i (insert j (t.erase i)) = insert j t := by rw [insert_comm, insert_erase hi_mem_t] exact ht𝒜 (mem_shadow_iff_insert_mem.mpr ⟨j, hj_not_t, heq' ▸ hu𝒜⟩) · have hcond : j ∈ insert u (insert j (t.erase i)) ∧ i ∉ insert u (insert j (t.erase i)) := by refine ⟨mem_insert_of_mem (mem_insert_self j _), ?_⟩ simp [mem_insert, mem_erase, Ne.symm hui, hij] have hsh : shiftSet i j (insert u (insert j (t.erase i))) = insert u t := by simp only [shiftSet, if_pos hcond] ext z by_cases hzi : z = i · subst z; simp [hi_mem_t] · by_cases hzj : z = j · subst z have huj : u ≠ j := fun h => hu_not (by rw [h]; exact mem_insert_self j _) simp [hzi, huj.symm, hj_not_t] · simp [mem_insert, mem_erase, hzi, hzj] have hu_not_t : u ∉ t := by intro hum exact hu_not (mem_insert_of_mem (mem_erase.mpr ⟨hui, hum⟩)) exact ht𝒜 (mem_shadow_iff_insert_mem.mpr ⟨u, hu_not_t, hsh ▸ hushift𝒜⟩) · by_cases hcond : j ∈ s' ∧ i ∉ s' · simp only [shiftSet, if_pos hcond] at hs'_eq have : j ∈ insert i (s'.erase j) := hs'_eq.symm ▸ mem_insert_of_mem (mem_insert_self j _) rw [mem_insert] at this exact notMem_erase j s' (this.resolve_left (Ne.symm hij)) · simp only [shiftSet, if_neg hcond] at hs'_eq have hj_s' : j ∈ s' := hs'_eq ▸ mem_insert_of_mem (mem_insert_self j _) have hi_s' : i ∈ s' := by by_contra hi; exact hcond ⟨hj_s', hi⟩ have hui : u = i := by have : i ∈ insert u (insert j (t.erase i)) := hs'_eq.symm ▸ hi_s' simp only [mem_insert, mem_erase, hij, ne_eq, not_true_eq_false, false_and, or_false] at this exact this.symm subst u have heq' : insert i (insert j (t.erase i)) = insert j t := by rw [insert_comm, insert_erase hi_mem_t] exact ht𝒜 (mem_shadow_iff_insert_mem.mpr ⟨j, hj_not_t, heq' ▸ (hs'_eq.symm ▸ hs'𝒜)⟩) exact ⟨hi_mem_t, hj_not_t, mem_sdiff.mpr ⟨hinv_in_shadA, hinv_not_shadB⟩⟩ have hcard_sdiff : (∂ ℬ \ ∂ 𝒜).card ≤ (∂ 𝒜 \ ∂ ℬ).card := by refine Finset.card_le_card_of_injOn (fun t => insert j (t.erase i)) ?_ ?_ · intro t ht exact (hmap t ht).2.2 · intro t₁ ht₁ t₂ ht₂ heq have h1 := hmap t₁ ht₁ have h2 := hmap t₂ ht₂ ext z by_cases hzi : z = i · subst hzi; simp [h1.1, h2.1] · by_cases hzj : z = j · subst hzj; simp [h1.2.1, h2.2.1] · have := Finset.ext_iff.mp heq z simpa [mem_insert, mem_erase, hzi, hzj] using this have h1 : (∂ ℬ).card = (∂ ℬ \ ∂ 𝒜).card + (∂ ℬ ∩ ∂ 𝒜).card := by rw [← card_union_of_disjoint (disjoint_sdiff_inter _ _), sdiff_union_inter] have h2 : (∂ 𝒜).card = (∂ 𝒜 \ ∂ ℬ).card + (∂ ℬ ∩ ∂ 𝒜).card := by rw [inter_comm, ← card_union_of_disjoint (disjoint_sdiff_inter _ _), sdiff_union_inter] omega /-- Total coordinate weight `∑_{s ∈ 𝒜} ∑_{a ∈ s} a.1`, strictly decreased by any nontrivial left-shift. -/ def familyWeight {n : ℕ} (𝒜 : Finset (Finset (Fin n))) : ℕ := ∑ s ∈ 𝒜, ∑ a ∈ s, a.1 lemma weight_shiftSet_lt {n : ℕ} {i j : Fin n} (hij : i < j) {s : Finset (Fin n)} (hc : j ∈ s ∧ i ∉ s) : ∑ a ∈ shiftSet i j s, a.1 < ∑ a ∈ s, a.1 := by simp only [shiftSet, if_pos hc] have hi : i ∉ s.erase j := fun hm => hc.2 (mem_of_mem_erase hm) rw [sum_insert hi] have hsum : ∑ a ∈ s.erase j, a.1 + j.1 = ∑ a ∈ s, a.1 := sum_erase_add s (fun a => a.1) hc.1 have hlt : i.1 < j.1 := hij omega lemma familyWeight_shiftFamily_lt {n : ℕ} {i j : Fin n} (hij : i < j) {𝒜 : Finset (Finset (Fin n))} (hnot : ¬ IsShiftedAt i j 𝒜) : familyWeight (shiftFamily i j 𝒜) < familyWeight 𝒜 := by unfold IsShiftedAt at hnot push Not at hnot rcases hnot with ⟨s₀, hs₀, hs₀_not⟩ unfold familyWeight shiftFamily have hinj : Set.InjOn (fun s => if shiftSet i j s ∈ 𝒜 then s else shiftSet i j s) (𝒜 : Set _) := by intro s₁ hs₁ s₂ hs₂ heq rw [SetLike.mem_coe] at hs₁ hs₂ dsimp only at heq split_ifs at heq with h1 h2 h2 · exact heq · exfalso; exact h2 (heq ▸ hs₁) · exfalso; exact h1 (heq.symm ▸ hs₂) · have hc1 : j ∈ s₁ ∧ i ∉ s₁ := by by_contra h; exact h1 (by simp [shiftSet, h, hs₁]) have hc2 : j ∈ s₂ ∧ i ∉ s₂ := by by_contra h; exact h2 (by simp [shiftSet, h, hs₂]) exact shiftSet_injOn_changed i j hc1 hc2 heq rw [sum_image hinj] apply sum_lt_sum · intro s hs split_ifs with h · exact le_rfl · have hc : j ∈ s ∧ i ∉ s := by by_contra hc; exact h (by simp [shiftSet, hc, hs]) exact Nat.le_of_lt (weight_shiftSet_lt hij hc) · refine ⟨s₀, hs₀, ?_⟩ rw [if_neg hs₀_not] have hc : j ∈ s₀ ∧ i ∉ s₀ := by by_contra hc; exact hs₀_not (by simp [shiftSet, hc, hs₀]) exact weight_shiftSet_lt hij hc /-- **Existence of a Left-Shifted Compression**: every `k`-uniform family `𝒜` can be transformed into a left-shifted `k`-uniform family `ℬ` of the same cardinality with `#(∂ ℬ) ≤ #(∂ 𝒜)`. -/ theorem exists_leftShifted_shadow_le {n k : ℕ} (𝒜 : Finset (Finset (Fin n))) (h𝒜 : (𝒜 : Set (Finset (Fin n))).Sized k) : ∃ ℬ : Finset (Finset (Fin n)), IsLeftShifted ℬ ∧ (ℬ : Set (Finset (Fin n))).Sized k ∧ ℬ.card = 𝒜.card ∧ (∂ ℬ).card ≤ (∂ 𝒜).card := by classical by_cases hsh : IsLeftShifted 𝒜 · exact ⟨𝒜, hsh, h𝒜, rfl, le_rfl⟩ · unfold IsLeftShifted at hsh push Not at hsh rcases hsh with ⟨i, j, hij, hnot⟩ have hlt : familyWeight (shiftFamily i j 𝒜) < familyWeight 𝒜 := familyWeight_shiftFamily_lt hij hnot obtain ⟨ℬ, hℬsh, hℬsz, hℬcard, hℬshad⟩ := exists_leftShifted_shadow_le (shiftFamily i j 𝒜) (sized_shiftFamily i j h𝒜) exact ⟨ℬ, hℬsh, hℬsz, hℬcard.trans (card_shiftFamily i j 𝒜), hℬshad.trans (card_shadow_shiftFamily_le i j 𝒜)⟩ termination_by familyWeight 𝒜 /-! ## Section 5: Lovász's Real Binomial Shadow Theorem (1979) -/ /-- The real generalized binomial coefficient `C(x, k) = ∏_{j=0}^{k-1} (x - j) / k!` for `x : ℝ`. -/ noncomputable def realBinom (x : ℝ) (k : ℕ) : ℝ := (∏ j ∈ Finset.range k, (x - (j : ℝ))) / (k.factorial : ℝ) @[simp] lemma realBinom_zero (x : ℝ) : realBinom x 0 = 1 := by simp [realBinom] @[simp] lemma realBinom_one (x : ℝ) : realBinom x 1 = x := by simp [realBinom] /-- On natural numbers `n : ℕ`, `realBinom (n : ℝ) k` agrees with `(n.choose k : ℝ)`. -/ theorem realBinom_natCast (n k : ℕ) : realBinom (n : ℝ) k = (n.choose k : ℝ) := by unfold realBinom have hfac : (k.factorial : ℝ) ≠ 0 := Nat.cast_ne_zero.mpr (Nat.factorial_ne_zero k) rw [div_eq_iff hfac] have hdesc : ∏ j ∈ Finset.range k, ((n : ℝ) - (j : ℝ)) = (n.descFactorial k : ℝ) := by clear hfac induction k with | zero => simp | succ k ih => rw [Finset.prod_range_succ, ih, Nat.descFactorial_succ] by_cases hkn : k ≤ n · push_cast [Nat.cast_sub hkn] ring · push Not at hkn have hzero : n.descFactorial k = 0 := Nat.descFactorial_eq_zero_iff_lt.mpr (by omega) simp [hzero] rw [hdesc] have hch := Nat.descFactorial_eq_factorial_mul_choose n k have hch' : (n.descFactorial k : ℝ) = (k.factorial : ℝ) * (n.choose k : ℝ) := by exact_mod_cast hch linarith /-- Pascal's identity for the real generalized binomial coefficient: `C(x, k + 1) = C(x - 1, k + 1) + C(x - 1, k)` for ALL real `x : ℝ` and `k : ℕ`. -/ theorem realBinom_pascal (x : ℝ) (k : ℕ) : realBinom x (k + 1) = realBinom (x - 1) (k + 1) + realBinom (x - 1) k := by unfold realBinom have hshift : ∏ j ∈ Finset.range k, (x - 1 - (j : ℝ)) = ∏ j ∈ Finset.range k, (x - ((j + 1 : ℕ) : ℝ)) := by refine Finset.prod_congr rfl fun j _ => ?_ push_cast; ring have hnum1 : ∏ j ∈ Finset.range (k + 1), (x - (j : ℝ)) = x * ∏ j ∈ Finset.range k, (x - 1 - (j : ℝ)) := by rw [Finset.prod_range_succ', hshift] simp only [Nat.cast_zero, sub_zero] ring have hnum2 : ∏ j ∈ Finset.range (k + 1), (x - 1 - (j : ℝ)) = (x - 1 - (k : ℝ)) * ∏ j ∈ Finset.range k, (x - 1 - (j : ℝ)) := by rw [Finset.prod_range_succ] ring rw [hnum1, hnum2, Nat.factorial_succ] have hfk : (k.factorial : ℝ) ≠ 0 := Nat.cast_ne_zero.mpr (Nat.factorial_ne_zero k) have hk1 : ((k + 1 : ℕ) : ℝ) ≠ 0 := Nat.cast_ne_zero.mpr (Nat.succ_ne_zero k) push_cast field_simp [hfk, hk1] ring lemma realBinom_nonneg {x : ℝ} {k : ℕ} (hx : (k : ℝ) - 1 ≤ x) : 0 ≤ realBinom x k := by unfold realBinom apply div_nonneg · apply Finset.prod_nonneg intro j hj rw [Finset.mem_range] at hj have : (j : ℝ) ≤ (k : ℝ) - 1 := by have : j + 1 ≤ k := hj have : (j : ℝ) + 1 ≤ (k : ℝ) := by exact_mod_cast this linarith linarith · positivity lemma realBinom_pos {x : ℝ} {k : ℕ} (hx : (k : ℝ) - 1 < x) : 0 < realBinom x k := by unfold realBinom apply div_pos · apply Finset.prod_pos intro j hj rw [Finset.mem_range] at hj have : (j : ℝ) ≤ (k : ℝ) - 1 := by have : j + 1 ≤ k := hj have : (j : ℝ) + 1 ≤ (k : ℝ) := by exact_mod_cast this linarith linarith · positivity lemma realBinom_lt_of_lt {x y : ℝ} {k : ℕ} (hk : 1 ≤ k) (hx : (k : ℝ) - 1 ≤ x) (hxy : x < y) : realBinom x k < realBinom y k := by unfold realBinom have hfk : (0 : ℝ) < (k.factorial : ℝ) := by positivity rw [div_lt_div_iff_of_pos_right hfk] have hprod : ∀ j ∈ Finset.range k, 0 ≤ x - (j : ℝ) ∧ x - (j : ℝ) < y - (j : ℝ) := by intro j hj rw [Finset.mem_range] at hj have hjle : (j : ℝ) ≤ (k : ℝ) - 1 := by have : j + 1 ≤ k := hj have : (j : ℝ) + 1 ≤ (k : ℝ) := by exact_mod_cast this linarith exact ⟨by linarith, by linarith⟩ cases k with | zero => omega | succ k => have h0 : 0 ∈ Finset.range (k + 1) := Finset.mem_range.mpr (Nat.succ_pos k) have hlt_prod : ∀ (s : Finset ℕ) (hs : s.Nonempty), (∀ j ∈ s, 0 ≤ x - (j : ℝ)) → (∀ j ∈ s, x - (j : ℝ) < y - (j : ℝ)) → ∏ j ∈ s, (x - (j : ℝ)) < ∏ j ∈ s, (y - (j : ℝ)) := by intro s induction s using Finset.induction_on with | empty => intro hs; exact absurd hs Finset.not_nonempty_empty | insert a s ha ih => intro _ hnn hlt rw [Finset.prod_insert ha, Finset.prod_insert ha] have ha_nn : 0 ≤ x - (a : ℝ) := hnn a (mem_insert_self a s) have ha_lt : x - (a : ℝ) < y - (a : ℝ) := hlt a (mem_insert_self a s) rcases s.eq_empty_or_nonempty with rfl | hne · simpa using ha_lt · have hs_nn : 0 ≤ ∏ j ∈ s, (x - (j : ℝ)) := Finset.prod_nonneg fun j hj => hnn j (mem_insert_of_mem hj) have hs_lt : ∏ j ∈ s, (x - (j : ℝ)) < ∏ j ∈ s, (y - (j : ℝ)) := ih hne (fun j hj => hnn j (mem_insert_of_mem hj)) (fun j hj => hlt j (mem_insert_of_mem hj)) have hy_pos : 0 < y - (a : ℝ) := lt_of_le_of_lt ha_nn ha_lt calc (x - (a : ℝ)) * ∏ j ∈ s, (x - (j : ℝ)) ≤ (y - (a : ℝ)) * ∏ j ∈ s, (x - (j : ℝ)) := mul_le_mul_of_nonneg_right (le_of_lt ha_lt) hs_nn _ < (y - (a : ℝ)) * ∏ j ∈ s, (y - (j : ℝ)) := mul_lt_mul_of_pos_left hs_lt hy_pos exact hlt_prod (Finset.range (k + 1)) ⟨0, h0⟩ (fun j hj => (hprod j hj).1) (fun j hj => (hprod j hj).2) lemma realBinom_le_of_le {x y : ℝ} {k : ℕ} (hx : (k : ℝ) - 1 ≤ x) (hxy : x ≤ y) : realBinom x k ≤ realBinom y k := by cases k with | zero => simp | succ k => rcases eq_or_lt_of_le hxy with rfl | hlt · exact le_rfl · exact le_of_lt (realBinom_lt_of_lt (Nat.succ_pos k) hx hlt) /-- Decomposition of a left-shifted family on `Fin (n + 1)` at vertex `0`: `link0 ℬ = {s.erase 0 | s ∈ ℬ, 0 ∈ s}` (projected to `Fin n`) and `del0 ℬ = {s | s ∈ ℬ, 0 ∉ s}` (projected to `Fin n`). -/ def dropZero {n : ℕ} (s : Finset (Fin (n + 1))) : Finset (Fin n) := (Finset.univ : Finset (Fin n)).filter (fun i => i.succ ∈ s) lemma mem_dropZero {n : ℕ} {s : Finset (Fin (n + 1))} {i : Fin n} : i ∈ dropZero s ↔ i.succ ∈ s := by simp [dropZero] lemma card_dropZero_of_notMem {n : ℕ} {s : Finset (Fin (n + 1))} (h0 : (0 : Fin (n + 1)) ∉ s) : (dropZero s).card = s.card := by refine Finset.card_bij (fun i _ => i.succ) ?_ ?_ ?_ · intro i hi; exact mem_dropZero.mp hi · intro i₁ _ i₂ _ heq; exact Fin.succ_injective _ heq · intro a ha have ha0 : a ≠ 0 := fun h => h0 (h ▸ ha) refine ⟨a.pred ha0, mem_dropZero.mpr ?_, Fin.succ_pred a ha0⟩ rwa [Fin.succ_pred] lemma card_dropZero_of_mem {n : ℕ} {s : Finset (Fin (n + 1))} (h0 : (0 : Fin (n + 1)) ∈ s) : (dropZero s).card = s.card - 1 := by have h1 : (dropZero s).card = (s.erase 0).card := by refine Finset.card_bij (fun i _ => i.succ) ?_ ?_ ?_ · intro i hi exact mem_erase.mpr ⟨Fin.succ_ne_zero i, mem_dropZero.mp hi⟩ · intro i₁ _ i₂ _ heq; exact Fin.succ_injective _ heq · intro a ha rw [mem_erase] at ha refine ⟨a.pred ha.1, mem_dropZero.mpr ?_, Fin.succ_pred a ha.1⟩ rw [Fin.succ_pred]; exact ha.2 rw [h1, card_erase_of_mem h0] lemma dropZero_inj_of_same_zero {n : ℕ} {s₁ s₂ : Finset (Fin (n + 1))} (h0 : ((0 : Fin (n + 1)) ∈ s₁) ↔ ((0 : Fin (n + 1)) ∈ s₂)) (heq : dropZero s₁ = dropZero s₂) : s₁ = s₂ := by ext a refine Fin.cases h0 (fun i => ?_) a have := Finset.ext_iff.mp heq i simpa [mem_dropZero] using this /-- Link of `0` in `ℬ`: `(k-1)`-sets `t` on `Fin n` such that `{0} ∪ t.map succ ∈ ℬ`. -/ def link0 {n : ℕ} (ℬ : Finset (Finset (Fin (n + 1)))) : Finset (Finset (Fin n)) := (ℬ.filter (fun s => (0 : Fin (n + 1)) ∈ s)).image dropZero /-- Deletion of `0` in `ℬ`: `k`-sets `t` on `Fin n` such that `t.map succ ∈ ℬ`. -/ def del0 {n : ℕ} (ℬ : Finset (Finset (Fin (n + 1)))) : Finset (Finset (Fin n)) := (ℬ.filter (fun s => (0 : Fin (n + 1)) ∉ s)).image dropZero lemma card_link0_add_card_del0 {n : ℕ} (ℬ : Finset (Finset (Fin (n + 1)))) : (link0 ℬ).card + (del0 ℬ).card = ℬ.card := by have h1 : (link0 ℬ).card = (ℬ.filter (fun s => (0 : Fin (n + 1)) ∈ s)).card := by apply card_image_of_injOn intro s₁ hs₁ s₂ hs₂ heq rw [SetLike.mem_coe, mem_filter] at hs₁ hs₂ exact dropZero_inj_of_same_zero (by simp [hs₁.2, hs₂.2]) heq have h2 : (del0 ℬ).card = (ℬ.filter (fun s => (0 : Fin (n + 1)) ∉ s)).card := by apply card_image_of_injOn intro s₁ hs₁ s₂ hs₂ heq rw [SetLike.mem_coe, mem_filter] at hs₁ hs₂ exact dropZero_inj_of_same_zero (by simp [hs₁.2, hs₂.2]) heq rw [h1, h2, card_filter_add_card_filter_not] lemma sized_link0 {n k : ℕ} {ℬ : Finset (Finset (Fin (n + 1)))} (hℬ : (ℬ : Set (Finset (Fin (n + 1)))).Sized (k + 1)) : (link0 ℬ : Set (Finset (Fin n))).Sized k := by intro t ht rw [SetLike.mem_coe, link0, mem_image] at ht rcases ht with ⟨s, hs, rfl⟩ rw [mem_filter] at hs rw [card_dropZero_of_mem hs.2, hℬ hs.1]; simp lemma sized_del0 {n k : ℕ} {ℬ : Finset (Finset (Fin (n + 1)))} (hℬ : (ℬ : Set (Finset (Fin (n + 1)))).Sized k) : (del0 ℬ : Set (Finset (Fin n))).Sized k := by intro t ht rw [SetLike.mem_coe, del0, mem_image] at ht rcases ht with ⟨s, hs, rfl⟩ rw [mem_filter] at hs rw [card_dropZero_of_notMem hs.2, hℬ hs.1] /-- Key left-shifting inclusion: in a left-shifted family `ℬ`, `∂ (del0 ℬ) ⊆ link0 ℬ`! -/ lemma shadow_del0_subset_link0 {n : ℕ} {ℬ : Finset (Finset (Fin (n + 1)))} (hsh : IsLeftShifted ℬ) : ∂ (del0 ℬ) ⊆ link0 ℬ := by intro t ht rw [mem_shadow_iff_insert_mem] at ht rcases ht with ⟨i, hi, hit⟩ rw [del0, mem_image] at hit rcases hit with ⟨s, hs, heq⟩ rw [mem_filter] at hs have his : i.succ ∈ s := by have : i ∈ dropZero s := heq.symm ▸ mem_insert_self i t exact mem_dropZero.mp this have hshifted : shiftSet 0 i.succ s ∈ ℬ := hsh 0 i.succ (Fin.succ_pos i) s hs.1 have hcond : i.succ ∈ s ∧ (0 : Fin (n + 1)) ∉ s := ⟨his, hs.2⟩ simp only [shiftSet, if_pos hcond] at hshifted rw [link0, mem_image] refine ⟨insert 0 (s.erase i.succ), mem_filter.mpr ⟨hshifted, mem_insert_self _ _⟩, ?_⟩ ext j rw [mem_dropZero, mem_insert, mem_erase] have h0ne : j.succ ≠ 0 := Fin.succ_ne_zero j simp only [h0ne, false_or] constructor · rintro ⟨hjne, hjs⟩ have hjne' : j ≠ i := fun h => hjne (congrArg Fin.succ h) have hjd : j ∈ insert i t := heq ▸ mem_dropZero.mpr hjs exact (mem_insert.mp hjd).resolve_left hjne' · intro hjt have hjne' : j ≠ i := fun h => hi (h ▸ hjt) refine ⟨fun h => hjne' (Fin.succ_injective _ h), ?_⟩ exact mem_dropZero.mp (heq.symm ▸ mem_insert_of_mem hjt) /-- Lower bound on `#(∂ ℬ)` from the vertex-`0` split: `#(∂ ℬ) ≥ #(link0 ℬ) + #(∂ (link0 ℬ))`! -/ lemma card_link0_add_card_shadow_link0_le {n : ℕ} (ℬ : Finset (Finset (Fin (n + 1)))) : (link0 ℬ).card + (∂ (link0 ℬ)).card ≤ (∂ ℬ).card := by have hsub1 : link0 ℬ ⊆ del0 (∂ ℬ) := by intro t ht rw [link0, mem_image] at ht rcases ht with ⟨s, hs, rfl⟩ rw [mem_filter] at hs rw [del0, mem_image] refine ⟨s.erase 0, mem_filter.mpr ⟨?_, notMem_erase 0 s⟩, ?_⟩ · exact mem_shadow_iff_insert_mem.mpr ⟨0, notMem_erase 0 s, by rw [insert_erase hs.2]; exact hs.1⟩ · ext i; simp [mem_dropZero, mem_erase, Fin.succ_ne_zero] have hsub2 : ∂ (link0 ℬ) ⊆ link0 (∂ ℬ) := by intro t ht rw [mem_shadow_iff_insert_mem] at ht rcases ht with ⟨i, hi, hit⟩ rw [link0, mem_image] at hit rcases hit with ⟨s, hs, heq⟩ rw [mem_filter] at hs have his : i.succ ∈ s := mem_dropZero.mp (heq.symm ▸ mem_insert_self i t) rw [link0, mem_image] refine ⟨s.erase i.succ, mem_filter.mpr ⟨?_, mem_erase.mpr ⟨(Fin.succ_ne_zero i).symm, hs.2⟩⟩, ?_⟩ · exact mem_shadow_iff_insert_mem.mpr ⟨i.succ, notMem_erase i.succ s, by rw [insert_erase his]; exact hs.1⟩ · ext j rw [mem_dropZero, mem_erase] constructor · rintro ⟨hji, hjs⟩ have hjne : j ≠ i := fun h => hji (congrArg Fin.succ h) exact (mem_insert.mp (heq ▸ mem_dropZero.mpr hjs)).resolve_left hjne · intro hjt have hjne : j ≠ i := fun h => hi (h ▸ hjt) exact ⟨fun h => hjne (Fin.succ_injective _ h), mem_dropZero.mp (heq.symm ▸ mem_insert_of_mem hjt)⟩ have hsplit := card_link0_add_card_del0 (∂ ℬ) have h1 := card_le_card hsub1 have h2 := card_le_card hsub2 omega /-- Left-shifting is inherited by both `link0 ℬ` and `del0 ℬ`. -/ lemma isLeftShifted_link0 {n : ℕ} {ℬ : Finset (Finset (Fin (n + 1)))} (hsh : IsLeftShifted ℬ) : IsLeftShifted (link0 ℬ) := by intro i j hij t ht rw [link0, mem_image] at ht ⊢ rcases ht with ⟨s, hs, rfl⟩ rw [mem_filter] at hs by_cases hcond : j ∈ dropZero s ∧ i ∉ dropZero s · simp only [shiftSet, if_pos hcond] have hcond' : j.succ ∈ s ∧ i.succ ∉ s := ⟨mem_dropZero.mp hcond.1, fun hm => hcond.2 (mem_dropZero.mpr hm)⟩ have hmem : shiftSet i.succ j.succ s ∈ ℬ := hsh i.succ j.succ (Fin.succ_lt_succ_iff.mpr hij) s hs.1 simp only [shiftSet, if_pos hcond'] at hmem refine ⟨insert i.succ (s.erase j.succ), mem_filter.mpr ⟨hmem, ?_⟩, ?_⟩ · exact mem_insert_of_mem (mem_erase.mpr ⟨(Fin.succ_ne_zero j).symm, hs.2⟩) · ext a simp only [mem_dropZero, mem_insert, mem_erase, ne_eq, Fin.succ_inj] · simp only [shiftSet, if_neg hcond] exact ⟨s, mem_filter.mpr hs, rfl⟩ lemma isLeftShifted_del0 {n : ℕ} {ℬ : Finset (Finset (Fin (n + 1)))} (hsh : IsLeftShifted ℬ) : IsLeftShifted (del0 ℬ) := by intro i j hij t ht rw [del0, mem_image] at ht ⊢ rcases ht with ⟨s, hs, rfl⟩ rw [mem_filter] at hs by_cases hcond : j ∈ dropZero s ∧ i ∉ dropZero s · simp only [shiftSet, if_pos hcond] have hcond' : j.succ ∈ s ∧ i.succ ∉ s := ⟨mem_dropZero.mp hcond.1, fun hm => hcond.2 (mem_dropZero.mpr hm)⟩ have hmem : shiftSet i.succ j.succ s ∈ ℬ := hsh i.succ j.succ (Fin.succ_lt_succ_iff.mpr hij) s hs.1 simp only [shiftSet, if_pos hcond'] at hmem refine ⟨insert i.succ (s.erase j.succ), mem_filter.mpr ⟨hmem, ?_⟩, ?_⟩ · simp [mem_insert, mem_erase, (Fin.succ_ne_zero i).symm, hs.2] · ext a simp only [mem_dropZero, mem_insert, mem_erase, ne_eq, Fin.succ_inj] · simp only [shiftSet, if_neg hcond] exact ⟨s, mem_filter.mpr hs, rfl⟩ /-- Every nonempty `(k + 1)`-uniform family has shadow of cardinality at least `k + 1`. -/ lemma card_shadow_ge_of_nonempty {α : Type*} [DecidableEq α] {k : ℕ} {ℱ : Finset (Finset α)} (hsz : (ℱ : Set (Finset α)).Sized (k + 1)) (hne : ℱ.Nonempty) : k + 1 ≤ (∂ ℱ).card := by rcases hne with ⟨s, hs⟩ have hsub : s.image (fun a => s.erase a) ⊆ ∂ ℱ := by intro t ht rw [mem_image] at ht rcases ht with ⟨a, ha, rfl⟩ exact mem_shadow_iff_insert_mem.mpr ⟨a, notMem_erase a s, by rw [insert_erase ha]; exact hs⟩ have hinj : Set.InjOn (fun a => s.erase a) (s : Set α) := by intro a₁ ha₁ a₂ ha₂ heq dsimp only at heq by_contra hne' have : a₁ ∈ s.erase a₂ := mem_erase.mpr ⟨hne', ha₁⟩ rw [← heq] at this exact notMem_erase a₁ s this calc k + 1 = s.card := (hsz hs).symm _ = (s.image (fun a => s.erase a)).card := (card_image_of_injOn hinj).symm _ ≤ (∂ ℱ).card := card_le_card hsub /-- Core induction for Lovász's theorem on left-shifted families (induction on `n`). -/ private theorem lovasz_leftShifted : ∀ {n k : ℕ}, 1 ≤ k → ∀ {ℬ : Finset (Finset (Fin n))}, IsLeftShifted ℬ → (ℬ : Set (Finset (Fin n))).Sized k → ∀ {x : ℝ}, (k : ℝ) ≤ x → realBinom x k ≤ (ℬ.card : ℝ) → realBinom x (k - 1) ≤ ((∂ ℬ).card : ℝ) | 0, k, hk, ℬ, _, hsz, x, hx, hcard => by exfalso have hempty : ℬ = ∅ := by ext s simp only [notMem_empty, iff_false] intro hs have hc : s.card = k := hsz hs have hz : s.card = 0 := by have : s = ∅ := Subsingleton.elim s ∅ simp [this] omega have hpos : 0 < realBinom x k := realBinom_pos (by linarith) rw [hempty] at hcard simp only [card_empty, Nat.cast_zero] at hcard linarith | n + 1, 1, _, ℬ, _, hsz, x, hx, hcard => by simp only [realBinom_one, Nat.sub_self, realBinom_zero, Nat.cast_one] at hx hcard ⊢ have hpos : (0 : ℝ) < (ℬ.card : ℝ) := by linarith have hne : ℬ.Nonempty := card_pos.mp (by exact_mod_cast hpos) have h1 : 1 ≤ (∂ ℬ).card := card_shadow_ge_of_nonempty hsz hne exact_mod_cast h1 | n + 1, k + 2, _, ℬ, hsh, hsz, x, hx, hcard => by change realBinom x (k + 1) ≤ ((∂ ℬ).card : ℝ) have hsplit : ((link0 ℬ).card : ℝ) + ((del0 ℬ).card : ℝ) = (ℬ.card : ℝ) := by exact_mod_cast card_link0_add_card_del0 ℬ have hshad_split : ((link0 ℬ).card : ℝ) + ((∂ (link0 ℬ)).card : ℝ) ≤ ((∂ ℬ).card : ℝ) := by exact_mod_cast card_link0_add_card_shadow_link0_le ℬ have hpas_top : realBinom x (k + 2) = realBinom (x - 1) (k + 2) + realBinom (x - 1) (k + 1) := realBinom_pascal x (k + 1) have hpas_bot : realBinom x (k + 1) = realBinom (x - 1) (k + 1) + realBinom (x - 1) k := realBinom_pascal x k by_cases hlink : realBinom (x - 1) (k + 1) ≤ ((link0 ℬ).card : ℝ) · -- Case 1: `|link0 ℬ| ≥ C(x - 1, k + 1)` → apply IH to `link0 ℬ` (on `Fin n`, uniformity `k + 1`). have hih := lovasz_leftShifted (n := n) (k := k + 1) (by omega) (isLeftShifted_link0 hsh) (sized_link0 hsz) (x := x - 1) (by push_cast at hx ⊢; linarith) hlink change realBinom (x - 1) k ≤ ((∂ (link0 ℬ)).card : ℝ) at hih linarith · -- Case 2: `|link0 ℬ| < C(x - 1, k + 1)` → then `|del0 ℬ| > C(x - 1, k + 2)`. -- We derive a contradiction with `∂ (del0 ℬ) ⊆ link0 ℬ`! exfalso push Not at hlink have hdel : realBinom (x - 1) (k + 2) < ((del0 ℬ).card : ℝ) := by linarith have hsub : ((∂ (del0 ℬ)).card : ℝ) ≤ ((link0 ℬ).card : ℝ) := by exact_mod_cast card_le_card (shadow_del0_subset_link0 hsh) by_cases hx1 : ((k + 2 : ℕ) : ℝ) ≤ x - 1 · -- Subcase 2a: `x - 1 ≥ k + 2` → IH on `del0 ℬ` gives `|∂ (del0 ℬ)| ≥ C(x - 1, k + 1)`! have hih := lovasz_leftShifted (n := n) (k := k + 2) (by omega) (isLeftShifted_del0 hsh) (sized_del0 hsz) (x := x - 1) hx1 (le_of_lt hdel) change realBinom (x - 1) (k + 1) ≤ ((∂ (del0 ℬ)).card : ℝ) at hih linarith · -- Subcase 2b: `k + 1 ≤ x - 1 < k + 2` → `C(x - 1, k + 2) ≥ 0`, so `del0 ℬ` is nonempty, -- hence `|∂ (del0 ℬ)| ≥ k + 2 = C(k + 2, k + 1) > C(x - 1, k + 1)`! push Not at hx1 have hnn : 0 ≤ realBinom (x - 1) (k + 2) := by apply realBinom_nonneg push_cast at hx ⊢; linarith have hdel_pos : (0 : ℝ) < ((del0 ℬ).card : ℝ) := lt_of_le_of_lt hnn hdel have hdel_ne : (del0 ℬ).Nonempty := card_pos.mp (by exact_mod_cast hdel_pos) have hge : ((k + 2 : ℕ) : ℝ) ≤ ((∂ (del0 ℬ)).card : ℝ) := by exact_mod_cast card_shadow_ge_of_nonempty (sized_del0 hsz) hdel_ne have hbinom_lt : realBinom (x - 1) (k + 1) < ((k + 2 : ℕ) : ℝ) := by have hnat : realBinom ((k + 2 : ℕ) : ℝ) (k + 1) = ((k + 2 : ℕ) : ℝ) := by rw [realBinom_natCast] have : (k + 2).choose (k + 1) = k + 2 := by rw [Nat.choose_succ_self_right] exact_mod_cast this rw [← hnat] exact realBinom_lt_of_lt (by omega) (by push_cast at hx ⊢; linarith) hx1 linarith /-- **Lovász's Real Binomial Shadow Theorem (1979)**: for every `k ≥ 1`, every `k`-uniform family `𝒜` of subsets of `Fin n`, and every real `x ≥ k`, if `#𝒜 ≥ C(x, k)` then `#(∂ 𝒜) ≥ C(x, k - 1)`. -/ theorem lovasz_real_binomial_shadow {n k : ℕ} (hk : 1 ≤ k) {𝒜 : Finset (Finset (Fin n))} (h𝒜 : (𝒜 : Set (Finset (Fin n))).Sized k) {x : ℝ} (hx : (k : ℝ) ≤ x) (hcard : realBinom x k ≤ (𝒜.card : ℝ)) : realBinom x (k - 1) ≤ ((∂ 𝒜).card : ℝ) := by obtain ⟨ℬ, hsh, hsz, hcardℬ, hshadℬ⟩ := exists_leftShifted_shadow_le 𝒜 h𝒜 have hcard' : realBinom x k ≤ (ℬ.card : ℝ) := by rwa [hcardℬ] have hlov := lovasz_leftShifted hk hsh hsz hx hcard' have hle : ((∂ ℬ).card : ℝ) ≤ ((∂ 𝒜).card : ℝ) := by exact_mod_cast hshadℬ exact le_trans hlov hle /-- **Iterated Lovász Real Binomial Shadow Theorem**: for every `r ≤ k`, every `k`-uniform family `𝒜` on `Fin n`, and every real `x ≥ k`, if `#𝒜 ≥ C(x, k)` then `#(∂^[r] 𝒜) ≥ C(x, k - r)`. -/ theorem lovasz_real_binomial_iterated_shadow {n k r : ℕ} (hrk : r ≤ k) {𝒜 : Finset (Finset (Fin n))} (h𝒜 : (𝒜 : Set (Finset (Fin n))).Sized k) {x : ℝ} (hx : (k : ℝ) ≤ x) (hcard : realBinom x k ≤ (𝒜.card : ℝ)) : realBinom x (k - r) ≤ ((∂^[r] 𝒜).card : ℝ) := by induction r generalizing k 𝒜 with | zero => simpa using hcard | succ r ih => have hk1 : 1 ≤ k := by omega have hstep := lovasz_real_binomial_shadow hk1 h𝒜 hx hcard have hsz' : (∂ 𝒜 : Set (Finset (Fin n))).Sized (k - 1) := h𝒜.shadow have hx' : ((k - 1 : ℕ) : ℝ) ≤ x := by have : (k - 1 : ℕ) ≤ k := Nat.sub_le k 1 have : ((k - 1 : ℕ) : ℝ) ≤ (k : ℝ) := by exact_mod_cast this linarith have hrec := ih (Nat.le_sub_of_add_le hrk) hsz' hx' hstep simpa [Function.iterate_succ_apply, Nat.sub_sub, add_comm 1 r] using hrec /-! ## Section 6: Concrete Verified Cascade & Lovász Witnesses -/ /-- Exact 3-cascade of `10`: `10 = C(5, 3)`, shadow `C(5, 2) = 10`, 2-shadow `C(5, 1) = 5`. -/ theorem cascade_example_10 : toCascade 3 10 = [5] ∧ cascadeShadow 3 (toCascade 3 10) = 10 ∧ cascadeIterShadow 2 3 (toCascade 3 10) = 5 := by decide /-- Exact 3-cascade of `14`: `14 = C(5, 3) + C(3, 2) + C(1, 1) = 10 + 3 + 1`, with shadow `C(5, 2) + C(3, 1) + C(1, 0) = 10 + 3 + 1 = 14`. -/ theorem cascade_example_14 : toCascade 3 14 = [5, 3, 1] ∧ cascadeVal 3 [5, 3, 1] = 14 ∧ cascadeShadow 3 [5, 3, 1] = 14 ∧ cascadeIterShadow 2 3 [5, 3, 1] = 6 := by decide /-- Exact non-integer Lovász witness at `x = 9/2, k = 3`: `C(9/2, 3) = (9/2)(7/2)(5/2)/6 = 105/16 = 6.5625`, `C(9/2, 2) = 63/8 = 7.875`. Thus any 3-uniform family with `≥ 7` edges has shadow `≥ ⌈7.875⌉ = 8`. -/ theorem lovasz_noninteger_witness {n : ℕ} {𝒜 : Finset (Finset (Fin n))} (h𝒜 : (𝒜 : Set (Finset (Fin n))).Sized 3) (hcard : 7 ≤ 𝒜.card) : 8 ≤ (∂ 𝒜).card := by have hb3 : realBinom ((9 : ℝ) / 2) 3 = 105 / 16 := by simp [realBinom, Finset.prod_range_succ]; norm_num have hb2 : realBinom ((9 : ℝ) / 2) 2 = 63 / 8 := by simp [realBinom, Finset.prod_range_succ]; norm_num have hle : realBinom ((9 : ℝ) / 2) 3 ≤ (𝒜.card : ℝ) := by rw [hb3] have h7 : (7 : ℝ) ≤ (𝒜.card : ℝ) := by exact_mod_cast hcard linarith have hlov := lovasz_real_binomial_shadow (k := 3) (by omega) h𝒜 (x := (9 : ℝ) / 2) (by norm_num) hle simp only [show 3 - 1 = 2 from rfl, hb2] at hlov have hlt : (7 : ℝ) < ((∂ 𝒜).card : ℝ) := by linarith have hlt_nat : 7 < (∂ 𝒜).card := by exact_mod_cast hlt omega /-! ## Axiom Verification -/ #print axioms isKCascade_iff_classical #print axioms cascadeVal_lt_choose_of_le #print axioms isKCascade_unique #print axioms toCascade_isKCascade #print axioms cascadeVal_toCascade #print axioms exists_unique_kCascade #print axioms card_cascadeFamily #print axioms isInitSeg_cascadeFamily #print axioms card_shadow_cascadeFamily #print axioms card_iterShadow_cascadeFamily #print axioms kruskal_katona_cascade #print axioms kruskal_katona_cascade_sharp #print axioms kruskal_katona_iterated_cascade #print axioms card_shiftFamily #print axioms sized_shiftFamily #print axioms card_shadow_shiftFamily_le #print axioms exists_leftShifted_shadow_le #print axioms realBinom_natCast #print axioms realBinom_pascal #print axioms lovasz_real_binomial_shadow #print axioms lovasz_real_binomial_iterated_shadow #print axioms cascade_example_10 #print axioms cascade_example_14 #print axioms lovasz_noninteger_witness end KruskalKatonaShadowTheorem