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
hPL : Fintype.card P = Fintype.card L
p : P
l : L
hpl : ¬p ∈ l
f : L → P
hf1 : Function.Bijective f
hf2 : ∀ (l : L), pointCount P l = lineCount L (f l)
⊢ lineCount L p = pointCount P l
P : Type u_1
L : Type u_2
inst✝³ : Membership P L
inst✝² : HasLines P L
inst✝¹ : Fintype P
inst✝ : Fintype L
hPL : Fintype.card P = Fintype.card L
p : P
l : L
hpl : ¬p ∈ l
⊢ lineCount L p = pointCount P l
obtain ⟨f, hf1, hf2⟩ := HasLines.exists_bijective_of_card_eq hPL
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
hPL : Fintype.card P = Fintype.card L
p : P
l : L
hpl : ¬p ∈ l
f : L → P
hf1 : Function.Bijective f
hf2 : ∀ (l : L), pointCount P l = lineCount L (f l)
s : Finset (P × L) := Set.toFinset {i | i.fst ∈ i.snd}
⊢ lineCount L p = pointCount P l
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
hPL : Fintype.card P = Fintype.card L
p : P
l : L
hpl : ¬p ∈ l
f : L → P
hf1 : Function.Bijective f
hf2 : ∀ (l : L), pointCount P l = lineCount L (f l)
⊢ lineCount L p = pointCount P l
let s : Finset (P × L) := Set.toFinset { i | i.1 ∈ i.2 }
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
hPL : Fintype.card P = Fintype.card L
p : P
l : L
hpl : ¬p ∈ l
f : L → P
hf1 : Function.Bijective f
hf2 : ∀ (l : L), pointCount P l = lineCount L (f l)
s : Finset (P × L) := Set.toFinset {i | i.fst ∈ i.snd}
step1 : ∑ i : P × L, lineCount L i.fst = ∑ i : P × L, pointCount P i.snd
⊢ lineCount L p = pointCount P l
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
hPL : Fintype.card P = Fintype.card L
p : P
l : L
hpl : ¬p ∈ l
f : L → P
hf1 : Function.Bijective f
hf2 : ∀ (l : L), pointCount P l = lineCount L (f l)
s : Finset (P × L) := Set.toFinset {i | i.fst ∈ i.snd}
⊢ lineCount L p = pointCount P l
have step1 : (∑ i : P × L, lineCount L i.1) = ∑ i : P × L, pointCount P i.2 := by
  rw [← Finset.univ_product_univ, Finset.sum_product_right, Finset.sum_product]
  simp_rw [Finset.sum_const, Finset.card_univ, hPL, sum_lineCount_eq_sum_pointCount]
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
hPL : Fintype.card P = Fintype.card L
p : P
l : L
hpl : ¬p ∈ l
f : L → P
hf1 : Function.Bijective f
hf2 : ∀ (l : L), pointCount P l = lineCount L (f l)
s : Finset (P × L) := Set.toFinset {i | i.fst ∈ i.snd}
step1 : ∑ i : P × L, lineCount L i.fst = ∑ i : P × L, pointCount P i.snd
step2 : ∑ i in s, lineCount L i.fst = ∑ i in s, pointCount P i.snd
step3 : ∑ i in sᶜ, lineCount L i.fst = ∑ i in sᶜ, pointCount P i.snd
⊢ lineCount L p = pointCount P l
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
hPL : Fintype.card P = Fintype.card L
p : P
l : L
hpl : ¬p ∈ l
f : L → P
hf1 : Function.Bijective f
hf2 : ∀ (l : L), pointCount P l = lineCount L (f l)
s : Finset (P × L) := Set.toFinset {i | i.fst ∈ i.snd}
step1 : ∑ i : P × L, lineCount L i.fst = ∑ i : P × L, pointCount P i.snd
step2 : ∑ i in s, lineCount L i.fst = ∑ i in s, pointCount P i.snd
⊢ lineCount L p = pointCount P l
have step3 : (∑ i in sᶜ, lineCount L i.1) = ∑ i in sᶜ, pointCount P i.2 := by
  rwa [← s.sum_add_sum_compl, ← s.sum_add_sum_compl, step2, add_left_cancel_iff] at step1
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
hPL : Fintype.card P = Fintype.card L
p : P
l : L
hpl : ¬p ∈ l
f : L → P
hf1 : Function.Bijective f
hf2 : ∀ (l : L), pointCount P l = lineCount L (f l)
s : Finset (P × L) := Set.toFinset {i | i.fst ∈ i.snd}
step1 : ∑ i : P × L, lineCount L i.fst = ∑ i : P × L, pointCount P i.snd
step2 : ∑ i in s, lineCount L i.fst = ∑ i in s, pointCount P i.snd
step3 :
  ∑ i in Set.toFinset ({i | i.fst ∈ i.snd}ᶜ), lineCount L i.fst =
    ∑ i in Set.toFinset ({i | i.fst ∈ i.snd}ᶜ), pointCount P i.snd
