l3lab/ntp-mathlib huggingface dataset:
/-- For a valuation subring `A`, `A.unitGroup` agrees with the units of `A`. -/
def unitGroupMulEquiv : A.unitGroup ≃* Aˣ where
  toFun x :=
    { val := ⟨(x : Kˣ), mem_of_valuation_le_one A _ x.prop.le⟩
      inv := ⟨((x⁻¹ : A.unitGroup) : Kˣ), mem_of_valuation_le_one _ _ x⁻¹.prop.le⟩
      -- Porting note: was `Units.mul_inv x`
      val_inv := Subtype.ext (by simp)
      -- Porting note: was `Units.inv_mul x`
      inv_val := Subtype.ext (by simp) }
  invFun x := ⟨Units.map A.subtype.toMonoidHom x, A.valuation_unit x⟩
  left_inv a := by 

Proof state:
K : Type u
inst✝ : Field K
A : ValuationSubring K
a : ↥(unitGroup A)
⊢ (fun x => { val := (Units.map ↑(subtype A)) x, property := (_ : (valuation A) ↑↑x = 1) })
      ((fun x =>
          { val := { val := ↑↑x, property := (_ : ↑↑x ∈ A) }, inv := { val := ↑↑x⁻¹, property := (_ : ↑↑x⁻¹ ∈ A) },
            val_inv :=
              (_ : { val := ↑↑x, property := (_ : ↑↑x ∈ A) } * { val := ↑↑x⁻¹, property := (_ : ↑↑x⁻¹ ∈ A) } = 1),
            inv_val :=
              (_ : { val := ↑↑x⁻¹, property := (_ : ↑↑x⁻¹ ∈ A) } * { val := ↑↑x, property := (_ : ↑↑x ∈ A) } = 1) })
        a) =
    a

Next tactic:
ext
/-- For a valuation subring `A`, `A.unitGroup` agrees with the units of `A`. -/
def unitGroupMulEquiv : A.unitGroup ≃* Aˣ where
  toFun x :=
    { val := ⟨(x : Kˣ), mem_of_valuation_le_one A _ x.prop.le⟩
      inv := ⟨((x⁻¹ : A.unitGroup) : Kˣ), mem_of_valuation_le_one _ _ x⁻¹.prop.le⟩
      -- Porting note: was `Units.mul_inv x`
      val_inv := Subtype.ext (by simp)
      -- Porting note: was `Units.inv_mul x`
      inv_val := Subtype.ext (by simp) }
  invFun x := ⟨Units.map A.subtype.toMonoidHom x, A.valuation_unit x⟩
  left_inv a := by ext; 

Proof state:
case a.a
K : Type u
inst✝ : Field K
A : ValuationSubring K
a : ↥(unitGroup A)
⊢ ↑↑((fun x => { val := (Units.map ↑(subtype A)) x, property := (_ : (valuation A) ↑↑x = 1) })
          ((fun x =>
              { val := { val := ↑↑x, property := (_ : ↑↑x ∈ A) }, inv := { val := ↑↑x⁻¹, property := (_ : ↑↑x⁻¹ ∈ A) },
                val_inv :=
                  (_ : { val := ↑↑x, property := (_ : ↑↑x ∈ A) } * { val := ↑↑x⁻¹, property := (_ : ↑↑x⁻¹ ∈ A) } = 1),
                inv_val :=
                  (_ : { val := ↑↑x⁻¹, property := (_ : ↑↑x⁻¹ ∈ A) } * { val := ↑↑x, property := (_ : ↑↑x ∈ A) } = 1) })
            a)) =
    ↑↑a

Next tactic:
rfl
/-- For a valuation subring `A`, `A.unitGroup` agrees with the units of `A`. -/
def unitGroupMulEquiv : A.unitGroup ≃* Aˣ where
  toFun x :=
    { val := ⟨(x : Kˣ), mem_of_valuation_le_one A _ x.prop.le⟩
      inv := ⟨((x⁻¹ : A.unitGroup) : Kˣ), mem_of_valuation_le_one _ _ x⁻¹.prop.le⟩
      -- Porting note: was `Units.mul_inv x`
      val_inv := Subtype.ext (by simp)
      -- Porting note: was `Units.inv_mul x`
      inv_val := Subtype.ext (by simp) }
  invFun x := ⟨Units.map A.subtype.toMonoidHom x, A.valuation_unit x⟩
  left_inv a := by ext; rfl
  right_inv a := by 

