Theorem: Configuration.Nondegenerate.exists_injective_of_card_le
File: Mathlib/Combinatorics/Configuration.lean

tactic: let t : L → Finset P := fun l => Set.toFinset { p | p ∉ l }
state_before: P : Type u_1
L : Type u_2
inst✝³ : Membership P L
inst✝² : Nondegenerate P L
inst✝¹ : Fintype P
inst✝ : Fintype L
h : Fintype.card L ≤ Fintype.card P
⊢ ∃ f, Function.Injective f ∧ ∀ (l : L), ¬f l ∈ l

tactic: suffices ∀ s : Finset L, s.card ≤ (s.biUnion t).card by
  obtain ⟨f, hf1, hf2⟩ := (Finset.all_card_le_biUnion_card_iff_exists_injective t).mp this
  exact ⟨f, hf1, fun l => Set.mem_toFinset.mp (hf2 l)⟩
state_before: P : Type u_1
L : Type u_2
inst✝³ : Membership P L
inst✝² : Nondegenerate P L
inst✝¹ : Fintype P
inst✝ : Fintype L
h : Fintype.card L ≤ Fintype.card P
t : L → Finset P := fun l => Set.toFinset {p | ¬p ∈ l}
⊢ ∃ f, Function.Injective f ∧ ∀ (l : L), ¬f l ∈ l

tactic: intro s
state_before: P : Type u_1
L : Type u_2
inst✝³ : Membership P L
inst✝² : Nondegenerate P L
inst✝¹ : Fintype P
inst✝ : Fintype L
h : Fintype.card L ≤ Fintype.card P
t : L → Finset P := fun l => Set.toFinset {p | ¬p ∈ l}
⊢ ∀ (s : Finset L), Finset.card s ≤ Finset.card (Finset.biUnion s t)

tactic: by_cases hs₀ : s.card = 0
state_before: P : Type u_1
L : Type u_2
inst✝³ : Membership P L
inst✝² : Nondegenerate P L
inst✝¹ : Fintype P
inst✝ : Fintype L
h : Fintype.card L ≤ Fintype.card P
t : L → Finset P := fun l => Set.toFinset {p | ¬p ∈ l}
s : Finset L
⊢ Finset.card s ≤ Finset.card (Finset.biUnion s t)

tactic: by_cases hs₁ : s.card = 1
state_before: case neg
P : Type u_1
L : Type u_2
inst✝³ : Membership P L
inst✝² : Nondegenerate P L
inst✝¹ : Fintype P
inst✝ : Fintype L
h : Fintype.card L ≤ Fintype.card P
t : L → Finset P := fun l => Set.toFinset {p | ¬p ∈ l}
s : Finset L
hs₀ : ¬Finset.card s = 0
⊢ Finset.card s ≤ Finset.card (Finset.biUnion s t)

tactic: suffices s.biUnion tᶜ.card ≤ sᶜ.card by
  rw [Finset.card_compl, Finset.card_compl, tsub_le_iff_left] at this
  replace := h.trans this
  rwa [← add_tsub_assoc_of_le s.card_le_univ, le_tsub_iff_left (le_add_left s.card_le_univ),
    add_le_add_iff_right] at this
state_before: case neg
P : Type u_1
L : Type u_2
inst✝³ : Membership P L
inst✝² : Nondegenerate P L
inst✝¹ : Fintype P
inst✝ : Fintype L
h : Fintype.card L ≤ Fintype.card P
t : L → Finset P := fun l => Set.toFinset {p | ¬p ∈ l}
s : Finset L
hs₀ : ¬Finset.card s = 0
hs₁ : ¬Finset.card s = 1
⊢ Finset.card s ≤ Finset.card (Finset.biUnion s t)

tactic: have hs₂ : s.biUnion tᶜ.card ≤ 1 := by
  refine' Finset.card_le_one_iff.mpr @fun p₁ p₂ hp₁ hp₂ => _
  simp_rw [Finset.mem_compl, Finset.mem_biUnion, exists_prop, not_exists, not_and,
    Set.mem_toFinset, Set.mem_setOf_eq, Classical.not_not] at hp₁ hp₂
  obtain ⟨l₁, l₂, hl₁, hl₂, hl₃⟩ :=
    Finset.one_lt_card_iff.mp (Nat.one_lt_iff_ne_zero_and_ne_one.mpr ⟨hs₀, hs₁⟩)
  exact (eq_or_eq (hp₁ l₁ hl₁) (hp₂ l₁ hl₁) (hp₁ l₂ hl₂) (hp₂ l₂ hl₂)).resolve_right hl₃