⊢ lineCount L p = pointCount P l
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
hPL : Fintype.card P = Fintype.card L
p : P
l : L
hpl : ¬p ∈ l
f : L → P
hf1 : Function.Bijective f
hf2 : ∀ (l : L), pointCount P l = lineCount L (f l)
s : Finset (P × L) := Set.toFinset {i | i.fst ∈ i.snd}
step1 : ∑ i : P × L, lineCount L i.fst = ∑ i : P × L, pointCount P i.snd
step2 : ∑ i in s, lineCount L i.fst = ∑ i in s, pointCount P i.snd
step3 : ∑ i in sᶜ, lineCount L i.fst = ∑ i in sᶜ, pointCount P i.snd
⊢ lineCount L p = pointCount P l
rw [← Set.toFinset_compl] at step3
no goals
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
hPL : Fintype.card P = Fintype.card L
p : P
l : L
hpl : ¬p ∈ l
f : L → P
hf1 : Function.Bijective f
hf2 : ∀ (l : L), pointCount P l = lineCount L (f l)
s : Finset (P × L) := Set.toFinset {i | i.fst ∈ i.snd}
step1 : ∑ i : P × L, lineCount L i.fst = ∑ i : P × L, pointCount P i.snd
step2 : ∑ i in s, lineCount L i.fst = ∑ i in s, pointCount P i.snd
step3 :
  ∑ i in Set.toFinset ({i | i.fst ∈ i.snd}ᶜ), lineCount L i.fst =
    ∑ i in Set.toFinset ({i | i.fst ∈ i.snd}ᶜ), pointCount P i.snd
⊢ lineCount L p = pointCount P l
exact
  ((Finset.sum_eq_sum_iff_of_le fun i hi =>
          HasLines.pointCount_le_lineCount (by exact Set.mem_toFinset.mp hi)).mp
      step3.symm (p, l) (Set.mem_toFinset.mpr hpl)).symm
P : Type u_1
L : Type u_2
inst✝³ : Membership P L
inst✝² : HasLines P L
inst✝¹ : Fintype P
inst✝ : Fintype L
hPL : Fintype.card P = Fintype.card L
p : P
l : L
hpl : ¬p ∈ l
f : L → P
hf1 : Function.Bijective f
hf2 : ∀ (l : L), pointCount P l = lineCount L (f l)
s : Finset (P × L) := Set.toFinset {i | i.fst ∈ i.snd}
⊢ ∑ y : L, ∑ x : P, lineCount L (x, y).fst = ∑ x : P, ∑ y : L, pointCount P (x, y).snd
P : Type u_1
L : Type u_2
inst✝³ : Membership P L
inst✝² : HasLines P L
inst✝¹ : Fintype P
inst✝ : Fintype L
hPL : Fintype.card P = Fintype.card L
p : P
l : L
hpl : ¬p ∈ l
f : L → P
hf1 : Function.Bijective f
hf2 : ∀ (l : L), pointCount P l = lineCount L (f l)
s : Finset (P × L) := Set.toFinset {i | i.fst ∈ i.snd}
⊢ ∑ i : P × L, lineCount L i.fst = ∑ i : P × L, pointCount P i.snd
rw [← Finset.univ_product_univ, Finset.sum_product_right, Finset.sum_product]
no goals
P : Type u_1
L : Type u_2
inst✝³ : Membership P L
inst✝² : HasLines P L
inst✝¹ : Fintype P
inst✝ : Fintype L
hPL : Fintype.card P = Fintype.card L
p : P
l : L
hpl : ¬p ∈ l
f : L → P
hf1 : Function.Bijective f
hf2 : ∀ (l : L), pointCount P l = lineCount L (f l)
s : Finset (P × L) := Set.toFinset {i | i.fst ∈ i.snd}
⊢ ∑ y : L, ∑ x : P, lineCount L (x, y).fst = ∑ x : P, ∑ y : L, pointCount P (x, y).snd
simp_rw [Finset.sum_const, Finset.card_univ, hPL, sum_lineCount_eq_sum_pointCount]
P : Type u_1
L : Type u_2
inst✝³ : Membership P L
inst✝² : HasLines P L
inst✝¹ : Fintype P
inst✝ : Fintype L
hPL : Fintype.card P = Fintype.card L
p : P
l : L
hpl : ¬p ∈ l
f : L → P
hf1 : Function.Bijective f
hf2 : ∀ (l : L), pointCount P l = lineCount L (f l)
s : Finset (P × L) := Set.toFinset {i | i.fst ∈ i.snd}
step1 : ∑ i : P × L, lineCount L i.fst = ∑ i : P × L, pointCount P i.snd
⊢ ∑ c : P, ∑ a in Set.toFinset {l | c ∈ l}, lineCount L (c, a).fst = ∑ i in s, pointCount P i.snd