Proof state:
K : Type u
inst✝ : Field K
A : ValuationSubring K
a : (↥A)ˣ
⊢ (fun x =>
        { val := { val := ↑↑x, property := (_ : ↑↑x ∈ A) }, inv := { val := ↑↑x⁻¹, property := (_ : ↑↑x⁻¹ ∈ A) },
          val_inv :=
            (_ : { val := ↑↑x, property := (_ : ↑↑x ∈ A) } * { val := ↑↑x⁻¹, property := (_ : ↑↑x⁻¹ ∈ A) } = 1),
          inv_val :=
            (_ : { val := ↑↑x⁻¹, property := (_ : ↑↑x⁻¹ ∈ A) } * { val := ↑↑x, property := (_ : ↑↑x ∈ A) } = 1) })
      ((fun x => { val := (Units.map ↑(subtype A)) x, property := (_ : (valuation A) ↑↑x = 1) }) a) =
    a

Next tactic:
ext
/-- For a valuation subring `A`, `A.unitGroup` agrees with the units of `A`. -/
def unitGroupMulEquiv : A.unitGroup ≃* Aˣ where
  toFun x :=
    { val := ⟨(x : Kˣ), mem_of_valuation_le_one A _ x.prop.le⟩
      inv := ⟨((x⁻¹ : A.unitGroup) : Kˣ), mem_of_valuation_le_one _ _ x⁻¹.prop.le⟩
      -- Porting note: was `Units.mul_inv x`
      val_inv := Subtype.ext (by simp)
      -- Porting note: was `Units.inv_mul x`
      inv_val := Subtype.ext (by simp) }
  invFun x := ⟨Units.map A.subtype.toMonoidHom x, A.valuation_unit x⟩
  left_inv a := by ext; rfl
  right_inv a := by ext; 

Proof state:
case a.a
K : Type u
inst✝ : Field K
A : ValuationSubring K
a : (↥A)ˣ
⊢ ↑↑((fun x =>
            { val := { val := ↑↑x, property := (_ : ↑↑x ∈ A) }, inv := { val := ↑↑x⁻¹, property := (_ : ↑↑x⁻¹ ∈ A) },
              val_inv :=
                (_ : { val := ↑↑x, property := (_ : ↑↑x ∈ A) } * { val := ↑↑x⁻¹, property := (_ : ↑↑x⁻¹ ∈ A) } = 1),
              inv_val :=
                (_ : { val := ↑↑x⁻¹, property := (_ : ↑↑x⁻¹ ∈ A) } * { val := ↑↑x, property := (_ : ↑↑x ∈ A) } = 1) })
          ((fun x => { val := (Units.map ↑(subtype A)) x, property := (_ : (valuation A) ↑↑x = 1) }) a)) =
    ↑↑a

Next tactic:
rfl
theorem unitGroup_le_unitGroup {A B : ValuationSubring K} : A.unitGroup ≤ B.unitGroup ↔ A ≤ B := by
  

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

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

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

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

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

Next tactic:
rw [← A.valuation_le_one_iff x, le_iff_lt_or_eq] at hx
theorem unitGroup_le_unitGroup {A B : ValuationSubring K} : A.unitGroup ≤ B.unitGroup ↔ A ≤ B := by
  constructor
  · intro h x hx
    rw [← A.valuation_le_one_iff x, le_iff_lt_or_eq] at hx
    

Proof state:
case mp
K : Type u
inst✝ : Field K
A✝ A B : ValuationSubring K
h : unitGroup A ≤ unitGroup B
x : K
hx : (valuation A) x < 1 ∨ (valuation A) x = 1
⊢ x ∈ B

Next tactic:
by_cases h_1 : x = 0
theorem unitGroup_le_unitGroup {A B : ValuationSubring K} : A.unitGroup ≤ B.unitGroup ↔ A ≤ B := by
  constructor
  · intro h x hx
    rw [← A.valuation_le_one_iff x, le_iff_lt_or_eq] at hx
    by_cases h_1 : x = 0; · 

