l3lab/ntp-mathlib huggingface dataset:
/-- The principal unit group of a valuation subring, as a subgroup of `Kˣ`. -/
def principalUnitGroup : Subgroup Kˣ where
  carrier := {x | A.valuation (x - 1) < 1}
  mul_mem' := by
    intro a b ha hb
    -- Porting note: added
    rw [Set.mem_setOf] at ha hb
    refine' lt_of_le_of_lt _ (max_lt hb ha)
    -- Porting note: `sub_add_sub_cancel` needed some help
    rw [← one_mul (A.valuation (b - 1)), ← A.valuation.map_one_add_of_lt ha, add_sub_cancel'_right,
      ← Valuation.map_mul, mul_sub_one, ← sub_add_sub_cancel (↑(a * b) : K) _ 1]
    

Proof state:
K : Type u
inst✝ : Field K
A : ValuationSubring K
a b : Kˣ
ha : (valuation A) (↑a - 1) < 1
hb : (valuation A) (↑b - 1) < 1
⊢ (valuation A) (↑(a * b) - ?m.1691571 + (?m.1691571 - 1)) ≤ max ((valuation A) (↑a * ↑b - ↑a)) ((valuation A) (↑a - 1))
K : Type u
inst✝ : Field K
A : ValuationSubring K
a b : Kˣ
ha : (valuation A) (↑a - 1) < 1
hb : (valuation A) (↑b - 1) < 1
⊢ K

Next tactic:
exact A.valuation.map_add _ _
/-- The principal unit group of a valuation subring, as a subgroup of `Kˣ`. -/
def principalUnitGroup : Subgroup Kˣ where
  carrier := {x | A.valuation (x - 1) < 1}
  mul_mem' := by
    intro a b ha hb
    -- Porting note: added
    rw [Set.mem_setOf] at ha hb
    refine' lt_of_le_of_lt _ (max_lt hb ha)
    -- Porting note: `sub_add_sub_cancel` needed some help
    rw [← one_mul (A.valuation (b - 1)), ← A.valuation.map_one_add_of_lt ha, add_sub_cancel'_right,
      ← Valuation.map_mul, mul_sub_one, ← sub_add_sub_cancel (↑(a * b) : K) _ 1]
    exact A.valuation.map_add _ _
  one_mem' := by 

Proof state:
K : Type u
inst✝ : Field K
A : ValuationSubring K
⊢ 1 ∈
    { carrier := {x | (valuation A) (↑x - 1) < 1},
        mul_mem' :=
          (_ :
            ∀ {a b : Kˣ},
              a ∈ {x | (valuation A) (↑x - 1) < 1} →
                b ∈ {x | (valuation A) (↑x - 1) < 1} → (valuation A) (↑(a * b) - 1) < 1) }.carrier

Next tactic:
simp
/-- The principal unit group of a valuation subring, as a subgroup of `Kˣ`. -/
def principalUnitGroup : Subgroup Kˣ where
  carrier := {x | A.valuation (x - 1) < 1}
  mul_mem' := by
    intro a b ha hb
    -- Porting note: added
    rw [Set.mem_setOf] at ha hb
    refine' lt_of_le_of_lt _ (max_lt hb ha)
    -- Porting note: `sub_add_sub_cancel` needed some help
    rw [← one_mul (A.valuation (b - 1)), ← A.valuation.map_one_add_of_lt ha, add_sub_cancel'_right,
      ← Valuation.map_mul, mul_sub_one, ← sub_add_sub_cancel (↑(a * b) : K) _ 1]
    exact A.valuation.map_add _ _
  one_mem' := by simp
  inv_mem' := by
    

