l3lab/ntp-mathlib huggingface dataset:
theorem Factors.finrank_pow_ramificationIdx [p.IsMaximal]
    (P : (factors (map (algebraMap R S) p)).toFinset) :
    finrank (R ⧸ p) (S ⧸ (P : Ideal S) ^ ramificationIdx (algebraMap R S) p P) =
      ramificationIdx (algebraMap R S) p P * inertiaDeg (algebraMap R S) p P := by
  

Proof state:
R : Type u
inst✝⁵ : CommRing R
S : Type v
inst✝⁴ : CommRing S
f : R →+* S
p : Ideal R
P✝ : Ideal S
inst✝³ : IsDomain S
inst✝² : IsDedekindDomain S
inst✝¹ : Algebra R S
inst✝ : IsMaximal p
P : { x // x ∈ Multiset.toFinset (factors (map (algebraMap R S) p)) }
⊢ finrank (R ⧸ p) (S ⧸ ↑P ^ ramificationIdx (algebraMap R S) p ↑P) =
    ramificationIdx (algebraMap R S) p ↑P * inertiaDeg (algebraMap R S) p ↑P

Next tactic:
rw [finrank_prime_pow_ramificationIdx, inertiaDeg_algebraMap]
theorem Factors.finrank_pow_ramificationIdx [p.IsMaximal]
    (P : (factors (map (algebraMap R S) p)).toFinset) :
    finrank (R ⧸ p) (S ⧸ (P : Ideal S) ^ ramificationIdx (algebraMap R S) p P) =
      ramificationIdx (algebraMap R S) p P * inertiaDeg (algebraMap R S) p P := by
  rw [finrank_prime_pow_ramificationIdx, inertiaDeg_algebraMap]
  

Proof state:
case he
R : Type u
inst✝⁵ : CommRing R
S : Type v
inst✝⁴ : CommRing S
f : R →+* S
p : Ideal R
P✝ : Ideal S
inst✝³ : IsDomain S
inst✝² : IsDedekindDomain S
inst✝¹ : Algebra R S
inst✝ : IsMaximal p
P : { x // x ∈ Multiset.toFinset (factors (map (algebraMap R S) p)) }
⊢ ramificationIdx (algebraMap R S) p ↑P ≠ 0
case hP0
R : Type u
inst✝⁵ : CommRing R
S : Type v
inst✝⁴ : CommRing S
f : R →+* S
p : Ideal R
P✝ : Ideal S
inst✝³ : IsDomain S
inst✝² : IsDedekindDomain S
inst✝¹ : Algebra R S
inst✝ : IsMaximal p
P : { x // x ∈ Multiset.toFinset (factors (map (algebraMap R S) p)) }
⊢ ↑P ≠ ⊥
case he
R : Type u
inst✝⁵ : CommRing R
S : Type v
inst✝⁴ : CommRing S
f : R →+* S
p : Ideal R
P✝ : Ideal S
inst✝³ : IsDomain S
inst✝² : IsDedekindDomain S
inst✝¹ : Algebra R S
inst✝ : IsMaximal p
P : { x // x ∈ Multiset.toFinset (factors (map (algebraMap R S) p)) }
⊢ ramificationIdx (algebraMap R S) p ↑P ≠ 0

Next tactic:
exacts [NeZero.ne _, Factors.ne_bot p P]
theorem Factors.inertiaDeg_ne_zero [IsNoetherian R S] [p.IsMaximal]
    (P : (factors (map (algebraMap R S) p)).toFinset) : inertiaDeg (algebraMap R S) p P ≠ 0 := by
  

Proof state:
R : Type u
inst✝⁶ : CommRing R
S : Type v
inst✝⁵ : CommRing S
f : R →+* S
p : Ideal R
P✝ : Ideal S
inst✝⁴ : IsDomain S
inst✝³ : IsDedekindDomain S
inst✝² : Algebra R S
inst✝¹ : IsNoetherian R S
inst✝ : IsMaximal p
P : { x // x ∈ Multiset.toFinset (factors (map (algebraMap R S) p)) }
⊢ inertiaDeg (algebraMap R S) p ↑P ≠ 0

Next tactic:
rw [inertiaDeg_algebraMap]
theorem Factors.inertiaDeg_ne_zero [IsNoetherian R S] [p.IsMaximal]
    (P : (factors (map (algebraMap R S) p)).toFinset) : inertiaDeg (algebraMap R S) p P ≠ 0 := by
  rw [inertiaDeg_algebraMap]; 

Proof state:
R : Type u
inst✝⁶ : CommRing R
S : Type v
inst✝⁵ : CommRing S
f : R →+* S
p : Ideal R
P✝ : Ideal S
inst✝⁴ : IsDomain S
inst✝³ : IsDedekindDomain S
inst✝² : Algebra R S
inst✝¹ : IsNoetherian R S
inst✝ : IsMaximal p
P : { x // x ∈ Multiset.toFinset (factors (map (algebraMap R S) p)) }
⊢ finrank (R ⧸ p) (S ⧸ ↑P) ≠ 0

Next tactic:
exact (FiniteDimensional.finrank_pos_iff.mpr inferInstance).ne'
instance Factors.finiteDimensional_quotient_pow [IsNoetherian R S] [p.IsMaximal]
    (P : (factors (map (algebraMap R S) p)).toFinset) :
    FiniteDimensional (R ⧸ p) (S ⧸ (P : Ideal S) ^ ramificationIdx (algebraMap R S) p P) := by
  

Proof state:
R : Type u
inst✝⁶ : CommRing R
S : Type v
inst✝⁵ : CommRing S
f : R →+* S
p : Ideal R
P✝ : Ideal S
inst✝⁴ : IsDomain S
inst✝³ : IsDedekindDomain S
inst✝² : Algebra R S
inst✝¹ : IsNoetherian R S
inst✝ : IsMaximal p
P : { x // x ∈ Multiset.toFinset (factors (map (algebraMap R S) p)) }
⊢ FiniteDimensional (R ⧸ p) (S ⧸ ↑P ^ ramificationIdx (algebraMap R S) p ↑P)

Next tactic:
refine FiniteDimensional.finiteDimensional_of_finrank ?_
instance Factors.finiteDimensional_quotient_pow [IsNoetherian R S] [p.IsMaximal]
    (P : (factors (map (algebraMap R S) p)).toFinset) :
    FiniteDimensional (R ⧸ p) (S ⧸ (P : Ideal S) ^ ramificationIdx (algebraMap R S) p P) := by
  refine FiniteDimensional.finiteDimensional_of_finrank ?_
  

Proof state:
R : Type u
inst✝⁶ : CommRing R
S : Type v
inst✝⁵ : CommRing S
f : R →+* S
p : Ideal R
P✝ : Ideal S
inst✝⁴ : IsDomain S
inst✝³ : IsDedekindDomain S
inst✝² : Algebra R S
inst✝¹ : IsNoetherian R S
inst✝ : IsMaximal p
P : { x // x ∈ Multiset.toFinset (factors (map (algebraMap R S) p)) }
⊢ 0 < finrank (R ⧸ p) (S ⧸ ↑P ^ ramificationIdx (algebraMap R S) p ↑P)

Next tactic:
rw [pos_iff_ne_zero, Factors.finrank_pow_ramificationIdx]
instance Factors.finiteDimensional_quotient_pow [IsNoetherian R S] [p.IsMaximal]
    (P : (factors (map (algebraMap R S) p)).toFinset) :
    FiniteDimensional (R ⧸ p) (S ⧸ (P : Ideal S) ^ ramificationIdx (algebraMap R S) p P) := by
  refine FiniteDimensional.finiteDimensional_of_finrank ?_
  rw [pos_iff_ne_zero, Factors.finrank_pow_ramificationIdx]
  

Proof state:
R : Type u
inst✝⁶ : CommRing R
S : Type v
inst✝⁵ : CommRing S
f : R →+* S
p : Ideal R
P✝ : Ideal S
inst✝⁴ : IsDomain S
inst✝³ : IsDedekindDomain S
inst✝² : Algebra R S
inst✝¹ : IsNoetherian R S
inst✝ : IsMaximal p
P : { x // x ∈ Multiset.toFinset (factors (map (algebraMap R S) p)) }
⊢ ramificationIdx (algebraMap R S) p ↑P * inertiaDeg (algebraMap R S) p ↑P ≠ 0

Next tactic:
exact mul_ne_zero (Factors.ramificationIdx_ne_zero p P) (Factors.inertiaDeg_ne_zero p P)
/-- **Chinese remainder theorem** for a ring of integers: if the prime ideal `p : Ideal R`
factors in `S` as `∏ i, P i ^ e i`, then `S ⧸ I` factors as `Π i, R ⧸ (P i ^ e i)`. -/
noncomputable def Factors.piQuotientEquiv (p : Ideal R) (hp : map (algebraMap R S) p ≠ ⊥) :
    S ⧸ map (algebraMap R S) p ≃+*
      ∀ P : (factors (map (algebraMap R S) p)).toFinset,
        S ⧸ (P : Ideal S) ^ ramificationIdx (algebraMap R S) p P :=
  (IsDedekindDomain.quotientEquivPiFactors hp).trans <|
    @RingEquiv.piCongrRight (factors (map (algebraMap R S) p)).toFinset
      (fun P => S ⧸ (P : Ideal S) ^ (factors (map (algebraMap R S) p)).count (P : Ideal S))
      (fun P => S ⧸ (P : Ideal S) ^ ramificationIdx (algebraMap R S) p P) _ _
      fun P : (factors (map (algebraMap R S) p)).toFinset =>
      Ideal.quotEquivOfEq <| by
        

Proof state:
R : Type u
inst✝⁴ : CommRing R
S : Type v
inst✝³ : CommRing S
f : R →+* S
p✝ : Ideal R
P✝ : Ideal S
inst✝² : IsDomain S
inst✝¹ : IsDedekindDomain S
inst✝ : Algebra R S
p : Ideal R
hp : map (algebraMap R S) p ≠ ⊥
P : { x // x ∈ Multiset.toFinset (factors (map (algebraMap R S) p)) }
⊢ ↑P ^ Multiset.count (↑P) (factors (map (algebraMap R S) p)) = ↑P ^ ramificationIdx (algebraMap R S) p ↑P

Next tactic:
rw [IsDedekindDomain.ramificationIdx_eq_factors_count hp (Factors.isPrime p P)
            (Factors.ne_bot p P)]
/-- **Chinese remainder theorem** for a ring of integers: if the prime ideal `p : Ideal R`
factors in `S` as `∏ i, P i ^ e i`,
then `S ⧸ I` factors `R ⧸ I`-linearly as `Π i, R ⧸ (P i ^ e i)`. -/
noncomputable def Factors.piQuotientLinearEquiv (p : Ideal R) (hp : map (algebraMap R S) p ≠ ⊥) :
    (S ⧸ map (algebraMap R S) p) ≃ₗ[R ⧸ p]
      ∀ P : (factors (map (algebraMap R S) p)).toFinset,
        S ⧸ (P : Ideal S) ^ ramificationIdx (algebraMap R S) p P :=
  { Factors.piQuotientEquiv p hp with
    map_smul' := by
      

Proof state:
R : Type u
inst✝⁴ : CommRing R
S : Type v
inst✝³ : CommRing S
f : R →+* S
p✝ : Ideal R
P : Ideal S
inst✝² : IsDomain S
inst✝¹ : IsDedekindDomain S
inst✝ : Algebra R S
p : Ideal R
hp : map (algebraMap R S) p ≠ ⊥
src✝ : S ⧸ map (algebraMap R S) p ≃+*
  ((P : { x // x ∈ Multiset.toFinset (factors (map (algebraMap R S) p)) }) →
    S ⧸ ↑P ^ ramificationIdx (algebraMap R S) p ↑P) :=
  piQuotientEquiv p hp
⊢ ∀ (r : R ⧸ p) (x : S ⧸ map (algebraMap R S) p),
    AddHom.toFun
        { toFun := src✝.toFun,
          map_add' :=
            (_ :
              ∀ (x y : S ⧸ map (algebraMap R S) p),
                Equiv.toFun src✝.toEquiv (x + y) = Equiv.toFun src✝.toEquiv x + Equiv.toFun src✝.toEquiv y) }
        (r • x) =
      (RingHom.id (R ⧸ p)) r •
        AddHom.toFun
          { toFun := src✝.toFun,
            map_add' :=
              (_ :
                ∀ (x y : S ⧸ map (algebraMap R S) p),
                  Equiv.toFun src✝.toEquiv (x + y) = Equiv.toFun src✝.toEquiv x + Equiv.toFun src✝.toEquiv y) }
          x

Next tactic:
rintro ⟨c⟩ ⟨x⟩
/-- **Chinese remainder theorem** for a ring of integers: if the prime ideal `p : Ideal R`
factors in `S` as `∏ i, P i ^ e i`,
then `S ⧸ I` factors `R ⧸ I`-linearly as `Π i, R ⧸ (P i ^ e i)`. -/
noncomputable def Factors.piQuotientLinearEquiv (p : Ideal R) (hp : map (algebraMap R S) p ≠ ⊥) :
    (S ⧸ map (algebraMap R S) p) ≃ₗ[R ⧸ p]
      ∀ P : (factors (map (algebraMap R S) p)).toFinset,
        S ⧸ (P : Ideal S) ^ ramificationIdx (algebraMap R S) p P :=
  { Factors.piQuotientEquiv p hp with
    map_smul' := by
      rintro ⟨c⟩ ⟨x⟩; 

Proof state:
case mk.mk
R : Type u
inst✝⁴ : CommRing R
S : Type v
inst✝³ : CommRing S
f : R →+* S
p✝ : Ideal R
P : Ideal S
inst✝² : IsDomain S
inst✝¹ : IsDedekindDomain S
inst✝ : Algebra R S
p : Ideal R
hp : map (algebraMap R S) p ≠ ⊥
src✝ : S ⧸ map (algebraMap R S) p ≃+*
  ((P : { x // x ∈ Multiset.toFinset (factors (map (algebraMap R S) p)) }) →
    S ⧸ ↑P ^ ramificationIdx (algebraMap R S) p ↑P) :=
  piQuotientEquiv p hp
r✝ : R ⧸ p
c : R
x✝ : S ⧸ map (algebraMap R S) p
x : S
⊢ AddHom.toFun
      { toFun := src✝.toFun,
        map_add' :=
          (_ :
            ∀ (x y : S ⧸ map (algebraMap R S) p),
              Equiv.toFun src✝.toEquiv (x + y) = Equiv.toFun src✝.toEquiv x + Equiv.toFun src✝.toEquiv y) }
      (Quot.mk Setoid.r c • Quot.mk Setoid.r x) =
    (RingHom.id (R ⧸ p)) (Quot.mk Setoid.r c) •
      AddHom.toFun
        { toFun := src✝.toFun,
          map_add' :=
            (_ :
              ∀ (x y : S ⧸ map (algebraMap R S) p),
                Equiv.toFun src✝.toEquiv (x + y) = Equiv.toFun src✝.toEquiv x + Equiv.toFun src✝.toEquiv y) }
        (Quot.mk Setoid.r x)

Next tactic:
ext P
/-- **Chinese remainder theorem** for a ring of integers: if the prime ideal `p : Ideal R`
factors in `S` as `∏ i, P i ^ e i`,
then `S ⧸ I` factors `R ⧸ I`-linearly as `Π i, R ⧸ (P i ^ e i)`. -/
noncomputable def Factors.piQuotientLinearEquiv (p : Ideal R) (hp : map (algebraMap R S) p ≠ ⊥) :
    (S ⧸ map (algebraMap R S) p) ≃ₗ[R ⧸ p]
      ∀ P : (factors (map (algebraMap R S) p)).toFinset,
        S ⧸ (P : Ideal S) ^ ramificationIdx (algebraMap R S) p P :=
  { Factors.piQuotientEquiv p hp with
    map_smul' := by
      rintro ⟨c⟩ ⟨x⟩; ext P
      

Proof state:
case mk.mk.h
R : Type u
inst✝⁴ : CommRing R
S : Type v
inst✝³ : CommRing S
f : R →+* S
p✝ : Ideal R
P✝ : Ideal S
inst✝² : IsDomain S
inst✝¹ : IsDedekindDomain S
inst✝ : Algebra R S
p : Ideal R
hp : map (algebraMap R S) p ≠ ⊥
src✝ : S ⧸ map (algebraMap R S) p ≃+*
  ((P : { x // x ∈ Multiset.toFinset (factors (map (algebraMap R S) p)) }) →
    S ⧸ ↑P ^ ramificationIdx (algebraMap R S) p ↑P) :=
  piQuotientEquiv p hp
r✝ : R ⧸ p
c : R
x✝ : S ⧸ map (algebraMap R S) p
x : S
P : { x // x ∈ Multiset.toFinset (factors (map (algebraMap R S) p)) }
⊢ AddHom.toFun
      { toFun := src✝.toFun,
        map_add' :=
          (_ :
            ∀ (x y : S ⧸ map (algebraMap R S) p),
              Equiv.toFun src✝.toEquiv (x + y) = Equiv.toFun src✝.toEquiv x + Equiv.toFun src✝.toEquiv y) }
      (Quot.mk Setoid.r c • Quot.mk Setoid.r x) P =
    ((RingHom.id (R ⧸ p)) (Quot.mk Setoid.r c) •
        AddHom.toFun
          { toFun := src✝.toFun,
            map_add' :=
              (_ :
                ∀ (x y : S ⧸ map (algebraMap R S) p),
                  Equiv.toFun src✝.toEquiv (x + y) = Equiv.toFun src✝.toEquiv x + Equiv.toFun src✝.toEquiv y) }
          (Quot.mk Setoid.r x))
      P

Next tactic:
simp only [Submodule.Quotient.quot_mk_eq_mk, Quotient.mk_eq_mk, Algebra.smul_def,
        Quotient.algebraMap_quotient_map_quotient, Quotient.mk_algebraMap,
        RingHomCompTriple.comp_apply, Pi.mul_apply, Pi.algebraMap_apply]
/-- **Chinese remainder theorem** for a ring of integers: if the prime ideal `p : Ideal R`
factors in `S` as `∏ i, P i ^ e i`,
then `S ⧸ I` factors `R ⧸ I`-linearly as `Π i, R ⧸ (P i ^ e i)`. -/
noncomputable def Factors.piQuotientLinearEquiv (p : Ideal R) (hp : map (algebraMap R S) p ≠ ⊥) :
    (S ⧸ map (algebraMap R S) p) ≃ₗ[R ⧸ p]
      ∀ P : (factors (map (algebraMap R S) p)).toFinset,
        S ⧸ (P : Ideal S) ^ ramificationIdx (algebraMap R S) p P :=
  { Factors.piQuotientEquiv p hp with
    map_smul' := by
      rintro ⟨c⟩ ⟨x⟩; ext P
      simp only [Submodule.Quotient.quot_mk_eq_mk, Quotient.mk_eq_mk, Algebra.smul_def,
        Quotient.algebraMap_quotient_map_quotient, Quotient.mk_algebraMap,
        RingHomCompTriple.comp_apply, Pi.mul_apply, Pi.algebraMap_apply]
      

Proof state:
case mk.mk.h
R : Type u
inst✝⁴ : CommRing R
S : Type v
inst✝³ : CommRing S
f : R →+* S
p✝ : Ideal R
P✝ : Ideal S
inst✝² : IsDomain S
inst✝¹ : IsDedekindDomain S
inst✝ : Algebra R S
p : Ideal R
hp : map (algebraMap R S) p ≠ ⊥
src✝ : S ⧸ map (algebraMap R S) p ≃+*
  ((P : { x // x ∈ Multiset.toFinset (factors (map (algebraMap R S) p)) }) →
    S ⧸ ↑P ^ ramificationIdx (algebraMap R S) p ↑P) :=
  piQuotientEquiv p hp
r✝ : R ⧸ p
c : R
x✝ : S ⧸ map (algebraMap R S) p
x : S
P : { x // x ∈ Multiset.toFinset (factors (map (algebraMap R S) p)) }
⊢ Equiv.toFun (piQuotientEquiv p hp).toEquiv
      ((algebraMap R (S ⧸ map (algebraMap R S) p)) c * (Quotient.mk (map (algebraMap R S) p)) x) P =
    (algebraMap (R ⧸ p) (S ⧸ ↑P ^ ramificationIdx (algebraMap R S) p ↑P)) ((Quotient.mk p) c) *
      Equiv.toFun (piQuotientEquiv p hp).toEquiv ((Quotient.mk (map (algebraMap R S) p)) x) P

Next tactic:
congr
/-- The **fundamental identity** of ramification index `e` and inertia degree `f`:
for `P` ranging over the primes lying over `p`, `∑ P, e P * f P = [Frac(S) : Frac(R)]`;
here `S` is a finite `R`-module (and thus `Frac(S) : Frac(R)` is a finite extension) and `p`
is maximal.
-/
theorem sum_ramification_inertia (K L : Type*) [Field K] [Field L] [IsDomain R]
    [IsDedekindDomain R] [Algebra R K] [IsFractionRing R K] [Algebra S L] [IsFractionRing S L]
    [Algebra K L] [Algebra R L] [IsScalarTower R S L] [IsScalarTower R K L] [IsNoetherian R S]
    [IsIntegralClosure S R L] [p.IsMaximal] (hp0 : p ≠ ⊥) :
    (∑ P in (factors (map (algebraMap R S) p)).toFinset,
        ramificationIdx (algebraMap R S) p P * inertiaDeg (algebraMap R S) p P) =
      finrank K L := by
  

Proof state:
R : Type u
inst✝¹⁹ : CommRing R
S : Type v
inst✝¹⁸ : CommRing S
f : R →+* S
p : Ideal R
P : Ideal S
inst✝¹⁷ : IsDomain S
inst✝¹⁶ : IsDedekindDomain S
inst✝¹⁵ : Algebra R S
K : Type u_1
L : Type u_2
inst✝¹⁴ : Field K
inst✝¹³ : Field L
inst✝¹² : IsDomain R
inst✝¹¹ : IsDedekindDomain R
inst✝¹⁰ : Algebra R K
inst✝⁹ : IsFractionRing R K
inst✝⁸ : Algebra S L
inst✝⁷ : IsFractionRing S L
inst✝⁶ : Algebra K L
inst✝⁵ : Algebra R L
inst✝⁴ : IsScalarTower R S L
inst✝³ : IsScalarTower R K L
inst✝² : IsNoetherian R S
inst✝¹ : IsIntegralClosure S R L
inst✝ : IsMaximal p
hp0 : p ≠ ⊥
⊢ ∑ P in Multiset.toFinset (factors (map (algebraMap R S) p)),
      ramificationIdx (algebraMap R S) p P * inertiaDeg (algebraMap R S) p P =
    finrank K L

Next tactic:
set e := ramificationIdx (algebraMap R S) p
/-- The **fundamental identity** of ramification index `e` and inertia degree `f`:
for `P` ranging over the primes lying over `p`, `∑ P, e P * f P = [Frac(S) : Frac(R)]`;
here `S` is a finite `R`-module (and thus `Frac(S) : Frac(R)` is a finite extension) and `p`
is maximal.
-/
theorem sum_ramification_inertia (K L : Type*) [Field K] [Field L] [IsDomain R]
    [IsDedekindDomain R] [Algebra R K] [IsFractionRing R K] [Algebra S L] [IsFractionRing S L]
    [Algebra K L] [Algebra R L] [IsScalarTower R S L] [IsScalarTower R K L] [IsNoetherian R S]
    [IsIntegralClosure S R L] [p.IsMaximal] (hp0 : p ≠ ⊥) :
    (∑ P in (factors (map (algebraMap R S) p)).toFinset,
        ramificationIdx (algebraMap R S) p P * inertiaDeg (algebraMap R S) p P) =
      finrank K L := by
  set e := ramificationIdx (algebraMap R S) p
  

Proof state:
R : Type u
inst✝¹⁹ : CommRing R
S : Type v
inst✝¹⁸ : CommRing S
f : R →+* S
p : Ideal R
P : Ideal S
inst✝¹⁷ : IsDomain S
inst✝¹⁶ : IsDedekindDomain S
inst✝¹⁵ : Algebra R S
K : Type u_1
L : Type u_2
inst✝¹⁴ : Field K
inst✝¹³ : Field L
inst✝¹² : IsDomain R
inst✝¹¹ : IsDedekindDomain R
inst✝¹⁰ : Algebra R K
inst✝⁹ : IsFractionRing R K
inst✝⁸ : Algebra S L
inst✝⁷ : IsFractionRing S L
inst✝⁶ : Algebra K L
inst✝⁵ : Algebra R L
inst✝⁴ : IsScalarTower R S L
inst✝³ : IsScalarTower R K L
inst✝² : IsNoetherian R S
inst✝¹ : IsIntegralClosure S R L
inst✝ : IsMaximal p
hp0 : p ≠ ⊥
e : Ideal S → ℕ := ramificationIdx (algebraMap R S) p
⊢ ∑ P in Multiset.toFinset (factors (map (algebraMap R S) p)), e P * inertiaDeg (algebraMap R S) p P = finrank K L

Next tactic:
set f := inertiaDeg (algebraMap R S) p
/-- The **fundamental identity** of ramification index `e` and inertia degree `f`:
for `P` ranging over the primes lying over `p`, `∑ P, e P * f P = [Frac(S) : Frac(R)]`;
here `S` is a finite `R`-module (and thus `Frac(S) : Frac(R)` is a finite extension) and `p`
is maximal.
-/
theorem sum_ramification_inertia (K L : Type*) [Field K] [Field L] [IsDomain R]
    [IsDedekindDomain R] [Algebra R K] [IsFractionRing R K] [Algebra S L] [IsFractionRing S L]
    [Algebra K L] [Algebra R L] [IsScalarTower R S L] [IsScalarTower R K L] [IsNoetherian R S]
    [IsIntegralClosure S R L] [p.IsMaximal] (hp0 : p ≠ ⊥) :
    (∑ P in (factors (map (algebraMap R S) p)).toFinset,
        ramificationIdx (algebraMap R S) p P * inertiaDeg (algebraMap R S) p P) =
      finrank K L := by
  set e := ramificationIdx (algebraMap R S) p
  set f := inertiaDeg (algebraMap R S) p
  

Proof state:
R : Type u
inst✝¹⁹ : CommRing R
S : Type v
inst✝¹⁸ : CommRing S
f✝ : R →+* S
p : Ideal R
P : Ideal S
inst✝¹⁷ : IsDomain S
inst✝¹⁶ : IsDedekindDomain S
inst✝¹⁵ : Algebra R S
K : Type u_1
L : Type u_2
inst✝¹⁴ : Field K
inst✝¹³ : Field L
inst✝¹² : IsDomain R
inst✝¹¹ : IsDedekindDomain R
inst✝¹⁰ : Algebra R K
inst✝⁹ : IsFractionRing R K
inst✝⁸ : Algebra S L
inst✝⁷ : IsFractionRing S L
inst✝⁶ : Algebra K L
inst✝⁵ : Algebra R L
inst✝⁴ : IsScalarTower R S L
inst✝³ : IsScalarTower R K L
inst✝² : IsNoetherian R S
inst✝¹ : IsIntegralClosure S R L
inst✝ : IsMaximal p
hp0 : p ≠ ⊥
e : Ideal S → ℕ := ramificationIdx (algebraMap R S) p
f : Ideal S → [inst : IsMaximal p] → ℕ := inertiaDeg (algebraMap R S) p
⊢ ∑ P in Multiset.toFinset (factors (map (algebraMap R S) p)), e P * f P = finrank K L

Next tactic:
have inj_RL : Function.Injective (algebraMap R L) := by
    rw [IsScalarTower.algebraMap_eq R K L, RingHom.coe_comp]
    exact (RingHom.injective _).comp (IsFractionRing.injective R K)
/-- The **fundamental identity** of ramification index `e` and inertia degree `f`:
for `P` ranging over the primes lying over `p`, `∑ P, e P * f P = [Frac(S) : Frac(R)]`;
here `S` is a finite `R`-module (and thus `Frac(S) : Frac(R)` is a finite extension) and `p`
is maximal.
-/
theorem sum_ramification_inertia (K L : Type*) [Field K] [Field L] [IsDomain R]
    [IsDedekindDomain R] [Algebra R K] [IsFractionRing R K] [Algebra S L] [IsFractionRing S L]
    [Algebra K L] [Algebra R L] [IsScalarTower R S L] [IsScalarTower R K L] [IsNoetherian R S]
    [IsIntegralClosure S R L] [p.IsMaximal] (hp0 : p ≠ ⊥) :
    (∑ P in (factors (map (algebraMap R S) p)).toFinset,
        ramificationIdx (algebraMap R S) p P * inertiaDeg (algebraMap R S) p P) =
      finrank K L := by
  set e := ramificationIdx (algebraMap R S) p
  set f := inertiaDeg (algebraMap R S) p
  have inj_RL : Function.Injective (algebraMap R L) := by
    

Proof state:
R : Type u
inst✝¹⁹ : CommRing R
S : Type v
inst✝¹⁸ : CommRing S
f✝ : R →+* S
p : Ideal R
P : Ideal S
inst✝¹⁷ : IsDomain S
inst✝¹⁶ : IsDedekindDomain S
inst✝¹⁵ : Algebra R S
K : Type u_1
L : Type u_2
inst✝¹⁴ : Field K
inst✝¹³ : Field L
inst✝¹² : IsDomain R
inst✝¹¹ : IsDedekindDomain R
inst✝¹⁰ : Algebra R K
inst✝⁹ : IsFractionRing R K
inst✝⁸ : Algebra S L
inst✝⁷ : IsFractionRing S L
inst✝⁶ : Algebra K L
inst✝⁵ : Algebra R L
inst✝⁴ : IsScalarTower R S L
inst✝³ : IsScalarTower R K L
inst✝² : IsNoetherian R S
inst✝¹ : IsIntegralClosure S R L
inst✝ : IsMaximal p
hp0 : p ≠ ⊥
e : Ideal S → ℕ := ramificationIdx (algebraMap R S) p
f : Ideal S → [inst : IsMaximal p] → ℕ := inertiaDeg (algebraMap R S) p
⊢ Function.Injective ⇑(algebraMap R L)

Next tactic:
rw [IsScalarTower.algebraMap_eq R K L, RingHom.coe_comp]
/-- The **fundamental identity** of ramification index `e` and inertia degree `f`:
for `P` ranging over the primes lying over `p`, `∑ P, e P * f P = [Frac(S) : Frac(R)]`;
here `S` is a finite `R`-module (and thus `Frac(S) : Frac(R)` is a finite extension) and `p`
is maximal.
-/
theorem sum_ramification_inertia (K L : Type*) [Field K] [Field L] [IsDomain R]
    [IsDedekindDomain R] [Algebra R K] [IsFractionRing R K] [Algebra S L] [IsFractionRing S L]
    [Algebra K L] [Algebra R L] [IsScalarTower R S L] [IsScalarTower R K L] [IsNoetherian R S]
    [IsIntegralClosure S R L] [p.IsMaximal] (hp0 : p ≠ ⊥) :
    (∑ P in (factors (map (algebraMap R S) p)).toFinset,
        ramificationIdx (algebraMap R S) p P * inertiaDeg (algebraMap R S) p P) =
      finrank K L := by
  set e := ramificationIdx (algebraMap R S) p
  set f := inertiaDeg (algebraMap R S) p
  have inj_RL : Function.Injective (algebraMap R L) := by
    rw [IsScalarTower.algebraMap_eq R K L, RingHom.coe_comp]
    

Proof state:
R : Type u
inst✝¹⁹ : CommRing R
S : Type v
inst✝¹⁸ : CommRing S
f✝ : R →+* S
p : Ideal R
P : Ideal S
inst✝¹⁷ : IsDomain S
inst✝¹⁶ : IsDedekindDomain S
inst✝¹⁵ : Algebra R S
K : Type u_1
L : Type u_2
inst✝¹⁴ : Field K
inst✝¹³ : Field L
inst✝¹² : IsDomain R
inst✝¹¹ : IsDedekindDomain R
inst✝¹⁰ : Algebra R K
inst✝⁹ : IsFractionRing R K
inst✝⁸ : Algebra S L
inst✝⁷ : IsFractionRing S L
inst✝⁶ : Algebra K L
inst✝⁵ : Algebra R L
inst✝⁴ : IsScalarTower R S L
inst✝³ : IsScalarTower R K L
inst✝² : IsNoetherian R S
inst✝¹ : IsIntegralClosure S R L
inst✝ : IsMaximal p
hp0 : p ≠ ⊥
e : Ideal S → ℕ := ramificationIdx (algebraMap R S) p
f : Ideal S → [inst : IsMaximal p] → ℕ := inertiaDeg (algebraMap R S) p
⊢ Function.Injective (⇑(algebraMap K L) ∘ ⇑(algebraMap R K))

Next tactic:
exact (RingHom.injective _).comp (IsFractionRing.injective R K)