case h
P : Type u_1
L : Type u_2
inst✝³ : Membership P L
inst✝² : HasLines P L
inst✝¹ : Fintype P
inst✝ : Fintype L
hPL : Fintype.card P = Fintype.card L
p : P
l : L
hpl : ¬p ∈ l
f : L → P
hf1 : Function.Bijective f
hf2 : ∀ (l : L), pointCount P l = lineCount L (f l)
s : Finset (P × L) := Set.toFinset {i | i.fst ∈ i.snd}
step1 : ∑ i : P × L, lineCount L i.fst = ∑ i : P × L, pointCount P i.snd
⊢ ∀ (p : P × L), p ∈ s ↔ p.fst ∈ Finset.univ ∧ p.snd ∈ Set.toFinset {l | p.fst ∈ l}
P : Type u_1
L : Type u_2
inst✝³ : Membership P L
inst✝² : HasLines P L
inst✝¹ : Fintype P
inst✝ : Fintype L
hPL : Fintype.card P = Fintype.card L
p : P
l : L
hpl : ¬p ∈ l
f : L → P
hf1 : Function.Bijective f
hf2 : ∀ (l : L), pointCount P l = lineCount L (f l)
s : Finset (P × L) := Set.toFinset {i | i.fst ∈ i.snd}
step1 : ∑ i : P × L, lineCount L i.fst = ∑ i : P × L, pointCount P i.snd
⊢ ∑ i in s, lineCount L i.fst = ∑ i in s, pointCount P i.snd
rw [s.sum_finset_product Finset.univ fun p => Set.toFinset { l | p ∈ l }]
P : Type u_1
L : Type u_2
inst✝³ : Membership P L
inst✝² : HasLines P L
inst✝¹ : Fintype P
inst✝ : Fintype L
hPL : Fintype.card P = Fintype.card L
p : P
l : L
hpl : ¬p ∈ l
f : L → P
hf1 : Function.Bijective f
hf2 : ∀ (l : L), pointCount P l = lineCount L (f l)
s : Finset (P × L) := Set.toFinset {i | i.fst ∈ i.snd}
step1 : ∑ i : P × L, lineCount L i.fst = ∑ i : P × L, pointCount P i.snd
⊢ ∑ c : P, ∑ a in Set.toFinset {l | c ∈ l}, lineCount L (c, a).fst =
    ∑ c : L, ∑ a in Set.toFinset {p | p ∈ c}, pointCount P (a, c).snd

case h
P : Type u_1
L : Type u_2
inst✝³ : Membership P L
inst✝² : HasLines P L
inst✝¹ : Fintype P
inst✝ : Fintype L
hPL : Fintype.card P = Fintype.card L
p : P
l : L
hpl : ¬p ∈ l
f : L → P
hf1 : Function.Bijective f
hf2 : ∀ (l : L), pointCount P l = lineCount L (f l)
s : Finset (P × L) := Set.toFinset {i | i.fst ∈ i.snd}
step1 : ∑ i : P × L, lineCount L i.fst = ∑ i : P × L, pointCount P i.snd
⊢ ∀ (p : P × L), p ∈ s ↔ p.snd ∈ Finset.univ ∧ p.fst ∈ Set.toFinset {p_1 | p_1 ∈ p.snd}

