Theorem: Configuration.HasLines.exists_bijective_of_card_eq
File: Mathlib/Combinatorics/Configuration.lean

tactic: classical
  obtain ⟨f, hf1, hf2⟩ := Nondegenerate.exists_injective_of_card_le (ge_of_eq h)
  have hf3 := (Fintype.bijective_iff_injective_and_card f).mpr ⟨hf1, h.symm⟩
  refine'
    ⟨f, hf3, fun l =>
      (Finset.sum_eq_sum_iff_of_le fun l _ => HasLines.pointCount_le_lineCount (hf2 l)).mp
        ((sum_lineCount_eq_sum_pointCount P L).symm.trans
          (Finset.sum_bij (fun l _ => f l) (fun l _ => Finset.mem_univ (f l))
              (fun l _ => refl (lineCount L (f l))) (fun l₁ l₂ hl₁ hl₂ hl => hf1 hl) fun p hp =>
              _).symm)
        l (Finset.mem_univ l)⟩
  obtain ⟨l, rfl⟩ := hf3.2 p
  exact ⟨l, Finset.mem_univ l, rfl⟩
state_before: P : Type u_1
L : Type u_2
inst✝³ : Membership P L
inst✝² : HasLines P L
inst✝¹ : Fintype P
inst✝ : Fintype L
h : Fintype.card P = Fintype.card L
⊢ ∃ f, Function.Bijective f ∧ ∀ (l : L), pointCount P l = lineCount L (f l)

tactic: obtain ⟨f, hf1, hf2⟩ := Nondegenerate.exists_injective_of_card_le (ge_of_eq h)
state_before: P : Type u_1
L : Type u_2
inst✝³ : Membership P L
inst✝² : HasLines P L
inst✝¹ : Fintype P
inst✝ : Fintype L
h : Fintype.card P = Fintype.card L
⊢ ∃ f, Function.Bijective f ∧ ∀ (l : L), pointCount P l = lineCount L (f l)

tactic: have hf3 := (Fintype.bijective_iff_injective_and_card f).mpr ⟨hf1, h.symm⟩
state_before: case intro.intro
P : Type u_1
L : Type u_2
inst✝³ : Membership P L
inst✝² : HasLines P L
inst✝¹ : Fintype P
inst✝ : Fintype L
h : Fintype.card P = Fintype.card L
f : L → P
hf1 : Function.Injective f
hf2 : ∀ (l : L), ¬f l ∈ l
⊢ ∃ f, Function.Bijective f ∧ ∀ (l : L), pointCount P l = lineCount L (f l)

tactic: refine'
  ⟨f, hf3, fun l =>
    (Finset.sum_eq_sum_iff_of_le fun l _ => HasLines.pointCount_le_lineCount (hf2 l)).mp
      ((sum_lineCount_eq_sum_pointCount P L).symm.trans
        (Finset.sum_bij (fun l _ => f l) (fun l _ => Finset.mem_univ (f l))
            (fun l _ => refl (lineCount L (f l))) (fun l₁ l₂ hl₁ hl₂ hl => hf1 hl) fun p hp =>
            _).symm)
      l (Finset.mem_univ l)⟩
state_before: case intro.intro
P : Type u_1
L : Type u_2
inst✝³ : Membership P L
inst✝² : HasLines P L
inst✝¹ : Fintype P
inst✝ : Fintype L
h : Fintype.card P = Fintype.card L
f : L → P
hf1 : Function.Injective f
hf2 : ∀ (l : L), ¬f l ∈ l
hf3 : Function.Bijective f
⊢ ∃ f, Function.Bijective f ∧ ∀ (l : L), pointCount P l = lineCount L (f l)

tactic: obtain ⟨l, rfl⟩ := hf3.2 p
state_before: case intro.intro
P : Type u_1
L : Type u_2
inst✝³ : Membership P L
inst✝² : HasLines P L
inst✝¹ : Fintype P
inst✝ : Fintype L
h : Fintype.card P = Fintype.card L
f : L → P
hf1 : Function.Injective f
hf2 : ∀ (l : L), ¬f l ∈ l
hf3 : Function.Bijective f
l : L
p : P
hp : p ∈ Finset.univ
⊢ ∃ a ha, p = (fun l x => f l) a ha

tactic: exact ⟨l, Finset.mem_univ l, rfl⟩
state_before: case intro.intro.intro
P : Type u_1
L : Type u_2
inst✝³ : Membership P L
inst✝² : HasLines P L
inst✝¹ : Fintype P
inst✝ : Fintype L
h : Fintype.card P = Fintype.card L
f : L → P
hf1 : Function.Injective f
hf2 : ∀ (l : L), ¬f l ∈ l
hf3 : Function.Bijective f
l✝ l : L
hp : f l ∈ Finset.univ
⊢ ∃ a ha, f l = (fun l x => f l) a ha