/-- Multiplicity of the ideal norm, for powers of prime ideals. -/
theorem cardQuot_pow_of_prime [IsDedekindDomain S] [Module.Finite ℤ S] [Module.Free ℤ S] {i : ℕ} :
    cardQuot (P ^ i) = cardQuot P ^ i := by
  let _ := Module.Free.chooseBasis ℤ S
  classical
  induction' i with i ih
  · simp
  letI := Ideal.fintypeQuotientOfFreeOfNeBot (P ^ i.succ) (pow_ne_zero _ hP)
  letI := Ideal.fintypeQuotientOfFreeOfNeBot (P ^ i) (pow_ne_zero _ hP)
  letI := Ideal.fintypeQuotientOfFreeOfNeBot P hP
  have : P ^ (i + 1) < P ^ i := Ideal.pow_succ_lt_pow hP i
  suffices hquot : map (P ^ i.succ).mkQ (P ^ i) ≃ S ⧸ P
  · rw [pow_succ (cardQuot P), ← ih, cardQuot_apply (P ^ i.succ), ←
      card_quotient_mul_card_quotient (P ^ i) (P ^ i.succ) this.le, cardQuot_apply (P ^ i),
      cardQuot_apply P]
    congr 1
    rw [Fintype.card_eq]
    exact ⟨hquot⟩
  choose a a_mem a_not_mem using SetLike.exists_of_lt this
  choose f g hg hf using fun c (hc : c ∈ P ^ i) =>
    Ideal.exists_mul_add_mem_pow_succ hP a c a_mem a_not_mem hc
  choose k hk_mem hk_eq using fun c' (hc' : c' ∈ map (mkQ (P ^ i.succ)) (P ^ i)) =>
    Submodule.mem_map.mp hc'
  refine Equiv.ofBijective (fun c' => Quotient.mk'' (f (k c' c'.prop) (hk_mem c' c'.prop))) ⟨?_, ?_⟩
  · rintro ⟨c₁', hc₁'⟩ ⟨c₂', hc₂'⟩ h
    rw [Subtype.mk_eq_mk, ← hk_eq _ hc₁', ← hk_eq _ hc₂', mkQ_apply, mkQ_apply,
      Submodule.Quotient.eq, ← hf _ (hk_mem _ hc₁'), ← hf _ (hk_mem _ hc₂')]
    refine Ideal.mul_add_mem_pow_succ_inj _ _ _ _ _ _ a_mem (hg _ _) (hg _ _) ?_
    simpa only [Submodule.Quotient.mk''_eq_mk, Submodule.Quotient.mk''_eq_mk,
      Submodule.Quotient.eq] using h
  · intro d'
    refine Quotient.inductionOn' d' fun d => ?_
    have hd' := (mem_map (f := mkQ (P ^ i.succ))).mpr ⟨a * d, Ideal.mul_mem_right d _ a_mem, rfl⟩
    refine ⟨⟨_, hd'⟩, ?_⟩
    simp only [Submodule.Quotient.mk''_eq_mk, Ideal.Quotient.mk_eq_mk, Ideal.Quotient.eq,
      Subtype.coe_mk]
    refine
      Ideal.mul_add_mem_pow_succ_unique hP a _ _ _ _ a_not_mem (hg _ (hk_mem _ hd')) (zero_mem _) ?_
    rw [hf, add_zero]
    

Proof state:
case hquot.refine_2
S : Type u_1
inst✝⁴ : CommRing S
inst✝³ : IsDomain S
P : Ideal S
P_prime : Ideal.IsPrime P
hP : P ≠ ⊥
inst✝² : IsDedekindDomain S
inst✝¹ : Module.Finite ℤ S
inst✝ : Module.Free ℤ S
x✝ : Basis (Module.Free.ChooseBasisIndex ℤ S) ℤ S := Module.Free.chooseBasis ℤ S
i : ℕ
ih : cardQuot (P ^ i) = cardQuot P ^ i
this✝² : Fintype (S ⧸ P ^ Nat.succ i) := Ideal.fintypeQuotientOfFreeOfNeBot (P ^ Nat.succ i) (_ : P ^ Nat.succ i ≠ 0)
this✝¹ : Fintype (S ⧸ P ^ i) := Ideal.fintypeQuotientOfFreeOfNeBot (P ^ i) (_ : P ^ i ≠ 0)
this✝ : Fintype (S ⧸ P) := Ideal.fintypeQuotientOfFreeOfNeBot P hP
this : P ^ (i + 1) < P ^ i
a : S
a_mem : a ∈ P ^ i
a_not_mem : a ∉ P ^ (i + 1)
f g : (c : S) → c ∈ P ^ i → S
hg : ∀ (c : S) (hc : c ∈ P ^ i), g c hc ∈ P ^ (i + 1)
hf : ∀ (c : S) (hc : c ∈ P ^ i), a * f c hc + g c hc = c
k : (c' : S ⧸ P ^ Nat.succ i) → c' ∈ map (mkQ (P ^ Nat.succ i)) (P ^ i) → S
hk_mem : ∀ (c' : S ⧸ P ^ Nat.succ i) (hc' : c' ∈ map (mkQ (P ^ Nat.succ i)) (P ^ i)), k c' hc' ∈ P ^ i
hk_eq :
  ∀ (c' : S ⧸ P ^ Nat.succ i) (hc' : c' ∈ map (mkQ (P ^ Nat.succ i)) (P ^ i)), (mkQ (P ^ Nat.succ i)) (k c' hc') = c'
d' : S ⧸ P
d : S
hd' : (mkQ (P ^ Nat.succ i)) (a * d) ∈ map (mkQ (P ^ Nat.succ i)) (P ^ i)
⊢ k ((mkQ (P ^ Nat.succ i)) (a * d))
        (_ : ↑{ val := (mkQ (P ^ Nat.succ i)) (a * d), property := hd' } ∈ map (mkQ (P ^ Nat.succ i)) (P ^ i)) -
      a * d ∈
    P ^ (i + 1)

Next tactic:
exact (Submodule.Quotient.eq _).mp (hk_eq _ hd')