Proof state:
case pos
K : Type u
inst✝ : Field K
A✝ A B : ValuationSubring K
h : unitGroup A ≤ unitGroup B
x : K
hx : (valuation A) x < 1 ∨ (valuation A) x = 1
h_1 : x = 0
⊢ x ∈ B

Next tactic:
simp only [h_1, zero_mem]
theorem unitGroup_le_unitGroup {A B : ValuationSubring K} : A.unitGroup ≤ B.unitGroup ↔ A ≤ B := by
  constructor
  · intro h x hx
    rw [← A.valuation_le_one_iff x, le_iff_lt_or_eq] at 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 : unitGroup A ≤ unitGroup B
x : K
hx : (valuation A) x < 1 ∨ (valuation A) x = 1
h_1 : ¬x = 0
⊢ x ∈ B

Next tactic:
by_cases h_2 : 1 + x = 0
theorem unitGroup_le_unitGroup {A B : ValuationSubring K} : A.unitGroup ≤ B.unitGroup ↔ A ≤ B := by
  constructor
  · intro h x hx
    rw [← A.valuation_le_one_iff x, le_iff_lt_or_eq] at hx
    by_cases h_1 : x = 0; · simp only [h_1, zero_mem]
    by_cases h_2 : 1 + x = 0
    · 

Proof state:
case pos
K : Type u
inst✝ : Field K
A✝ A B : ValuationSubring K
h : unitGroup A ≤ unitGroup B
x : K
hx : (valuation A) x < 1 ∨ (valuation A) x = 1
h_1 : ¬x = 0
h_2 : 1 + x = 0
⊢ x ∈ B

Next tactic:
simp only [← add_eq_zero_iff_neg_eq.1 h_2, neg_mem _ _ (one_mem _)]
theorem unitGroup_le_unitGroup {A B : ValuationSubring K} : A.unitGroup ≤ B.unitGroup ↔ A ≤ B := by
  constructor
  · intro h x hx
    rw [← A.valuation_le_one_iff x, le_iff_lt_or_eq] at hx
    by_cases h_1 : x = 0; · simp only [h_1, zero_mem]
    by_cases h_2 : 1 + x = 0
    · simp only [← add_eq_zero_iff_neg_eq.1 h_2, neg_mem _ _ (one_mem _)]
    

Proof state:
case neg
K : Type u
inst✝ : Field K
A✝ A B : ValuationSubring K
h : unitGroup A ≤ unitGroup B
x : K
hx : (valuation A) x < 1 ∨ (valuation A) x = 1
h_1 : ¬x = 0
h_2 : ¬1 + x = 0
⊢ x ∈ B

Next tactic:
cases' hx with hx hx
theorem unitGroup_le_unitGroup {A B : ValuationSubring K} : A.unitGroup ≤ B.unitGroup ↔ A ≤ B := by
  constructor
  · intro h x hx
    rw [← A.valuation_le_one_iff x, le_iff_lt_or_eq] at hx
    by_cases h_1 : x = 0; · simp only [h_1, zero_mem]
    by_cases h_2 : 1 + x = 0
    · simp only [← add_eq_zero_iff_neg_eq.1 h_2, neg_mem _ _ (one_mem _)]
    cases' hx with hx hx
    · 

Proof state:
case neg.inl
K : Type u
inst✝ : Field K
A✝ A B : ValuationSubring K
h : unitGroup A ≤ unitGroup B
x : K
h_1 : ¬x = 0
h_2 : ¬1 + x = 0
hx : (valuation A) x < 1
⊢ x ∈ B

Next tactic:
have := h (show Units.mk0 _ h_2 ∈ A.unitGroup from A.valuation.map_one_add_of_lt hx)
theorem unitGroup_le_unitGroup {A B : ValuationSubring K} : A.unitGroup ≤ B.unitGroup ↔ A ≤ B := by
  constructor
  · intro h x hx
    rw [← A.valuation_le_one_iff x, le_iff_lt_or_eq] at hx
    by_cases h_1 : x = 0; · simp only [h_1, zero_mem]
    by_cases h_2 : 1 + x = 0
    · simp only [← add_eq_zero_iff_neg_eq.1 h_2, neg_mem _ _ (one_mem _)]
    cases' hx with hx hx
    · have := h (show Units.mk0 _ h_2 ∈ A.unitGroup from A.valuation.map_one_add_of_lt hx)
      