state_before: case neg
P : Type u_1
L : Type u_2
inst✝³ : Membership P L
inst✝² : Nondegenerate P L
inst✝¹ : Fintype P
inst✝ : Fintype L
h : Fintype.card L ≤ Fintype.card P
t : L → Finset P := fun l => Set.toFinset {p | ¬p ∈ l}
s : Finset L
hs₀ : ¬Finset.card s = 0
hs₁ : ¬Finset.card s = 1
⊢ Finset.card (Finset.biUnion s tᶜ) ≤ Finset.card (sᶜ)

tactic: by_cases hs₃ : sᶜ.card = 0
state_before: case neg
P : Type u_1
L : Type u_2
inst✝³ : Membership P L
inst✝² : Nondegenerate P L
inst✝¹ : Fintype P
inst✝ : Fintype L
h : Fintype.card L ≤ Fintype.card P
t : L → Finset P := fun l => Set.toFinset {p | ¬p ∈ l}
s : Finset L
hs₀ : ¬Finset.card s = 0
hs₁ : ¬Finset.card s = 1
hs₂ : Finset.card (Finset.biUnion s tᶜ) ≤ 1
⊢ Finset.card (Finset.biUnion s tᶜ) ≤ Finset.card (sᶜ)

tactic: obtain ⟨f, hf1, hf2⟩ := (Finset.all_card_le_biUnion_card_iff_exists_injective t).mp this
state_before: P : Type u_1
L : Type u_2
inst✝³ : Membership P L
inst✝² : Nondegenerate P L
inst✝¹ : Fintype P
inst✝ : Fintype L
h : Fintype.card L ≤ Fintype.card P
t : L → Finset P := fun l => Set.toFinset {p | ¬p ∈ l}
this : ∀ (s : Finset L), Finset.card s ≤ Finset.card (Finset.biUnion s t)
⊢ ∃ f, Function.Injective f ∧ ∀ (l : L), ¬f l ∈ l

tactic: exact ⟨f, hf1, fun l => Set.mem_toFinset.mp (hf2 l)⟩
state_before: case intro.intro
P : Type u_1
L : Type u_2
inst✝³ : Membership P L
inst✝² : Nondegenerate P L
inst✝¹ : Fintype P
inst✝ : Fintype L
h : Fintype.card L ≤ Fintype.card P
t : L → Finset P := fun l => Set.toFinset {p | ¬p ∈ l}
this : ∀ (s : Finset L), Finset.card s ≤ Finset.card (Finset.biUnion s t)
f : L → P
hf1 : Function.Injective f
hf2 : ∀ (x : L), f x ∈ t x
⊢ ∃ f, Function.Injective f ∧ ∀ (l : L), ¬f l ∈ l

tactic: simp_rw [hs₀, zero_le]
state_before: case pos
P : Type u_1
L : Type u_2
inst✝³ : Membership P L
inst✝² : Nondegenerate P L
inst✝¹ : Fintype P
inst✝ : Fintype L
h : Fintype.card L ≤ Fintype.card P
t : L → Finset P := fun l => Set.toFinset {p | ¬p ∈ l}
s : Finset L
hs₀ : Finset.card s = 0
⊢ Finset.card s ≤ Finset.card (Finset.biUnion s t)

tactic: obtain ⟨l, rfl⟩ := Finset.card_eq_one.mp hs₁
state_before: case pos
P : Type u_1
L : Type u_2
inst✝³ : Membership P L
inst✝² : Nondegenerate P L
inst✝¹ : Fintype P
inst✝ : Fintype L
h : Fintype.card L ≤ Fintype.card P
t : L → Finset P := fun l => Set.toFinset {p | ¬p ∈ l}
s : Finset L
hs₀ : ¬Finset.card s = 0
hs₁ : Finset.card s = 1
⊢ Finset.card s ≤ Finset.card (Finset.biUnion s t)

