Theorem: Fintype.card_embedding_eq
File: Mathlib/Data/Fintype/CardEmbedding.lean

tactic: refine Fintype.induction_empty_option (P := fun t ↦ ‖t ↪ β‖ = ‖β‖.descFactorial ‖t‖)
      (fun α₁ α₂ h₂ e ih ↦ ?_) (?_) (fun γ h ih ↦ ?_) α <;> dsimp only <;> clear! α
state_before: α : Type u_1
β : Type u_2
inst✝¹ : Fintype α
inst✝ : Fintype β
emb : Fintype (α ↪ β)
⊢ ‖α ↪ β‖ = ‖β‖.descFactorial ‖α‖
state_after: case refine_1
β : Type u_2
inst✝ : Fintype β
α₁ α₂ : Type u_1
h₂ : Fintype α₂
e : α₁ ≃ α₂
ih : (fun t [Fintype t] => ‖t ↪ β‖ = ‖β‖.descFactorial ‖t‖) α₁
⊢ ‖α₂ ↪ β‖ = ‖β‖.descFactorial ‖α₂‖

case refine_2
β : Type u_2
inst✝ : Fintype β
⊢ ‖PEmpty.{u_1 + 1} ↪ β‖ = ‖β‖.descFactorial ‖PEmpty.{u_1 + 1}‖

case refine_3
β : Type u_2
inst✝ : Fintype β
γ : Type u_1
h : Fintype γ
ih : (fun t [Fintype t] => ‖t ↪ β‖ = ‖β‖.descFactorial ‖t‖) γ
⊢ ‖Option γ ↪ β‖ = ‖β‖.descFactorial ‖Option γ‖

tactic: letI := Fintype.ofEquiv _ e.symm
state_before: case refine_1
β : Type u_2
inst✝ : Fintype β
α₁ α₂ : Type u_1
h₂ : Fintype α₂
e : α₁ ≃ α₂
ih : (fun t [Fintype t] => ‖t ↪ β‖ = ‖β‖.descFactorial ‖t‖) α₁
⊢ ‖α₂ ↪ β‖ = ‖β‖.descFactorial ‖α₂‖
state_after: case refine_1
β : Type u_2
inst✝ : Fintype β
α₁ α₂ : Type u_1
h₂ : Fintype α₂
e : α₁ ≃ α₂
ih : (fun t [Fintype t] => ‖t ↪ β‖ = ‖β‖.descFactorial ‖t‖) α₁
this : Fintype α₁ := ofEquiv α₂ e.symm
⊢ ‖α₂ ↪ β‖ = ‖β‖.descFactorial ‖α₂‖

tactic: rw [← card_congr (Equiv.embeddingCongr e (Equiv.refl β)), ih, card_congr e]
state_before: case refine_1
β : Type u_2
inst✝ : Fintype β
α₁ α₂ : Type u_1
h₂ : Fintype α₂
e : α₁ ≃ α₂
ih : (fun t [Fintype t] => ‖t ↪ β‖ = ‖β‖.descFactorial ‖t‖) α₁
this : Fintype α₁ := ofEquiv α₂ e.symm
⊢ ‖α₂ ↪ β‖ = ‖β‖.descFactorial ‖α₂‖
state_after: no goals

tactic: rw [card_pempty, Nat.descFactorial_zero, card_eq_one_iff]
state_before: case refine_2
β : Type u_2
inst✝ : Fintype β
⊢ ‖PEmpty.{u_1 + 1} ↪ β‖ = ‖β‖.descFactorial ‖PEmpty.{u_1 + 1}‖
state_after: case refine_2
β : Type u_2
inst✝ : Fintype β
⊢ ∃ x, ∀ (y : PEmpty.{u_1 + 1} ↪ β), y = x

tactic: exact ⟨Embedding.ofIsEmpty, fun x ↦ DFunLike.ext _ _ isEmptyElim⟩
state_before: case refine_2
β : Type u_2
inst✝ : Fintype β
⊢ ∃ x, ∀ (y : PEmpty.{u_1 + 1} ↪ β), y = x
state_after: no goals

tactic: classical
dsimp only at ih
rw [card_option, Nat.descFactorial_succ, card_congr (Embedding.optionEmbeddingEquiv γ β),
    card_sigma, ← ih]
simp only [Fintype.card_compl_set, Fintype.card_range, Finset.sum_const, Finset.card_univ,
  Nat.nsmul_eq_mul, mul_comm]
state_before: case refine_3
β : Type u_2
inst✝ : Fintype β
γ : Type u_1
h : Fintype γ
ih : (fun t [Fintype t] => ‖t ↪ β‖ = ‖β‖.descFactorial ‖t‖) γ
⊢ ‖Option γ ↪ β‖ = ‖β‖.descFactorial ‖Option γ‖
state_after: no goals

tactic: dsimp only at ih
state_before: case refine_3
β : Type u_2
inst✝ : Fintype β
γ : Type u_1
h : Fintype γ
ih : (fun t [Fintype t] => ‖t ↪ β‖ = ‖β‖.descFactorial ‖t‖) γ
⊢ ‖Option γ ↪ β‖ = ‖β‖.descFactorial ‖Option γ‖
state_after: case refine_3
β : Type u_2
inst✝ : Fintype β
γ : Type u_1
h : Fintype γ
ih : ‖γ ↪ β‖ = ‖β‖.descFactorial ‖γ‖
⊢ ‖Option γ ↪ β‖ = ‖β‖.descFactorial ‖Option γ‖

tactic: rw [card_option, Nat.descFactorial_succ, card_congr (Embedding.optionEmbeddingEquiv γ β),
    card_sigma, ← ih]
state_before: case refine_3
β : Type u_2
inst✝ : Fintype β
γ : Type u_1
h : Fintype γ
ih : ‖γ ↪ β‖ = ‖β‖.descFactorial ‖γ‖
⊢ ‖Option γ ↪ β‖ = ‖β‖.descFactorial ‖Option γ‖
state_after: case refine_3
β : Type u_2
inst✝ : Fintype β
γ : Type u_1
h : Fintype γ
ih : ‖γ ↪ β‖ = ‖β‖.descFactorial ‖γ‖
⊢ ∑ i : γ ↪ β, ‖↑(Set.range ⇑i)ᶜ‖ = (‖β‖ - ‖γ‖) * ‖γ ↪ β‖

tactic: simp only [Fintype.card_compl_set, Fintype.card_range, Finset.sum_const, Finset.card_univ,
  Nat.nsmul_eq_mul, mul_comm]
state_before: case refine_3
β : Type u_2
inst✝ : Fintype β
γ : Type u_1
h : Fintype γ
ih : ‖γ ↪ β‖ = ‖β‖.descFactorial ‖γ‖
⊢ ∑ i : γ ↪ β, ‖↑(Set.range ⇑i)ᶜ‖ = (‖β‖ - ‖γ‖) * ‖γ ↪ β‖
state_after: no goals