ring_theory.valuation.valuation_ringMathlib.RingTheory.Valuation.ValuationRing

This file has been ported!

Changes since the initial port

The following section lists changes to this file in mathlib3 and mathlib4 that occured after the initial port. Most recent changes are shown first. Hovering over a commit will show all commits associated with the same mathlib3 commit.

Changes in mathlib3

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(last sync)

Changes in mathlib3port

mathlib3
mathlib3port
Diff
@@ -74,7 +74,7 @@ instance : LE (ValueGroup A K) :=
         rintro _ _ a b ⟨c, rfl⟩ ⟨d, rfl⟩; ext
         constructor
         · rintro ⟨e, he⟩; use(c⁻¹ : Aˣ) * e * d
-          apply_fun fun t => c⁻¹ • t at he 
+          apply_fun fun t => c⁻¹ • t at he
           simpa [mul_smul] using he
         · rintro ⟨e, he⟩; dsimp
           use(d⁻¹ : Aˣ) * c * e
@@ -149,9 +149,9 @@ noncomputable instance : LinearOrderedCommGroupWithZero (ValueGroup A K) :=
       have : IsUnit e := by
         apply isUnit_of_dvd_one
         use f; rw [mul_comm]
-        rw [← mul_smul, Algebra.smul_def] at hf 
-        nth_rw 2 [← one_mul b] at hf 
-        rw [← (algebraMap A K).map_one] at hf 
+        rw [← mul_smul, Algebra.smul_def] at hf
+        nth_rw 2 [← one_mul b] at hf
+        rw [← (algebraMap A K).map_one] at hf
         exact IsFractionRing.injective _ _ (mul_right_cancel₀ hb hf).symm
       apply Quotient.sound'
       use this.unit, rfl
@@ -170,7 +170,7 @@ noncomputable instance : LinearOrderedCommGroupWithZero (ValueGroup A K) :=
     exists_pair_ne := by
       use 0, 1
       intro c; obtain ⟨d, hd⟩ := Quotient.exact' c
-      apply_fun fun t => d⁻¹ • t at hd 
+      apply_fun fun t => d⁻¹ • t at hd
       simpa using hd
     inv_zero := by apply Quotient.sound'; rw [inv_zero]; apply Setoid.refl'
     mul_inv_cancel := by
@@ -239,11 +239,11 @@ noncomputable def equivInteger : A ≃+* (valuation A K).integer :=
     (by
       constructor
       · intro x y h
-        apply_fun (coe : _ → K) at h 
-        dsimp at h 
+        apply_fun (coe : _ → K) at h
+        dsimp at h
         exact IsFractionRing.injective _ _ h
       · rintro ⟨a, ha : a ∈ (Valuation A K).integer⟩
-        rw [mem_integer_iff] at ha 
+        rw [mem_integer_iff] at ha
         obtain ⟨a, rfl⟩ := ha
         use a, rfl)
 #align valuation_ring.equiv_integer ValuationRing.equivInteger
@@ -289,8 +289,8 @@ instance [DecidableRel ((· ≤ ·) : Ideal A → Ideal A → Prop)] : LinearOrd
     le_total := by
       intro α β
       by_cases h : α ≤ β; · exact Or.inl h
-      erw [Classical.not_forall] at h 
-      push_neg at h 
+      erw [Classical.not_forall] at h
+      push_neg at h
       obtain ⟨a, h₁, h₂⟩ := h
       right
       intro b hb
@@ -323,7 +323,7 @@ theorem iff_ideal_total : ValuationRing R ↔ IsTotal (Ideal R) (· ≤ ·) := b
   classical
   refine' ⟨fun _ => ⟨le_total⟩, fun H => iff_dvd_total.mpr ⟨fun a b => _⟩⟩
   have := @IsTotal.total _ _ H (Ideal.span {a}) (Ideal.span {b})
-  simp_rw [Ideal.span_singleton_le_span_singleton] at this 
+  simp_rw [Ideal.span_singleton_le_span_singleton] at this
   exact this.symm
 #align valuation_ring.iff_ideal_total ValuationRing.iff_ideal_total
 -/
@@ -340,7 +340,7 @@ theorem dvd_total [h : ValuationRing R] (x y : R) : x ∣ y ∨ y ∣ x :=
 theorem unique_irreducible [ValuationRing R] ⦃p q : R⦄ (hp : Irreducible p) (hq : Irreducible q) :
     Associated p q := by
   have := dvd_total p q
-  rw [Irreducible.dvd_comm hp hq, or_self_iff] at this 
+  rw [Irreducible.dvd_comm hp hq, or_self_iff] at this
   exact associated_of_dvd_dvd (Irreducible.dvd_symm hq hp this) this
 #align valuation_ring.unique_irreducible ValuationRing.unique_irreducible
 -/
@@ -370,9 +370,9 @@ theorem iff_isInteger_or_isInteger :
     replace ha := (map_ne_zero_iff _ (IsFractionRing.injective R K)).mpr ha
     replace hb := (map_ne_zero_iff _ (IsFractionRing.injective R K)).mpr hb
     obtain ⟨c, e⟩ | ⟨c, e⟩ := H (algebraMap R K a / algebraMap R K b)
-    · rw [eq_div_iff hb, ← map_mul, (IsFractionRing.injective R K).eq_iff, mul_comm] at e 
+    · rw [eq_div_iff hb, ← map_mul, (IsFractionRing.injective R K).eq_iff, mul_comm] at e
       exact ⟨c, Or.inr e⟩
-    · rw [inv_div, eq_div_iff ha, ← map_mul, (IsFractionRing.injective R K).eq_iff, mul_comm c] at e 
+    · rw [inv_div, eq_div_iff ha, ← map_mul, (IsFractionRing.injective R K).eq_iff, mul_comm c] at e
       exact ⟨c, Or.inl e⟩
 #align valuation_ring.iff_is_integer_or_is_integer ValuationRing.iff_isInteger_or_isInteger
 -/
Diff
@@ -41,7 +41,7 @@ We also provide the equivalence of the following notions for a domain `R` in `va
 universe u v w
 
 #print ValuationRing /-
-/- ./././Mathport/Syntax/Translate/Command.lean:404:30: infer kinds are unsupported in Lean 4: #[`cond] [] -/
+/- ./././Mathport/Syntax/Translate/Command.lean:400:30: infer kinds are unsupported in Lean 4: #[`cond] [] -/
 /-- An integral domain is called a `valuation ring` provided that for any pair
 of elements `a b : A`, either `a` divides `b` or vice versa. -/
 class ValuationRing (A : Type u) [CommRing A] [IsDomain A] : Prop where
Diff
@@ -156,7 +156,7 @@ noncomputable instance : LinearOrderedCommGroupWithZero (ValueGroup A K) :=
       apply Quotient.sound'
       use this.unit, rfl
     le_total := ValuationRing.le_total _ _
-    decidableLe := by classical
+    decidableLe := by classical infer_instance
     mul_assoc := by rintro ⟨a⟩ ⟨b⟩ ⟨c⟩; apply Quotient.sound'; rw [mul_assoc]; apply Setoid.refl'
     one_mul := by rintro ⟨a⟩; apply Quotient.sound'; rw [one_mul]; apply Setoid.refl'
     mul_one := by rintro ⟨a⟩; apply Quotient.sound'; rw [mul_one]; apply Setoid.refl'
@@ -310,12 +310,21 @@ variable {R : Type _} [CommRing R] [IsDomain R] {K : Type _}
 variable [Field K] [Algebra R K] [IsFractionRing R K]
 
 #print ValuationRing.iff_dvd_total /-
-theorem iff_dvd_total : ValuationRing R ↔ IsTotal R (· ∣ ·) := by classical
+theorem iff_dvd_total : ValuationRing R ↔ IsTotal R (· ∣ ·) := by
+  classical
+  refine' ⟨fun H => ⟨fun a b => _⟩, fun H => ⟨fun a b => _⟩⟩ <;> skip
+  · obtain ⟨c, rfl | rfl⟩ := @ValuationRing.cond _ _ H a b <;> simp
+  · obtain ⟨c, rfl⟩ | ⟨c, rfl⟩ := @IsTotal.total _ _ H a b <;> use c <;> simp
 #align valuation_ring.iff_dvd_total ValuationRing.iff_dvd_total
 -/
 
 #print ValuationRing.iff_ideal_total /-
-theorem iff_ideal_total : ValuationRing R ↔ IsTotal (Ideal R) (· ≤ ·) := by classical
+theorem iff_ideal_total : ValuationRing R ↔ IsTotal (Ideal R) (· ≤ ·) := by
+  classical
+  refine' ⟨fun _ => ⟨le_total⟩, fun H => iff_dvd_total.mpr ⟨fun a b => _⟩⟩
+  have := @IsTotal.total _ _ H (Ideal.span {a}) (Ideal.span {b})
+  simp_rw [Ideal.span_singleton_le_span_singleton] at this 
+  exact this.symm
 #align valuation_ring.iff_ideal_total ValuationRing.iff_ideal_total
 -/
 
@@ -380,10 +389,40 @@ theorem isInteger_or_isInteger [h : ValuationRing R] (x : K) :
 variable {R}
 
 -- This implies that valuation rings are integrally closed through typeclass search.
-instance (priority := 100) [ValuationRing R] : IsBezout R := by classical
+instance (priority := 100) [ValuationRing R] : IsBezout R := by
+  classical
+  rw [IsBezout.iff_span_pair_isPrincipal]
+  intro x y
+  rw [Ideal.span_insert]
+  cases le_total (Ideal.span {x} : Ideal R) (Ideal.span {y})
+  · erw [sup_eq_right.mpr h]; exact ⟨⟨_, rfl⟩⟩
+  · erw [sup_eq_left.mpr h]; exact ⟨⟨_, rfl⟩⟩
 
 #print ValuationRing.iff_local_bezout_domain /-