tactic: obtain ⟨p, hl⟩ := exists_point l
state_before: case pos.intro
P : Type u_1
L : Type u_2
inst✝³ : Membership P L
inst✝² : Nondegenerate P L
inst✝¹ : Fintype P
inst✝ : Fintype L
h : Fintype.card L ≤ Fintype.card P
t : L → Finset P := fun l => Set.toFinset {p | ¬p ∈ l}
l : L
hs₀ : ¬Finset.card {l} = 0
hs₁ : Finset.card {l} = 1
⊢ Finset.card {l} ≤ Finset.card (Finset.biUnion {l} t)

tactic: rw [Finset.card_singleton, Finset.singleton_biUnion, Nat.one_le_iff_ne_zero]
state_before: case pos.intro.intro
P : Type u_1
L : Type u_2
inst✝³ : Membership P L
inst✝² : Nondegenerate P L
inst✝¹ : Fintype P
inst✝ : Fintype L
h : Fintype.card L ≤ Fintype.card P
t : L → Finset P := fun l => Set.toFinset {p | ¬p ∈ l}
l : L
hs₀ : ¬Finset.card {l} = 0
hs₁ : Finset.card {l} = 1
p : P
hl : ¬p ∈ l
⊢ Finset.card {l} ≤ Finset.card (Finset.biUnion {l} t)

tactic: exact Finset.card_ne_zero_of_mem (Set.mem_toFinset.mpr hl)
state_before: case pos.intro.intro
P : Type u_1
L : Type u_2
inst✝³ : Membership P L
inst✝² : Nondegenerate P L
inst✝¹ : Fintype P
inst✝ : Fintype L
h : Fintype.card L ≤ Fintype.card P
t : L → Finset P := fun l => Set.toFinset {p | ¬p ∈ l}
l : L
hs₀ : ¬Finset.card {l} = 0
hs₁ : Finset.card {l} = 1
p : P
hl : ¬p ∈ l
⊢ Finset.card (t l) ≠ 0

tactic: rw [Finset.card_compl, Finset.card_compl, tsub_le_iff_left] at this
state_before: P : Type u_1
L : Type u_2
inst✝³ : Membership P L
inst✝² : Nondegenerate P L
inst✝¹ : Fintype P
inst✝ : Fintype L
h : Fintype.card L ≤ Fintype.card P
t : L → Finset P := fun l => Set.toFinset {p | ¬p ∈ l}
s : Finset L
hs₀ : ¬Finset.card s = 0
hs₁ : ¬Finset.card s = 1
this : Finset.card (Finset.biUnion s tᶜ) ≤ Finset.card (sᶜ)
⊢ Finset.card s ≤ Finset.card (Finset.biUnion s t)

tactic: replace := h.trans this
state_before: P : Type u_1
L : Type u_2
inst✝³ : Membership P L
inst✝² : Nondegenerate P L
inst✝¹ : Fintype P
inst✝ : Fintype L
h : Fintype.card L ≤ Fintype.card P
t : L → Finset P := fun l => Set.toFinset {p | ¬p ∈ l}
s : Finset L
hs₀ : ¬Finset.card s = 0
hs₁ : ¬Finset.card s = 1
this✝ : Fintype.card P - Finset.card (Finset.biUnion s t) ≤ Fintype.card L - Finset.card s
this : Fintype.card P ≤ Finset.card (Finset.biUnion s t) + (Fintype.card L - Finset.card s)
⊢ Finset.card s ≤ Finset.card (Finset.biUnion s t)

tactic: rwa [← add_tsub_assoc_of_le s.card_le_univ, le_tsub_iff_left (le_add_left s.card_le_univ),
  add_le_add_iff_right] at this
state_before: P : Type u_1
L : Type u_2
inst✝³ : Membership P L
inst✝² : Nondegenerate P L
inst✝¹ : Fintype P
inst✝ : Fintype L
h : Fintype.card L ≤ Fintype.card P
t : L → Finset P := fun l => Set.toFinset {p | ¬p ∈ l}
s : Finset L
hs₀ : ¬Finset.card s = 0
hs₁ : ¬Finset.card s = 1
this✝ : Fintype.card P - Finset.card (Finset.biUnion s t) ≤ Fintype.card L - Finset.card s
this : Fintype.card L ≤ Finset.card (Finset.biUnion s t) + (Fintype.card L - Finset.card s)
⊢ Finset.card s ≤ Finset.card (Finset.biUnion s t)