case h
P : Type u_1
L : Type u_2
inst✝³ : Membership P L
inst✝² : HasLines P L
inst✝¹ : Fintype P
inst✝ : Fintype L
hPL : Fintype.card P = Fintype.card L
p : P
l : L
hpl : ¬p ∈ l
f : L → P
hf1 : Function.Bijective f
hf2 : ∀ (l : L), pointCount P l = lineCount L (f l)
s : Finset (P × L) := Set.toFinset {i | i.fst ∈ i.snd}
step1 : ∑ i : P × L, lineCount L i.fst = ∑ i : P × L, pointCount P i.snd
⊢ ∀ (p : P × L), p ∈ s ↔ p.fst ∈ Finset.univ ∧ p.snd ∈ Set.toFinset {l | p.fst ∈ l}
P : Type u_1
L : Type u_2
inst✝³ : Membership P L
inst✝² : HasLines P L
inst✝¹ : Fintype P
inst✝ : Fintype L
hPL : Fintype.card P = Fintype.card L
p : P
l : L
hpl : ¬p ∈ l
f : L → P
hf1 : Function.Bijective f
hf2 : ∀ (l : L), pointCount P l = lineCount L (f l)
s : Finset (P × L) := Set.toFinset {i | i.fst ∈ i.snd}
step1 : ∑ i : P × L, lineCount L i.fst = ∑ i : P × L, pointCount P i.snd
⊢ ∑ c : P, ∑ a in Set.toFinset {l | c ∈ l}, lineCount L (c, a).fst = ∑ i in s, pointCount P i.snd

case h
P : Type u_1
L : Type u_2
inst✝³ : Membership P L
inst✝² : HasLines P L
inst✝¹ : Fintype P
inst✝ : Fintype L
hPL : Fintype.card P = Fintype.card L
p : P
l : L
hpl : ¬p ∈ l
f : L → P
hf1 : Function.Bijective f
hf2 : ∀ (l : L), pointCount P l = lineCount L (f l)
s : Finset (P × L) := Set.toFinset {i | i.fst ∈ i.snd}
step1 : ∑ i : P × L, lineCount L i.fst = ∑ i : P × L, pointCount P i.snd
⊢ ∀ (p : P × L), p ∈ s ↔ p.fst ∈ Finset.univ ∧ p.snd ∈ Set.toFinset {l | p.fst ∈ l}
rw [s.sum_finset_product_right Finset.univ fun l => Set.toFinset { p | p ∈ l }]
case refine'_1
P : Type u_1
L : Type u_2
inst✝³ : Membership P L
inst✝² : HasLines P L
inst✝¹ : Fintype P
inst✝ : Fintype L
hPL : Fintype.card P = Fintype.card L
p : P
l✝ : L
hpl : ¬p ∈ l✝
f : L → P
hf1 : Function.Bijective f
hf2 : ∀ (l : L), pointCount P l = lineCount L (f l)
s : Finset (P × L) := Set.toFinset {i | i.fst ∈ i.snd}
step1 : ∑ i : P × L, lineCount L i.fst = ∑ i : P × L, pointCount P i.snd
l : L
hl : l ∈ Finset.univ
⊢ ∑ a in Set.toFinset {p | p ∈ l}, pointCount P (a, l).snd =
    ∑ a in Set.toFinset {l_1 | (fun l x => f l) l hl ∈ l_1}, lineCount L ((fun l x => f l) l hl, a).fst

case refine'_2
P : Type u_1
L : Type u_2
inst✝³ : Membership P L
inst✝² : HasLines P L
inst✝¹ : Fintype P
inst✝ : Fintype L
hPL : Fintype.card P = Fintype.card L
p✝ : P
l : L
hpl : ¬p✝ ∈ l
f : L → P
hf1 : Function.Bijective f
hf2 : ∀ (l : L), pointCount P l = lineCount L (f l)
s : Finset (P × L) := Set.toFinset {i | i.fst ∈ i.snd}
step1 : ∑ i : P × L, lineCount L i.fst = ∑ i : P × L, pointCount P i.snd
p : P
x✝ : p ∈ Finset.univ
⊢ ∃ a ha, p = (fun l x => f l) a ha

