l3lab/ntp-mathlib huggingface dataset:
/-- The multiplicative `v`-adic valuation on `Kˣ` modulo `n`-th powers. -/
def valuationOfNeZeroMod (n : ℕ) : (K/n) →* Multiplicative (ZMod n) :=
  (Int.quotientZMultiplesNatEquivZMod n).toMultiplicative.toMonoidHom.comp <|
    QuotientGroup.map (powMonoidHom n : Kˣ →* Kˣ).range
      (AddSubgroup.toSubgroup (AddSubgroup.zmultiples (n : ℤ)))
      v.valuationOfNeZero
      (by
        rintro _ ⟨x, rfl⟩
        exact
          ⟨v.valuationOfNeZero x, by 

Proof state:
R : Type u
inst✝⁵ : CommRing R
inst✝⁴ : IsDomain R
inst✝³ : IsDedekindDomain R
K : Type v
inst✝² : Field K
inst✝¹ : Algebra R K
inst✝ : IsFractionRing R K
v : HeightOneSpectrum R
n : ℕ
x : Kˣ
⊢ (fun x => x • ↑n) ((valuationOfNeZero v) x) = Multiplicative.toAdd ((valuationOfNeZero v) ((powMonoidHom n) x))

Next tactic:
simp only [powMonoidHom_apply, map_pow, Int.toAdd_pow]
/-- The multiplicative `v`-adic valuation on `Kˣ` modulo `n`-th powers. -/
def valuationOfNeZeroMod (n : ℕ) : (K/n) →* Multiplicative (ZMod n) :=
  (Int.quotientZMultiplesNatEquivZMod n).toMultiplicative.toMonoidHom.comp <|
    QuotientGroup.map (powMonoidHom n : Kˣ →* Kˣ).range
      (AddSubgroup.toSubgroup (AddSubgroup.zmultiples (n : ℤ)))
      v.valuationOfNeZero
      (by
        rintro _ ⟨x, rfl⟩
        exact
          ⟨v.valuationOfNeZero x, by simp only [powMonoidHom_apply, map_pow, Int.toAdd_pow]; 

Proof state:
R : Type u
inst✝⁵ : CommRing R
inst✝⁴ : IsDomain R
inst✝³ : IsDedekindDomain R
K : Type v
inst✝² : Field K
inst✝¹ : Algebra R K
inst✝ : IsFractionRing R K
v : HeightOneSpectrum R
n : ℕ
x : Kˣ
⊢ (valuationOfNeZero v) x • ↑n = Multiplicative.toAdd ((valuationOfNeZero v) x) * ↑n

Next tactic:
rfl
@[simp]
theorem valuation_of_unit_mod_eq (n : ℕ) (x : Rˣ) :
    v.valuationOfNeZeroMod n (Units.map (algebraMap R K : R →* K) x : K/n) = 1 := by
  -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644
  

Proof state:
R : Type u
inst✝⁵ : CommRing R
inst✝⁴ : IsDomain R
inst✝³ : IsDedekindDomain R
K : Type v
inst✝² : Field K
inst✝¹ : Algebra R K
inst✝ : IsFractionRing R K
v : HeightOneSpectrum R
n : ℕ
x : Rˣ
⊢ (valuationOfNeZeroMod v n) ↑((Units.map ↑(algebraMap R K)) x) = 1

Next tactic:
erw [valuationOfNeZeroMod, MonoidHom.comp_apply, ← QuotientGroup.coe_mk',
    QuotientGroup.map_mk' (G := Kˣ) (N := MonoidHom.range (powMonoidHom n)),
    valuation_of_unit_eq, QuotientGroup.mk_one, map_one]
/-- The Selmer group `K⟮S, n⟯`. -/
def selmerGroup : Subgroup <| K/n where
  carrier := {x : K/n | ∀ (v) (_ : v ∉ S), (v : HeightOneSpectrum R).valuationOfNeZeroMod n x = 1}
  one_mem' _ _ := by rw [map_one]
  mul_mem' hx hy v hv := by 

Proof state:
R : Type u
inst✝⁵ : CommRing R
inst✝⁴ : IsDomain R
inst✝³ : IsDedekindDomain R
K : Type v
inst✝² : Field K
inst✝¹ : Algebra R K
inst✝ : IsFractionRing R K
v✝ : HeightOneSpectrum R
S S' : Set (HeightOneSpectrum R)
n : ℕ
a✝ b✝ : Kˣ ⧸ MonoidHom.range (powMonoidHom n)
hx : a✝ ∈ {x | ∀ v ∉ S, (HeightOneSpectrum.valuationOfNeZeroMod v n) x = 1}
hy : b✝ ∈ {x | ∀ v ∉ S, (HeightOneSpectrum.valuationOfNeZeroMod v n) x = 1}
v : HeightOneSpectrum R
hv : v ∉ S
⊢ (HeightOneSpectrum.valuationOfNeZeroMod v n) (a✝ * b✝) = 1

Next tactic:
rw [map_mul, hx v hv, hy v hv, one_mul]
/-- The Selmer group `K⟮S, n⟯`. -/
def selmerGroup : Subgroup <| K/n where
  carrier := {x : K/n | ∀ (v) (_ : v ∉ S), (v : HeightOneSpectrum R).valuationOfNeZeroMod n x = 1}
  one_mem' _ _ := by 

Proof state:
R : Type u
inst✝⁵ : CommRing R
inst✝⁴ : IsDomain R
inst✝³ : IsDedekindDomain R
K : Type v
inst✝² : Field K
inst✝¹ : Algebra R K
inst✝ : IsFractionRing R K
v : HeightOneSpectrum R
S S' : Set (HeightOneSpectrum R)
n : ℕ
x✝¹ : HeightOneSpectrum R
x✝ : x✝¹ ∉ S
⊢ (HeightOneSpectrum.valuationOfNeZeroMod x✝¹ n) 1 = 1

Next tactic:
rw [map_one]
/-- The Selmer group `K⟮S, n⟯`. -/
def selmerGroup : Subgroup <| K/n where
  carrier := {x : K/n | ∀ (v) (_ : v ∉ S), (v : HeightOneSpectrum R).valuationOfNeZeroMod n x = 1}
  one_mem' _ _ := by rw [map_one]
  mul_mem' hx hy v hv := by rw [map_mul, hx v hv, hy v hv, one_mul]
  inv_mem' hx v hv := by 

Proof state:
R : Type u
inst✝⁵ : CommRing R
inst✝⁴ : IsDomain R
inst✝³ : IsDedekindDomain R
K : Type v
inst✝² : Field K
inst✝¹ : Algebra R K
inst✝ : IsFractionRing R K
v✝ : HeightOneSpectrum R
S S' : Set (HeightOneSpectrum R)
n : ℕ
x✝ : Kˣ ⧸ MonoidHom.range (powMonoidHom n)
hx :
  x✝ ∈
    {
          toSubsemigroup :=
            { carrier := {x | ∀ v ∉ S, (HeightOneSpectrum.valuationOfNeZeroMod v n) x = 1},
              mul_mem' :=
                (_ :
                  ∀ {a b : Kˣ ⧸ MonoidHom.range (powMonoidHom n)},
                    a ∈ {x | ∀ v ∉ S, (HeightOneSpectrum.valuationOfNeZeroMod v n) x = 1} →
                      b ∈ {x | ∀ v ∉ S, (HeightOneSpectrum.valuationOfNeZeroMod v n) x = 1} →
                        ∀ v ∉ S, (HeightOneSpectrum.valuationOfNeZeroMod v n) (a * b) = 1) },
          one_mem' := (_ : ∀ x ∉ S, (HeightOneSpectrum.valuationOfNeZeroMod x n) 1 = 1) }.toSubsemigroup.carrier
v : HeightOneSpectrum R
hv : v ∉ S
⊢ (HeightOneSpectrum.valuationOfNeZeroMod v n) x✝⁻¹ = 1

Next tactic:
rw [map_inv, hx v hv, inv_one]
/-- The multiplicative `v`-adic valuations on `K⟮S, n⟯` for all `v ∈ S`. -/
def valuation : K⟮S,n⟯ →* S → Multiplicative (ZMod n) where
  toFun x v := (v : HeightOneSpectrum R).valuationOfNeZeroMod n (x : K/n)
  map_one' := funext fun v => map_one _
  map_mul' x y := by 

Proof state:
R : Type u
inst✝⁵ : CommRing R
inst✝⁴ : IsDomain R
inst✝³ : IsDedekindDomain R
K : Type v
inst✝² : Field K
inst✝¹ : Algebra R K
inst✝ : IsFractionRing R K
v : HeightOneSpectrum R
S S' : Set (HeightOneSpectrum R)
n : ℕ
x y : ↥selmerGroup
⊢ OneHom.toFun
      { toFun := fun x v => (HeightOneSpectrum.valuationOfNeZeroMod (↑v) n) ↑x,
        map_one' := (_ : (fun x v => (HeightOneSpectrum.valuationOfNeZeroMod (↑v) n) ↑x) 1 = 1) }
      (x * y) =
    OneHom.toFun
        { toFun := fun x v => (HeightOneSpectrum.valuationOfNeZeroMod (↑v) n) ↑x,
          map_one' := (_ : (fun x v => (HeightOneSpectrum.valuationOfNeZeroMod (↑v) n) ↑x) 1 = 1) }
        x *
      OneHom.toFun
        { toFun := fun x v => (HeightOneSpectrum.valuationOfNeZeroMod (↑v) n) ↑x,
          map_one' := (_ : (fun x v => (HeightOneSpectrum.valuationOfNeZeroMod (↑v) n) ↑x) 1 = 1) }
        y

Next tactic:
simp only [Submonoid.coe_mul, Subgroup.coe_toSubmonoid, map_mul]
/-- The multiplicative `v`-adic valuations on `K⟮S, n⟯` for all `v ∈ S`. -/
def valuation : K⟮S,n⟯ →* S → Multiplicative (ZMod n) where
  toFun x v := (v : HeightOneSpectrum R).valuationOfNeZeroMod n (x : K/n)
  map_one' := funext fun v => map_one _
  map_mul' x y := by simp only [Submonoid.coe_mul, Subgroup.coe_toSubmonoid, map_mul]; 

Proof state:
R : Type u
inst✝⁵ : CommRing R
inst✝⁴ : IsDomain R
inst✝³ : IsDedekindDomain R
K : Type v
inst✝² : Field K
inst✝¹ : Algebra R K
inst✝ : IsFractionRing R K
v : HeightOneSpectrum R
S S' : Set (HeightOneSpectrum R)
n : ℕ
x y : ↥selmerGroup
⊢ (fun v => (HeightOneSpectrum.valuationOfNeZeroMod (↑v) n) ↑x * (HeightOneSpectrum.valuationOfNeZeroMod (↑v) n) ↑y) =
    (fun v => (HeightOneSpectrum.valuationOfNeZeroMod (↑v) n) ↑x) * fun v =>
      (HeightOneSpectrum.valuationOfNeZeroMod (↑v) n) ↑y

Next tactic:
rfl
theorem valuation_ker_eq :
    valuation.ker = K⟮(∅ : Set <| HeightOneSpectrum R),n⟯.subgroupOf (K⟮S,n⟯) := by
  

Proof state:
R : Type u
inst✝⁵ : CommRing R
inst✝⁴ : IsDomain R
inst✝³ : IsDedekindDomain R
K : Type v
inst✝² : Field K
inst✝¹ : Algebra R K
inst✝ : IsFractionRing R K
v : HeightOneSpectrum R
S S' : Set (HeightOneSpectrum R)
n : ℕ
⊢ MonoidHom.ker valuation = Subgroup.subgroupOf selmerGroup selmerGroup

Next tactic:
ext ⟨_, hx⟩
theorem valuation_ker_eq :
    valuation.ker = K⟮(∅ : Set <| HeightOneSpectrum R),n⟯.subgroupOf (K⟮S,n⟯) := by
  ext ⟨_, hx⟩
  

Proof state:
case h.mk
R : Type u
inst✝⁵ : CommRing R
inst✝⁴ : IsDomain R
inst✝³ : IsDedekindDomain R
K : Type v
inst✝² : Field K
inst✝¹ : Algebra R K
inst✝ : IsFractionRing R K
v : HeightOneSpectrum R
S S' : Set (HeightOneSpectrum R)
n : ℕ
val✝ : Kˣ ⧸ MonoidHom.range (powMonoidHom n)
hx : val✝ ∈ selmerGroup
⊢ { val := val✝, property := hx } ∈ MonoidHom.ker valuation ↔
    { val := val✝, property := hx } ∈ Subgroup.subgroupOf selmerGroup selmerGroup

Next tactic:
constructor
theorem valuation_ker_eq :
    valuation.ker = K⟮(∅ : Set <| HeightOneSpectrum R),n⟯.subgroupOf (K⟮S,n⟯) := by
  ext ⟨_, hx⟩
  constructor
  · 

Proof state:
case h.mk.mp
R : Type u
inst✝⁵ : CommRing R
inst✝⁴ : IsDomain R
inst✝³ : IsDedekindDomain R
K : Type v
inst✝² : Field K
inst✝¹ : Algebra R K
inst✝ : IsFractionRing R K
v : HeightOneSpectrum R
S S' : Set (HeightOneSpectrum R)
n : ℕ
val✝ : Kˣ ⧸ MonoidHom.range (powMonoidHom n)
hx : val✝ ∈ selmerGroup
⊢ { val := val✝, property := hx } ∈ MonoidHom.ker valuation →
    { val := val✝, property := hx } ∈ Subgroup.subgroupOf selmerGroup selmerGroup

Next tactic:
intro hx' v _
theorem valuation_ker_eq :
    valuation.ker = K⟮(∅ : Set <| HeightOneSpectrum R),n⟯.subgroupOf (K⟮S,n⟯) := by
  ext ⟨_, hx⟩
  constructor
  · intro hx' v _
    

Proof state:
case h.mk.mp
R : Type u
inst✝⁵ : CommRing R
inst✝⁴ : IsDomain R
inst✝³ : IsDedekindDomain R
K : Type v
inst✝² : Field K
inst✝¹ : Algebra R K
inst✝ : IsFractionRing R K
v✝ : HeightOneSpectrum R
S S' : Set (HeightOneSpectrum R)
n : ℕ
val✝ : Kˣ ⧸ MonoidHom.range (powMonoidHom n)
hx : val✝ ∈ selmerGroup
hx' : { val := val✝, property := hx } ∈ MonoidHom.ker valuation
v : HeightOneSpectrum R
x✝ : v ∉ ∅
⊢ (HeightOneSpectrum.valuationOfNeZeroMod v n) ((Subgroup.subtype selmerGroup) { val := val✝, property := hx }) = 1

Next tactic:
by_cases hv : v ∈ S
theorem valuation_ker_eq :
    valuation.ker = K⟮(∅ : Set <| HeightOneSpectrum R),n⟯.subgroupOf (K⟮S,n⟯) := by
  ext ⟨_, hx⟩
  constructor
  · intro hx' v _
    by_cases hv : v ∈ S
    · 

Proof state:
case pos
R : Type u
inst✝⁵ : CommRing R
inst✝⁴ : IsDomain R
inst✝³ : IsDedekindDomain R
K : Type v
inst✝² : Field K
inst✝¹ : Algebra R K
inst✝ : IsFractionRing R K
v✝ : HeightOneSpectrum R
S S' : Set (HeightOneSpectrum R)
n : ℕ
val✝ : Kˣ ⧸ MonoidHom.range (powMonoidHom n)
hx : val✝ ∈ selmerGroup
hx' : { val := val✝, property := hx } ∈ MonoidHom.ker valuation
v : HeightOneSpectrum R
x✝ : v ∉ ∅
hv : v ∈ S
⊢ (HeightOneSpectrum.valuationOfNeZeroMod v n) ((Subgroup.subtype selmerGroup) { val := val✝, property := hx }) = 1

Next tactic:
exact congr_fun hx' ⟨v, hv⟩
theorem valuation_ker_eq :
    valuation.ker = K⟮(∅ : Set <| HeightOneSpectrum R),n⟯.subgroupOf (K⟮S,n⟯) := by
  ext ⟨_, hx⟩
  constructor
  · intro hx' v _
    by_cases hv : v ∈ S
    · exact congr_fun hx' ⟨v, hv⟩
    · 

Proof state:
case neg
R : Type u
inst✝⁵ : CommRing R
inst✝⁴ : IsDomain R
inst✝³ : IsDedekindDomain R
K : Type v
inst✝² : Field K
inst✝¹ : Algebra R K
inst✝ : IsFractionRing R K
v✝ : HeightOneSpectrum R
S S' : Set (HeightOneSpectrum R)
n : ℕ
val✝ : Kˣ ⧸ MonoidHom.range (powMonoidHom n)
hx : val✝ ∈ selmerGroup
hx' : { val := val✝, property := hx } ∈ MonoidHom.ker valuation
v : HeightOneSpectrum R
x✝ : v ∉ ∅
hv : v ∉ S
⊢ (HeightOneSpectrum.valuationOfNeZeroMod v n) ((Subgroup.subtype selmerGroup) { val := val✝, property := hx }) = 1

Next tactic:
exact hx v hv
theorem valuation_ker_eq :
    valuation.ker = K⟮(∅ : Set <| HeightOneSpectrum R),n⟯.subgroupOf (K⟮S,n⟯) := by
  ext ⟨_, hx⟩
  constructor
  · intro hx' v _
    by_cases hv : v ∈ S
    · exact congr_fun hx' ⟨v, hv⟩
    · exact hx v hv
  · 

Proof state:
case h.mk.mpr
R : Type u
inst✝⁵ : CommRing R
inst✝⁴ : IsDomain R
inst✝³ : IsDedekindDomain R
K : Type v
inst✝² : Field K
inst✝¹ : Algebra R K
inst✝ : IsFractionRing R K
v : HeightOneSpectrum R
S S' : Set (HeightOneSpectrum R)
n : ℕ
val✝ : Kˣ ⧸ MonoidHom.range (powMonoidHom n)
hx : val✝ ∈ selmerGroup
⊢ { val := val✝, property := hx } ∈ Subgroup.subgroupOf selmerGroup selmerGroup →
    { val := val✝, property := hx } ∈ MonoidHom.ker valuation

Next tactic:
exact fun hx' => funext fun v => hx' v <| Set.not_mem_empty v
/-- The natural homomorphism from `Rˣ` to `K⟮∅, n⟯`. -/
def fromUnit {n : ℕ} : Rˣ →* K⟮(∅ : Set <| HeightOneSpectrum R),n⟯ where
  toFun x :=
    ⟨QuotientGroup.mk <| Units.map (algebraMap R K).toMonoidHom x, fun v _ =>
      v.valuation_of_unit_mod_eq n x⟩
  map_one' := by 

Proof state:
R : Type u
inst✝⁵ : CommRing R
inst✝⁴ : IsDomain R
inst✝³ : IsDedekindDomain R
K : Type v
inst✝² : Field K
inst✝¹ : Algebra R K
inst✝ : IsFractionRing R K
v : HeightOneSpectrum R
S S' : Set (HeightOneSpectrum R)
n✝ n : ℕ
⊢ (fun x =>
        { val := ↑((Units.map ↑(algebraMap R K)) x),
          property :=
            (_ : ∀ v ∉ ∅, (HeightOneSpectrum.valuationOfNeZeroMod v n) ↑((Units.map ↑(algebraMap R K)) x) = 1) })
      1 =
    1

Next tactic:
simp only [map_one, QuotientGroup.mk_one, Subgroup.mk_eq_one_iff]
/-- The natural homomorphism from `Rˣ` to `K⟮∅, n⟯`. -/
def fromUnit {n : ℕ} : Rˣ →* K⟮(∅ : Set <| HeightOneSpectrum R),n⟯ where
  toFun x :=
    ⟨QuotientGroup.mk <| Units.map (algebraMap R K).toMonoidHom x, fun v _ =>
      v.valuation_of_unit_mod_eq n x⟩
  map_one' := by simp only [map_one, QuotientGroup.mk_one, Subgroup.mk_eq_one_iff]
  map_mul' _ _ := by 

Proof state:
R : Type u
inst✝⁵ : CommRing R
inst✝⁴ : IsDomain R
inst✝³ : IsDedekindDomain R
K : Type v
inst✝² : Field K
inst✝¹ : Algebra R K
inst✝ : IsFractionRing R K
v : HeightOneSpectrum R
S S' : Set (HeightOneSpectrum R)
n✝ n : ℕ
x✝¹ x✝ : Rˣ
⊢ OneHom.toFun
      {
        toFun := fun x =>
          { val := ↑((Units.map ↑(algebraMap R K)) x),
            property :=
              (_ : ∀ v ∉ ∅, (HeightOneSpectrum.valuationOfNeZeroMod v n) ↑((Units.map ↑(algebraMap R K)) x) = 1) },
        map_one' :=
          (_ :
            { val := ↑((Units.map ↑(algebraMap R K)) 1),
                property :=
                  (_ : ∀ v ∉ ∅, (HeightOneSpectrum.valuationOfNeZeroMod v n) ↑((Units.map ↑(algebraMap R K)) 1) = 1) } =
              1) }
      (x✝¹ * x✝) =
    OneHom.toFun
        {
          toFun := fun x =>
            { val := ↑((Units.map ↑(algebraMap R K)) x),
              property :=
                (_ : ∀ v ∉ ∅, (HeightOneSpectrum.valuationOfNeZeroMod v n) ↑((Units.map ↑(algebraMap R K)) x) = 1) },
          map_one' :=
            (_ :
              { val := ↑((Units.map ↑(algebraMap R K)) 1),
                  property :=
                    (_ :
                      ∀ v ∉ ∅, (HeightOneSpectrum.valuationOfNeZeroMod v n) ↑((Units.map ↑(algebraMap R K)) 1) = 1) } =
                1) }
        x✝¹ *
      OneHom.toFun
        {
          toFun := fun x =>
            { val := ↑((Units.map ↑(algebraMap R K)) x),
              property :=
                (_ : ∀ v ∉ ∅, (HeightOneSpectrum.valuationOfNeZeroMod v n) ↑((Units.map ↑(algebraMap R K)) x) = 1) },
          map_one' :=
            (_ :
              { val := ↑((Units.map ↑(algebraMap R K)) 1),
                  property :=
                    (_ :
                      ∀ v ∉ ∅, (HeightOneSpectrum.valuationOfNeZeroMod v n) ↑((Units.map ↑(algebraMap R K)) 1) = 1) } =
                1) }
        x✝

Next tactic:
simp only [RingHom.toMonoidHom_eq_coe, map_mul, MonoidHom.mem_range,
    powMonoidHom_apply, QuotientGroup.mk_mul, Submonoid.mk_mul_mk]
theorem fromUnit_ker [hn : Fact <| 0 < n] :
    (@fromUnit R _ _ _ K _ _ _ n).ker = (powMonoidHom n : Rˣ →* Rˣ).range := by
  

Proof state:
R : Type u
inst✝⁵ : CommRing R
inst✝⁴ : IsDomain R
inst✝³ : IsDedekindDomain R
K : Type v
inst✝² : Field K
inst✝¹ : Algebra R K
inst✝ : IsFractionRing R K
v : HeightOneSpectrum R
S S' : Set (HeightOneSpectrum R)
n : ℕ
hn : Fact (0 < n)
⊢ MonoidHom.ker fromUnit = MonoidHom.range (powMonoidHom n)

Next tactic:
ext ⟨_, _, _, _⟩
theorem fromUnit_ker [hn : Fact <| 0 < n] :
    (@fromUnit R _ _ _ K _ _ _ n).ker = (powMonoidHom n : Rˣ →* Rˣ).range := by
  ext ⟨_, _, _, _⟩
  

Proof state:
case h.mk
R : Type u
inst✝⁵ : CommRing R
inst✝⁴ : IsDomain R
inst✝³ : IsDedekindDomain R
K : Type v
inst✝² : Field K
inst✝¹ : Algebra R K
inst✝ : IsFractionRing R K
v : HeightOneSpectrum R
S S' : Set (HeightOneSpectrum R)
n : ℕ
hn : Fact (0 < n)
val✝ inv✝ : R
val_inv✝ : val✝ * inv✝ = 1
inv_val✝ : inv✝ * val✝ = 1
⊢ { val := val✝, inv := inv✝, val_inv := val_inv✝, inv_val := inv_val✝ } ∈ MonoidHom.ker fromUnit ↔
    { val := val✝, inv := inv✝, val_inv := val_inv✝, inv_val := inv_val✝ } ∈ MonoidHom.range (powMonoidHom n)

Next tactic:
constructor
theorem fromUnit_ker [hn : Fact <| 0 < n] :
    (@fromUnit R _ _ _ K _ _ _ n).ker = (powMonoidHom n : Rˣ →* Rˣ).range := by
  ext ⟨_, _, _, _⟩
  constructor
  · 

Proof state:
case h.mk.mp
R : Type u
inst✝⁵ : CommRing R
inst✝⁴ : IsDomain R
inst✝³ : IsDedekindDomain R
K : Type v
inst✝² : Field K
inst✝¹ : Algebra R K
inst✝ : IsFractionRing R K
v : HeightOneSpectrum R
S S' : Set (HeightOneSpectrum R)
n : ℕ
hn : Fact (0 < n)
val✝ inv✝ : R
val_inv✝ : val✝ * inv✝ = 1
inv_val✝ : inv✝ * val✝ = 1
⊢ { val := val✝, inv := inv✝, val_inv := val_inv✝, inv_val := inv_val✝ } ∈ MonoidHom.ker fromUnit →
    { val := val✝, inv := inv✝, val_inv := val_inv✝, inv_val := inv_val✝ } ∈ MonoidHom.range (powMonoidHom n)

Next tactic:
intro hx
theorem fromUnit_ker [hn : Fact <| 0 < n] :
    (@fromUnit R _ _ _ K _ _ _ n).ker = (powMonoidHom n : Rˣ →* Rˣ).range := by
  ext ⟨_, _, _, _⟩
  constructor
  · intro hx
    

Proof state:
case h.mk.mp
R : Type u
inst✝⁵ : CommRing R
inst✝⁴ : IsDomain R
inst✝³ : IsDedekindDomain R
K : Type v
inst✝² : Field K
inst✝¹ : Algebra R K
inst✝ : IsFractionRing R K
v : HeightOneSpectrum R
S S' : Set (HeightOneSpectrum R)
n : ℕ
hn : Fact (0 < n)
val✝ inv✝ : R
val_inv✝ : val✝ * inv✝ = 1
inv_val✝ : inv✝ * val✝ = 1
hx : { val := val✝, inv := inv✝, val_inv := val_inv✝, inv_val := inv_val✝ } ∈ MonoidHom.ker fromUnit
⊢ { val := val✝, inv := inv✝, val_inv := val_inv✝, inv_val := inv_val✝ } ∈ MonoidHom.range (powMonoidHom n)

Next tactic:
rcases (QuotientGroup.eq_one_iff _).mp (Subtype.mk.inj hx) with ⟨⟨v, i, vi, iv⟩, hx⟩
theorem fromUnit_ker [hn : Fact <| 0 < n] :
    (@fromUnit R _ _ _ K _ _ _ n).ker = (powMonoidHom n : Rˣ →* Rˣ).range := by
  ext ⟨_, _, _, _⟩
  constructor
  · intro hx
    rcases (QuotientGroup.eq_one_iff _).mp (Subtype.mk.inj hx) with ⟨⟨v, i, vi, iv⟩, hx⟩
    

Proof state:
case h.mk.mp.intro.mk
R : Type u
inst✝⁵ : CommRing R
inst✝⁴ : IsDomain R
inst✝³ : IsDedekindDomain R
K : Type v
inst✝² : Field K
inst✝¹ : Algebra R K
inst✝ : IsFractionRing R K
v✝ : HeightOneSpectrum R
S S' : Set (HeightOneSpectrum R)
n : ℕ
hn : Fact (0 < n)
val✝ inv✝ : R
val_inv✝ : val✝ * inv✝ = 1
inv_val✝ : inv✝ * val✝ = 1
hx✝ : { val := val✝, inv := inv✝, val_inv := val_inv✝, inv_val := inv_val✝ } ∈ MonoidHom.ker fromUnit
v i : K
vi : v * i = 1
iv : i * v = 1
hx :
  (powMonoidHom n) { val := v, inv := i, val_inv := vi, inv_val := iv } =
    (Units.map ↑(algebraMap R K)) { val := val✝, inv := inv✝, val_inv := val_inv✝, inv_val := inv_val✝ }
⊢ { val := val✝, inv := inv✝, val_inv := val_inv✝, inv_val := inv_val✝ } ∈ MonoidHom.range (powMonoidHom n)

Next tactic:
have hv : ↑(_ ^ n : Kˣ) = algebraMap R K _ := by exact congr_arg Units.val hx
theorem fromUnit_ker [hn : Fact <| 0 < n] :
    (@fromUnit R _ _ _ K _ _ _ n).ker = (powMonoidHom n : Rˣ →* Rˣ).range := by
  ext ⟨_, _, _, _⟩
  constructor
  · intro hx
    rcases (QuotientGroup.eq_one_iff _).mp (Subtype.mk.inj hx) with ⟨⟨v, i, vi, iv⟩, hx⟩
    have hv : ↑(_ ^ n : Kˣ) = algebraMap R K _ := by 

Proof state:
R : Type u
inst✝⁵ : CommRing R
inst✝⁴ : IsDomain R
inst✝³ : IsDedekindDomain R
K : Type v
inst✝² : Field K
inst✝¹ : Algebra R K
inst✝ : IsFractionRing R K
v✝ : HeightOneSpectrum R
S S' : Set (HeightOneSpectrum R)
n : ℕ
hn : Fact (0 < n)
val✝ inv✝ : R
val_inv✝ : val✝ * inv✝ = 1
inv_val✝ : inv✝ * val✝ = 1
hx✝ : { val := val✝, inv := inv✝, val_inv := val_inv✝, inv_val := inv_val✝ } ∈ MonoidHom.ker fromUnit
v i : K
vi : v * i = 1
iv : i * v = 1
hx :
  (powMonoidHom n) { val := v, inv := i, val_inv := vi, inv_val := iv } =
    (Units.map ↑(algebraMap R K)) { val := val✝, inv := inv✝, val_inv := val_inv✝, inv_val := inv_val✝ }
⊢ ↑(?m.1081528 ^ n) = (algebraMap R K) ?m.1081470

Next tactic:
exact congr_arg Units.val hx
theorem fromUnit_ker [hn : Fact <| 0 < n] :
    (@fromUnit R _ _ _ K _ _ _ n).ker = (powMonoidHom n : Rˣ →* Rˣ).range := by
  ext ⟨_, _, _, _⟩
  constructor
  · intro hx
    rcases (QuotientGroup.eq_one_iff _).mp (Subtype.mk.inj hx) with ⟨⟨v, i, vi, iv⟩, hx⟩
    have hv : ↑(_ ^ n : Kˣ) = algebraMap R K _ := by exact congr_arg Units.val hx
    

Proof state:
case h.mk.mp.intro.mk
R : Type u
inst✝⁵ : CommRing R
inst✝⁴ : IsDomain R
inst✝³ : IsDedekindDomain R
K : Type v
inst✝² : Field K
inst✝¹ : Algebra R K
inst✝ : IsFractionRing R K
v✝ : HeightOneSpectrum R
S S' : Set (HeightOneSpectrum R)
n : ℕ
hn : Fact (0 < n)
val✝ inv✝ : R
val_inv✝ : val✝ * inv✝ = 1
inv_val✝ : inv✝ * val✝ = 1
hx✝ : { val := val✝, inv := inv✝, val_inv := val_inv✝, inv_val := inv_val✝ } ∈ MonoidHom.ker fromUnit
v i : K
vi : v * i = 1
iv : i * v = 1
hx :
  (powMonoidHom n) { val := v, inv := i, val_inv := vi, inv_val := iv } =
    (Units.map ↑(algebraMap R K)) { val := val✝, inv := inv✝, val_inv := val_inv✝, inv_val := inv_val✝ }
hv :
  ↑({ val := v, inv := i, val_inv := vi, inv_val := iv } ^ n) =
    (algebraMap R K) ↑{ val := val✝, inv := inv✝, val_inv := val_inv✝, inv_val := inv_val✝ }
⊢ { val := val✝, inv := inv✝, val_inv := val_inv✝, inv_val := inv_val✝ } ∈ MonoidHom.range (powMonoidHom n)

Next tactic:
have hi : ↑(_ ^ n : Kˣ)⁻¹ = algebraMap R K _ := by exact congr_arg Units.inv hx
theorem fromUnit_ker [hn : Fact <| 0 < n] :
    (@fromUnit R _ _ _ K _ _ _ n).ker = (powMonoidHom n : Rˣ →* Rˣ).range := by
  ext ⟨_, _, _, _⟩
  constructor
  · intro hx
    rcases (QuotientGroup.eq_one_iff _).mp (Subtype.mk.inj hx) with ⟨⟨v, i, vi, iv⟩, hx⟩
    have hv : ↑(_ ^ n : Kˣ) = algebraMap R K _ := by exact congr_arg Units.val hx
    have hi : ↑(_ ^ n : Kˣ)⁻¹ = algebraMap R K _ := by 

Proof state:
R : Type u
inst✝⁵ : CommRing R
inst✝⁴ : IsDomain R
inst✝³ : IsDedekindDomain R
K : Type v
inst✝² : Field K
inst✝¹ : Algebra R K
inst✝ : IsFractionRing R K
v✝ : HeightOneSpectrum R
S S' : Set (HeightOneSpectrum R)
n : ℕ
hn : Fact (0 < n)
val✝ inv✝ : R
val_inv✝ : val✝ * inv✝ = 1
inv_val✝ : inv✝ * val✝ = 1
hx✝ : { val := val✝, inv := inv✝, val_inv := val_inv✝, inv_val := inv_val✝ } ∈ MonoidHom.ker fromUnit
v i : K
vi : v * i = 1
iv : i * v = 1
hx :
  (powMonoidHom n) { val := v, inv := i, val_inv := vi, inv_val := iv } =
    (Units.map ↑(algebraMap R K)) { val := val✝, inv := inv✝, val_inv := val_inv✝, inv_val := inv_val✝ }
hv :
  ↑({ val := v, inv := i, val_inv := vi, inv_val := iv } ^ n) =
    (algebraMap R K) ↑{ val := val✝, inv := inv✝, val_inv := val_inv✝, inv_val := inv_val✝ }
⊢ ↑(?m.1141793 ^ n)⁻¹ = (algebraMap R K) ?m.1141780

Next tactic:
exact congr_arg Units.inv hx
theorem fromUnit_ker [hn : Fact <| 0 < n] :
    (@fromUnit R _ _ _ K _ _ _ n).ker = (powMonoidHom n : Rˣ →* Rˣ).range := by
  ext ⟨_, _, _, _⟩
  constructor
  · intro hx
    rcases (QuotientGroup.eq_one_iff _).mp (Subtype.mk.inj hx) with ⟨⟨v, i, vi, iv⟩, hx⟩
    have hv : ↑(_ ^ n : Kˣ) = algebraMap R K _ := by exact congr_arg Units.val hx
    have hi : ↑(_ ^ n : Kˣ)⁻¹ = algebraMap R K _ := by exact congr_arg Units.inv hx
    

Proof state:
case h.mk.mp.intro.mk
R : Type u
inst✝⁵ : CommRing R
inst✝⁴ : IsDomain R
inst✝³ : IsDedekindDomain R
K : Type v
inst✝² : Field K
inst✝¹ : Algebra R K
inst✝ : IsFractionRing R K
v✝ : HeightOneSpectrum R
S S' : Set (HeightOneSpectrum R)
n : ℕ
hn : Fact (0 < n)
val✝ inv✝ : R
val_inv✝ : val✝ * inv✝ = 1
inv_val✝ : inv✝ * val✝ = 1
hx✝ : { val := val✝, inv := inv✝, val_inv := val_inv✝, inv_val := inv_val✝ } ∈ MonoidHom.ker fromUnit
v i : K
vi : v * i = 1
iv : i * v = 1
hx :
  (powMonoidHom n) { val := v, inv := i, val_inv := vi, inv_val := iv } =
    (Units.map ↑(algebraMap R K)) { val := val✝, inv := inv✝, val_inv := val_inv✝, inv_val := inv_val✝ }
hv :
  ↑({ val := v, inv := i, val_inv := vi, inv_val := iv } ^ n) =
    (algebraMap R K) ↑{ val := val✝, inv := inv✝, val_inv := val_inv✝, inv_val := inv_val✝ }
hi :
  ↑({ val := v, inv := i, val_inv := vi, inv_val := iv } ^ n)⁻¹ =
    (algebraMap R K) { val := val✝, inv := inv✝, val_inv := val_inv✝, inv_val := inv_val✝ }.inv
⊢ { val := val✝, inv := inv✝, val_inv := val_inv✝, inv_val := inv_val✝ } ∈ MonoidHom.range (powMonoidHom n)

Next tactic:
rw [Units.val_pow_eq_pow_val] at hv