Proof state:
case neg.inl
K : Type u
inst✝ : Field K
A✝ A B : ValuationSubring K
h : unitGroup A ≤ unitGroup B
x : K
h_1 : ¬x = 0
h_2 : ¬1 + x = 0
hx : (valuation A) x < 1
this : Units.mk0 (1 + x) h_2 ∈ unitGroup B
⊢ x ∈ B

Next tactic:
simpa using
        B.add_mem _ _ (show 1 + x ∈ B from SetLike.coe_mem (B.unitGroupMulEquiv ⟨_, this⟩ : B))
          (B.neg_mem _ B.one_mem)
theorem unitGroup_le_unitGroup {A B : ValuationSubring K} : A.unitGroup ≤ B.unitGroup ↔ A ≤ B := by
  constructor
  · intro h x hx
    rw [← A.valuation_le_one_iff x, le_iff_lt_or_eq] at hx
    by_cases h_1 : x = 0; · simp only [h_1, zero_mem]
    by_cases h_2 : 1 + x = 0
    · simp only [← add_eq_zero_iff_neg_eq.1 h_2, neg_mem _ _ (one_mem _)]
    cases' hx with hx hx
    · have := h (show Units.mk0 _ h_2 ∈ A.unitGroup from A.valuation.map_one_add_of_lt hx)
      simpa using
        B.add_mem _ _ (show 1 + x ∈ B from SetLike.coe_mem (B.unitGroupMulEquiv ⟨_, this⟩ : B))
          (B.neg_mem _ B.one_mem)
    · 

Proof state:
case neg.inr
K : Type u
inst✝ : Field K
A✝ A B : ValuationSubring K
h : unitGroup A ≤ unitGroup B
x : K
h_1 : ¬x = 0
h_2 : ¬1 + x = 0
hx : (valuation A) x = 1
⊢ x ∈ B

Next tactic:
have := h (show Units.mk0 x h_1 ∈ A.unitGroup from hx)
theorem unitGroup_le_unitGroup {A B : ValuationSubring K} : A.unitGroup ≤ B.unitGroup ↔ A ≤ B := by
  constructor
  · intro h x hx
    rw [← A.valuation_le_one_iff x, le_iff_lt_or_eq] at hx
    by_cases h_1 : x = 0; · simp only [h_1, zero_mem]
    by_cases h_2 : 1 + x = 0
    · simp only [← add_eq_zero_iff_neg_eq.1 h_2, neg_mem _ _ (one_mem _)]
    cases' hx with hx hx
    · have := h (show Units.mk0 _ h_2 ∈ A.unitGroup from A.valuation.map_one_add_of_lt hx)
      simpa using
        B.add_mem _ _ (show 1 + x ∈ B from SetLike.coe_mem (B.unitGroupMulEquiv ⟨_, this⟩ : B))
          (B.neg_mem _ B.one_mem)
    · have := h (show Units.mk0 x h_1 ∈ A.unitGroup from hx)
      

Proof state:
case neg.inr
K : Type u
inst✝ : Field K
A✝ A B : ValuationSubring K
h : unitGroup A ≤ unitGroup B
x : K
h_1 : ¬x = 0
h_2 : ¬1 + x = 0
hx : (valuation A) x = 1
this : Units.mk0 x h_1 ∈ unitGroup B
⊢ x ∈ B