case h
P : Type u_1
L : Type u_2
inst✝³ : Membership P L
inst✝² : HasLines P L
inst✝¹ : Fintype P
inst✝ : Fintype L
hPL : Fintype.card P = Fintype.card L
p : P
l : L
hpl : ¬p ∈ l
f : L → P
hf1 : Function.Bijective f
hf2 : ∀ (l : L), pointCount P l = lineCount L (f l)
s : Finset (P × L) := Set.toFinset {i | i.fst ∈ i.snd}
step1 : ∑ i : P × L, lineCount L i.fst = ∑ i : P × L, pointCount P i.snd
⊢ ∀ (p : P × L), p ∈ s ↔ p.snd ∈ Finset.univ ∧ p.fst ∈ Set.toFinset {p_1 | p_1 ∈ p.snd}

case h
P : Type u_1
L : Type u_2
inst✝³ : Membership P L
inst✝² : HasLines P L
inst✝¹ : Fintype P
inst✝ : Fintype L
hPL : Fintype.card P = Fintype.card L
p : P
l : L
hpl : ¬p ∈ l
f : L → P
hf1 : Function.Bijective f
hf2 : ∀ (l : L), pointCount P l = lineCount L (f l)
s : Finset (P × L) := Set.toFinset {i | i.fst ∈ i.snd}
step1 : ∑ i : P × L, lineCount L i.fst = ∑ i : P × L, pointCount P i.snd
⊢ ∀ (p : P × L), p ∈ s ↔ p.fst ∈ Finset.univ ∧ p.snd ∈ Set.toFinset {l | p.fst ∈ l}
P : Type u_1
L : Type u_2
inst✝³ : Membership P L
inst✝² : HasLines P L
inst✝¹ : Fintype P
inst✝ : Fintype L
hPL : Fintype.card P = Fintype.card L
p : P
l : L
hpl : ¬p ∈ l
f : L → P
hf1 : Function.Bijective f
hf2 : ∀ (l : L), pointCount P l = lineCount L (f l)
s : Finset (P × L) := Set.toFinset {i | i.fst ∈ i.snd}
step1 : ∑ i : P × L, lineCount L i.fst = ∑ i : P × L, pointCount P i.snd
⊢ ∑ c : P, ∑ a in Set.toFinset {l | c ∈ l}, lineCount L (c, a).fst =
    ∑ c : L, ∑ a in Set.toFinset {p | p ∈ c}, pointCount P (a, c).snd

case h
P : Type u_1
L : Type u_2
inst✝³ : Membership P L
inst✝² : HasLines P L
inst✝¹ : Fintype P
inst✝ : Fintype L
hPL : Fintype.card P = Fintype.card L
p : P
l : L
hpl : ¬p ∈ l
f : L → P
hf1 : Function.Bijective f
hf2 : ∀ (l : L), pointCount P l = lineCount L (f l)
s : Finset (P × L) := Set.toFinset {i | i.fst ∈ i.snd}
step1 : ∑ i : P × L, lineCount L i.fst = ∑ i : P × L, pointCount P i.snd
⊢ ∀ (p : P × L), p ∈ s ↔ p.snd ∈ Finset.univ ∧ p.fst ∈ Set.toFinset {p_1 | p_1 ∈ p.snd}

case h
P : Type u_1
L : Type u_2
inst✝³ : Membership P L
inst✝² : HasLines P L
inst✝¹ : Fintype P
inst✝ : Fintype L
hPL : Fintype.card P = Fintype.card L
p : P
l : L
hpl : ¬p ∈ l
f : L → P
hf1 : Function.Bijective f
hf2 : ∀ (l : L), pointCount P l = lineCount L (f l)
s : Finset (P × L) := Set.toFinset {i | i.fst ∈ i.snd}
step1 : ∑ i : P × L, lineCount L i.fst = ∑ i : P × L, pointCount P i.snd
⊢ ∀ (p : P × L), p ∈ s ↔ p.fst ∈ Finset.univ ∧ p.snd ∈ Set.toFinset {l | p.fst ∈ l}
refine'
  (Finset.sum_bij (fun l _ => f l) (fun l _ => Finset.mem_univ (f l)) (fun l hl => _)
      (fun _ _ _ _ h => hf1.1 h) fun p _ => _).symm
