l3lab/ntp-mathlib huggingface dataset:
theorem ramificationIdx_lt {n : ℕ} (hgt : ¬map f p ≤ P ^ n) : ramificationIdx f p P < n := by
  cases' n with n n
  · simp at hgt
  · rw [Nat.lt_succ_iff]
    have : ∀ k, map f p ≤ P ^ k → k ≤ n := by
      refine fun k hk => le_of_not_lt fun hnk => ?_
      

Proof state:
R : Type u
inst✝¹ : CommRing R
S : Type v
inst✝ : CommRing S
f : R →+* S
p : Ideal R
P : Ideal S
n : ℕ
hgt : ¬map f p ≤ P ^ Nat.succ n
k : ℕ
hk : map f p ≤ P ^ k
hnk : n < k
⊢ False

Next tactic:
exact hgt (hk.trans (Ideal.pow_le_pow_right hnk))
theorem ramificationIdx_lt {n : ℕ} (hgt : ¬map f p ≤ P ^ n) : ramificationIdx f p P < n := by
  cases' n with n n
  · simp at hgt
  · rw [Nat.lt_succ_iff]
    have : ∀ k, map f p ≤ P ^ k → k ≤ n := by
      refine fun k hk => le_of_not_lt fun hnk => ?_
      exact hgt (hk.trans (Ideal.pow_le_pow_right hnk))
    

Proof state:
case succ
R : Type u
inst✝¹ : CommRing R
S : Type v
inst✝ : CommRing S
f : R →+* S
p : Ideal R
P : Ideal S
n : ℕ
hgt : ¬map f p ≤ P ^ Nat.succ n
this : ∀ (k : ℕ), map f p ≤ P ^ k → k ≤ n
⊢ ramificationIdx f p P ≤ n

Next tactic:
rw [ramificationIdx_eq_find ⟨n, this⟩]
theorem ramificationIdx_lt {n : ℕ} (hgt : ¬map f p ≤ P ^ n) : ramificationIdx f p P < n := by
  cases' n with n n
  · simp at hgt
  · rw [Nat.lt_succ_iff]
    have : ∀ k, map f p ≤ P ^ k → k ≤ n := by
      refine fun k hk => le_of_not_lt fun hnk => ?_
      exact hgt (hk.trans (Ideal.pow_le_pow_right hnk))
    rw [ramificationIdx_eq_find ⟨n, this⟩]
    

Proof state:
case succ
R : Type u
inst✝¹ : CommRing R
S : Type v
inst✝ : CommRing S
f : R →+* S
p : Ideal R
P : Ideal S
n : ℕ
hgt : ¬map f p ≤ P ^ Nat.succ n
this : ∀ (k : ℕ), map f p ≤ P ^ k → k ≤ n
⊢ Nat.find (_ : ∃ n, ∀ (k : ℕ), map f p ≤ P ^ k → k ≤ n) ≤ n