Next tactic:
refine' SetLike.coe_mem (B.unitGroupMulEquiv ⟨_, this⟩ : B)
theorem unitGroup_le_unitGroup {A B : ValuationSubring K} : A.unitGroup ≤ B.unitGroup ↔ A ≤ B := by
  constructor
  · intro h x hx
    rw [← A.valuation_le_one_iff x, le_iff_lt_or_eq] at hx
    by_cases h_1 : x = 0; · simp only [h_1, zero_mem]
    by_cases h_2 : 1 + x = 0
    · simp only [← add_eq_zero_iff_neg_eq.1 h_2, neg_mem _ _ (one_mem _)]
    cases' hx with hx hx
    · have := h (show Units.mk0 _ h_2 ∈ A.unitGroup from A.valuation.map_one_add_of_lt hx)
      simpa using
        B.add_mem _ _ (show 1 + x ∈ B from SetLike.coe_mem (B.unitGroupMulEquiv ⟨_, this⟩ : B))
          (B.neg_mem _ B.one_mem)
    · have := h (show Units.mk0 x h_1 ∈ A.unitGroup from hx)
      refine' SetLike.coe_mem (B.unitGroupMulEquiv ⟨_, this⟩ : B)
  · 

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

Next tactic:
rintro h x (hx : A.valuation x = 1)
theorem unitGroup_le_unitGroup {A B : ValuationSubring K} : A.unitGroup ≤ B.unitGroup ↔ A ≤ B := by
  constructor
  · intro h x hx
    rw [← A.valuation_le_one_iff x, le_iff_lt_or_eq] at hx
    by_cases h_1 : x = 0; · simp only [h_1, zero_mem]
    by_cases h_2 : 1 + x = 0
    · simp only [← add_eq_zero_iff_neg_eq.1 h_2, neg_mem _ _ (one_mem _)]
    cases' hx with hx hx
    · have := h (show Units.mk0 _ h_2 ∈ A.unitGroup from A.valuation.map_one_add_of_lt hx)
      simpa using
        B.add_mem _ _ (show 1 + x ∈ B from SetLike.coe_mem (B.unitGroupMulEquiv ⟨_, this⟩ : B))
          (B.neg_mem _ B.one_mem)
    · have := h (show Units.mk0 x h_1 ∈ A.unitGroup from hx)
      refine' SetLike.coe_mem (B.unitGroupMulEquiv ⟨_, this⟩ : B)
  · rintro h x (hx : A.valuation x = 1)
    

Proof state:
case mpr
K : Type u
inst✝ : Field K
A✝ A B : ValuationSubring K
h : A ≤ B
x : Kˣ
hx : (valuation A) ↑x = 1
⊢ x ∈ unitGroup B

Next tactic:
apply_fun A.mapOfLE B h at hx
theorem unitGroup_le_unitGroup {A B : ValuationSubring K} : A.unitGroup ≤ B.unitGroup ↔ A ≤ B := by
  constructor
  · intro h x hx
    rw [← A.valuation_le_one_iff x, le_iff_lt_or_eq] at hx
    by_cases h_1 : x = 0; · simp only [h_1, zero_mem]
    by_cases h_2 : 1 + x = 0
    · simp only [← add_eq_zero_iff_neg_eq.1 h_2, neg_mem _ _ (one_mem _)]
    cases' hx with hx hx
    · have := h (show Units.mk0 _ h_2 ∈ A.unitGroup from A.valuation.map_one_add_of_lt hx)
      simpa using
        B.add_mem _ _ (show 1 + x ∈ B from SetLike.coe_mem (B.unitGroupMulEquiv ⟨_, this⟩ : B))
          (B.neg_mem _ B.one_mem)
    · have := h (show Units.mk0 x h_1 ∈ A.unitGroup from hx)
      refine' SetLike.coe_mem (B.unitGroupMulEquiv ⟨_, this⟩ : B)
  · rintro h x (hx : A.valuation x = 1)
    apply_fun A.mapOfLE B h at hx
    

Proof state:
case mpr
K : Type u
inst✝ : Field K
A✝ A B : ValuationSubring K
h : A ≤ B
x : Kˣ
hx : (mapOfLE A B h) ((valuation A) ↑x) = (mapOfLE A B h) 1
⊢ x ∈ unitGroup B

Next tactic:
simpa using hx
theorem unitGroup_injective : Function.Injective (unitGroup : ValuationSubring K → Subgroup _) :=
  fun A B h => by 

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

Next tactic:
simpa only [le_antisymm_iff, unitGroup_le_unitGroup] using h
theorem nonunits_le_nonunits {A B : ValuationSubring K} : B.nonunits ≤ A.nonunits ↔ A ≤ B := by
  

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

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

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

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

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