Proof state:
K : Type u
inst✝ : Field K
A : ValuationSubring K
⊢ ∀ {x : Kˣ},
    x ∈
        {
              toSubsemigroup :=
                { carrier := {x | (valuation A) (↑x - 1) < 1},
                  mul_mem' :=
                    (_ :
                      ∀ {a b : Kˣ},
                        a ∈ {x | (valuation A) (↑x - 1) < 1} →
                          b ∈ {x | (valuation A) (↑x - 1) < 1} → (valuation A) (↑(a * b) - 1) < 1) },
              one_mem' := (_ : (valuation A) (1 - 1) < 1) }.toSubsemigroup.carrier →
      x⁻¹ ∈
        {
              toSubsemigroup :=
                { carrier := {x | (valuation A) (↑x - 1) < 1},
                  mul_mem' :=
                    (_ :
                      ∀ {a b : Kˣ},
                        a ∈ {x | (valuation A) (↑x - 1) < 1} →
                          b ∈ {x | (valuation A) (↑x - 1) < 1} → (valuation A) (↑(a * b) - 1) < 1) },
              one_mem' := (_ : (valuation A) (1 - 1) < 1) }.toSubsemigroup.carrier

Next tactic:
dsimp
/-- The principal unit group of a valuation subring, as a subgroup of `Kˣ`. -/
def principalUnitGroup : Subgroup Kˣ where
  carrier := {x | A.valuation (x - 1) < 1}
  mul_mem' := by
    intro a b ha hb
    -- Porting note: added
    rw [Set.mem_setOf] at ha hb
    refine' lt_of_le_of_lt _ (max_lt hb ha)
    -- Porting note: `sub_add_sub_cancel` needed some help
    rw [← one_mul (A.valuation (b - 1)), ← A.valuation.map_one_add_of_lt ha, add_sub_cancel'_right,
      ← Valuation.map_mul, mul_sub_one, ← sub_add_sub_cancel (↑(a * b) : K) _ 1]
    exact A.valuation.map_add _ _
  one_mem' := by simp
  inv_mem' := by
    dsimp
    

Proof state:
K : Type u
inst✝ : Field K
A : ValuationSubring K
⊢ ∀ {x : Kˣ}, (valuation A) (↑x - 1) < 1 → (valuation A) (↑x⁻¹ - 1) < 1

Next tactic:
intro a ha
/-- The principal unit group of a valuation subring, as a subgroup of `Kˣ`. -/
def principalUnitGroup : Subgroup Kˣ where
  carrier := {x | A.valuation (x - 1) < 1}
  mul_mem' := by
    intro a b ha hb
    -- Porting note: added
    rw [Set.mem_setOf] at ha hb
    refine' lt_of_le_of_lt _ (max_lt hb ha)
    -- Porting note: `sub_add_sub_cancel` needed some help
    rw [← one_mul (A.valuation (b - 1)), ← A.valuation.map_one_add_of_lt ha, add_sub_cancel'_right,
      ← Valuation.map_mul, mul_sub_one, ← sub_add_sub_cancel (↑(a * b) : K) _ 1]
    exact A.valuation.map_add _ _
  one_mem' := by simp
  inv_mem' := by
    dsimp
    intro a ha
    

Proof state:
K : Type u
inst✝ : Field K
A : ValuationSubring K
a : Kˣ
ha : (valuation A) (↑a - 1) < 1
⊢ (valuation A) (↑a⁻¹ - 1) < 1

Next tactic:
conv =>
      lhs
      rw [← mul_one (A.valuation _), ← A.valuation.map_one_add_of_lt ha]
/-- The principal unit group of a valuation subring, as a subgroup of `Kˣ`. -/
def principalUnitGroup : Subgroup Kˣ where
  carrier := {x | A.valuation (x - 1) < 1}
  mul_mem' := by
    intro a b ha hb
    -- Porting note: added
    rw [Set.mem_setOf] at ha hb
    refine' lt_of_le_of_lt _ (max_lt hb ha)
    -- Porting note: `sub_add_sub_cancel` needed some help
    rw [← one_mul (A.valuation (b - 1)), ← A.valuation.map_one_add_of_lt ha, add_sub_cancel'_right,
      ← Valuation.map_mul, mul_sub_one, ← sub_add_sub_cancel (↑(a * b) : K) _ 1]
    exact A.valuation.map_add _ _
  one_mem' := by simp
  inv_mem' := by
    dsimp
    intro a ha
    conv =>
      

Proof state:
K : Type u
inst✝ : Field K
A : ValuationSubring K
a : Kˣ
ha : (valuation A) (↑a - 1) < 1
| (valuation A) (↑a⁻¹ - 1) < 1

Next tactic:
lhs
      rw [← mul_one (A.valuation _), ← A.valuation.map_one_add_of_lt ha]
/-- The principal unit group of a valuation subring, as a subgroup of `Kˣ`. -/
def principalUnitGroup : Subgroup Kˣ where
  carrier := {x | A.valuation (x - 1) < 1}
  mul_mem' := by
    intro a b ha hb
    -- Porting note: added
    rw [Set.mem_setOf] at ha hb
    refine' lt_of_le_of_lt _ (max_lt hb ha)
    -- Porting note: `sub_add_sub_cancel` needed some help
    rw [← one_mul (A.valuation (b - 1)), ← A.valuation.map_one_add_of_lt ha, add_sub_cancel'_right,
      ← Valuation.map_mul, mul_sub_one, ← sub_add_sub_cancel (↑(a * b) : K) _ 1]
    exact A.valuation.map_add _ _
  one_mem' := by simp
  inv_mem' := by
    dsimp
    intro a ha
    conv =>
      

Proof state:
K : Type u
inst✝ : Field K
A : ValuationSubring K
a : Kˣ
ha : (valuation A) (↑a - 1) < 1
| (valuation A) (↑a⁻¹ - 1) < 1

Next tactic:
lhs
/-- The principal unit group of a valuation subring, as a subgroup of `Kˣ`. -/
def principalUnitGroup : Subgroup Kˣ where
  carrier := {x | A.valuation (x - 1) < 1}
  mul_mem' := by
    intro a b ha hb
    -- Porting note: added
    rw [Set.mem_setOf] at ha hb
    refine' lt_of_le_of_lt _ (max_lt hb ha)
    -- Porting note: `sub_add_sub_cancel` needed some help
    rw [← one_mul (A.valuation (b - 1)), ← A.valuation.map_one_add_of_lt ha, add_sub_cancel'_right,
      ← Valuation.map_mul, mul_sub_one, ← sub_add_sub_cancel (↑(a * b) : K) _ 1]
    exact A.valuation.map_add _ _
  one_mem' := by simp
  inv_mem' := by
    dsimp
    intro a ha
    conv =>
      lhs
      

Proof state:
K : Type u
inst✝ : Field K
A : ValuationSubring K
a : Kˣ
ha : (valuation A) (↑a - 1) < 1
| (valuation A) (↑a⁻¹ - 1)

Next tactic:
rw [← mul_one (A.valuation _), ← A.valuation.map_one_add_of_lt ha]
/-- The principal unit group of a valuation subring, as a subgroup of `Kˣ`. -/
def principalUnitGroup : Subgroup Kˣ where
  carrier := {x | A.valuation (x - 1) < 1}
  mul_mem' := by
    intro a b ha hb
    -- Porting note: added
    rw [Set.mem_setOf] at ha hb
    refine' lt_of_le_of_lt _ (max_lt hb ha)
    -- Porting note: `sub_add_sub_cancel` needed some help
    rw [← one_mul (A.valuation (b - 1)), ← A.valuation.map_one_add_of_lt ha, add_sub_cancel'_right,
      ← Valuation.map_mul, mul_sub_one, ← sub_add_sub_cancel (↑(a * b) : K) _ 1]
    exact A.valuation.map_add _ _
  one_mem' := by simp
  inv_mem' := by
    dsimp
    intro a ha
    conv =>
      lhs
      rw [← mul_one (A.valuation _), ← A.valuation.map_one_add_of_lt ha]
    

Proof state:
K : Type u
inst✝ : Field K
A : ValuationSubring K
a : Kˣ
ha : (valuation A) (↑a - 1) < 1
⊢ (valuation A) (↑a⁻¹ - 1) * (valuation A) (1 + (↑a - 1)) < 1

Next tactic:
rwa [add_sub_cancel'_right, ← Valuation.map_mul, sub_mul, Units.inv_mul, ← neg_sub, one_mul,
      Valuation.map_neg]
theorem principal_units_le_units : A.principalUnitGroup ≤ A.unitGroup := fun a h => by
  

Proof state:
K : Type u
inst✝ : Field K
A : ValuationSubring K
a : Kˣ
h : a ∈ principalUnitGroup A
⊢ a ∈ unitGroup A

Next tactic:
simpa only [add_sub_cancel'_right] using A.valuation.map_one_add_of_lt h
theorem principalUnitGroup_le_principalUnitGroup {A B : ValuationSubring K} :
    B.principalUnitGroup ≤ A.principalUnitGroup ↔ A ≤ B := by
  

Proof state:
K : Type u
inst✝ : Field K
A✝ A B : ValuationSubring K
⊢ principalUnitGroup B ≤ principalUnitGroup A ↔ A ≤ B

Next tactic:
constructor
theorem principalUnitGroup_le_principalUnitGroup {A B : ValuationSubring K} :
    B.principalUnitGroup ≤ A.principalUnitGroup ↔ A ≤ B := by
  constructor
  · 

Proof state:
case mp
K : Type u
inst✝ : Field K
A✝ A B : ValuationSubring K
⊢ principalUnitGroup B ≤ principalUnitGroup A → A ≤ B

Next tactic:
intro h x hx
theorem principalUnitGroup_le_principalUnitGroup {A B : ValuationSubring K} :
    B.principalUnitGroup ≤ A.principalUnitGroup ↔ A ≤ B := by
  constructor
  · intro h x hx
    

Proof state:
case mp
K : Type u
inst✝ : Field K
A✝ A B : ValuationSubring K
h : principalUnitGroup B ≤ principalUnitGroup A
x : K
hx : x ∈ A
⊢ x ∈ B

Next tactic:
by_cases h_1 : x = 0
theorem principalUnitGroup_le_principalUnitGroup {A B : ValuationSubring K} :
    B.principalUnitGroup ≤ A.principalUnitGroup ↔ A ≤ B := by
  constructor
  · intro h x hx
    by_cases h_1 : x = 0; · 

Proof state:
case pos
K : Type u
inst✝ : Field K
A✝ A B : ValuationSubring K
h : principalUnitGroup B ≤ principalUnitGroup A
x : K
hx : x ∈ A
h_1 : x = 0
⊢ x ∈ B

Next tactic:
simp only [h_1, zero_mem]
theorem principalUnitGroup_le_principalUnitGroup {A B : ValuationSubring K} :
    B.principalUnitGroup ≤ A.principalUnitGroup ↔ A ≤ B := by
  constructor
  · intro h x hx
    by_cases h_1 : x = 0; · simp only [h_1, zero_mem]
    

Proof state:
case neg
K : Type u
inst✝ : Field K
A✝ A B : ValuationSubring K
h : principalUnitGroup B ≤ principalUnitGroup A
x : K
hx : x ∈ A
h_1 : ¬x = 0
⊢ x ∈ B

Next tactic:
by_cases h_2 : x⁻¹ + 1 = 0
theorem principalUnitGroup_le_principalUnitGroup {A B : ValuationSubring K} :
    B.principalUnitGroup ≤ A.principalUnitGroup ↔ A ≤ B := by
  constructor
  · intro h x hx
    by_cases h_1 : x = 0; · simp only [h_1, zero_mem]
    by_cases h_2 : x⁻¹ + 1 = 0
    · 

Proof state:
case pos
K : Type u
inst✝ : Field K
A✝ A B : ValuationSubring K
h : principalUnitGroup B ≤ principalUnitGroup A
x : K
hx : x ∈ A
h_1 : ¬x = 0
h_2 : x⁻¹ + 1 = 0
⊢ x ∈ B

Next tactic:
rw [add_eq_zero_iff_eq_neg, inv_eq_iff_eq_inv, inv_neg, inv_one] at h_2
theorem principalUnitGroup_le_principalUnitGroup {A B : ValuationSubring K} :
    B.principalUnitGroup ≤ A.principalUnitGroup ↔ A ≤ B := by
  constructor
  · intro h x hx
    by_cases h_1 : x = 0; · simp only [h_1, zero_mem]
    by_cases h_2 : x⁻¹ + 1 = 0
    · rw [add_eq_zero_iff_eq_neg, inv_eq_iff_eq_inv, inv_neg, inv_one] at h_2
      

Proof state:
case pos
K : Type u
inst✝ : Field K
A✝ A B : ValuationSubring K
h : principalUnitGroup B ≤ principalUnitGroup A
x : K
hx : x ∈ A
h_1 : ¬x = 0
h_2 : x = -1
⊢ x ∈ B

Next tactic:
simpa only [h_2] using B.neg_mem _ B.one_mem
theorem principalUnitGroup_le_principalUnitGroup {A B : ValuationSubring K} :
    B.principalUnitGroup ≤ A.principalUnitGroup ↔ A ≤ B := by
  constructor
  · intro h x hx
    by_cases h_1 : x = 0; · simp only [h_1, zero_mem]
    by_cases h_2 : x⁻¹ + 1 = 0
    · rw [add_eq_zero_iff_eq_neg, inv_eq_iff_eq_inv, inv_neg, inv_one] at h_2
      simpa only [h_2] using B.neg_mem _ B.one_mem
    · 

Proof state:
case neg
K : Type u
inst✝ : Field K
A✝ A B : ValuationSubring K
h : principalUnitGroup B ≤ principalUnitGroup A
x : K
hx : x ∈ A
h_1 : ¬x = 0
h_2 : ¬x⁻¹ + 1 = 0
⊢ x ∈ B

Next tactic:
rw [← valuation_le_one_iff, ← not_lt, Valuation.one_lt_val_iff _ h_1, ← add_sub_cancel x⁻¹, ←
        Units.val_mk0 h_2, ← mem_principalUnitGroup_iff] at hx ⊢
theorem principalUnitGroup_le_principalUnitGroup {A B : ValuationSubring K} :
    B.principalUnitGroup ≤ A.principalUnitGroup ↔ A ≤ B := by
  constructor
  · intro h x hx
    by_cases h_1 : x = 0; · simp only [h_1, zero_mem]
    by_cases h_2 : x⁻¹ + 1 = 0
    · rw [add_eq_zero_iff_eq_neg, inv_eq_iff_eq_inv, inv_neg, inv_one] at h_2
      simpa only [h_2] using B.neg_mem _ B.one_mem
    · rw [← valuation_le_one_iff, ← not_lt, Valuation.one_lt_val_iff _ h_1, ← add_sub_cancel x⁻¹, ←
        Units.val_mk0 h_2, ← mem_principalUnitGroup_iff] at hx ⊢
      

Proof state:
case neg
K : Type u
inst✝ : Field K
A✝ A B : ValuationSubring K
h : principalUnitGroup B ≤ principalUnitGroup A
x : K
hx✝¹ : ¬(valuation A) x⁻¹ < 1
hx✝ : ¬(valuation A) (x⁻¹ + 1 - 1) < 1
h_1 : ¬x = 0
h_2 : ¬x⁻¹ + 1 = 0
hx : Units.mk0 (x⁻¹ + 1) h_2 ∉ principalUnitGroup A
⊢ Units.mk0 (x⁻¹ + 1) h_2 ∉ principalUnitGroup B

Next tactic:
simpa only [hx] using @h (Units.mk0 (x⁻¹ + 1) h_2)
theorem principalUnitGroup_le_principalUnitGroup {A B : ValuationSubring K} :
    B.principalUnitGroup ≤ A.principalUnitGroup ↔ A ≤ B := by
  constructor
  · intro h x hx
    by_cases h_1 : x = 0; · simp only [h_1, zero_mem]
    by_cases h_2 : x⁻¹ + 1 = 0
    · rw [add_eq_zero_iff_eq_neg, inv_eq_iff_eq_inv, inv_neg, inv_one] at h_2
      simpa only [h_2] using B.neg_mem _ B.one_mem
    · rw [← valuation_le_one_iff, ← not_lt, Valuation.one_lt_val_iff _ h_1, ← add_sub_cancel x⁻¹, ←
        Units.val_mk0 h_2, ← mem_principalUnitGroup_iff] at hx ⊢
      simpa only [hx] using @h (Units.mk0 (x⁻¹ + 1) h_2)
  · 

Proof state:
case mpr
K : Type u
inst✝ : Field K
A✝ A B : ValuationSubring K
⊢ A ≤ B → principalUnitGroup B ≤ principalUnitGroup A

Next tactic:
intro h x hx
theorem principalUnitGroup_le_principalUnitGroup {A B : ValuationSubring K} :
    B.principalUnitGroup ≤ A.principalUnitGroup ↔ A ≤ B := by
  constructor
  · intro h x hx
    by_cases h_1 : x = 0; · simp only [h_1, zero_mem]
    by_cases h_2 : x⁻¹ + 1 = 0
    · rw [add_eq_zero_iff_eq_neg, inv_eq_iff_eq_inv, inv_neg, inv_one] at h_2
      simpa only [h_2] using B.neg_mem _ B.one_mem
    · rw [← valuation_le_one_iff, ← not_lt, Valuation.one_lt_val_iff _ h_1, ← add_sub_cancel x⁻¹, ←
        Units.val_mk0 h_2, ← mem_principalUnitGroup_iff] at hx ⊢
      simpa only [hx] using @h (Units.mk0 (x⁻¹ + 1) h_2)
  · intro h x hx
    

Proof state:
case mpr
K : Type u
inst✝ : Field K
A✝ A B : ValuationSubring K
h : A ≤ B
x : Kˣ
hx : x ∈ principalUnitGroup B
⊢ x ∈ principalUnitGroup A

Next tactic:
by_contra h_1
theorem principalUnitGroup_le_principalUnitGroup {A B : ValuationSubring K} :
    B.principalUnitGroup ≤ A.principalUnitGroup ↔ A ≤ B := by
  constructor
  · intro h x hx
    by_cases h_1 : x = 0; · simp only [h_1, zero_mem]
    by_cases h_2 : x⁻¹ + 1 = 0
    · rw [add_eq_zero_iff_eq_neg, inv_eq_iff_eq_inv, inv_neg, inv_one] at h_2
      simpa only [h_2] using B.neg_mem _ B.one_mem
    · rw [← valuation_le_one_iff, ← not_lt, Valuation.one_lt_val_iff _ h_1, ← add_sub_cancel x⁻¹, ←
        Units.val_mk0 h_2, ← mem_principalUnitGroup_iff] at hx ⊢
      simpa only [hx] using @h (Units.mk0 (x⁻¹ + 1) h_2)
  · intro h x hx
    by_contra h_1; 

Proof state:
case mpr
K : Type u
inst✝ : Field K
A✝ A B : ValuationSubring K
h : A ≤ B
x : Kˣ
hx : x ∈ principalUnitGroup B
h_1 : x ∉ principalUnitGroup A
⊢ False

Next tactic:
exact not_lt.2 (monotone_mapOfLE _ _ h (not_lt.1 h_1)) hx
theorem principalUnitGroup_injective :
    Function.Injective (principalUnitGroup : ValuationSubring K → Subgroup _) := fun A B h => by
  

Proof state:
K : Type u
inst✝ : Field K
A✝ A B : ValuationSubring K
h : principalUnitGroup A = principalUnitGroup B
⊢ A = B

Next tactic:
simpa [le_antisymm_iff, principalUnitGroup_le_principalUnitGroup] using h.symm
theorem coe_mem_principalUnitGroup_iff {x : A.unitGroup} :
    (x : Kˣ) ∈ A.principalUnitGroup ↔
      A.unitGroupMulEquiv x ∈ (Units.map (LocalRing.residue A).toMonoidHom).ker := by
  

Proof state:
K : Type u
inst✝ : Field K
A : ValuationSubring K
x : ↥(unitGroup A)
⊢ ↑x ∈ principalUnitGroup A ↔ (unitGroupMulEquiv A) x ∈ MonoidHom.ker (Units.map ↑(LocalRing.residue ↥A))

Next tactic:
rw [MonoidHom.mem_ker, Units.ext_iff]
theorem coe_mem_principalUnitGroup_iff {x : A.unitGroup} :
    (x : Kˣ) ∈ A.principalUnitGroup ↔
      A.unitGroupMulEquiv x ∈ (Units.map (LocalRing.residue A).toMonoidHom).ker := by
  rw [MonoidHom.mem_ker, Units.ext_iff]
  

Proof state:
K : Type u
inst✝ : Field K
A : ValuationSubring K
x : ↥(unitGroup A)
⊢ ↑x ∈ principalUnitGroup A ↔ ↑((Units.map ↑(LocalRing.residue ↥A)) ((unitGroupMulEquiv A) x)) = ↑1

Next tactic:
let π := Ideal.Quotient.mk (LocalRing.maximalIdeal A)
theorem coe_mem_principalUnitGroup_iff {x : A.unitGroup} :
    (x : Kˣ) ∈ A.principalUnitGroup ↔
      A.unitGroupMulEquiv x ∈ (Units.map (LocalRing.residue A).toMonoidHom).ker := by
  rw [MonoidHom.mem_ker, Units.ext_iff]
  let π := Ideal.Quotient.mk (LocalRing.maximalIdeal A); 

Proof state:
K : Type u
inst✝ : Field K
A : ValuationSubring K
x : ↥(unitGroup A)
π : ↥A →+* ↥A ⧸ LocalRing.maximalIdeal ↥A := Ideal.Quotient.mk (LocalRing.maximalIdeal ↥A)
⊢ ↑x ∈ principalUnitGroup A ↔ ↑((Units.map ↑(LocalRing.residue ↥A)) ((unitGroupMulEquiv A) x)) = ↑1

Next tactic:
convert_to _ ↔ π _ = 1
theorem coe_mem_principalUnitGroup_iff {x : A.unitGroup} :
    (x : Kˣ) ∈ A.principalUnitGroup ↔
      A.unitGroupMulEquiv x ∈ (Units.map (LocalRing.residue A).toMonoidHom).ker := by
  rw [MonoidHom.mem_ker, Units.ext_iff]
  let π := Ideal.Quotient.mk (LocalRing.maximalIdeal A); convert_to _ ↔ π _ = 1
  

Proof state:
case convert_3
K : Type u
inst✝ : Field K
A : ValuationSubring K
x : ↥(unitGroup A)
π : ↥A →+* ↥A ⧸ LocalRing.maximalIdeal ↥A := Ideal.Quotient.mk (LocalRing.maximalIdeal ↥A)
⊢ ↑x ∈ principalUnitGroup A ↔ π ↑((unitGroupMulEquiv A) x) = 1

Next tactic:
rw [← π.map_one, ← sub_eq_zero, ← π.map_sub, Ideal.Quotient.eq_zero_iff_mem, valuation_lt_one_iff]
theorem coe_mem_principalUnitGroup_iff {x : A.unitGroup} :
    (x : Kˣ) ∈ A.principalUnitGroup ↔
      A.unitGroupMulEquiv x ∈ (Units.map (LocalRing.residue A).toMonoidHom).ker := by
  rw [MonoidHom.mem_ker, Units.ext_iff]
  let π := Ideal.Quotient.mk (LocalRing.maximalIdeal A); convert_to _ ↔ π _ = 1
  rw [← π.map_one, ← sub_eq_zero, ← π.map_sub, Ideal.Quotient.eq_zero_iff_mem, valuation_lt_one_iff]
  

Proof state:
case convert_3
K : Type u
inst✝ : Field K
A : ValuationSubring K
x : ↥(unitGroup A)
π : ↥A →+* ↥A ⧸ LocalRing.maximalIdeal ↥A := Ideal.Quotient.mk (LocalRing.maximalIdeal ↥A)
⊢ ↑x ∈ principalUnitGroup A ↔ (valuation A) ↑(↑((unitGroupMulEquiv A) x) - 1) < 1

Next tactic:
simp [mem_principalUnitGroup_iff]
/-- The principal unit group agrees with the kernel of the canonical map from
the units of `A` to the units of the residue field of `A`. -/
def principalUnitGroupEquiv :
    A.principalUnitGroup ≃* (Units.map (LocalRing.residue A).toMonoidHom).ker where
  toFun x :=
    ⟨A.unitGroupMulEquiv ⟨_, A.principal_units_le_units x.2⟩,
      A.coe_mem_principalUnitGroup_iff.1 x.2⟩
  invFun x :=
    ⟨A.unitGroupMulEquiv.symm x, by
      

Proof state:
K : Type u
inst✝ : Field K
A : ValuationSubring K
x : ↥(MonoidHom.ker (Units.map ↑(LocalRing.residue ↥A)))
⊢ ↑((MulEquiv.symm (unitGroupMulEquiv A)) ↑x) ∈ principalUnitGroup A

Next tactic:
rw [A.coe_mem_principalUnitGroup_iff]
/-- The principal unit group agrees with the kernel of the canonical map from
the units of `A` to the units of the residue field of `A`. -/
def principalUnitGroupEquiv :
    A.principalUnitGroup ≃* (Units.map (LocalRing.residue A).toMonoidHom).ker where
  toFun x :=
    ⟨A.unitGroupMulEquiv ⟨_, A.principal_units_le_units x.2⟩,
      A.coe_mem_principalUnitGroup_iff.1 x.2⟩
  invFun x :=
    ⟨A.unitGroupMulEquiv.symm x, by
      rw [A.coe_mem_principalUnitGroup_iff]; 

Proof state:
K : Type u
inst✝ : Field K
A : ValuationSubring K
x : ↥(MonoidHom.ker (Units.map ↑(LocalRing.residue ↥A)))
⊢ (unitGroupMulEquiv A) ((MulEquiv.symm (unitGroupMulEquiv A)) ↑x) ∈ MonoidHom.ker (Units.map ↑(LocalRing.residue ↥A))

Next tactic:
simpa using SetLike.coe_mem x
/-- The principal unit group agrees with the kernel of the canonical map from
the units of `A` to the units of the residue field of `A`. -/
def principalUnitGroupEquiv :
    A.principalUnitGroup ≃* (Units.map (LocalRing.residue A).toMonoidHom).ker where
  toFun x :=
    ⟨A.unitGroupMulEquiv ⟨_, A.principal_units_le_units x.2⟩,
      A.coe_mem_principalUnitGroup_iff.1 x.2⟩
  invFun x :=
    ⟨A.unitGroupMulEquiv.symm x, by
      rw [A.coe_mem_principalUnitGroup_iff]; simpa using SetLike.coe_mem x⟩
  left_inv x := by 

Proof state:
K : Type u
inst✝ : Field K
A : ValuationSubring K
x : ↥(principalUnitGroup A)
⊢ (fun x =>
        { val := ↑((MulEquiv.symm (unitGroupMulEquiv A)) ↑x),
          property := (_ : ↑((MulEquiv.symm (unitGroupMulEquiv A)) ↑x) ∈ principalUnitGroup A) })
      ((fun x =>
          { val := (unitGroupMulEquiv A) { val := ↑x, property := (_ : ↑x ∈ unitGroup A) },
            property :=
              (_ :
                (unitGroupMulEquiv A) { val := ↑x, property := (_ : ↑x ∈ unitGroup A) } ∈
                  MonoidHom.ker (Units.map ↑(LocalRing.residue ↥A))) })
        x) =
    x

Next tactic:
simp
/-- The principal unit group agrees with the kernel of the canonical map from
the units of `A` to the units of the residue field of `A`. -/
def principalUnitGroupEquiv :
    A.principalUnitGroup ≃* (Units.map (LocalRing.residue A).toMonoidHom).ker where
  toFun x :=
    ⟨A.unitGroupMulEquiv ⟨_, A.principal_units_le_units x.2⟩,
      A.coe_mem_principalUnitGroup_iff.1 x.2⟩
  invFun x :=
    ⟨A.unitGroupMulEquiv.symm x, by
      rw [A.coe_mem_principalUnitGroup_iff]; simpa using SetLike.coe_mem x⟩
  left_inv x := by simp
  right_inv x := by 

Proof state:
K : Type u
inst✝ : Field K
A : ValuationSubring K
x : ↥(MonoidHom.ker (Units.map ↑(LocalRing.residue ↥A)))
⊢ (fun x =>
        { val := (unitGroupMulEquiv A) { val := ↑x, property := (_ : ↑x ∈ unitGroup A) },
          property :=
            (_ :
              (unitGroupMulEquiv A) { val := ↑x, property := (_ : ↑x ∈ unitGroup A) } ∈
                MonoidHom.ker (Units.map ↑(LocalRing.residue ↥A))) })
      ((fun x =>
          { val := ↑((MulEquiv.symm (unitGroupMulEquiv A)) ↑x),
            property := (_ : ↑((MulEquiv.symm (unitGroupMulEquiv A)) ↑x) ∈ principalUnitGroup A) })
        x) =
    x

Next tactic:
simp
theorem ker_unitGroupToResidueFieldUnits :
    A.unitGroupToResidueFieldUnits.ker = A.principalUnitGroup.comap A.unitGroup.subtype := by
  

Proof state:
K : Type u
inst✝ : Field K
A : ValuationSubring K
⊢ MonoidHom.ker (unitGroupToResidueFieldUnits A) =
    Subgroup.comap (Subgroup.subtype (unitGroup A)) (principalUnitGroup A)

Next tactic:
ext
theorem ker_unitGroupToResidueFieldUnits :
    A.unitGroupToResidueFieldUnits.ker = A.principalUnitGroup.comap A.unitGroup.subtype := by
  ext
  -- Porting note: simp fails but rw works
  -- See https://github.com/leanprover-community/mathlib4/issues/5026
  -- simp [Subgroup.mem_comap, Subgroup.coeSubtype, coe_mem_principalUnitGroup_iff]
  

Proof state:
case h
K : Type u
inst✝ : Field K
A : ValuationSubring K
x✝ : ↥(unitGroup A)
⊢ x✝ ∈ MonoidHom.ker (unitGroupToResidueFieldUnits A) ↔
    x✝ ∈ Subgroup.comap (Subgroup.subtype (unitGroup A)) (principalUnitGroup A)

Next tactic:
rw [Subgroup.mem_comap, Subgroup.coeSubtype, coe_mem_principalUnitGroup_iff]