Lean / Reader
Lean reader

Erdos824CommonExtensions.lean

96 lines4 declarationsno sorryimports Mathlib.Algebra.BigOperators.Group.Finset.Basic Mathlib.Data.Fintype.BigOperators Mathlib.Tactic
  1. import Mathlib.Algebra.BigOperators.Group.Finset.Basic
  2. import Mathlib.Data.Fintype.BigOperators
  3. import Mathlib.Tactic
  4. /-! A finite form of dependent random choice. The three vertices may coincide,
  5. so the conclusion supplies common extensions of sets of size one, two or three. -/
  6. namespace Erdos824CommonExtensions
  7. open Finset
  8. open scoped BigOperators
  9. private def tuples {β : Type*} (t : ℕ) (s : Finset β) : Finset (Fin t → β) :=
  10. Fintype.piFinset fun _ => s
  11. private theorem card_tuples {β : Type*} (t : ℕ) (s : Finset β) :
  12. (tuples t s).card = s.card ^ t := by simp [tuples]
  13. private theorem incidence {α β : Type*} (U : Finset α) (V : Finset β)
  14. (R : α → β → Prop) [DecidableRel R] :
  15. (∑ y ∈ V, (U.filter fun x => R x y).card) =
  16. ∑ x ∈ U, (V.filter fun y => R x y).card := by
  17. simp only [Finset.card_filter]
  18. exact Finset.sum_comm
  19. /-- An exact integer criterion for a set of more than w vertices such that
  20. every triple has at least b common neighbors in V. -/
  21. theorem dependent_choice {α β : Type*} [DecidableEq α] [DecidableEq β]
  22. (U : Finset α) (V : Finset β) (N : α → Finset β) (t b w : ℕ)
  23. (hN : ∀ x∈U, N x ⊆ V)
  24. (hmass : V.card^t * w + U.card^3 * b^t < ∑ x ∈ U, (N x).card ^ t) :
  25. ∃ W ⊆ U, w < W.card ∧
  26. ∀ x∈W, ∀ y∈W, ∀ z∈W, b ≤ ((N x ∩ N y) ∩ N z).card := by
  27. classical
  28. let T := tuples t V
  29. let A (g : Fin t → β) := U.filter fun x => g ∈ tuples t (N x)
  30. let triples := U ×ˢ (U ×ˢ U)
  31. let common (q : α × (α × α)) := (N q.1 ∩ N q.2.1) ∩ N q.2.2
  32. let bad := triples.filter fun q => (common q).card < b
  33. let hits (g : Fin t → β) := bad.filter fun q => g ∈ tuples t (common q)
  34. have hsub {s : Finset β} (hs : s ⊆ V) : tuples t s ⊆ T := by
  35. intro g hg
  36. exact Fintype.mem_piFinset.mpr fun i => hs (Fintype.mem_piFinset.mp hg i)
  37. have hfilter (s : Finset β) (hs : s ⊆ V) :
  38. (T.filter fun g => g ∈ tuples t s) = tuples t s := by
  39. ext g
  40. simp only [mem_filter, and_iff_right_iff_imp]
  41. exact fun hg => hsub hs hg
  42. have ha : (∑ g ∈ T, (A g).card) = ∑ x ∈ U, (N x).card ^ t := by
  43. rw [show (∑ g ∈ T, (A g).card) = _ from incidence U T (fun x g => g ∈ tuples t (N x))]
  44. exact Finset.sum_congr rfl fun x hx => by rw [hfilter _ (hN x hx), card_tuples]
  45. have hb : (∑ g ∈ T, (hits g).card) ≤ U.card^3 * b^t := by
  46. rw [show (∑ g ∈ T, (hits g).card) = _ from incidence bad T (fun q g => g ∈ tuples t (common q))]
  47. calc
  48. _ ≤ ∑ _q ∈ bad, b^t := by
  49. apply Finset.sum_le_sum
  50. intro q hq
  51. have hbad := (Finset.mem_filter.mp hq).2
  52. have htup : (T.filter fun g => g ∈ tuples t (common q)).card ≤ (tuples t (common q)).card :=
  53. Finset.card_le_card fun _ h => (Finset.mem_filter.mp h).2
  54. exact htup.trans ((card_tuples _ _).le.trans (Nat.pow_le_pow_left (Nat.le_of_lt hbad) t))
  55. _ = bad.card * b^t := by simp
  56. _ ≤ U.card^3 * b^t := by
  57. apply Nat.mul_le_mul_right
  58. exact (Finset.card_le_card (Finset.filter_subset _ _)).trans_eq (by simp [triples]; ring)
  59. obtain ⟨g,hg,hlarge⟩ : ∃ g∈T, w+(hits g).card < (A g).card := by
  60. by_contra! h
  61. have hh := Finset.sum_le_sum h
  62. rw [ha, Finset.sum_add_distrib] at hh
  63. have ht : (∑ _g ∈ T, w) = V.card^t * w := by simp [T, card_tuples]
  64. omega
  65. let drops := (hits g).image Prod.fst
  66. let W := A g \ drops
  67. have hW {x} (hx : x∈W) : x∈A g := (mem_sdiff.mp hx).1
  68. refine ⟨W,(fun x hx => (mem_filter.mp (hW hx)).1), ?_, ?_⟩
  69. · have hs := Finset.card_sdiff_add_card_inter (A g) drops
  70. have hcap : ((A g) ∩ drops).card ≤ (hits g).card :=
  71. (Finset.card_le_card Finset.inter_subset_right).trans Finset.card_image_le
  72. change w < ((A g) \ drops).card
  73. omega
  74. · intro x hx y hy z hz
  75. by_contra! hlt
  76. have hxb := mem_filter.mp (hW hx)
  77. have hyb := mem_filter.mp (hW hy)
  78. have hzb := mem_filter.mp (hW hz)
  79. have hq : (x,y,z) ∈ bad := mem_filter.mpr
  80. ⟨mem_product.mpr ⟨hxb.1,mem_product.mpr ⟨hyb.1,hzb.1⟩⟩, hlt⟩
  81. have hhit : (x,y,z) ∈ hits g := by
  82. apply mem_filter.mpr
  83. refine ⟨hq,Fintype.mem_piFinset.mpr fun i => ?_⟩
  84. exact mem_inter.mpr ⟨mem_inter.mpr
  85. ⟨Fintype.mem_piFinset.mp hxb.2 i,Fintype.mem_piFinset.mp hyb.2 i⟩,
  86. Fintype.mem_piFinset.mp hzb.2 i⟩
  87. exact (mem_sdiff.mp hx).2 (Finset.mem_image_of_mem Prod.fst hhit)
  88. #print axioms dependent_choice
  89. end Erdos824CommonExtensions