Next tactic:
by_cases h_1 : x = 0
theorem nonunits_le_nonunits {A B : ValuationSubring K} : B.nonunits ≤ A.nonunits ↔ 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 : nonunits B ≤ nonunits A
x : K
hx : x ∈ A
h_1 : x = 0
⊢ x ∈ B

Next tactic:
simp only [h_1, zero_mem]
theorem nonunits_le_nonunits {A B : ValuationSubring K} : B.nonunits ≤ A.nonunits ↔ 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 : nonunits B ≤ nonunits A
x : K
hx : x ∈ A
h_1 : ¬x = 0
⊢ x ∈ B

Next tactic:
rw [← valuation_le_one_iff, ← not_lt, Valuation.one_lt_val_iff _ h_1] at hx ⊢
theorem nonunits_le_nonunits {A B : ValuationSubring K} : B.nonunits ≤ A.nonunits ↔ A ≤ B := by
  constructor
  · intro h x hx
    by_cases h_1 : x = 0; · simp only [h_1, zero_mem]
    rw [← valuation_le_one_iff, ← not_lt, Valuation.one_lt_val_iff _ h_1] at hx ⊢
    

Proof state:
case neg
K : Type u
inst✝ : Field K
A✝ A B : ValuationSubring K
h : nonunits B ≤ nonunits A
x : K
hx : ¬(valuation A) x⁻¹ < 1
h_1 : ¬x = 0
⊢ ¬(valuation B) x⁻¹ < 1

Next tactic:
by_contra h_2
theorem nonunits_le_nonunits {A B : ValuationSubring K} : B.nonunits ≤ A.nonunits ↔ A ≤ B := by
  constructor
  · intro h x hx
    by_cases h_1 : x = 0; · simp only [h_1, zero_mem]
    rw [← valuation_le_one_iff, ← not_lt, Valuation.one_lt_val_iff _ h_1] at hx ⊢
    by_contra h_2; 

Proof state:
case neg
K : Type u
inst✝ : Field K
A✝ A B : ValuationSubring K
h : nonunits B ≤ nonunits A
x : K
hx : ¬(valuation A) x⁻¹ < 1
h_1 : ¬x = 0
h_2 : (valuation B) x⁻¹ < 1
⊢ False

Next tactic:
exact hx (h h_2)
theorem nonunits_le_nonunits {A B : ValuationSubring K} : B.nonunits ≤ A.nonunits ↔ A ≤ B := by
  constructor
  · intro h x hx
    by_cases h_1 : x = 0; · simp only [h_1, zero_mem]
    rw [← valuation_le_one_iff, ← not_lt, Valuation.one_lt_val_iff _ h_1] at hx ⊢
    by_contra h_2; exact hx (h h_2)
  · 

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