no goals
case h
P : Type u_1
L : Type u_2
inst✝³ : Membership P L
inst✝² : HasLines P L
inst✝¹ : Fintype P
inst✝ : Fintype L
hPL : Fintype.card P = Fintype.card L
p : P
l : L
hpl : ¬p ∈ l
f : L → P
hf1 : Function.Bijective f
hf2 : ∀ (l : L), pointCount P l = lineCount L (f l)
s : Finset (P × L) := Set.toFinset {i | i.fst ∈ i.snd}
step1 : ∑ i : P × L, lineCount L i.fst = ∑ i : P × L, pointCount P i.snd
⊢ ∀ (p : P × L), p ∈ s ↔ p.snd ∈ Finset.univ ∧ p.fst ∈ Set.toFinset {p_1 | p_1 ∈ p.snd}

case h
P : Type u_1
L : Type u_2
inst✝³ : Membership P L
inst✝² : HasLines P L
inst✝¹ : Fintype P
inst✝ : Fintype L
hPL : Fintype.card P = Fintype.card L
p : P
l : L
hpl : ¬p ∈ l
f : L → P
hf1 : Function.Bijective f
hf2 : ∀ (l : L), pointCount P l = lineCount L (f l)
s : Finset (P × L) := Set.toFinset {i | i.fst ∈ i.snd}
step1 : ∑ i : P × L, lineCount L i.fst = ∑ i : P × L, pointCount P i.snd
⊢ ∀ (p : P × L), p ∈ s ↔ p.fst ∈ Finset.univ ∧ p.snd ∈ Set.toFinset {l | p.fst ∈ l}
all_goals simp_rw [Finset.mem_univ, true_and_iff, Set.mem_toFinset]; exact fun p => Iff.rfl
case refine'_1
P : Type u_1
L : Type u_2
inst✝³ : Membership P L
inst✝² : HasLines P L
inst✝¹ : Fintype P
inst✝ : Fintype L
hPL : Fintype.card P = Fintype.card L
p : P
l✝ : L
hpl : ¬p ∈ l✝
f : L → P
hf1 : Function.Bijective f
hf2 : ∀ (l : L), pointCount P l = lineCount L (f l)
s : Finset (P × L) := Set.toFinset {i | i.fst ∈ i.snd}
step1 : ∑ i : P × L, lineCount L i.fst = ∑ i : P × L, pointCount P i.snd
l : L
hl : l ∈ Finset.univ
⊢ Nat.card ↑{p | p ∈ l} • pointCount P l = Nat.card ↑{l_1 | f l ∈ l_1} • lineCount L (f l)
case refine'_1
P : Type u_1
L : Type u_2
inst✝³ : Membership P L
inst✝² : HasLines P L
inst✝¹ : Fintype P
inst✝ : Fintype L
hPL : Fintype.card P = Fintype.card L
p : P
l✝ : L
hpl : ¬p ∈ l✝
f : L → P
hf1 : Function.Bijective f
hf2 : ∀ (l : L), pointCount P l = lineCount L (f l)
s : Finset (P × L) := Set.toFinset {i | i.fst ∈ i.snd}
step1 : ∑ i : P × L, lineCount L i.fst = ∑ i : P × L, pointCount P i.snd
l : L
hl : l ∈ Finset.univ
⊢ ∑ a in Set.toFinset {p | p ∈ l}, pointCount P (a, l).snd =
    ∑ a in Set.toFinset {l_1 | (fun l x => f l) l hl ∈ l_1}, lineCount L ((fun l x => f l) l hl, a).fst