-theorem iff_local_bezout_domain : ValuationRing R ↔ LocalRing R ∧ IsBezout R := by classical
+theorem iff_local_bezout_domain : ValuationRing R ↔ LocalRing R ∧ IsBezout R := by
+  classical
+  refine' ⟨fun H => ⟨inferInstance, inferInstance⟩, _⟩
+  rintro ⟨h₁, h₂⟩
+  skip
+  refine' iff_dvd_total.mpr ⟨fun a b => _⟩
+  obtain ⟨g, e : _ = Ideal.span _⟩ := IsBezout.span_pair_isPrincipal a b
+  obtain ⟨a, rfl⟩ :=
+    ideal.mem_span_singleton'.mp
+      (show a ∈ Ideal.span {g} by rw [← e]; exact Ideal.subset_span (by simp))
+  obtain ⟨b, rfl⟩ :=
+    ideal.mem_span_singleton'.mp
+      (show b ∈ Ideal.span {g} by rw [← e]; exact Ideal.subset_span (by simp))
+  obtain ⟨x, y, e'⟩ :=
+    ideal.mem_span_pair.mp
+      (show g ∈ Ideal.span {a * g, b * g} by rw [e]; exact Ideal.subset_span (by simp))
+  cases' eq_or_ne g 0 with h h
+  · simp [h]
+  have : x * a + y * b = 1 := by apply mul_left_injective₀ h; convert e' <;> ring_nf
+  cases' LocalRing.isUnit_or_isUnit_of_add_one this with h' h'
+  left
+  swap
+  right
+  all_goals exact mul_dvd_mul_right (is_unit_iff_forall_dvd.mp (isUnit_of_mul_isUnit_right h') _) _
 #align valuation_ring.iff_local_bezout_domain ValuationRing.iff_local_bezout_domain
 -/
 
Diff
@@ -156,7 +156,7 @@ noncomputable instance : LinearOrderedCommGroupWithZero (ValueGroup A K) :=
       apply Quotient.sound'
       use this.unit, rfl
     le_total := ValuationRing.le_total _ _
-    decidableLe := by classical infer_instance
+    decidableLe := by classical
     mul_assoc := by rintro ⟨a⟩ ⟨b⟩ ⟨c⟩; apply Quotient.sound'; rw [mul_assoc]; apply Setoid.refl'
     one_mul := by rintro ⟨a⟩; apply Quotient.sound'; rw [one_mul]; apply Setoid.refl'
     mul_one := by rintro ⟨a⟩; apply Quotient.sound'; rw [mul_one]; apply Setoid.refl'
@@ -310,21 +310,12 @@ variable {R : Type _} [CommRing R] [IsDomain R] {K : Type _}
 variable [Field K] [Algebra R K] [IsFractionRing R K]
 
 #print ValuationRing.iff_dvd_total /-
-theorem iff_dvd_total : ValuationRing R ↔ IsTotal R (· ∣ ·) := by
-  classical
-  refine' ⟨fun H => ⟨fun a b => _⟩, fun H => ⟨fun a b => _⟩⟩ <;> skip
-  · obtain ⟨c, rfl | rfl⟩ := @ValuationRing.cond _ _ H a b <;> simp
-  · obtain ⟨c, rfl⟩ | ⟨c, rfl⟩ := @IsTotal.total _ _ H a b <;> use c <;> simp
+theorem iff_dvd_total : ValuationRing R ↔ IsTotal R (· ∣ ·) := by classical
 #align valuation_ring.iff_dvd_total ValuationRing.iff_dvd_total
 -/
 
 #print ValuationRing.iff_ideal_total /-
-theorem iff_ideal_total : ValuationRing R ↔ IsTotal (Ideal R) (· ≤ ·) := by
-  classical
-  refine' ⟨fun _ => ⟨le_total⟩, fun H => iff_dvd_total.mpr ⟨fun a b => _⟩⟩
-  have := @IsTotal.total _ _ H (Ideal.span {a}) (Ideal.span {b})
-  simp_rw [Ideal.span_singleton_le_span_singleton] at this 
-  exact this.symm
+theorem iff_ideal_total : ValuationRing R ↔ IsTotal (Ideal R) (· ≤ ·) := by classical
 #align valuation_ring.iff_ideal_total ValuationRing.iff_ideal_total
 -/
 
@@ -389,40 +380,10 @@ theorem isInteger_or_isInteger [h : ValuationRing R] (x : K) :
 variable {R}
 
 -- This implies that valuation rings are integrally closed through typeclass search.
-instance (priority := 100) [ValuationRing R] : IsBezout R := by
-  classical
-  rw [IsBezout.iff_span_pair_isPrincipal]
-  intro x y
-  rw [Ideal.span_insert]
-  cases le_total (Ideal.span {x} : Ideal R) (Ideal.span {y})
-  · erw [sup_eq_right.mpr h]; exact ⟨⟨_, rfl⟩⟩
-  · erw [sup_eq_left.mpr h]; exact ⟨⟨_, rfl⟩⟩
+instance (priority := 100) [ValuationRing R] : IsBezout R := by classical
 
 #print ValuationRing.iff_local_bezout_domain /-
-theorem iff_local_bezout_domain : ValuationRing R ↔ LocalRing R ∧ IsBezout R := by
-  classical
-  refine' ⟨fun H => ⟨inferInstance, inferInstance⟩, _⟩
-  rintro ⟨h₁, h₂⟩
-  skip
-  refine' iff_dvd_total.mpr ⟨fun a b => _⟩
-  obtain ⟨g, e : _ = Ideal.span _⟩ := IsBezout.span_pair_isPrincipal a b
-  obtain ⟨a, rfl⟩ :=
-    ideal.mem_span_singleton'.mp
-      (show a ∈ Ideal.span {g} by rw [← e]; exact Ideal.subset_span (by simp))
-  obtain ⟨b, rfl⟩ :=
-    ideal.mem_span_singleton'.mp
-      (show b ∈ Ideal.span {g} by rw [← e]; exact Ideal.subset_span (by simp))
-  obtain ⟨x, y, e'⟩ :=
-    ideal.mem_span_pair.mp
-      (show g ∈ Ideal.span {a * g, b * g} by rw [e]; exact Ideal.subset_span (by simp))
-  cases' eq_or_ne g 0 with h h
-  · simp [h]
-  have : x * a + y * b = 1 := by apply mul_left_injective₀ h; convert e' <;> ring_nf
-  cases' LocalRing.isUnit_or_isUnit_of_add_one this with h' h'
-  left
-  swap
-  right
-  all_goals exact mul_dvd_mul_right (is_unit_iff_forall_dvd.mp (isUnit_of_mul_isUnit_right h') _) _
+theorem iff_local_bezout_domain : ValuationRing R ↔ LocalRing R ∧ IsBezout R := by classical
 #align valuation_ring.iff_local_bezout_domain ValuationRing.iff_local_bezout_domain
 -/
 
Diff
@@ -41,7 +41,7 @@ We also provide the equivalence of the following notions for a domain `R` in `va
 universe u v w
 
 #print ValuationRing /-
-/- ./././Mathport/Syntax/Translate/Command.lean:394:30: infer kinds are unsupported in Lean 4: #[`cond] [] -/
+/- ./././Mathport/Syntax/Translate/Command.lean:404:30: infer kinds are unsupported in Lean 4: #[`cond] [] -/
 /-- An integral domain is called a `valuation ring` provided that for any pair
 of elements `a b : A`, either `a` divides `b` or vice versa. -/
 class ValuationRing (A : Type u) [CommRing A] [IsDomain A] : Prop where
Diff
@@ -289,7 +289,7 @@ instance [DecidableRel ((· ≤ ·) : Ideal A → Ideal A → Prop)] : LinearOrd
     le_total := by
       intro α β
       by_cases h : α ≤ β; · exact Or.inl h
-      erw [not_forall] at h 
+      erw [Classical.not_forall] at h 
       push_neg at h 
       obtain ⟨a, h₁, h₂⟩ := h
       right
Diff
@@ -3,13 +3,13 @@ Copyright (c) 2022 Adam Topaz. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Adam Topaz
 -/
-import Mathbin.RingTheory.Valuation.Integers
-import Mathbin.RingTheory.Ideal.LocalRing
-import Mathbin.RingTheory.Localization.FractionRing
-import Mathbin.RingTheory.Localization.Integer
-import Mathbin.RingTheory.DiscreteValuationRing.Basic
-import Mathbin.RingTheory.Bezout
-import Mathbin.Tactic.FieldSimp
+import RingTheory.Valuation.Integers
+import RingTheory.Ideal.LocalRing
+import RingTheory.Localization.FractionRing
+import RingTheory.Localization.Integer
+import RingTheory.DiscreteValuationRing.Basic
+import RingTheory.Bezout
+import Tactic.FieldSimp
 
 #align_import ring_theory.valuation.valuation_ring from "leanprover-community/mathlib"@"c20927220ef87bb4962ba08bf6da2ce3cf50a6dd"
 
@@ -41,7 +41,7 @@ We also provide the equivalence of the following notions for a domain `R` in `va
 universe u v w
 
 #print ValuationRing /-
-/- ./././Mathport/Syntax/Translate/Command.lean:393:30: infer kinds are unsupported in Lean 4: #[`cond] [] -/
+/- ./././Mathport/Syntax/Translate/Command.lean:394:30: infer kinds are unsupported in Lean 4: #[`cond] [] -/
 /-- An integral domain is called a `valuation ring` provided that for any pair
 of elements `a b : A`, either `a` divides `b` or vice versa. -/
 class ValuationRing (A : Type u) [CommRing A] [IsDomain A] : Prop where
Diff
@@ -233,7 +233,7 @@ noncomputable def equivInteger : A ≃+* (valuation A K).integer :=
   RingEquiv.ofBijective
     (show A →ₙ+* (valuation A K).integer from
       { toFun := fun a => ⟨algebraMap A K a, (mem_integer_iff _ _ _).mpr ⟨a, rfl⟩⟩
-        map_mul' := fun _ _ => by ext1; exact (algebraMap A K).map_mul _ _
+        map_mul' := fun _ _ => by ext1; exact (algebraMap A K).map_hMul _ _
         map_zero' := by ext1; exact (algebraMap A K).map_zero
         map_add' := fun _ _ => by ext1; exact (algebraMap A K).map_add _ _ })
     (by
Diff
@@ -73,11 +73,11 @@ instance : LE (ValueGroup A K) :=
       (by
         rintro _ _ a b ⟨c, rfl⟩ ⟨d, rfl⟩; ext
         constructor
-        · rintro ⟨e, he⟩; use (c⁻¹ : Aˣ) * e * d
+        · rintro ⟨e, he⟩; use(c⁻¹ : Aˣ) * e * d
           apply_fun fun t => c⁻¹ • t at he 
           simpa [mul_smul] using he
         · rintro ⟨e, he⟩; dsimp
-          use (d⁻¹ : Aˣ) * c * e
+          use(d⁻¹ : Aˣ) * c * e
           erw [← he, ← mul_smul, ← mul_smul]
           congr 1
           rw [mul_comm]
@@ -508,12 +508,12 @@ instance (priority := 100) of_discreteValuationRing : ValuationRing A :=
   obtain ⟨m, u, rfl⟩ := DiscreteValuationRing.eq_unit_mul_pow_irreducible ha hϖ
   obtain ⟨n, v, rfl⟩ := DiscreteValuationRing.eq_unit_mul_pow_irreducible hb hϖ
   cases' le_total m n with h h
-  · use (u⁻¹ * v : Aˣ) * ϖ ^ (n - m); left
+  · use(u⁻¹ * v : Aˣ) * ϖ ^ (n - m); left
     simp_rw [mul_comm (u : A), Units.val_mul, ← mul_assoc, mul_assoc _ (u : A)]
     simp only [Units.mul_inv, mul_one, mul_comm _ (v : A), mul_assoc, ← pow_add]
     congr 2
     linarith
-  · use (v⁻¹ * u : Aˣ) * ϖ ^ (m - n); right
+  · use(v⁻¹ * u : Aˣ) * ϖ ^ (m - n); right
     simp_rw [mul_comm (v : A), Units.val_mul, ← mul_assoc, mul_assoc _ (v : A)]
     simp only [Units.mul_inv, mul_one, mul_comm _ (u : A), mul_assoc, ← pow_add]
     congr 2
Diff
@@ -2,11 +2,6 @@
 Copyright (c) 2022 Adam Topaz. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Adam Topaz
-
-! This file was ported from Lean 3 source module ring_theory.valuation.valuation_ring
-! leanprover-community/mathlib commit c20927220ef87bb4962ba08bf6da2ce3cf50a6dd
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
 -/
 import Mathbin.RingTheory.Valuation.Integers
 import Mathbin.RingTheory.Ideal.LocalRing
@@ -16,6 +11,8 @@ import Mathbin.RingTheory.DiscreteValuationRing.Basic
 import Mathbin.RingTheory.Bezout
 import Mathbin.Tactic.FieldSimp
 
+#align_import ring_theory.valuation.valuation_ring from "leanprover-community/mathlib"@"c20927220ef87bb4962ba08bf6da2ce3cf50a6dd"
+
 /-!
 # Valuation Rings
 
Diff
@@ -44,7 +44,7 @@ We also provide the equivalence of the following notions for a domain `R` in `va
 universe u v w
 
 #print ValuationRing /-
-/- ./././Mathport/Syntax/Translate/Command.lean:394:30: infer kinds are unsupported in Lean 4: #[`cond] [] -/
+/- ./././Mathport/Syntax/Translate/Command.lean:393:30: infer kinds are unsupported in Lean 4: #[`cond] [] -/
 /-- An integral domain is called a `valuation ring` provided that for any pair
 of elements `a b : A`, either `a` divides `b` or vice versa. -/
 class ValuationRing (A : Type u) [CommRing A] [IsDomain A] : Prop where
@@ -116,6 +116,7 @@ instance : Inv (ValueGroup A K) :=
 
 variable [IsDomain A] [ValuationRing A] [IsFractionRing A K]
 
+#print ValuationRing.le_total /-
 protected theorem le_total (a b : ValueGroup A K) : a ≤ b ∨ b ≤ a :=
   by
   rcases a with ⟨a⟩; rcases b with ⟨b⟩
@@ -135,6 +136,7 @@ protected theorem le_total (a b : ValueGroup A K) : a ≤ b ∨ b ≤ a :=
     field_simp
     simp only [← RingHom.map_mul, ← h]; congr 1; ring
 #align valuation_ring.le_total ValuationRing.le_total
+-/
 
 noncomputable instance : LinearOrderedCommGroupWithZero (ValueGroup A K) :=
   { (inferInstance : LE (ValueGroup A K)), (inferInstance : Mul (ValueGroup A K)),
@@ -184,6 +186,7 @@ noncomputable instance : LinearOrderedCommGroupWithZero (ValueGroup A K) :=
       simp only [Classical.not_not] at ha ⊢
       rw [ha]; rfl }
 
+#print ValuationRing.valuation /-
 /-- Any valuation ring induces a valuation on its fraction field. -/
 def valuation : Valuation K (ValueGroup A K)
     where
@@ -212,7 +215,9 @@ def valuation : Valuation K (ValueGroup A K)
       simp only [← RingHom.map_mul, ← RingHom.map_add, ← (algebraMap A K).map_one, ← h]
       congr 1; ring
 #align valuation_ring.valuation ValuationRing.valuation
+-/
 
+#print ValuationRing.mem_integer_iff /-
 theorem mem_integer_iff (x : K) : x ∈ (valuation A K).integer ↔ ∃ a : A, algebraMap A K a = x :=
   by
   constructor
@@ -223,7 +228,9 @@ theorem mem_integer_iff (x : K) : x ∈ (valuation A K).integer ↔ ∃ a : A, a
     use c
     rw [Algebra.smul_def, mul_one]
 #align valuation_ring.mem_integer_iff ValuationRing.mem_integer_iff
+-/
 
+#print ValuationRing.equivInteger /-
 /-- The valuation ring `A` is isomorphic to the ring of integers of its associated valuation. -/
 noncomputable def equivInteger : A ≃+* (valuation A K).integer :=
   RingEquiv.ofBijective
@@ -243,15 +250,20 @@ noncomputable def equivInteger : A ≃+* (valuation A K).integer :=
         obtain ⟨a, rfl⟩ := ha
         use a, rfl)
 #align valuation_ring.equiv_integer ValuationRing.equivInteger
+-/
 
+#print ValuationRing.coe_equivInteger_apply /-
 @[simp]
 theorem coe_equivInteger_apply (a : A) : (equivInteger A K a : K) = algebraMap A K a :=
   rfl
 #align valuation_ring.coe_equiv_integer_apply ValuationRing.coe_equivInteger_apply
+-/
 
+#print ValuationRing.range_algebraMap_eq /-
 theorem range_algebraMap_eq : (valuation A K).integer = (algebraMap A K).range := by ext;
   exact mem_integer_iff _ _ _
 #align valuation_ring.range_algebra_map_eq ValuationRing.range_algebraMap_eq
+-/
 
 end
 
@@ -327,15 +339,18 @@ theorem dvd_total [h : ValuationRing R] (x y : R) : x ∣ y ∨ y ∣ x :=
 #align valuation_ring.dvd_total ValuationRing.dvd_total
 -/
 
+#print ValuationRing.unique_irreducible /-
 theorem unique_irreducible [ValuationRing R] ⦃p q : R⦄ (hp : Irreducible p) (hq : Irreducible q) :
     Associated p q := by
   have := dvd_total p q
   rw [Irreducible.dvd_comm hp hq, or_self_iff] at this 
   exact associated_of_dvd_dvd (Irreducible.dvd_symm hq hp this) this
 #align valuation_ring.unique_irreducible ValuationRing.unique_irreducible
+-/
 
 variable (R)
 
+#print ValuationRing.iff_isInteger_or_isInteger /-
 theorem iff_isInteger_or_isInteger :
     ValuationRing R ↔ ∀ x : K, IsLocalization.IsInteger R x ∨ IsLocalization.IsInteger R x⁻¹ :=
   by
@@ -363,13 +378,16 @@ theorem iff_isInteger_or_isInteger :
     · rw [inv_div, eq_div_iff ha, ← map_mul, (IsFractionRing.injective R K).eq_iff, mul_comm c] at e 
       exact ⟨c, Or.inl e⟩
 #align valuation_ring.iff_is_integer_or_is_integer ValuationRing.iff_isInteger_or_isInteger
+-/
 
 variable {K}
 
+#print ValuationRing.isInteger_or_isInteger /-
 theorem isInteger_or_isInteger [h : ValuationRing R] (x : K) :
     IsLocalization.IsInteger R x ∨ IsLocalization.IsInteger R x⁻¹ :=
   (iff_isInteger_or_isInteger R K).mp h x
 #align valuation_ring.is_integer_or_is_integer ValuationRing.isInteger_or_isInteger
+-/
 
 variable {R}
 
@@ -411,6 +429,7 @@ theorem iff_local_bezout_domain : ValuationRing R ↔ LocalRing R ∧ IsBezout R
 #align valuation_ring.iff_local_bezout_domain ValuationRing.iff_local_bezout_domain
 -/
 
+#print ValuationRing.tFAE /-
 protected theorem tFAE (R : Type u) [CommRing R] [IsDomain R] :
     TFAE
       [ValuationRing R,
@@ -423,9 +442,11 @@ protected theorem tFAE (R : Type u) [CommRing R] [IsDomain R] :
   tfae_have 1 ↔ 5; · exact iff_local_bezout_domain
   tfae_finish
 #align valuation_ring.tfae ValuationRing.tFAE
+-/
 
 end
 
+#print Function.Surjective.valuationRing /-
 theorem Function.Surjective.valuationRing {R S : Type _} [CommRing R] [IsDomain R] [ValuationRing R]
     [CommRing S] [IsDomain S] (f : R →+* S) (hf : Function.Surjective f) : ValuationRing S :=
   ⟨fun a b => by
@@ -433,14 +454,13 @@ theorem Function.Surjective.valuationRing {R S : Type _} [CommRing R] [IsDomain
     obtain ⟨c, rfl | rfl⟩ := ValuationRing.cond a b
     exacts [⟨f c, Or.inl <| (map_mul _ _ _).symm⟩, ⟨f c, Or.inr <| (map_mul _ _ _).symm⟩]⟩
 #align function.surjective.valuation_ring Function.Surjective.valuationRing
+-/
 
 section
 
 variable {𝒪 : Type u} {K : Type v} {Γ : Type w} [CommRing 𝒪] [IsDomain 𝒪] [Field K] [Algebra 𝒪 K]
   [LinearOrderedCommGroupWithZero Γ] (v : Valuation K Γ) (hh : v.Integers 𝒪)
 
-include hh
-
 #print ValuationRing.of_integers /-
 /-- If `𝒪` satisfies `v.integers 𝒪` where `v` is a valuation on a field, then `𝒪`
 is a valuation ring. -/
Diff
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Adam Topaz
 
 ! This file was ported from Lean 3 source module ring_theory.valuation.valuation_ring
-! leanprover-community/mathlib commit c163ec99dfc664628ca15d215fce0a5b9c265b68
+! leanprover-community/mathlib commit c20927220ef87bb4962ba08bf6da2ce3cf50a6dd
 ! Please do not edit these lines, except to modify the commit id
 ! if you have ported upstream changes.
 -/
@@ -19,6 +19,9 @@ import Mathbin.Tactic.FieldSimp
 /-!
 # Valuation Rings
 
+> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.
+> Any changes to this file require a corresponding PR to mathlib4.
+
 A valuation ring is a domain such that for every pair of elements `a b`, either `a` divides
 `b` or vice-versa.
 
Diff
@@ -40,12 +40,14 @@ We also provide the equivalence of the following notions for a domain `R` in `va
 
 universe u v w
 
+#print ValuationRing /-
 /- ./././Mathport/Syntax/Translate/Command.lean:394:30: infer kinds are unsupported in Lean 4: #[`cond] [] -/
 /-- An integral domain is called a `valuation ring` provided that for any pair
 of elements `a b : A`, either `a` divides `b` or vice versa. -/
 class ValuationRing (A : Type u) [CommRing A] [IsDomain A] : Prop where
   cond : ∀ a b : A, ∃ c : A, a * c = b ∨ b * c = a
 #align valuation_ring ValuationRing
+-/
 
 namespace ValuationRing
 
@@ -55,10 +57,12 @@ variable (A : Type u) [CommRing A]
 
 variable (K : Type v) [Field K] [Algebra A K]
 
+#print ValuationRing.ValueGroup /-
 /-- The value group of the valuation ring `A`. Note: this is actually a group with zero. -/
 def ValueGroup : Type v :=
   Quotient (MulAction.orbitRel Aˣ K)
 #align valuation_ring.value_group ValuationRing.ValueGroup
+-/
 
 instance : Inhabited (ValueGroup A K) :=
   ⟨Quotient.mk'' 0⟩
@@ -293,13 +297,16 @@ variable {R : Type _} [CommRing R] [IsDomain R] {K : Type _}
 
 variable [Field K] [Algebra R K] [IsFractionRing R K]
 
+#print ValuationRing.iff_dvd_total /-
 theorem iff_dvd_total : ValuationRing R ↔ IsTotal R (· ∣ ·) := by
   classical
   refine' ⟨fun H => ⟨fun a b => _⟩, fun H => ⟨fun a b => _⟩⟩ <;> skip
   · obtain ⟨c, rfl | rfl⟩ := @ValuationRing.cond _ _ H a b <;> simp
   · obtain ⟨c, rfl⟩ | ⟨c, rfl⟩ := @IsTotal.total _ _ H a b <;> use c <;> simp
 #align valuation_ring.iff_dvd_total ValuationRing.iff_dvd_total
+-/
 
+#print ValuationRing.iff_ideal_total /-
 theorem iff_ideal_total : ValuationRing R ↔ IsTotal (Ideal R) (· ≤ ·) := by
   classical
   refine' ⟨fun _ => ⟨le_total⟩, fun H => iff_dvd_total.mpr ⟨fun a b => _⟩⟩
@@ -307,12 +314,15 @@ theorem iff_ideal_total : ValuationRing R ↔ IsTotal (Ideal R) (· ≤ ·) := b
   simp_rw [Ideal.span_singleton_le_span_singleton] at this 
   exact this.symm
 #align valuation_ring.iff_ideal_total ValuationRing.iff_ideal_total
+-/
 
 variable {R} (K)
 
+#print ValuationRing.dvd_total /-
 theorem dvd_total [h : ValuationRing R] (x y : R) : x ∣ y ∨ y ∣ x :=
   @IsTotal.total _ (iff_dvd_total.mp h) x y
 #align valuation_ring.dvd_total ValuationRing.dvd_total
+-/
 
 theorem unique_irreducible [ValuationRing R] ⦃p q : R⦄ (hp : Irreducible p) (hq : Irreducible q) :
     Associated p q := by
@@ -370,6 +380,7 @@ instance (priority := 100) [ValuationRing R] : IsBezout R := by
   · erw [sup_eq_right.mpr h]; exact ⟨⟨_, rfl⟩⟩
   · erw [sup_eq_left.mpr h]; exact ⟨⟨_, rfl⟩⟩
 
+#print ValuationRing.iff_local_bezout_domain /-
 theorem iff_local_bezout_domain : ValuationRing R ↔ LocalRing R ∧ IsBezout R := by
   classical
   refine' ⟨fun H => ⟨inferInstance, inferInstance⟩, _⟩
@@ -395,6 +406,7 @@ theorem iff_local_bezout_domain : ValuationRing R ↔ LocalRing R ∧ IsBezout R
   right
   all_goals exact mul_dvd_mul_right (is_unit_iff_forall_dvd.mp (isUnit_of_mul_isUnit_right h') _) _
 #align valuation_ring.iff_local_bezout_domain ValuationRing.iff_local_bezout_domain
+-/
 
 protected theorem tFAE (R : Type u) [CommRing R] [IsDomain R] :
     TFAE
@@ -426,6 +438,7 @@ variable {𝒪 : Type u} {K : Type v} {Γ : Type w} [CommRing 𝒪] [IsDomain 
 
 include hh
 
+#print ValuationRing.of_integers /-
 /-- If `𝒪` satisfies `v.integers 𝒪` where `v` is a valuation on a field, then `𝒪`
 is a valuation ring. -/
 theorem of_integers : ValuationRing 𝒪 := by
@@ -437,6 +450,7 @@ theorem of_integers : ValuationRing 𝒪 := by
   · obtain ⟨c, hc⟩ := Valuation.Integers.dvd_of_le hh h
     use c; exact Or.inl hc.symm
 #align valuation_ring.of_integers ValuationRing.of_integers
+-/
 
 end
 
@@ -444,6 +458,7 @@ section
 
 variable (K : Type u) [Field K]
 
+#print ValuationRing.of_field /-
 /-- A field is a valuation ring. -/
 instance (priority := 100) of_field : ValuationRing K :=
   by
@@ -453,6 +468,7 @@ instance (priority := 100) of_field : ValuationRing K :=
   · use 0; left; simp [h]
   · use a * b⁻¹; right; field_simp; rw [mul_comm]
 #align valuation_ring.of_field ValuationRing.of_field
+-/
 
 end
 
@@ -460,6 +476,7 @@ section
 
 variable (A : Type u) [CommRing A] [IsDomain A] [DiscreteValuationRing A]
 
+#print ValuationRing.of_discreteValuationRing /-
 /-- A DVR is a valuation ring. -/
 instance (priority := 100) of_discreteValuationRing : ValuationRing A :=
   by
@@ -482,6 +499,7 @@ instance (priority := 100) of_discreteValuationRing : ValuationRing A :=
     congr 2
     linarith
 #align valuation_ring.of_discrete_valuation_ring ValuationRing.of_discreteValuationRing
+-/
 
 end
 
Diff
@@ -40,7 +40,7 @@ We also provide the equivalence of the following notions for a domain `R` in `va
 
 universe u v w
 
-/- ./././Mathport/Syntax/Translate/Command.lean:393:30: infer kinds are unsupported in Lean 4: #[`cond] [] -/
+/- ./././Mathport/Syntax/Translate/Command.lean:394:30: infer kinds are unsupported in Lean 4: #[`cond] [] -/
 /-- An integral domain is called a `valuation ring` provided that for any pair
 of elements `a b : A`, either `a` divides `b` or vice versa. -/
 class ValuationRing (A : Type u) [CommRing A] [IsDomain A] : Prop where
@@ -70,7 +70,7 @@ instance : LE (ValueGroup A K) :=
         rintro _ _ a b ⟨c, rfl⟩ ⟨d, rfl⟩; ext
         constructor
         · rintro ⟨e, he⟩; use (c⁻¹ : Aˣ) * e * d
-          apply_fun fun t => c⁻¹ • t  at he 
+          apply_fun fun t => c⁻¹ • t at he 
           simpa [mul_smul] using he
         · rintro ⟨e, he⟩; dsimp
           use (d⁻¹ : Aˣ) * c * e
@@ -164,7 +164,7 @@ noncomputable instance : LinearOrderedCommGroupWithZero (ValueGroup A K) :=
     exists_pair_ne := by
       use 0, 1
       intro c; obtain ⟨d, hd⟩ := Quotient.exact' c
-      apply_fun fun t => d⁻¹ • t  at hd 
+      apply_fun fun t => d⁻¹ • t at hd 
       simpa using hd
     inv_zero := by apply Quotient.sound'; rw [inv_zero]; apply Setoid.refl'
     mul_inv_cancel := by
@@ -228,7 +228,7 @@ noncomputable def equivInteger : A ≃+* (valuation A K).integer :=
     (by
       constructor
       · intro x y h
-        apply_fun (coe : _ → K)  at h 
+        apply_fun (coe : _ → K) at h 
         dsimp at h 
         exact IsFractionRing.injective _ _ h
       · rintro ⟨a, ha : a ∈ (Valuation A K).integer⟩
@@ -274,7 +274,7 @@ instance [DecidableRel ((· ≤ ·) : Ideal A → Ideal A → Prop)] : LinearOrd
       intro α β
       by_cases h : α ≤ β; · exact Or.inl h
       erw [not_forall] at h 
-      push_neg  at h 
+      push_neg at h 
       obtain ⟨a, h₁, h₂⟩ := h
       right
       intro b hb
@@ -295,17 +295,17 @@ variable [Field K] [Algebra R K] [IsFractionRing R K]
 
 theorem iff_dvd_total : ValuationRing R ↔ IsTotal R (· ∣ ·) := by
   classical
-    refine' ⟨fun H => ⟨fun a b => _⟩, fun H => ⟨fun a b => _⟩⟩ <;> skip
-    · obtain ⟨c, rfl | rfl⟩ := @ValuationRing.cond _ _ H a b <;> simp
-    · obtain ⟨c, rfl⟩ | ⟨c, rfl⟩ := @IsTotal.total _ _ H a b <;> use c <;> simp
+  refine' ⟨fun H => ⟨fun a b => _⟩, fun H => ⟨fun a b => _⟩⟩ <;> skip
+  · obtain ⟨c, rfl | rfl⟩ := @ValuationRing.cond _ _ H a b <;> simp
+  · obtain ⟨c, rfl⟩ | ⟨c, rfl⟩ := @IsTotal.total _ _ H a b <;> use c <;> simp
 #align valuation_ring.iff_dvd_total ValuationRing.iff_dvd_total
 
 theorem iff_ideal_total : ValuationRing R ↔ IsTotal (Ideal R) (· ≤ ·) := by
   classical
-    refine' ⟨fun _ => ⟨le_total⟩, fun H => iff_dvd_total.mpr ⟨fun a b => _⟩⟩
-    have := @IsTotal.total _ _ H (Ideal.span {a}) (Ideal.span {b})
-    simp_rw [Ideal.span_singleton_le_span_singleton] at this 
-    exact this.symm
+  refine' ⟨fun _ => ⟨le_total⟩, fun H => iff_dvd_total.mpr ⟨fun a b => _⟩⟩
+  have := @IsTotal.total _ _ H (Ideal.span {a}) (Ideal.span {b})
+  simp_rw [Ideal.span_singleton_le_span_singleton] at this 
+  exact this.symm
 #align valuation_ring.iff_ideal_total ValuationRing.iff_ideal_total
 
 variable {R} (K)
@@ -363,38 +363,37 @@ variable {R}
 -- This implies that valuation rings are integrally closed through typeclass search.
 instance (priority := 100) [ValuationRing R] : IsBezout R := by
   classical
-    rw [IsBezout.iff_span_pair_isPrincipal]
-    intro x y
-    rw [Ideal.span_insert]
-    cases le_total (Ideal.span {x} : Ideal R) (Ideal.span {y})
-    · erw [sup_eq_right.mpr h]; exact ⟨⟨_, rfl⟩⟩
-    · erw [sup_eq_left.mpr h]; exact ⟨⟨_, rfl⟩⟩
+  rw [IsBezout.iff_span_pair_isPrincipal]
+  intro x y
+  rw [Ideal.span_insert]
+  cases le_total (Ideal.span {x} : Ideal R) (Ideal.span {y})
+  · erw [sup_eq_right.mpr h]; exact ⟨⟨_, rfl⟩⟩
+  · erw [sup_eq_left.mpr h]; exact ⟨⟨_, rfl⟩⟩
 
 theorem iff_local_bezout_domain : ValuationRing R ↔ LocalRing R ∧ IsBezout R := by
   classical
-    refine' ⟨fun H => ⟨inferInstance, inferInstance⟩, _⟩
-    rintro ⟨h₁, h₂⟩
-    skip
-    refine' iff_dvd_total.mpr ⟨fun a b => _⟩
-    obtain ⟨g, e : _ = Ideal.span _⟩ := IsBezout.span_pair_isPrincipal a b
-    obtain ⟨a, rfl⟩ :=
-      ideal.mem_span_singleton'.mp
-        (show a ∈ Ideal.span {g} by rw [← e]; exact Ideal.subset_span (by simp))
-    obtain ⟨b, rfl⟩ :=
-      ideal.mem_span_singleton'.mp
-        (show b ∈ Ideal.span {g} by rw [← e]; exact Ideal.subset_span (by simp))
-    obtain ⟨x, y, e'⟩ :=
-      ideal.mem_span_pair.mp
-        (show g ∈ Ideal.span {a * g, b * g} by rw [e]; exact Ideal.subset_span (by simp))
-    cases' eq_or_ne g 0 with h h
-    · simp [h]
-    have : x * a + y * b = 1 := by apply mul_left_injective₀ h; convert e' <;> ring_nf
-    cases' LocalRing.isUnit_or_isUnit_of_add_one this with h' h'
-    left
-    swap
-    right
-    all_goals
-      exact mul_dvd_mul_right (is_unit_iff_forall_dvd.mp (isUnit_of_mul_isUnit_right h') _) _
+  refine' ⟨fun H => ⟨inferInstance, inferInstance⟩, _⟩
+  rintro ⟨h₁, h₂⟩
+  skip
+  refine' iff_dvd_total.mpr ⟨fun a b => _⟩
+  obtain ⟨g, e : _ = Ideal.span _⟩ := IsBezout.span_pair_isPrincipal a b
+  obtain ⟨a, rfl⟩ :=
+    ideal.mem_span_singleton'.mp
+      (show a ∈ Ideal.span {g} by rw [← e]; exact Ideal.subset_span (by simp))
+  obtain ⟨b, rfl⟩ :=
+    ideal.mem_span_singleton'.mp
+      (show b ∈ Ideal.span {g} by rw [← e]; exact Ideal.subset_span (by simp))
+  obtain ⟨x, y, e'⟩ :=
+    ideal.mem_span_pair.mp
+      (show g ∈ Ideal.span {a * g, b * g} by rw [e]; exact Ideal.subset_span (by simp))
+  cases' eq_or_ne g 0 with h h
+  · simp [h]
+  have : x * a + y * b = 1 := by apply mul_left_injective₀ h; convert e' <;> ring_nf
+  cases' LocalRing.isUnit_or_isUnit_of_add_one this with h' h'
+  left
+  swap
+  right
+  all_goals exact mul_dvd_mul_right (is_unit_iff_forall_dvd.mp (isUnit_of_mul_isUnit_right h') _) _
 #align valuation_ring.iff_local_bezout_domain ValuationRing.iff_local_bezout_domain
 
 protected theorem tFAE (R : Type u) [CommRing R] [IsDomain R] :
Diff
@@ -70,7 +70,7 @@ instance : LE (ValueGroup A K) :=
         rintro _ _ a b ⟨c, rfl⟩ ⟨d, rfl⟩; ext
         constructor
         · rintro ⟨e, he⟩; use (c⁻¹ : Aˣ) * e * d
-          apply_fun fun t => c⁻¹ • t  at he
+          apply_fun fun t => c⁻¹ • t  at he 
           simpa [mul_smul] using he
         · rintro ⟨e, he⟩; dsimp
           use (d⁻¹ : Aˣ) * c * e
@@ -143,9 +143,9 @@ noncomputable instance : LinearOrderedCommGroupWithZero (ValueGroup A K) :=
       have : IsUnit e := by
         apply isUnit_of_dvd_one
         use f; rw [mul_comm]
-        rw [← mul_smul, Algebra.smul_def] at hf
-        nth_rw 2 [← one_mul b] at hf
-        rw [← (algebraMap A K).map_one] at hf
+        rw [← mul_smul, Algebra.smul_def] at hf 
+        nth_rw 2 [← one_mul b] at hf 
+        rw [← (algebraMap A K).map_one] at hf 
         exact IsFractionRing.injective _ _ (mul_right_cancel₀ hb hf).symm
       apply Quotient.sound'
       use this.unit, rfl
@@ -164,7 +164,7 @@ noncomputable instance : LinearOrderedCommGroupWithZero (ValueGroup A K) :=
     exists_pair_ne := by
       use 0, 1
       intro c; obtain ⟨d, hd⟩ := Quotient.exact' c
-      apply_fun fun t => d⁻¹ • t  at hd
+      apply_fun fun t => d⁻¹ • t  at hd 
       simpa using hd
     inv_zero := by apply Quotient.sound'; rw [inv_zero]; apply Setoid.refl'
     mul_inv_cancel := by
@@ -174,7 +174,7 @@ noncomputable instance : LinearOrderedCommGroupWithZero (ValueGroup A K) :=
       simp only [one_smul]
       apply (mul_inv_cancel _).symm
       contrapose ha
-      simp only [Classical.not_not] at ha⊢
+      simp only [Classical.not_not] at ha ⊢
       rw [ha]; rfl }
 
 /-- Any valuation ring induces a valuation on its fraction field. -/
@@ -228,11 +228,11 @@ noncomputable def equivInteger : A ≃+* (valuation A K).integer :=
     (by
       constructor
       · intro x y h
-        apply_fun (coe : _ → K)  at h
-        dsimp at h
+        apply_fun (coe : _ → K)  at h 
+        dsimp at h 
         exact IsFractionRing.injective _ _ h
       · rintro ⟨a, ha : a ∈ (Valuation A K).integer⟩
-        rw [mem_integer_iff] at ha
+        rw [mem_integer_iff] at ha 
         obtain ⟨a, rfl⟩ := ha
         use a, rfl)
 #align valuation_ring.equiv_integer ValuationRing.equivInteger
@@ -273,8 +273,8 @@ instance [DecidableRel ((· ≤ ·) : Ideal A → Ideal A → Prop)] : LinearOrd
     le_total := by
       intro α β
       by_cases h : α ≤ β; · exact Or.inl h
-      erw [not_forall] at h
-      push_neg  at h
+      erw [not_forall] at h 
+      push_neg  at h 
       obtain ⟨a, h₁, h₂⟩ := h
       right
       intro b hb
@@ -304,7 +304,7 @@ theorem iff_ideal_total : ValuationRing R ↔ IsTotal (Ideal R) (· ≤ ·) := b
   classical
     refine' ⟨fun _ => ⟨le_total⟩, fun H => iff_dvd_total.mpr ⟨fun a b => _⟩⟩
     have := @IsTotal.total _ _ H (Ideal.span {a}) (Ideal.span {b})
-    simp_rw [Ideal.span_singleton_le_span_singleton] at this
+    simp_rw [Ideal.span_singleton_le_span_singleton] at this 
     exact this.symm
 #align valuation_ring.iff_ideal_total ValuationRing.iff_ideal_total
 
@@ -317,7 +317,7 @@ theorem dvd_total [h : ValuationRing R] (x y : R) : x ∣ y ∨ y ∣ x :=
 theorem unique_irreducible [ValuationRing R] ⦃p q : R⦄ (hp : Irreducible p) (hq : Irreducible q) :
     Associated p q := by
   have := dvd_total p q
-  rw [Irreducible.dvd_comm hp hq, or_self_iff] at this
+  rw [Irreducible.dvd_comm hp hq, or_self_iff] at this 
   exact associated_of_dvd_dvd (Irreducible.dvd_symm hq hp this) this
 #align valuation_ring.unique_irreducible ValuationRing.unique_irreducible
 
@@ -345,9 +345,9 @@ theorem iff_isInteger_or_isInteger :
     replace ha := (map_ne_zero_iff _ (IsFractionRing.injective R K)).mpr ha
     replace hb := (map_ne_zero_iff _ (IsFractionRing.injective R K)).mpr hb
     obtain ⟨c, e⟩ | ⟨c, e⟩ := H (algebraMap R K a / algebraMap R K b)
-    · rw [eq_div_iff hb, ← map_mul, (IsFractionRing.injective R K).eq_iff, mul_comm] at e
+    · rw [eq_div_iff hb, ← map_mul, (IsFractionRing.injective R K).eq_iff, mul_comm] at e 
       exact ⟨c, Or.inr e⟩
-    · rw [inv_div, eq_div_iff ha, ← map_mul, (IsFractionRing.injective R K).eq_iff, mul_comm c] at e
+    · rw [inv_div, eq_div_iff ha, ← map_mul, (IsFractionRing.injective R K).eq_iff, mul_comm c] at e 
       exact ⟨c, Or.inl e⟩
 #align valuation_ring.iff_is_integer_or_is_integer ValuationRing.iff_isInteger_or_isInteger
 
@@ -417,7 +417,7 @@ theorem Function.Surjective.valuationRing {R S : Type _} [CommRing R] [IsDomain
   ⟨fun a b => by
     obtain ⟨⟨a, rfl⟩, ⟨b, rfl⟩⟩ := hf a, hf b
     obtain ⟨c, rfl | rfl⟩ := ValuationRing.cond a b
-    exacts[⟨f c, Or.inl <| (map_mul _ _ _).symm⟩, ⟨f c, Or.inr <| (map_mul _ _ _).symm⟩]⟩
+    exacts [⟨f c, Or.inl <| (map_mul _ _ _).symm⟩, ⟨f c, Or.inr <| (map_mul _ _ _).symm⟩]⟩
 #align function.surjective.valuation_ring Function.Surjective.valuationRing
 
 section
Diff
@@ -69,12 +69,10 @@ instance : LE (ValueGroup A K) :=
       (by
         rintro _ _ a b ⟨c, rfl⟩ ⟨d, rfl⟩; ext
         constructor
-        · rintro ⟨e, he⟩
-          use (c⁻¹ : Aˣ) * e * d
+        · rintro ⟨e, he⟩; use (c⁻¹ : Aˣ) * e * d
           apply_fun fun t => c⁻¹ • t  at he
           simpa [mul_smul] using he
-        · rintro ⟨e, he⟩
-          dsimp
+        · rintro ⟨e, he⟩; dsimp
           use (d⁻¹ : Aˣ) * c * e
           erw [← he, ← mul_smul, ← mul_smul]
           congr 1
@@ -123,16 +121,12 @@ protected theorem le_total (a b : ValueGroup A K) : a ≤ b ∨ b ≤ a :=
     use c
     rw [Algebra.smul_def]
     field_simp
-    simp only [← RingHom.map_mul, ← h]
-    congr 1
-    ring
+    simp only [← RingHom.map_mul, ← h]; congr 1; ring
   · left
     use c
     rw [Algebra.smul_def]
     field_simp
-    simp only [← RingHom.map_mul, ← h]
-    congr 1
-    ring
+    simp only [← RingHom.map_mul, ← h]; congr 1; ring
 #align valuation_ring.le_total ValuationRing.le_total
 
 noncomputable instance : LinearOrderedCommGroupWithZero (ValueGroup A K) :=
@@ -141,22 +135,14 @@ noncomputable instance : LinearOrderedCommGroupWithZero (ValueGroup A K) :=
     (inferInstance :
       One (ValueGroup A
           K)) with
-    le_refl := by
-      rintro ⟨⟩
-      use 1
-      rw [one_smul]
-    le_trans := by
-      rintro ⟨a⟩ ⟨b⟩ ⟨c⟩ ⟨e, rfl⟩ ⟨f, rfl⟩
-      use e * f
-      rw [mul_smul]
+    le_refl := by rintro ⟨⟩; use 1; rw [one_smul]
+    le_trans := by rintro ⟨a⟩ ⟨b⟩ ⟨c⟩ ⟨e, rfl⟩ ⟨f, rfl⟩; use e * f; rw [mul_smul]
     le_antisymm := by
       rintro ⟨a⟩ ⟨b⟩ ⟨e, rfl⟩ ⟨f, hf⟩
-      by_cases hb : b = 0
-      · simp [hb]
+      by_cases hb : b = 0; · simp [hb]
       have : IsUnit e := by
         apply isUnit_of_dvd_one
-        use f
-        rw [mul_comm]
+        use f; rw [mul_comm]
         rw [← mul_smul, Algebra.smul_def] at hf
         nth_rw 2 [← one_mul b] at hf
         rw [← (algebraMap A K).map_one] at hf
@@ -165,49 +151,22 @@ noncomputable instance : LinearOrderedCommGroupWithZero (ValueGroup A K) :=
       use this.unit, rfl
     le_total := ValuationRing.le_total _ _
     decidableLe := by classical infer_instance
-    mul_assoc := by
-      rintro ⟨a⟩ ⟨b⟩ ⟨c⟩
-      apply Quotient.sound'
-      rw [mul_assoc]
-      apply Setoid.refl'
-    one_mul := by
-      rintro ⟨a⟩
-      apply Quotient.sound'
-      rw [one_mul]
-      apply Setoid.refl'
-    mul_one := by
-      rintro ⟨a⟩
-      apply Quotient.sound'
-      rw [mul_one]
-      apply Setoid.refl'
-    mul_comm := by
-      rintro ⟨a⟩ ⟨b⟩
-      apply Quotient.sound'
-      rw [mul_comm]
-      apply Setoid.refl'
+    mul_assoc := by rintro ⟨a⟩ ⟨b⟩ ⟨c⟩; apply Quotient.sound'; rw [mul_assoc]; apply Setoid.refl'
+    one_mul := by rintro ⟨a⟩; apply Quotient.sound'; rw [one_mul]; apply Setoid.refl'
+    mul_one := by rintro ⟨a⟩; apply Quotient.sound'; rw [mul_one]; apply Setoid.refl'
+    mul_comm := by rintro ⟨a⟩ ⟨b⟩; apply Quotient.sound'; rw [mul_comm]; apply Setoid.refl'
     mul_le_mul_left := by
       rintro ⟨a⟩ ⟨b⟩ ⟨c, rfl⟩ ⟨d⟩
       use c; simp only [Algebra.smul_def]; ring
-    zero_mul := by
-      rintro ⟨a⟩
-      apply Quotient.sound'
-      rw [MulZeroClass.zero_mul]
-      apply Setoid.refl'
-    mul_zero := by
-      rintro ⟨a⟩
-      apply Quotient.sound'
-      rw [MulZeroClass.mul_zero]
-      apply Setoid.refl'
+    zero_mul := by rintro ⟨a⟩; apply Quotient.sound'; rw [MulZeroClass.zero_mul]; apply Setoid.refl'
+    mul_zero := by rintro ⟨a⟩; apply Quotient.sound'; rw [MulZeroClass.mul_zero]; apply Setoid.refl'
     zero_le_one := ⟨0, by rw [zero_smul]⟩
     exists_pair_ne := by
       use 0, 1
       intro c; obtain ⟨d, hd⟩ := Quotient.exact' c
       apply_fun fun t => d⁻¹ • t  at hd
       simpa using hd
-    inv_zero := by
-      apply Quotient.sound'
-      rw [inv_zero]
-      apply Setoid.refl'
+    inv_zero := by apply Quotient.sound'; rw [inv_zero]; apply Setoid.refl'
     mul_inv_cancel := by
       rintro ⟨a⟩ ha
       apply Quotient.sound'
@@ -238,15 +197,13 @@ def valuation : Valuation K (ValueGroup A K)
       rw [Algebra.smul_def]
       field_simp
       simp only [← RingHom.map_mul, ← RingHom.map_add, ← (algebraMap A K).map_one, ← h]
-      congr 1
-      ring
+      congr 1; ring
     · apply le_trans _ (le_max_right _ _)
       use c + 1
       rw [Algebra.smul_def]
       field_simp
       simp only [← RingHom.map_mul, ← RingHom.map_add, ← (algebraMap A K).map_one, ← h]
-      congr 1
-      ring
+      congr 1; ring
 #align valuation_ring.valuation ValuationRing.valuation
 
 theorem mem_integer_iff (x : K) : x ∈ (valuation A K).integer ↔ ∃ a : A, algebraMap A K a = x :=
@@ -265,15 +222,9 @@ noncomputable def equivInteger : A ≃+* (valuation A K).integer :=
   RingEquiv.ofBijective
     (show A →ₙ+* (valuation A K).integer from
       { toFun := fun a => ⟨algebraMap A K a, (mem_integer_iff _ _ _).mpr ⟨a, rfl⟩⟩
-        map_mul' := fun _ _ => by
-          ext1
-          exact (algebraMap A K).map_mul _ _
-        map_zero' := by
-          ext1
-          exact (algebraMap A K).map_zero
-        map_add' := fun _ _ => by
-          ext1
-          exact (algebraMap A K).map_add _ _ })
+        map_mul' := fun _ _ => by ext1; exact (algebraMap A K).map_mul _ _
+        map_zero' := by ext1; exact (algebraMap A K).map_zero
+        map_add' := fun _ _ => by ext1; exact (algebraMap A K).map_add _ _ })
     (by
       constructor
       · intro x y h
@@ -291,9 +242,7 @@ theorem coe_equivInteger_apply (a : A) : (equivInteger A K a : K) = algebraMap A
   rfl
 #align valuation_ring.coe_equiv_integer_apply ValuationRing.coe_equivInteger_apply
 
-theorem range_algebraMap_eq : (valuation A K).integer = (algebraMap A K).range :=
-  by
-  ext
+theorem range_algebraMap_eq : (valuation A K).integer = (algebraMap A K).range := by ext;
   exact mem_integer_iff _ _ _
 #align valuation_ring.range_algebra_map_eq ValuationRing.range_algebraMap_eq
 
@@ -332,9 +281,7 @@ instance [DecidableRel ((· ≤ ·) : Ideal A → Ideal A → Prop)] : LinearOrd
       obtain ⟨c, h | h⟩ := ValuationRing.cond a b
       · rw [← h]
         exact Ideal.mul_mem_right _ _ h₁
-      · exfalso
-        apply h₂
-        rw [← h]
+      · exfalso; apply h₂; rw [← h]
         apply Ideal.mul_mem_right _ _ hb
     decidableLe := inferInstance }
 
@@ -393,12 +340,8 @@ theorem iff_isInteger_or_isInteger :
   · intro H
     constructor
     intro a b
-    by_cases ha : a = 0
-    · subst ha
-      exact ⟨0, Or.inr <| MulZeroClass.mul_zero b⟩
-    by_cases hb : b = 0
-    · subst hb
-      exact ⟨0, Or.inl <| MulZeroClass.mul_zero a⟩
+    by_cases ha : a = 0; · subst ha; exact ⟨0, Or.inr <| MulZeroClass.mul_zero b⟩
+    by_cases hb : b = 0; · subst hb; exact ⟨0, Or.inl <| MulZeroClass.mul_zero a⟩
     replace ha := (map_ne_zero_iff _ (IsFractionRing.injective R K)).mpr ha
     replace hb := (map_ne_zero_iff _ (IsFractionRing.injective R K)).mpr hb
     obtain ⟨c, e⟩ | ⟨c, e⟩ := H (algebraMap R K a / algebraMap R K b)
@@ -424,10 +367,8 @@ instance (priority := 100) [ValuationRing R] : IsBezout R := by
     intro x y
     rw [Ideal.span_insert]
     cases le_total (Ideal.span {x} : Ideal R) (Ideal.span {y})
-    · erw [sup_eq_right.mpr h]
-      exact ⟨⟨_, rfl⟩⟩
-    · erw [sup_eq_left.mpr h]
-      exact ⟨⟨_, rfl⟩⟩
+    · erw [sup_eq_right.mpr h]; exact ⟨⟨_, rfl⟩⟩
+    · erw [sup_eq_left.mpr h]; exact ⟨⟨_, rfl⟩⟩
 
 theorem iff_local_bezout_domain : ValuationRing R ↔ LocalRing R ∧ IsBezout R := by
   classical
@@ -438,24 +379,16 @@ theorem iff_local_bezout_domain : ValuationRing R ↔ LocalRing R ∧ IsBezout R
     obtain ⟨g, e : _ = Ideal.span _⟩ := IsBezout.span_pair_isPrincipal a b
     obtain ⟨a, rfl⟩ :=
       ideal.mem_span_singleton'.mp
-        (show a ∈ Ideal.span {g} by
-          rw [← e]
-          exact Ideal.subset_span (by simp))
+        (show a ∈ Ideal.span {g} by rw [← e]; exact Ideal.subset_span (by simp))
     obtain ⟨b, rfl⟩ :=
       ideal.mem_span_singleton'.mp
-        (show b ∈ Ideal.span {g} by
-          rw [← e]
-          exact Ideal.subset_span (by simp))
+        (show b ∈ Ideal.span {g} by rw [← e]; exact Ideal.subset_span (by simp))
     obtain ⟨x, y, e'⟩ :=
       ideal.mem_span_pair.mp
-        (show g ∈ Ideal.span {a * g, b * g} by
-          rw [e]
-          exact Ideal.subset_span (by simp))
+        (show g ∈ Ideal.span {a * g, b * g} by rw [e]; exact Ideal.subset_span (by simp))
     cases' eq_or_ne g 0 with h h
     · simp [h]
-    have : x * a + y * b = 1 := by
-      apply mul_left_injective₀ h
-      convert e' <;> ring_nf
+    have : x * a + y * b = 1 := by apply mul_left_injective₀ h; convert e' <;> ring_nf
     cases' LocalRing.isUnit_or_isUnit_of_add_one this with h' h'
     left
     swap
@@ -501,11 +434,9 @@ theorem of_integers : ValuationRing 𝒪 := by
   intro a b
   cases le_total (v (algebraMap 𝒪 K a)) (v (algebraMap 𝒪 K b))
   · obtain ⟨c, hc⟩ := Valuation.Integers.dvd_of_le hh h
-    use c
-    exact Or.inr hc.symm
+    use c; exact Or.inr hc.symm
   · obtain ⟨c, hc⟩ := Valuation.Integers.dvd_of_le hh h
-    use c
-    exact Or.inl hc.symm
+    use c; exact Or.inl hc.symm
 #align valuation_ring.of_integers ValuationRing.of_integers
 
 end
@@ -520,13 +451,8 @@ instance (priority := 100) of_field : ValuationRing K :=
   constructor
   intro a b
   by_cases b = 0
-  · use 0
-    left
-    simp [h]
-  · use a * b⁻¹
-    right
-    field_simp
-    rw [mul_comm]
+  · use 0; left; simp [h]
+  · use a * b⁻¹; right; field_simp; rw [mul_comm]
 #align valuation_ring.of_field ValuationRing.of_field
 
 end
@@ -540,26 +466,18 @@ instance (priority := 100) of_discreteValuationRing : ValuationRing A :=
   by
   constructor
   intro a b
-  by_cases ha : a = 0;
-  · use 0
-    right
-    simp [ha]
-  by_cases hb : b = 0;
-  · use 0
-    left
-    simp [hb]
+  by_cases ha : a = 0; · use 0; right; simp [ha]
+  by_cases hb : b = 0; · use 0; left; simp [hb]
   obtain ⟨ϖ, hϖ⟩ := DiscreteValuationRing.exists_irreducible A
   obtain ⟨m, u, rfl⟩ := DiscreteValuationRing.eq_unit_mul_pow_irreducible ha hϖ
   obtain ⟨n, v, rfl⟩ := DiscreteValuationRing.eq_unit_mul_pow_irreducible hb hϖ
   cases' le_total m n with h h
-  · use (u⁻¹ * v : Aˣ) * ϖ ^ (n - m)
-    left
+  · use (u⁻¹ * v : Aˣ) * ϖ ^ (n - m); left
     simp_rw [mul_comm (u : A), Units.val_mul, ← mul_assoc, mul_assoc _ (u : A)]
     simp only [Units.mul_inv, mul_one, mul_comm _ (v : A), mul_assoc, ← pow_add]
     congr 2
     linarith
-  · use (v⁻¹ * u : Aˣ) * ϖ ^ (m - n)
-    right
+  · use (v⁻¹ * u : Aˣ) * ϖ ^ (m - n); right
     simp_rw [mul_comm (v : A), Units.val_mul, ← mul_assoc, mul_assoc _ (v : A)]
     simp only [Units.mul_inv, mul_one, mul_comm _ (u : A), mul_assoc, ← pow_add]
     congr 2
Diff
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Adam Topaz
 
 ! This file was ported from Lean 3 source module ring_theory.valuation.valuation_ring
-! leanprover-community/mathlib commit a47cda9662ff3925c6df271090b5808adbca5b46
+! leanprover-community/mathlib commit c163ec99dfc664628ca15d215fce0a5b9c265b68
 ! Please do not edit these lines, except to modify the commit id
 ! if you have ported upstream changes.
 -/
@@ -12,7 +12,7 @@ import Mathbin.RingTheory.Valuation.Integers
 import Mathbin.RingTheory.Ideal.LocalRing
 import Mathbin.RingTheory.Localization.FractionRing
 import Mathbin.RingTheory.Localization.Integer
-import Mathbin.RingTheory.DiscreteValuationRing
+import Mathbin.RingTheory.DiscreteValuationRing.Basic
 import Mathbin.RingTheory.Bezout
 import Mathbin.Tactic.FieldSimp
 
Diff
@@ -40,7 +40,7 @@ We also provide the equivalence of the following notions for a domain `R` in `va
 
 universe u v w
 
-/- ./././Mathport/Syntax/Translate/Command.lean:388:30: infer kinds are unsupported in Lean 4: #[`cond] [] -/
+/- ./././Mathport/Syntax/Translate/Command.lean:393:30: infer kinds are unsupported in Lean 4: #[`cond] [] -/
 /-- An integral domain is called a `valuation ring` provided that for any pair
 of elements `a b : A`, either `a` divides `b` or vice versa. -/
 class ValuationRing (A : Type u) [CommRing A] [IsDomain A] : Prop where
Diff
@@ -191,12 +191,12 @@ noncomputable instance : LinearOrderedCommGroupWithZero (ValueGroup A K) :=
     zero_mul := by
       rintro ⟨a⟩
       apply Quotient.sound'
-      rw [zero_mul]
+      rw [MulZeroClass.zero_mul]
       apply Setoid.refl'
     mul_zero := by
       rintro ⟨a⟩
       apply Quotient.sound'
-      rw [mul_zero]
+      rw [MulZeroClass.mul_zero]
       apply Setoid.refl'
     zero_le_one := ⟨0, by rw [zero_smul]⟩
     exists_pair_ne := by
@@ -395,10 +395,10 @@ theorem iff_isInteger_or_isInteger :
     intro a b
     by_cases ha : a = 0
     · subst ha
-      exact ⟨0, Or.inr <| mul_zero b⟩
+      exact ⟨0, Or.inr <| MulZeroClass.mul_zero b⟩
     by_cases hb : b = 0
     · subst hb
-      exact ⟨0, Or.inl <| mul_zero a⟩
+      exact ⟨0, Or.inl <| MulZeroClass.mul_zero a⟩
     replace ha := (map_ne_zero_iff _ (IsFractionRing.injective R K)).mpr ha
     replace hb := (map_ne_zero_iff _ (IsFractionRing.injective R K)).mpr hb
     obtain ⟨c, e⟩ | ⟨c, e⟩ := H (algebraMap R K a / algebraMap R K b)

Changes in mathlib4

mathlib3
mathlib4
chore: make some proofs more robust (#12466)

Notably, these cause issues on nightly-2024-04-25

Co-authored-by: adamtopaz <github@adamtopaz.com>

Diff
@@ -70,11 +70,9 @@ instance : LE (ValueGroup A K) :=
           apply_fun fun t => c⁻¹ • t at he
           simpa [mul_smul] using he
         · rintro ⟨e, he⟩; dsimp
-          use (d⁻¹ : Aˣ) * c * e
-          erw [← he, ← mul_smul, ← mul_smul]
-          congr 1
-          rw [mul_comm]
-          simp only [← mul_assoc, ← Units.val_mul, mul_inv_self, one_mul])
+          use c * e * (d⁻¹ : Aˣ)
+          simp_rw [Units.smul_def, ← he, mul_smul]
+          rw [← mul_smul _ _ b, Units.inv_mul, one_smul])
 
 instance : Zero (ValueGroup A K) := ⟨Quotient.mk'' 0⟩
 
feat: Axiomatise b ≠ 0 → a * b / b = a (#12424)

This lets us unify a few lemmas between GroupWithZero and EuclideanDomain and two lemmas that were previously proved separately for Nat, Int, Polynomial.

Diff
@@ -430,7 +430,7 @@ instance (priority := 100) of_field : ValuationRing K := by
   intro a b
   by_cases h : b = 0
   · use 0; left; simp [h]
-  · use a * b⁻¹; right; field_simp; rw [mul_comm]
+  · use a * b⁻¹; right; field_simp
 #align valuation_ring.of_field ValuationRing.of_field
 
 end
chore(*): remove empty lines between variable statements (#11418)

Empty lines were removed by executing the following Python script twice

import os
import re


# Loop through each file in the repository
for dir_path, dirs, files in os.walk('.'):
  for filename in files:
    if filename.endswith('.lean'):
      file_path = os.path.join(dir_path, filename)

      # Open the file and read its contents
      with open(file_path, 'r') as file:
        content = file.read()

      # Use a regular expression to replace sequences of "variable" lines separated by empty lines
      # with sequences without empty lines
      modified_content = re.sub(r'(variable.*\n)\n(variable(?! .* in))', r'\1\2', content)

      # Write the modified content back to the file
      with open(file_path, 'w') as file:
        file.write(modified_content)
Diff
@@ -52,7 +52,6 @@ namespace ValuationRing
 section
 
 variable (A : Type u) [CommRing A]
-
 variable (K : Type v) [Field K] [Algebra A K]
 
 /-- The value group of the valuation ring `A`. Note: this is actually a group with zero. -/
@@ -280,7 +279,6 @@ end
 section
 
 variable {R : Type*} [CommRing R] [IsDomain R] {K : Type*}
-
 variable [Field K] [Algebra R K] [IsFractionRing R K]
 
 theorem iff_dvd_total : ValuationRing R ↔ IsTotal R (· ∣ ·) := by
feat: A dedekind domain that is local is a PID. (#9282)

Co-authored-by: Andrew Yang <36414270+erdOne@users.noreply.github.com>

Diff
@@ -356,10 +356,8 @@ instance (priority := 100) [ValuationRing R] : IsBezout R := by
   · erw [sup_eq_right.mpr h]; exact ⟨⟨_, rfl⟩⟩
   · erw [sup_eq_left.mpr h]; exact ⟨⟨_, rfl⟩⟩
 
-theorem iff_local_bezout_domain : ValuationRing R ↔ LocalRing R ∧ IsBezout R := by
+instance (priority := 100) [LocalRing R] [IsBezout R] : ValuationRing R := by
   classical
-  refine ⟨fun H => ⟨inferInstance, inferInstance⟩, ?_⟩
-  rintro ⟨h₁, h₂⟩
   refine iff_dvd_total.mpr ⟨fun a b => ?_⟩
   obtain ⟨g, e : _ = Ideal.span _⟩ := IsBezout.span_pair_isPrincipal a b
   obtain ⟨a, rfl⟩ := Ideal.mem_span_singleton'.mp
@@ -377,6 +375,9 @@ theorem iff_local_bezout_domain : ValuationRing R ↔ LocalRing R ∧ IsBezout R
   swap
   right
   all_goals exact mul_dvd_mul_right (isUnit_iff_forall_dvd.mp (isUnit_of_mul_isUnit_right h') _) _
+
+theorem iff_local_bezout_domain : ValuationRing R ↔ LocalRing R ∧ IsBezout R :=
+  ⟨fun _ ↦ ⟨inferInstance, inferInstance⟩, fun ⟨_, _⟩ ↦ inferInstance⟩
 #align valuation_ring.iff_local_bezout_domain ValuationRing.iff_local_bezout_domain
 
 protected theorem tFAE (R : Type u) [CommRing R] [IsDomain R] :
chore: remove uses of cases' (#9171)

I literally went through and regex'd some uses of cases', replacing them with rcases; this is meant to be a low effort PR as I hope that tools can do this in the future.

rcases is an easier replacement than cases, though with better tools we could in future do a second pass converting simple rcases added here (and existing ones) to cases.

Diff
@@ -352,7 +352,7 @@ instance (priority := 100) [ValuationRing R] : IsBezout R := by
   rw [IsBezout.iff_span_pair_isPrincipal]
   intro x y
   rw [Ideal.span_insert]
-  cases' le_total (Ideal.span {x} : Ideal R) (Ideal.span {y}) with h h
+  rcases le_total (Ideal.span {x} : Ideal R) (Ideal.span {y}) with h | h
   · erw [sup_eq_right.mpr h]; exact ⟨⟨_, rfl⟩⟩
   · erw [sup_eq_left.mpr h]; exact ⟨⟨_, rfl⟩⟩
 
@@ -368,7 +368,7 @@ theorem iff_local_bezout_domain : ValuationRing R ↔ LocalRing R ∧ IsBezout R
       (show b ∈ Ideal.span {g} by rw [← e]; exact Ideal.subset_span (by simp))
   obtain ⟨x, y, e'⟩ := Ideal.mem_span_pair.mp
       (show g ∈ Ideal.span {a * g, b * g} by rw [e]; exact Ideal.subset_span (by simp))
-  cases' eq_or_ne g 0 with h h
+  rcases eq_or_ne g 0 with h | h
   · simp [h]
   have : x * a + y * b = 1 := by
     apply mul_left_injective₀ h; convert e' using 1 <;> ring
@@ -412,7 +412,7 @@ is a valuation ring. -/
 theorem of_integers : ValuationRing 𝒪 := by
   constructor
   intro a b
-  cases' le_total (v (algebraMap 𝒪 K a)) (v (algebraMap 𝒪 K b)) with h h
+  rcases le_total (v (algebraMap 𝒪 K a)) (v (algebraMap 𝒪 K b)) with h | h
   · obtain ⟨c, hc⟩ := Valuation.Integers.dvd_of_le hh h
     use c; exact Or.inr hc.symm
   · obtain ⟨c, hc⟩ := Valuation.Integers.dvd_of_le hh h
@@ -449,7 +449,7 @@ instance (priority := 100) of_discreteValuationRing : ValuationRing A := by
   obtain ⟨ϖ, hϖ⟩ := DiscreteValuationRing.exists_irreducible A
   obtain ⟨m, u, rfl⟩ := DiscreteValuationRing.eq_unit_mul_pow_irreducible ha hϖ
   obtain ⟨n, v, rfl⟩ := DiscreteValuationRing.eq_unit_mul_pow_irreducible hb hϖ
-  cases' le_total m n with h h
+  rcases le_total m n with h | h
   · use (u⁻¹ * v : Aˣ) * ϖ ^ (n - m); left
     simp_rw [mul_comm (u : A), Units.val_mul, ← mul_assoc, mul_assoc _ (u : A)]
     simp only [Units.mul_inv, mul_one, mul_comm _ (v : A), mul_assoc, ← pow_add]
chore (Order.Defs): reorder parents to simplify instances and avoid non-reducible defeq checks (#9034)

Currently, OrderDual.orderedCommMonoid unifies with LinearOrderedAddCommMonoid.toOrderedAddCommMonoid at instance transparency because of an extra eta expansion in its definition. The provided instances can be synthesized by Lean and deleted. This removes the extraneous eta expansion but causes defeq to fail at instance transparency. To fix this, we reorder the parents of LinearOrderedAddCommMonoid. We also do this for the non-Add version.

Diff
@@ -126,7 +126,7 @@ protected theorem le_total (a b : ValueGroup A K) : a ≤ b ∨ b ≤ a := by
 
 -- Porting note: it is much faster to split the instance `LinearOrderedCommGroupWithZero`
 -- into two parts
-noncomputable instance : LinearOrder (ValueGroup A K) where
+noncomputable instance linearOrder : LinearOrder (ValueGroup A K) where
   le_refl := by rintro ⟨⟩; use 1; rw [one_smul]
   le_trans := by rintro ⟨a⟩ ⟨b⟩ ⟨c⟩ ⟨e, rfl⟩ ⟨f, rfl⟩; use e * f; rw [mul_smul]
   le_antisymm := by
@@ -146,33 +146,34 @@ noncomputable instance : LinearOrder (ValueGroup A K) where
   decidableLE := by classical infer_instance
 
 noncomputable instance linearOrderedCommGroupWithZero :
-    LinearOrderedCommGroupWithZero (ValueGroup A K) where
-  mul_assoc := by rintro ⟨a⟩ ⟨b⟩ ⟨c⟩; apply Quotient.sound'; rw [mul_assoc]; apply Setoid.refl'
-  one_mul := by rintro ⟨a⟩; apply Quotient.sound'; rw [one_mul]; apply Setoid.refl'
-  mul_one := by rintro ⟨a⟩; apply Quotient.sound'; rw [mul_one]; apply Setoid.refl'
-  mul_comm := by rintro ⟨a⟩ ⟨b⟩; apply Quotient.sound'; rw [mul_comm]; apply Setoid.refl'
-  mul_le_mul_left := by
-    rintro ⟨a⟩ ⟨b⟩ ⟨c, rfl⟩ ⟨d⟩
-    use c; simp only [Algebra.smul_def]; ring
-  zero_mul := by rintro ⟨a⟩; apply Quotient.sound'; rw [zero_mul]; apply Setoid.refl'
-  mul_zero := by rintro ⟨a⟩; apply Quotient.sound'; rw [mul_zero]; apply Setoid.refl'
-  zero_le_one := ⟨0, by rw [zero_smul]⟩
-  exists_pair_ne := by
-    use 0, 1
-    intro c; obtain ⟨d, hd⟩ := Quotient.exact' c
-    apply_fun fun t => d⁻¹ • t at hd
-    simp only [inv_smul_smul, smul_zero, one_ne_zero] at hd
-  inv_zero := by apply Quotient.sound'; rw [inv_zero]; apply Setoid.refl'
-  mul_inv_cancel := by
-    rintro ⟨a⟩ ha
-    apply Quotient.sound'
-    use 1
-    simp only [one_smul, ne_eq]
-    apply (mul_inv_cancel _).symm
-    contrapose ha
-    simp only [Classical.not_not] at ha ⊢
-    rw [ha]
-    rfl
+    LinearOrderedCommGroupWithZero (ValueGroup A K) :=
+  { linearOrder .. with
+    mul_assoc := by rintro ⟨a⟩ ⟨b⟩ ⟨c⟩; apply Quotient.sound'; rw [mul_assoc]; apply Setoid.refl'
+    one_mul := by rintro ⟨a⟩; apply Quotient.sound'; rw [one_mul]; apply Setoid.refl'
+    mul_one := by rintro ⟨a⟩; apply Quotient.sound'; rw [mul_one]; apply Setoid.refl'
+    mul_comm := by rintro ⟨a⟩ ⟨b⟩; apply Quotient.sound'; rw [mul_comm]; apply Setoid.refl'
+    mul_le_mul_left := by
+      rintro ⟨a⟩ ⟨b⟩ ⟨c, rfl⟩ ⟨d⟩
+      use c; simp only [Algebra.smul_def]; ring
+    zero_mul := by rintro ⟨a⟩; apply Quotient.sound'; rw [zero_mul]; apply Setoid.refl'
+    mul_zero := by rintro ⟨a⟩; apply Quotient.sound'; rw [mul_zero]; apply Setoid.refl'
+    zero_le_one := ⟨0, by rw [zero_smul]⟩
+    exists_pair_ne := by
+      use 0, 1
+      intro c; obtain ⟨d, hd⟩ := Quotient.exact' c
+      apply_fun fun t => d⁻¹ • t at hd
+      simp only [inv_smul_smul, smul_zero, one_ne_zero] at hd
+    inv_zero := by apply Quotient.sound'; rw [inv_zero]; apply Setoid.refl'
+    mul_inv_cancel := by
+      rintro ⟨a⟩ ha
+      apply Quotient.sound'
+      use 1
+      simp only [one_smul, ne_eq]
+      apply (mul_inv_cancel _).symm
+      contrapose ha
+      simp only [Classical.not_not] at ha ⊢
+      rw [ha]
+      rfl }
 
 /-- Any valuation ring induces a valuation on its fraction field. -/
 def valuation : Valuation K (ValueGroup A K) where
chore: add missing hypothesis names to by_cases (#8533)

I've also got a change to make this required, but I'd like to land this first.

Diff
@@ -428,7 +428,7 @@ variable (K : Type u) [Field K]
 instance (priority := 100) of_field : ValuationRing K := by
   constructor
   intro a b
-  by_cases b = 0
+  by_cases h : b = 0
   · use 0; left; simp [h]
   · use a * b⁻¹; right; field_simp; rw [mul_comm]
 #align valuation_ring.of_field ValuationRing.of_field
chore: only four spaces for subsequent lines (#7286)

Co-authored-by: Moritz Firsching <firsching@google.com>

Diff
@@ -45,7 +45,7 @@ class ValuationRing (A : Type u) [CommRing A] [IsDomain A] : Prop where
 
 -- Porting note: this lemma is needed since infer kinds are unsupported in Lean 4
 lemma ValuationRing.cond {A : Type u} [CommRing A] [IsDomain A] [ValuationRing A] (a b : A) :
-  ∃ c : A, a * c = b ∨ b * c = a := @ValuationRing.cond' A _ _ _ _ _
+    ∃ c : A, a * c = b ∨ b * c = a := @ValuationRing.cond' A _ _ _ _ _
 
 namespace ValuationRing
 
chore: drop MulZeroClass. in mul_zero/zero_mul (#6682)

Search&replace MulZeroClass.mul_zero -> mul_zero, MulZeroClass.zero_mul -> zero_mul.

These were introduced by Mathport, as the full name of mul_zero is actually MulZeroClass.mul_zero (it's exported with the short name).

Diff
@@ -154,8 +154,8 @@ noncomputable instance linearOrderedCommGroupWithZero :
   mul_le_mul_left := by
     rintro ⟨a⟩ ⟨b⟩ ⟨c, rfl⟩ ⟨d⟩
     use c; simp only [Algebra.smul_def]; ring
-  zero_mul := by rintro ⟨a⟩; apply Quotient.sound'; rw [MulZeroClass.zero_mul]; apply Setoid.refl'
-  mul_zero := by rintro ⟨a⟩; apply Quotient.sound'; rw [MulZeroClass.mul_zero]; apply Setoid.refl'
+  zero_mul := by rintro ⟨a⟩; apply Quotient.sound'; rw [zero_mul]; apply Setoid.refl'
+  mul_zero := by rintro ⟨a⟩; apply Quotient.sound'; rw [mul_zero]; apply Setoid.refl'
   zero_le_one := ⟨0, by rw [zero_smul]⟩
   exists_pair_ne := by
     use 0, 1
@@ -325,8 +325,8 @@ theorem iff_isInteger_or_isInteger :
   · intro H
     constructor
     intro a b
-    by_cases ha : a = 0; · subst ha; exact ⟨0, Or.inr <| MulZeroClass.mul_zero b⟩
-    by_cases hb : b = 0; · subst hb; exact ⟨0, Or.inl <| MulZeroClass.mul_zero a⟩
+    by_cases ha : a = 0; · subst ha; exact ⟨0, Or.inr <| mul_zero b⟩
+    by_cases hb : b = 0; · subst hb; exact ⟨0, Or.inl <| mul_zero a⟩
     replace ha := (map_ne_zero_iff _ (IsFractionRing.injective R K)).mpr ha
     replace hb := (map_ne_zero_iff _ (IsFractionRing.injective R K)).mpr hb
     obtain ⟨c, e⟩ | ⟨c, e⟩ := H (algebraMap R K a / algebraMap R K b)
chore: banish Type _ and Sort _ (#6499)

We remove all possible occurences of Type _ and Sort _ in favor of Type* and Sort*.

This has nice performance benefits.

Diff
@@ -278,7 +278,7 @@ end
 
 section
 
-variable {R : Type _} [CommRing R] [IsDomain R] {K : Type _}
+variable {R : Type*} [CommRing R] [IsDomain R] {K : Type*}
 
 variable [Field K] [Algebra R K] [IsFractionRing R K]
 
@@ -392,7 +392,7 @@ protected theorem tFAE (R : Type u) [CommRing R] [IsDomain R] :
 
 end
 
-theorem _root_.Function.Surjective.valuationRing {R S : Type _} [CommRing R] [IsDomain R]
+theorem _root_.Function.Surjective.valuationRing {R S : Type*} [CommRing R] [IsDomain R]
     [ValuationRing R] [CommRing S] [IsDomain S] (f : R →+* S) (hf : Function.Surjective f) :
     ValuationRing S :=
   ⟨fun a b => by
chore: script to replace headers with #align_import statements (#5979)

Open in Gitpod

Co-authored-by: Eric Wieser <wieser.eric@gmail.com> Co-authored-by: Scott Morrison <scott.morrison@gmail.com>

Diff
@@ -2,11 +2,6 @@
 Copyright (c) 2022 Adam Topaz. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Adam Topaz
-
-! This file was ported from Lean 3 source module ring_theory.valuation.valuation_ring
-! leanprover-community/mathlib commit c163ec99dfc664628ca15d215fce0a5b9c265b68
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
 -/
 import Mathlib.RingTheory.Valuation.Integers
 import Mathlib.RingTheory.Ideal.LocalRing
@@ -16,6 +11,8 @@ import Mathlib.RingTheory.DiscreteValuationRing.Basic
 import Mathlib.RingTheory.Bezout
 import Mathlib.Tactic.FieldSimp
 
+#align_import ring_theory.valuation.valuation_ring from "leanprover-community/mathlib"@"c163ec99dfc664628ca15d215fce0a5b9c265b68"
+
 /-!
 # Valuation Rings
 
chore: cleanup whitespace (#5988)

Grepping for [^ .:{-] [^ :] and reviewing the results. Once I started I couldn't stop. :-)

Co-authored-by: Scott Morrison <scott.morrison@gmail.com>

Diff
@@ -131,7 +131,7 @@ protected theorem le_total (a b : ValueGroup A K) : a ≤ b ∨ b ≤ a := by
 -- into two parts
 noncomputable instance : LinearOrder (ValueGroup A K) where
   le_refl := by rintro ⟨⟩; use 1; rw [one_smul]
-  le_trans :=  by rintro ⟨a⟩ ⟨b⟩ ⟨c⟩ ⟨e, rfl⟩ ⟨f, rfl⟩; use e * f; rw [mul_smul]
+  le_trans := by rintro ⟨a⟩ ⟨b⟩ ⟨c⟩ ⟨e, rfl⟩ ⟨f, rfl⟩; use e * f; rw [mul_smul]
   le_antisymm := by
     rintro ⟨a⟩ ⟨b⟩ ⟨e, rfl⟩ ⟨f, hf⟩
     by_cases hb : b = 0; · simp [hb]
feat: port RingTheory.Valuation.ValuationSubring (#4791)

Co-authored-by: Moritz Firsching <firsching@google.com> Co-authored-by: Ruben Van de Velde <65514131+Ruben-VandeVelde@users.noreply.github.com> Co-authored-by: Xavier-François Roblot <46200072+xroblot@users.noreply.github.com>

Diff
@@ -148,7 +148,8 @@ noncomputable instance : LinearOrder (ValueGroup A K) where
   le_total := ValuationRing.le_total _ _
   decidableLE := by classical infer_instance
 
-noncomputable instance : LinearOrderedCommGroupWithZero (ValueGroup A K) where
+noncomputable instance linearOrderedCommGroupWithZero :
+    LinearOrderedCommGroupWithZero (ValueGroup A K) where
   mul_assoc := by rintro ⟨a⟩ ⟨b⟩ ⟨c⟩; apply Quotient.sound'; rw [mul_assoc]; apply Setoid.refl'
   one_mul := by rintro ⟨a⟩; apply Quotient.sound'; rw [one_mul]; apply Setoid.refl'
   mul_one := by rintro ⟨a⟩; apply Quotient.sound'; rw [mul_one]; apply Setoid.refl'
@@ -247,7 +248,7 @@ section
 
 variable (A : Type u) [CommRing A] [IsDomain A] [ValuationRing A]
 
-instance (priority := 100) : LocalRing A :=
+instance (priority := 100) localRing : LocalRing A :=
   LocalRing.of_isUnit_or_isUnit_one_sub_self
     (by
       intro a
feat: port RingTheory.Valuation.ValuationRing (#4720)

Dependencies 10 + 642

643 files ported (98.5%)
267320 lines ported (98.7%)
Show graph

The unported dependencies are