Next tactic:
intro h x hx
theorem nonunits_le_nonunits {A B : ValuationSubring K} : B.nonunits ≤ A.nonunits ↔ A ≤ B := by
  constructor
  · intro h x hx
    by_cases h_1 : x = 0; · simp only [h_1, zero_mem]
    rw [← valuation_le_one_iff, ← not_lt, Valuation.one_lt_val_iff _ h_1] at hx ⊢
    by_contra h_2; exact hx (h 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 ∈ nonunits B
⊢ x ∈ nonunits A

Next tactic:
by_contra h_1
theorem nonunits_le_nonunits {A B : ValuationSubring K} : B.nonunits ≤ A.nonunits ↔ A ≤ B := by
  constructor
  · intro h x hx
    by_cases h_1 : x = 0; · simp only [h_1, zero_mem]
    rw [← valuation_le_one_iff, ← not_lt, Valuation.one_lt_val_iff _ h_1] at hx ⊢
    by_contra h_2; exact hx (h 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 ∈ nonunits B
h_1 : x ∉ nonunits A
⊢ False

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

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

Next tactic:
simpa only [le_antisymm_iff, nonunits_le_nonunits] using h.symm
/-- `A.nonunits` agrees with the maximal ideal of `A`, after taking its image in `K`. -/
theorem image_maximalIdeal : ((↑) : A → K) '' LocalRing.maximalIdeal A = A.nonunits := by
  

Proof state:
K : Type u
inst✝ : Field K
A : ValuationSubring K
⊢ Subtype.val '' ↑(LocalRing.maximalIdeal ↥A) = ↑(nonunits A)

Next tactic:
ext a
/-- `A.nonunits` agrees with the maximal ideal of `A`, after taking its image in `K`. -/
theorem image_maximalIdeal : ((↑) : A → K) '' LocalRing.maximalIdeal A = A.nonunits := by
  ext a
  

Proof state:
case h
K : Type u
inst✝ : Field K
A : ValuationSubring K
a : K
⊢ a ∈ Subtype.val '' ↑(LocalRing.maximalIdeal ↥A) ↔ a ∈ ↑(nonunits A)

Next tactic:
simp only [Set.mem_image, SetLike.mem_coe, mem_nonunits_iff_exists_mem_maximalIdeal]
/-- `A.nonunits` agrees with the maximal ideal of `A`, after taking its image in `K`. -/
theorem image_maximalIdeal : ((↑) : A → K) '' LocalRing.maximalIdeal A = A.nonunits := by
  ext a
  simp only [Set.mem_image, SetLike.mem_coe, mem_nonunits_iff_exists_mem_maximalIdeal]
  

Proof state:
case h
K : Type u
inst✝ : Field K
A : ValuationSubring K
a : K
⊢ (∃ x ∈ LocalRing.maximalIdeal ↥A, ↑x = a) ↔ ∃ (ha : a ∈ A), { val := a, property := ha } ∈ LocalRing.maximalIdeal ↥A

Next tactic:
erw [Subtype.exists]
/-- `A.nonunits` agrees with the maximal ideal of `A`, after taking its image in `K`. -/
theorem image_maximalIdeal : ((↑) : A → K) '' LocalRing.maximalIdeal A = A.nonunits := by
  ext a
  simp only [Set.mem_image, SetLike.mem_coe, mem_nonunits_iff_exists_mem_maximalIdeal]
  erw [Subtype.exists]
  

Proof state:
case h
K : Type u
inst✝ : Field K
A : ValuationSubring K
a : K
⊢ (∃ a_1,
      ∃ (b : a_1 ∈ ↑A),
        { val := a_1, property := b } ∈ LocalRing.maximalIdeal ↥A ∧ ↑{ val := a_1, property := b } = a) ↔
    ∃ (ha : a ∈ A), { val := a, property := ha } ∈ LocalRing.maximalIdeal ↥A

Next tactic:
simp_rw [exists_and_right, exists_eq_right]
/-- `A.nonunits` agrees with the maximal ideal of `A`, after taking its image in `K`. -/
theorem image_maximalIdeal : ((↑) : A → K) '' LocalRing.maximalIdeal A = A.nonunits := by
  ext a
  simp only [Set.mem_image, SetLike.mem_coe, mem_nonunits_iff_exists_mem_maximalIdeal]
  erw [Subtype.exists]
  simp_rw [exists_and_right, exists_eq_right]
  -- Porting note: added
  

Proof state:
case h
K : Type u
inst✝ : Field K
A : ValuationSubring K
a : K
⊢ (∃ (x : a ∈ ↑A), { val := a, property := (_ : a ∈ ↑A) } ∈ LocalRing.maximalIdeal ↥A) ↔
    ∃ (ha : a ∈ A), { val := a, property := ha } ∈ LocalRing.maximalIdeal ↥A

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
    

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

Next tactic:
intro a b ha hb
/-- 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
    

Proof state:
K : Type u
inst✝ : Field K
A : ValuationSubring K
a b : Kˣ
ha : a ∈ {x | (valuation A) (↑x - 1) < 1}
hb : b ∈ {x | (valuation A) (↑x - 1) < 1}
⊢ a * b ∈ {x | (valuation A) (↑x - 1) < 1}

Next tactic:
rw [Set.mem_setOf] at ha hb
/-- 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
    

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
⊢ a * b ∈ {x | (valuation A) (↑x - 1) < 1}

Next tactic:
refine' lt_of_le_of_lt _ (max_lt hb 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
    

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) - 1) ≤ max ((valuation A) (↑b - 1)) ((valuation A) (↑a - 1))

Next tactic:
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]