tactic: refine' Finset.card_le_one_iff.mpr @fun p₁ p₂ hp₁ hp₂ => _
state_before: P : Type u_1
L : Type u_2
inst✝³ : Membership P L
inst✝² : Nondegenerate P L
inst✝¹ : Fintype P
inst✝ : Fintype L
h : Fintype.card L ≤ Fintype.card P
t : L → Finset P := fun l => Set.toFinset {p | ¬p ∈ l}
s : Finset L
hs₀ : ¬Finset.card s = 0
hs₁ : ¬Finset.card s = 1
⊢ Finset.card (Finset.biUnion s tᶜ) ≤ 1

tactic: simp_rw [Finset.mem_compl, Finset.mem_biUnion, exists_prop, not_exists, not_and,
  Set.mem_toFinset, Set.mem_setOf_eq, Classical.not_not] at hp₁ hp₂
state_before: P : Type u_1
L : Type u_2
inst✝³ : Membership P L
inst✝² : Nondegenerate P L
inst✝¹ : Fintype P
inst✝ : Fintype L
h : Fintype.card L ≤ Fintype.card P
t : L → Finset P := fun l => Set.toFinset {p | ¬p ∈ l}
s : Finset L
hs₀ : ¬Finset.card s = 0
hs₁ : ¬Finset.card s = 1
p₁ p₂ : P
hp₁ : p₁ ∈ Finset.biUnion s tᶜ
hp₂ : p₂ ∈ Finset.biUnion s tᶜ
⊢ p₁ = p₂

tactic: obtain ⟨l₁, l₂, hl₁, hl₂, hl₃⟩ :=
  Finset.one_lt_card_iff.mp (Nat.one_lt_iff_ne_zero_and_ne_one.mpr ⟨hs₀, hs₁⟩)
state_before: P : Type u_1
L : Type u_2
inst✝³ : Membership P L
inst✝² : Nondegenerate P L
inst✝¹ : Fintype P
inst✝ : Fintype L
h : Fintype.card L ≤ Fintype.card P
t : L → Finset P := fun l => Set.toFinset {p | ¬p ∈ l}
s : Finset L
hs₀ : ¬Finset.card s = 0
hs₁ : ¬Finset.card s = 1
p₁ p₂ : P
hp₁ : ∀ (x : L), x ∈ s → p₁ ∈ x
hp₂ : ∀ (x : L), x ∈ s → p₂ ∈ x
⊢ p₁ = p₂

tactic: exact (eq_or_eq (hp₁ l₁ hl₁) (hp₂ l₁ hl₁) (hp₁ l₂ hl₂) (hp₂ l₂ hl₂)).resolve_right hl₃
state_before: case intro.intro.intro.intro
P : Type u_1
L : Type u_2
inst✝³ : Membership P L
inst✝² : Nondegenerate P L
inst✝¹ : Fintype P
inst✝ : Fintype L
h : Fintype.card L ≤ Fintype.card P
t : L → Finset P := fun l => Set.toFinset {p | ¬p ∈ l}
s : Finset L
hs₀ : ¬Finset.card s = 0
hs₁ : ¬Finset.card s = 1
p₁ p₂ : P
hp₁ : ∀ (x : L), x ∈ s → p₁ ∈ x
hp₂ : ∀ (x : L), x ∈ s → p₂ ∈ x
l₁ l₂ : L
hl₁ : l₁ ∈ s
hl₂ : l₂ ∈ s
hl₃ : l₁ ≠ l₂
⊢ p₁ = p₂

tactic: rw [hs₃, le_zero_iff]
state_before: case pos
P : Type u_1
L : Type u_2
inst✝³ : Membership P L
inst✝² : Nondegenerate P L
inst✝¹ : Fintype P
inst✝ : Fintype L
h : Fintype.card L ≤ Fintype.card P
t : L → Finset P := fun l => Set.toFinset {p | ¬p ∈ l}
s : Finset L
hs₀ : ¬Finset.card s = 0
hs₁ : ¬Finset.card s = 1
hs₂ : Finset.card (Finset.biUnion s tᶜ) ≤ 1
hs₃ : Finset.card (sᶜ) = 0
⊢ Finset.card (Finset.biUnion s tᶜ) ≤ Finset.card (sᶜ)