Next tactic:
exact Nat.find_min' ⟨n, this⟩ this
@[simp]
theorem ramificationIdx_bot : ramificationIdx f ⊥ P = 0 :=
  dif_neg <| not_exists.mpr fun n hn => n.lt_succ_self.not_le (hn _ (by 

Proof state:
R : Type u
inst✝¹ : CommRing R
S : Type v
inst✝ : CommRing S
f : R →+* S
p : Ideal R
P : Ideal S
n : ℕ
hn : ∀ a ∈ {n | map f ⊥ ≤ P ^ n}, a ≤ n
⊢ Nat.succ n ∈ {n | map f ⊥ ≤ P ^ n}

Next tactic:
simp
@[simp]
theorem ramificationIdx_of_not_le (h : ¬map f p ≤ P) : ramificationIdx f p P = 0 :=
  ramificationIdx_spec (by 

Proof state:
R : Type u
inst✝¹ : CommRing R
S : Type v
inst✝ : CommRing S
f : R →+* S
p : Ideal R
P : Ideal S
h : ¬map f p ≤ P
⊢ map f p ≤ P ^ 0

Next tactic:
simp
@[simp]
theorem ramificationIdx_of_not_le (h : ¬map f p ≤ P) : ramificationIdx f p P = 0 :=
  ramificationIdx_spec (by simp) (by 

Proof state:
R : Type u
inst✝¹ : CommRing R
S : Type v
inst✝ : CommRing S
f : R →+* S
p : Ideal R
P : Ideal S
h : ¬map f p ≤ P
⊢ ¬map f p ≤ P ^ (0 + 1)

Next tactic:
simpa using h
theorem ramificationIdx_ne_zero {e : ℕ} (he : e ≠ 0) (hle : map f p ≤ P ^ e)
    (hnle : ¬map f p ≤ P ^ (e + 1)) : ramificationIdx f 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
e : ℕ
he : e ≠ 0
hle : map f p ≤ P ^ e
hnle : ¬map f p ≤ P ^ (e + 1)
⊢ ramificationIdx f p P ≠ 0

Next tactic:
rwa [ramificationIdx_spec hle hnle]
theorem le_pow_of_le_ramificationIdx {n : ℕ} (hn : n ≤ ramificationIdx f p P) :
    map f p ≤ P ^ n := by
  

Proof state:
R : Type u
inst✝¹ : CommRing R
S : Type v
inst✝ : CommRing S
f : R →+* S
p : Ideal R
P : Ideal S
n : ℕ
hn : n ≤ ramificationIdx f p P
⊢ map f p ≤ P ^ n

Next tactic:
contrapose! hn
theorem le_pow_of_le_ramificationIdx {n : ℕ} (hn : n ≤ ramificationIdx f p P) :
    map f p ≤ P ^ n := by
  contrapose! hn
  

Proof state:
R : Type u
inst✝¹ : CommRing R
S : Type v
inst✝ : CommRing S
f : R →+* S
p : Ideal R
P : Ideal S
n : ℕ
hn : ¬map f p ≤ P ^ n
⊢ ramificationIdx f p P < n

Next tactic:
exact ramificationIdx_lt hn
theorem ramificationIdx_eq_normalizedFactors_count (hp0 : map f p ≠ ⊥) (hP : P.IsPrime)
    (hP0 : P ≠ ⊥) : ramificationIdx f p P = (normalizedFactors (map f p)).count 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
hp0 : map f p ≠ ⊥
hP : IsPrime P
hP0 : P ≠ ⊥
⊢ ramificationIdx f p P = Multiset.count P (normalizedFactors (map f p))

Next tactic:
have hPirr := (Ideal.prime_of_isPrime hP0 hP).irreducible
theorem ramificationIdx_eq_normalizedFactors_count (hp0 : map f p ≠ ⊥) (hP : P.IsPrime)
    (hP0 : P ≠ ⊥) : ramificationIdx f p P = (normalizedFactors (map f p)).count P := by
  have hPirr := (Ideal.prime_of_isPrime hP0 hP).irreducible
  

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
hp0 : map f p ≠ ⊥
hP : IsPrime P
hP0 : P ≠ ⊥
hPirr : Irreducible P
⊢ ramificationIdx f p P = Multiset.count P (normalizedFactors (map f p))

Next tactic:
refine ramificationIdx_spec (Ideal.le_of_dvd ?_) (mt Ideal.dvd_iff_le.mpr ?_)
theorem ramificationIdx_eq_normalizedFactors_count (hp0 : map f p ≠ ⊥) (hP : P.IsPrime)
    (hP0 : P ≠ ⊥) : ramificationIdx f p P = (normalizedFactors (map f p)).count P := by
  have hPirr := (Ideal.prime_of_isPrime hP0 hP).irreducible
  refine ramificationIdx_spec (Ideal.le_of_dvd ?_) (mt Ideal.dvd_iff_le.mpr ?_) <;>
    

Proof state:
case refine_1
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
hp0 : map f p ≠ ⊥
hP : IsPrime P
hP0 : P ≠ ⊥
hPirr : Irreducible P
⊢ P ^ Multiset.count P (normalizedFactors (map f p)) ∣ map f p

Next tactic:
rw [dvd_iff_normalizedFactors_le_normalizedFactors (pow_ne_zero _ hP0) hp0,
      normalizedFactors_pow, normalizedFactors_irreducible hPirr, normalize_eq,
      Multiset.nsmul_singleton, ← Multiset.le_count_iff_replicate_le]
theorem ramificationIdx_eq_normalizedFactors_count (hp0 : map f p ≠ ⊥) (hP : P.IsPrime)
    (hP0 : P ≠ ⊥) : ramificationIdx f p P = (normalizedFactors (map f p)).count P := by
  have hPirr := (Ideal.prime_of_isPrime hP0 hP).irreducible
  refine ramificationIdx_spec (Ideal.le_of_dvd ?_) (mt Ideal.dvd_iff_le.mpr ?_) <;>
    

Proof state:
case refine_2
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
hp0 : map f p ≠ ⊥
hP : IsPrime P
hP0 : P ≠ ⊥
hPirr : Irreducible P
⊢ ¬P ^ (Multiset.count P (normalizedFactors (map f p)) + 1) ∣ map f p

Next tactic:
rw [dvd_iff_normalizedFactors_le_normalizedFactors (pow_ne_zero _ hP0) hp0,
      normalizedFactors_pow, normalizedFactors_irreducible hPirr, normalize_eq,
      Multiset.nsmul_singleton, ← Multiset.le_count_iff_replicate_le]
theorem ramificationIdx_eq_normalizedFactors_count (hp0 : map f p ≠ ⊥) (hP : P.IsPrime)
    (hP0 : P ≠ ⊥) : ramificationIdx f p P = (normalizedFactors (map f p)).count P := by
  have hPirr := (Ideal.prime_of_isPrime hP0 hP).irreducible
  refine ramificationIdx_spec (Ideal.le_of_dvd ?_) (mt Ideal.dvd_iff_le.mpr ?_) <;>
    rw [dvd_iff_normalizedFactors_le_normalizedFactors (pow_ne_zero _ hP0) hp0,
      normalizedFactors_pow, normalizedFactors_irreducible hPirr, normalize_eq,
      Multiset.nsmul_singleton, ← Multiset.le_count_iff_replicate_le]
  · 

Proof state:
case refine_2
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
hp0 : map f p ≠ ⊥
hP : IsPrime P
hP0 : P ≠ ⊥
hPirr : Irreducible P
⊢ ¬Multiset.count P (normalizedFactors (map f p)) + 1 ≤ Multiset.count P (normalizedFactors (map f p))

Next tactic:
exact (Nat.lt_succ_self _).not_le
theorem ramificationIdx_eq_factors_count (hp0 : map f p ≠ ⊥) (hP : P.IsPrime) (hP0 : P ≠ ⊥) :
    ramificationIdx f p P = (factors (map f p)).count 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
hp0 : map f p ≠ ⊥
hP : IsPrime P
hP0 : P ≠ ⊥
⊢ ramificationIdx f p P = Multiset.count P (factors (map f p))

Next tactic:
rw [IsDedekindDomain.ramificationIdx_eq_normalizedFactors_count hp0 hP hP0,
    factors_eq_normalizedFactors]
theorem ramificationIdx_ne_zero (hp0 : map f p ≠ ⊥) (hP : P.IsPrime) (le : map f p ≤ P) :
    ramificationIdx f 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
hp0 : map f p ≠ ⊥
hP : IsPrime P
le : map f p ≤ P
⊢ ramificationIdx f p P ≠ 0

Next tactic:
have hP0 : P ≠ ⊥ := by
    rintro rfl
    have := le_bot_iff.mp le
    contradiction
theorem ramificationIdx_ne_zero (hp0 : map f p ≠ ⊥) (hP : P.IsPrime) (le : map f p ≤ P) :
    ramificationIdx f p P ≠ 0 := by
  have hP0 : 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
hp0 : map f p ≠ ⊥
hP : IsPrime P
le : map f p ≤ P
⊢ P ≠ ⊥

Next tactic:
rintro rfl
theorem ramificationIdx_ne_zero (hp0 : map f p ≠ ⊥) (hP : P.IsPrime) (le : map f p ≤ P) :
    ramificationIdx f p P ≠ 0 := by
  have hP0 : P ≠ ⊥ := by
    rintro rfl
    

Proof state:
R : Type u
inst✝³ : CommRing R
S : Type v
inst✝² : CommRing S
f : R →+* S
p : Ideal R
inst✝¹ : IsDomain S
inst✝ : IsDedekindDomain S
hp0 : map f p ≠ ⊥
hP : IsPrime ⊥
le : map f p ≤ ⊥
⊢ False

Next tactic:
have := le_bot_iff.mp le
theorem ramificationIdx_ne_zero (hp0 : map f p ≠ ⊥) (hP : P.IsPrime) (le : map f p ≤ P) :
    ramificationIdx f p P ≠ 0 := by
  have hP0 : P ≠ ⊥ := by
    rintro rfl
    have := le_bot_iff.mp le
    

Proof state:
R : Type u
inst✝³ : CommRing R
S : Type v
inst✝² : CommRing S
f : R →+* S
p : Ideal R
inst✝¹ : IsDomain S
inst✝ : IsDedekindDomain S
hp0 : map f p ≠ ⊥
hP : IsPrime ⊥
le : map f p ≤ ⊥
this : map f p = ⊥
⊢ False

Next tactic:
contradiction
theorem ramificationIdx_ne_zero (hp0 : map f p ≠ ⊥) (hP : P.IsPrime) (le : map f p ≤ P) :
    ramificationIdx f p P ≠ 0 := by
  have hP0 : P ≠ ⊥ := by
    rintro rfl
    have := le_bot_iff.mp le
    contradiction
  

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
hp0 : map f p ≠ ⊥
hP : IsPrime P
le : map f p ≤ P
hP0 : P ≠ ⊥
⊢ ramificationIdx f p P ≠ 0

Next tactic:
have hPirr := (Ideal.prime_of_isPrime hP0 hP).irreducible
theorem ramificationIdx_ne_zero (hp0 : map f p ≠ ⊥) (hP : P.IsPrime) (le : map f p ≤ P) :
    ramificationIdx f p P ≠ 0 := by
  have hP0 : P ≠ ⊥ := by
    rintro rfl
    have := le_bot_iff.mp le
    contradiction
  have hPirr := (Ideal.prime_of_isPrime hP0 hP).irreducible
  

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
hp0 : map f p ≠ ⊥
hP : IsPrime P
le : map f p ≤ P
hP0 : P ≠ ⊥
hPirr : Irreducible P
⊢ ramificationIdx f p P ≠ 0

Next tactic:
rw [IsDedekindDomain.ramificationIdx_eq_normalizedFactors_count hp0 hP hP0]
theorem ramificationIdx_ne_zero (hp0 : map f p ≠ ⊥) (hP : P.IsPrime) (le : map f p ≤ P) :
    ramificationIdx f p P ≠ 0 := by
  have hP0 : P ≠ ⊥ := by
    rintro rfl
    have := le_bot_iff.mp le
    contradiction
  have hPirr := (Ideal.prime_of_isPrime hP0 hP).irreducible
  rw [IsDedekindDomain.ramificationIdx_eq_normalizedFactors_count hp0 hP hP0]
  

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
hp0 : map f p ≠ ⊥
hP : IsPrime P
le : map f p ≤ P
hP0 : P ≠ ⊥
hPirr : Irreducible P
⊢ Multiset.count P (normalizedFactors (map f p)) ≠ 0

Next tactic:
obtain ⟨P', hP', P'_eq⟩ :=
    exists_mem_normalizedFactors_of_dvd hp0 hPirr (Ideal.dvd_iff_le.mpr le)
theorem ramificationIdx_ne_zero (hp0 : map f p ≠ ⊥) (hP : P.IsPrime) (le : map f p ≤ P) :
    ramificationIdx f p P ≠ 0 := by
  have hP0 : P ≠ ⊥ := by
    rintro rfl
    have := le_bot_iff.mp le
    contradiction
  have hPirr := (Ideal.prime_of_isPrime hP0 hP).irreducible
  rw [IsDedekindDomain.ramificationIdx_eq_normalizedFactors_count hp0 hP hP0]
  obtain ⟨P', hP', P'_eq⟩ :=
    exists_mem_normalizedFactors_of_dvd hp0 hPirr (Ideal.dvd_iff_le.mpr le)
  

Proof state:
case intro.intro
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
hp0 : map f p ≠ ⊥
hP : IsPrime P
le : map f p ≤ P
hP0 : P ≠ ⊥
hPirr : Irreducible P
P' : Ideal S
hP' : P' ∈ normalizedFactors (map f p)
P'_eq : Associated P P'
⊢ Multiset.count P (normalizedFactors (map f p)) ≠ 0

Next tactic:
rwa [Multiset.count_ne_zero, associated_iff_eq.mp P'_eq]
@[simp]
theorem inertiaDeg_of_subsingleton [hp : p.IsMaximal] [hQ : Subsingleton (S ⧸ P)] :
    inertiaDeg f 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
hp : IsMaximal p
hQ : Subsingleton (S ⧸ P)
⊢ inertiaDeg f p P = 0

Next tactic:
have := Ideal.Quotient.subsingleton_iff.mp hQ
@[simp]
theorem inertiaDeg_of_subsingleton [hp : p.IsMaximal] [hQ : Subsingleton (S ⧸ P)] :
    inertiaDeg f p P = 0 := by
  have := Ideal.Quotient.subsingleton_iff.mp hQ
  

Proof state:
R : Type u
inst✝¹ : CommRing R
S : Type v
inst✝ : CommRing S
f : R →+* S
p : Ideal R
P : Ideal S
hp : IsMaximal p
hQ : Subsingleton (S ⧸ P)
this : P = ⊤
⊢ inertiaDeg f p P = 0

Next tactic:
subst this
@[simp]
theorem inertiaDeg_of_subsingleton [hp : p.IsMaximal] [hQ : Subsingleton (S ⧸ P)] :
    inertiaDeg f p P = 0 := by
  have := Ideal.Quotient.subsingleton_iff.mp hQ
  subst this
  

Proof state:
R : Type u
inst✝¹ : CommRing R
S : Type v
inst✝ : CommRing S
f : R →+* S
p : Ideal R
hp : IsMaximal p
hQ : Subsingleton (S ⧸ ⊤)
⊢ inertiaDeg f p ⊤ = 0

Next tactic:
exact dif_neg fun h => hp.ne_top <| h.symm.trans comap_top
@[simp]
theorem inertiaDeg_algebraMap [Algebra R S] [Algebra (R ⧸ p) (S ⧸ P)]
    [IsScalarTower R (R ⧸ p) (S ⧸ P)] [hp : p.IsMaximal] :
    inertiaDeg (algebraMap R S) p P = finrank (R ⧸ p) (S ⧸ 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✝² : Algebra R S
inst✝¹ : Algebra (R ⧸ p) (S ⧸ P)
inst✝ : IsScalarTower R (R ⧸ p) (S ⧸ P)
hp : IsMaximal p
⊢ inertiaDeg (algebraMap R S) p P = finrank (R ⧸ p) (S ⧸ P)

Next tactic:
nontriviality S ⧸ P using inertiaDeg_of_subsingleton, finrank_zero_of_subsingleton
@[simp]
theorem inertiaDeg_algebraMap [Algebra R S] [Algebra (R ⧸ p) (S ⧸ P)]
    [IsScalarTower R (R ⧸ p) (S ⧸ P)] [hp : p.IsMaximal] :
    inertiaDeg (algebraMap R S) p P = finrank (R ⧸ p) (S ⧸ P) := by
  nontriviality S ⧸ P using inertiaDeg_of_subsingleton, finrank_zero_of_subsingleton
  

Proof state:
R : Type u
inst✝⁴ : CommRing R
S : Type v
inst✝³ : CommRing S
f : R →+* S
p : Ideal R
P : Ideal S
inst✝² : Algebra R S
inst✝¹ : Algebra (R ⧸ p) (S ⧸ P)
inst✝ : IsScalarTower R (R ⧸ p) (S ⧸ P)
hp : IsMaximal p
✝ : Nontrivial (S ⧸ P)
⊢ inertiaDeg (algebraMap R S) p P = finrank (R ⧸ p) (S ⧸ P)

Next tactic:
have := comap_eq_of_scalar_tower_quotient (algebraMap (R ⧸ p) (S ⧸ P)).injective
@[simp]
theorem inertiaDeg_algebraMap [Algebra R S] [Algebra (R ⧸ p) (S ⧸ P)]
    [IsScalarTower R (R ⧸ p) (S ⧸ P)] [hp : p.IsMaximal] :
    inertiaDeg (algebraMap R S) p P = finrank (R ⧸ p) (S ⧸ P) := by
  nontriviality S ⧸ P using inertiaDeg_of_subsingleton, finrank_zero_of_subsingleton
  have := comap_eq_of_scalar_tower_quotient (algebraMap (R ⧸ p) (S ⧸ P)).injective
  

Proof state:
R : Type u
inst✝⁴ : CommRing R
S : Type v
inst✝³ : CommRing S
f : R →+* S
p : Ideal R
P : Ideal S
inst✝² : Algebra R S
inst✝¹ : Algebra (R ⧸ p) (S ⧸ P)
inst✝ : IsScalarTower R (R ⧸ p) (S ⧸ P)
hp : IsMaximal p
✝ : Nontrivial (S ⧸ P)
this : comap (algebraMap R S) P = p
⊢ inertiaDeg (algebraMap R S) p P = finrank (R ⧸ p) (S ⧸ P)

Next tactic:
rw [inertiaDeg, dif_pos this]
@[simp]
theorem inertiaDeg_algebraMap [Algebra R S] [Algebra (R ⧸ p) (S ⧸ P)]
    [IsScalarTower R (R ⧸ p) (S ⧸ P)] [hp : p.IsMaximal] :
    inertiaDeg (algebraMap R S) p P = finrank (R ⧸ p) (S ⧸ P) := by
  nontriviality S ⧸ P using inertiaDeg_of_subsingleton, finrank_zero_of_subsingleton
  have := comap_eq_of_scalar_tower_quotient (algebraMap (R ⧸ p) (S ⧸ P)).injective
  rw [inertiaDeg, dif_pos this]
  

Proof state:
R : Type u
inst✝⁴ : CommRing R
S : Type v
inst✝³ : CommRing S
f : R →+* S
p : Ideal R
P : Ideal S
inst✝² : Algebra R S
inst✝¹ : Algebra (R ⧸ p) (S ⧸ P)
inst✝ : IsScalarTower R (R ⧸ p) (S ⧸ P)
hp : IsMaximal p
✝ : Nontrivial (S ⧸ P)
this : comap (algebraMap R S) P = p
⊢ finrank (R ⧸ p) (S ⧸ P) = finrank (R ⧸ p) (S ⧸ P)

Next tactic:
congr
@[simp]
theorem inertiaDeg_algebraMap [Algebra R S] [Algebra (R ⧸ p) (S ⧸ P)]
    [IsScalarTower R (R ⧸ p) (S ⧸ P)] [hp : p.IsMaximal] :
    inertiaDeg (algebraMap R S) p P = finrank (R ⧸ p) (S ⧸ P) := by
  nontriviality S ⧸ P using inertiaDeg_of_subsingleton, finrank_zero_of_subsingleton
  have := comap_eq_of_scalar_tower_quotient (algebraMap (R ⧸ p) (S ⧸ P)).injective
  rw [inertiaDeg, dif_pos this]
  congr
  

Proof state:
case h.e_5.h.h.e_5.h
R : Type u
inst✝⁴ : CommRing R
S : Type v
inst✝³ : CommRing S
f : R →+* S
p : Ideal R
P : Ideal S
inst✝² : Algebra R S
inst✝¹ : Algebra (R ⧸ p) (S ⧸ P)
inst✝ : IsScalarTower R (R ⧸ p) (S ⧸ P)
hp : IsMaximal p
✝ : Nontrivial (S ⧸ P)
this : comap (algebraMap R S) P = p
⊢ RingHom.toAlgebra
      (Quotient.lift p (RingHom.comp (Quotient.mk P) (algebraMap R S))
        (_ : ∀ x ∈ p, (Quotient.mk P) ((algebraMap R S) x) = 0)) =
    inst✝¹

Next tactic:
refine' Algebra.algebra_ext _ _ fun x' => Quotient.inductionOn' x' fun x => _
@[simp]
theorem inertiaDeg_algebraMap [Algebra R S] [Algebra (R ⧸ p) (S ⧸ P)]
    [IsScalarTower R (R ⧸ p) (S ⧸ P)] [hp : p.IsMaximal] :
    inertiaDeg (algebraMap R S) p P = finrank (R ⧸ p) (S ⧸ P) := by
  nontriviality S ⧸ P using inertiaDeg_of_subsingleton, finrank_zero_of_subsingleton
  have := comap_eq_of_scalar_tower_quotient (algebraMap (R ⧸ p) (S ⧸ P)).injective
  rw [inertiaDeg, dif_pos this]
  congr
  refine' Algebra.algebra_ext _ _ fun x' => Quotient.inductionOn' x' fun x => _
  

Proof state:
case h.e_5.h.h.e_5.h
R : Type u
inst✝⁴ : CommRing R
S : Type v
inst✝³ : CommRing S
f : R →+* S
p : Ideal R
P : Ideal S
inst✝² : Algebra R S
inst✝¹ : Algebra (R ⧸ p) (S ⧸ P)
inst✝ : IsScalarTower R (R ⧸ p) (S ⧸ P)
hp : IsMaximal p
✝ : Nontrivial (S ⧸ P)
this : comap (algebraMap R S) P = p
x' : R ⧸ p
x : R
⊢ (algebraMap (R ⧸ p) (S ⧸ P)) (Quotient.mk'' x) = (algebraMap (R ⧸ p) (S ⧸ P)) (Quotient.mk'' x)

Next tactic:
change Ideal.Quotient.lift p _ _ (Ideal.Quotient.mk p x) = algebraMap _ _ (Ideal.Quotient.mk p x)
@[simp]
theorem inertiaDeg_algebraMap [Algebra R S] [Algebra (R ⧸ p) (S ⧸ P)]
    [IsScalarTower R (R ⧸ p) (S ⧸ P)] [hp : p.IsMaximal] :
    inertiaDeg (algebraMap R S) p P = finrank (R ⧸ p) (S ⧸ P) := by
  nontriviality S ⧸ P using inertiaDeg_of_subsingleton, finrank_zero_of_subsingleton
  have := comap_eq_of_scalar_tower_quotient (algebraMap (R ⧸ p) (S ⧸ P)).injective
  rw [inertiaDeg, dif_pos this]
  congr
  refine' Algebra.algebra_ext _ _ fun x' => Quotient.inductionOn' x' fun x => _
  change Ideal.Quotient.lift p _ _ (Ideal.Quotient.mk p x) = algebraMap _ _ (Ideal.Quotient.mk p x)
  

Proof state:
case h.e_5.h.h.e_5.h
R : Type u
inst✝⁴ : CommRing R
S : Type v
inst✝³ : CommRing S
f : R →+* S
p : Ideal R
P : Ideal S
inst✝² : Algebra R S
inst✝¹ : Algebra (R ⧸ p) (S ⧸ P)
inst✝ : IsScalarTower R (R ⧸ p) (S ⧸ P)
hp : IsMaximal p
✝ : Nontrivial (S ⧸ P)
this : comap (algebraMap R S) P = p
x' : R ⧸ p
x : R
⊢ (Quotient.lift p (RingHom.comp (Quotient.mk P) (algebraMap R S))
        (_ : ∀ x ∈ p, (Quotient.mk P) ((algebraMap R S) x) = 0))
      ((Quotient.mk p) x) =
    (algebraMap (R ⧸ p) (S ⧸ P)) ((Quotient.mk p) x)

Next tactic:
rw [Ideal.Quotient.lift_mk, ← Ideal.Quotient.algebraMap_eq P, ← IsScalarTower.algebraMap_eq,
    ← Ideal.Quotient.algebraMap_eq, ← IsScalarTower.algebraMap_apply]
/-- Let `V` be a vector space over `K = Frac(R)`, `S / R` a ring extension
and `V'` a module over `S`. If `b`, in the intersection `V''` of `V` and `V'`,
is linear independent over `S` in `V'`, then it is linear independent over `R` in `V`.

The statement we prove is actually slightly more general:
 * it suffices that the inclusion `algebraMap R S : R → S` is nontrivial
 * the function `f' : V'' → V'` doesn't need to be injective
-/
theorem FinrankQuotientMap.linearIndependent_of_nontrivial [IsDomain R] [IsDedekindDomain R]
    (hRS : RingHom.ker (algebraMap R S) ≠ ⊤) (f : V'' →ₗ[R] V) (hf : Function.Injective f)
    (f' : V'' →ₗ[R] V') {ι : Type*} {b : ι → V''} (hb' : LinearIndependent S (f' ∘ b)) :
    LinearIndependent K (f ∘ b) := 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✝¹⁷ : Algebra R S
K : Type u_1
inst✝¹⁶ : Field K
inst✝¹⁵ : Algebra R K
hRK : IsFractionRing R K
L : Type u_2
inst✝¹⁴ : Field L
inst✝¹³ : Algebra S L
inst✝¹² : IsFractionRing S L
V : Type u_3
V' : Type u_4
V'' : Type u_5
inst✝¹¹ : AddCommGroup V
inst✝¹⁰ : Module R V
inst✝⁹ : Module K V
inst✝⁸ : IsScalarTower R K V
inst✝⁷ : AddCommGroup V'
inst✝⁶ : Module R V'
inst✝⁵ : Module S V'
inst✝⁴ : IsScalarTower R S V'
inst✝³ : AddCommGroup V''
inst✝² : Module R V''
inst✝¹ : IsDomain R
inst✝ : IsDedekindDomain R
hRS : RingHom.ker (algebraMap R S) ≠ ⊤
f : V'' →ₗ[R] V
hf : Function.Injective ⇑f
f' : V'' →ₗ[R] V'
ι : Type u_6
b : ι → V''
hb' : LinearIndependent S (⇑f' ∘ b)
⊢ LinearIndependent K (⇑f ∘ b)

Next tactic:
contrapose! hb' with hb
/-- Let `V` be a vector space over `K = Frac(R)`, `S / R` a ring extension
and `V'` a module over `S`. If `b`, in the intersection `V''` of `V` and `V'`,
is linear independent over `S` in `V'`, then it is linear independent over `R` in `V`.

The statement we prove is actually slightly more general:
 * it suffices that the inclusion `algebraMap R S : R → S` is nontrivial
 * the function `f' : V'' → V'` doesn't need to be injective
-/
theorem FinrankQuotientMap.linearIndependent_of_nontrivial [IsDomain R] [IsDedekindDomain R]
    (hRS : RingHom.ker (algebraMap R S) ≠ ⊤) (f : V'' →ₗ[R] V) (hf : Function.Injective f)
    (f' : V'' →ₗ[R] V') {ι : Type*} {b : ι → V''} (hb' : LinearIndependent S (f' ∘ b)) :
    LinearIndependent K (f ∘ b) := by
  contrapose! hb' with hb
  -- Informally, if we have a nontrivial linear dependence with coefficients `g` in `K`,
  -- then we can find a linear dependence with coefficients `I.Quotient.mk g'` in `R/I`,
  -- where `I = ker (algebraMap R S)`.
  -- We make use of the same principle but stay in `R` everywhere.
  

Proof state:
R : Type u
inst✝¹⁹ : CommRing R
S : Type v
inst✝¹⁸ : CommRing S
f✝ : R →+* S
p : Ideal R
P : Ideal S
inst✝¹⁷ : Algebra R S
K : Type u_1
inst✝¹⁶ : Field K
inst✝¹⁵ : Algebra R K
hRK : IsFractionRing R K
L : Type u_2
inst✝¹⁴ : Field L
inst✝¹³ : Algebra S L
inst✝¹² : IsFractionRing S L
V : Type u_3
V' : Type u_4
V'' : Type u_5
inst✝¹¹ : AddCommGroup V
inst✝¹⁰ : Module R V
inst✝⁹ : Module K V
inst✝⁸ : IsScalarTower R K V
inst✝⁷ : AddCommGroup V'
inst✝⁶ : Module R V'
inst✝⁵ : Module S V'
inst✝⁴ : IsScalarTower R S V'
inst✝³ : AddCommGroup V''
inst✝² : Module R V''
inst✝¹ : IsDomain R
inst✝ : IsDedekindDomain R
hRS : RingHom.ker (algebraMap R S) ≠ ⊤
f : V'' →ₗ[R] V
hf : Function.Injective ⇑f
f' : V'' →ₗ[R] V'
ι : Type u_6
b : ι → V''
hb : ¬LinearIndependent K (⇑f ∘ b)
⊢ ¬LinearIndependent S (⇑f' ∘ b)

Next tactic:
simp only [linearIndependent_iff', not_forall] at hb ⊢