simp_rw [Finset.sum_const, Set.toFinset_card, ← Nat.card_eq_fintype_card]
case refine'_1
P : Type u_1
L : Type u_2
inst✝³ : Membership P L
inst✝² : HasLines P L
inst✝¹ : Fintype P
inst✝ : Fintype L
hPL : Fintype.card P = Fintype.card L
p : P
l✝ : L
hpl : ¬p ∈ l✝
f : L → P
hf1 : Function.Bijective f
hf2 : ∀ (l : L), pointCount P l = lineCount L (f l)
s : Finset (P × L) := Set.toFinset {i | i.fst ∈ i.snd}
step1 : ∑ i : P × L, lineCount L i.fst = ∑ i : P × L, pointCount P i.snd
l : L
hl : l ∈ Finset.univ
⊢ pointCount P l • pointCount P l = lineCount L (f l) • lineCount L (f l)
case refine'_1
P : Type u_1
L : Type u_2
inst✝³ : Membership P L
inst✝² : HasLines P L
inst✝¹ : Fintype P
inst✝ : Fintype L
hPL : Fintype.card P = Fintype.card L
p : P
l✝ : L
hpl : ¬p ∈ l✝
f : L → P
hf1 : Function.Bijective f
hf2 : ∀ (l : L), pointCount P l = lineCount L (f l)
s : Finset (P × L) := Set.toFinset {i | i.fst ∈ i.snd}
step1 : ∑ i : P × L, lineCount L i.fst = ∑ i : P × L, pointCount P i.snd
l : L
hl : l ∈ Finset.univ
⊢ Nat.card ↑{p | p ∈ l} • pointCount P l = Nat.card ↑{l_1 | f l ∈ l_1} • lineCount L (f l)
change pointCount P l • pointCount P l = lineCount L (f l) • lineCount L (f l)
no goals
case refine'_1
P : Type u_1
L : Type u_2
inst✝³ : Membership P L
inst✝² : HasLines P L
inst✝¹ : Fintype P
inst✝ : Fintype L
hPL : Fintype.card P = Fintype.card L
p : P
l✝ : L
hpl : ¬p ∈ l✝
f : L → P
hf1 : Function.Bijective f
hf2 : ∀ (l : L), pointCount P l = lineCount L (f l)
s : Finset (P × L) := Set.toFinset {i | i.fst ∈ i.snd}
step1 : ∑ i : P × L, lineCount L i.fst = ∑ i : P × L, pointCount P i.snd
l : L
hl : l ∈ Finset.univ
⊢ pointCount P l • pointCount P l = lineCount L (f l) • lineCount L (f l)
rw [hf2]
case refine'_2.intro
P : Type u_1
L : Type u_2
inst✝³ : Membership P L
inst✝² : HasLines P L
inst✝¹ : Fintype P
inst✝ : Fintype L
hPL : Fintype.card P = Fintype.card L
p✝ : P
l✝ : L
hpl : ¬p✝ ∈ l✝
f : L → P
hf1 : Function.Bijective f
hf2 : ∀ (l : L), pointCount P l = lineCount L (f l)
s : Finset (P × L) := Set.toFinset {i | i.fst ∈ i.snd}
step1 : ∑ i : P × L, lineCount L i.fst = ∑ i : P × L, pointCount P i.snd
p : P
x✝ : p ∈ Finset.univ
l : L
hl : f l = p
⊢ ∃ a ha, p = (fun l x => f l) a ha
case refine'_2
P : Type u_1
L : Type u_2
inst✝³ : Membership P L
inst✝² : HasLines P L
inst✝¹ : Fintype P
inst✝ : Fintype L
hPL : Fintype.card P = Fintype.card L
p✝ : P
l : L
hpl : ¬p✝ ∈ l
f : L → P
hf1 : Function.Bijective f
hf2 : ∀ (l : L), pointCount P l = lineCount L (f l)
s : Finset (P × L) := Set.toFinset {i | i.fst ∈ i.snd}
step1 : ∑ i : P × L, lineCount L i.fst = ∑ i : P × L, pointCount P i.snd
p : P
x✝ : p ∈ Finset.univ
⊢ ∃ a ha, p = (fun l x => f l) a ha
obtain ⟨l, hl⟩ := hf1.2 p
no goals
case refine'_2.intro
P : Type u_1
L : Type u_2
inst✝³ : Membership P L
inst✝² : HasLines P L
inst✝¹ : Fintype P
inst✝ : Fintype L
hPL : Fintype.card P = Fintype.card L
p✝ : P
l✝ : L
hpl : ¬p✝ ∈ l✝
f : L → P
hf1 : Function.Bijective f
hf2 : ∀ (l : L), pointCount P l = lineCount L (f l)
s : Finset (P × L) := Set.toFinset {i | i.fst ∈ i.snd}
step1 : ∑ i : P × L, lineCount L i.fst = ∑ i : P × L, pointCount P i.snd
p : P
x✝ : p ∈ Finset.univ
l : L
hl : f l = p
⊢ ∃ a ha, p = (fun l x => f l) a ha
exact ⟨l, Finset.mem_univ l, hl.symm⟩
case h
P : Type u_1
L : Type u_2
inst✝³ : Membership P L
inst✝² : HasLines P L
inst✝¹ : Fintype P
inst✝ : Fintype L
hPL : Fintype.card P = Fintype.card L
p : P
l : L
hpl : ¬p ∈ l
f : L → P
hf1 : Function.Bijective f
hf2 : ∀ (l : L), pointCount P l = lineCount L (f l)
s : Finset (P × L) := Set.toFinset {i | i.fst ∈ i.snd}
step1 : ∑ i : P × L, lineCount L i.fst = ∑ i : P × L, pointCount P i.snd
⊢ ∀ (p : P × L), p ∈ {i | i.fst ∈ i.snd} ↔ p.snd ∈ {l | p.fst ∈ l}
case h
P : Type u_1
L : Type u_2
inst✝³ : Membership P L
inst✝² : HasLines P L
inst✝¹ : Fintype P
inst✝ : Fintype L
hPL : Fintype.card P = Fintype.card L
p : P
l : L
hpl : ¬p ∈ l
f : L → P
hf1 : Function.Bijective f
hf2 : ∀ (l : L), pointCount P l = lineCount L (f l)
s : Finset (P × L) := Set.toFinset {i | i.fst ∈ i.snd}
step1 : ∑ i : P × L, lineCount L i.fst = ∑ i : P × L, pointCount P i.snd
⊢ ∀ (p : P × L), p ∈ s ↔ p.fst ∈ Finset.univ ∧ p.snd ∈ Set.toFinset {l | p.fst ∈ l}
simp_rw [Finset.mem_univ, true_and_iff, Set.mem_toFinset]
no goals
case h
P : Type u_1
L : Type u_2
inst✝³ : Membership P L
inst✝² : HasLines P L
inst✝¹ : Fintype P
inst✝ : Fintype L
hPL : Fintype.card P = Fintype.card L
p : P
l : L
hpl : ¬p ∈ l
f : L → P
hf1 : Function.Bijective f
hf2 : ∀ (l : L), pointCount P l = lineCount L (f l)
s : Finset (P × L) := Set.toFinset {i | i.fst ∈ i.snd}
step1 : ∑ i : P × L, lineCount L i.fst = ∑ i : P × L, pointCount P i.snd
⊢ ∀ (p : P × L), p ∈ {i | i.fst ∈ i.snd} ↔ p.snd ∈ {l | p.fst ∈ l}
exact fun p => Iff.rfl
no goals
P : Type u_1
L : Type u_2
inst✝³ : Membership P L
inst✝² : HasLines P L
inst✝¹ : Fintype P
inst✝ : Fintype L
hPL : Fintype.card P = Fintype.card L
p : P
l : L
hpl : ¬p ∈ l
f : L → P
hf1 : Function.Bijective f
hf2 : ∀ (l : L), pointCount P l = lineCount L (f l)
s : Finset (P × L) := Set.toFinset {i | i.fst ∈ i.snd}
step1 : ∑ i : P × L, lineCount L i.fst = ∑ i : P × L, pointCount P i.snd
step2 : ∑ i in s, lineCount L i.fst = ∑ i in s, pointCount P i.snd
⊢ ∑ i in sᶜ, lineCount L i.fst = ∑ i in sᶜ, pointCount P i.snd
rwa [← s.sum_add_sum_compl, ← s.sum_add_sum_compl, step2, add_left_cancel_iff] at step1
no goals
P : Type u_1
L : Type u_2
inst✝³ : Membership P L
inst✝² : HasLines P L
inst✝¹ : Fintype P
inst✝ : Fintype L
hPL : Fintype.card P = Fintype.card L
p : P
l : L
hpl : ¬p ∈ l
f : L → P
hf1 : Function.Bijective f
hf2 : ∀ (l : L), pointCount P l = lineCount L (f l)
s : Finset (P × L) := Set.toFinset {i | i.fst ∈ i.snd}
step1 : ∑ i : P × L, lineCount L i.fst = ∑ i : P × L, pointCount P i.snd
step2 : ∑ i in s, lineCount L i.fst = ∑ i in s, pointCount P i.snd
step3 :
  ∑ i in Set.toFinset ({i | i.fst ∈ i.snd}ᶜ), lineCount L i.fst =
    ∑ i in Set.toFinset ({i | i.fst ∈ i.snd}ᶜ), pointCount P i.snd
i : P × L
hi : i ∈ Set.toFinset ({i | i.fst ∈ i.snd}ᶜ)
⊢ ¬i.fst ∈ i.snd
exact Set.mem_toFinset.mp hi