tactic: rw [Finset.card_compl, tsub_eq_zero_iff_le, LE.le.le_iff_eq (Finset.card_le_univ _), eq_comm,
  Finset.card_eq_iff_eq_univ] at hs₃⊢
state_before: case pos
P : Type u_1
L : Type u_2
inst✝³ : Membership P L
inst✝² : Nondegenerate P L
inst✝¹ : Fintype P
inst✝ : Fintype L
h : Fintype.card L ≤ Fintype.card P
t : L → Finset P := fun l => Set.toFinset {p | ¬p ∈ l}
s : Finset L
hs₀ : ¬Finset.card s = 0
hs₁ : ¬Finset.card s = 1
hs₂ : Finset.card (Finset.biUnion s tᶜ) ≤ 1
hs₃ : Finset.card (sᶜ) = 0
⊢ Finset.card (Finset.biUnion s tᶜ) = 0

tactic: rw [hs₃]
state_before: case pos
P : Type u_1
L : Type u_2
inst✝³ : Membership P L
inst✝² : Nondegenerate P L
inst✝¹ : Fintype P
inst✝ : Fintype L
h : Fintype.card L ≤ Fintype.card P
t : L → Finset P := fun l => Set.toFinset {p | ¬p ∈ l}
s : Finset L
hs₀ : ¬Finset.card s = 0
hs₁ : ¬Finset.card s = 1
hs₂ : Finset.card (Finset.biUnion s tᶜ) ≤ 1
hs₃ : s = Finset.univ
⊢ Finset.biUnion s t = Finset.univ

tactic: rw [Finset.eq_univ_iff_forall] at hs₃⊢
state_before: case pos
P : Type u_1
L : Type u_2
inst✝³ : Membership P L
inst✝² : Nondegenerate P L
inst✝¹ : Fintype P
inst✝ : Fintype L
h : Fintype.card L ≤ Fintype.card P
t : L → Finset P := fun l => Set.toFinset {p | ¬p ∈ l}
s : Finset L
hs₀ : ¬Finset.card s = 0
hs₁ : ¬Finset.card s = 1
hs₂ : Finset.card (Finset.biUnion s tᶜ) ≤ 1
hs₃ : s = Finset.univ
⊢ Finset.biUnion Finset.univ t = Finset.univ

tactic: exact fun p =>
  Exists.elim (exists_line p)fun l hl => Finset.mem_biUnion.mpr ⟨l, Finset.mem_univ l, Set.mem_toFinset.mpr hl⟩
state_before: case pos
P : Type u_1
L : Type u_2
inst✝³ : Membership P L
inst✝² : Nondegenerate P L
inst✝¹ : Fintype P
inst✝ : Fintype L
h : Fintype.card L ≤ Fintype.card P
t : L → Finset P := fun l => Set.toFinset {p | ¬p ∈ l}
s : Finset L
hs₀ : ¬Finset.card s = 0
hs₁ : ¬Finset.card s = 1
hs₂ : Finset.card (Finset.biUnion s tᶜ) ≤ 1
hs₃ : ∀ (x : L), x ∈ s
⊢ ∀ (x : P), x ∈ Finset.biUnion Finset.univ t

tactic: exact hs₂.trans (Nat.one_le_iff_ne_zero.mpr hs₃)
state_before: case neg
P : Type u_1
L : Type u_2
inst✝³ : Membership P L
inst✝² : Nondegenerate P L
inst✝¹ : Fintype P
inst✝ : Fintype L
h : Fintype.card L ≤ Fintype.card P
t : L → Finset P := fun l => Set.toFinset {p | ¬p ∈ l}
s : Finset L
hs₀ : ¬Finset.card s = 0
hs₁ : ¬Finset.card s = 1
hs₂ : Finset.card (Finset.biUnion s tᶜ) ≤ 1
hs₃ : ¬Finset.card (sᶜ) = 0
⊢ Finset.card (Finset.biUnion s tᶜ) ≤ Finset.card (sᶜ)