l3lab/ntp-mathlib huggingface dataset:
/-- 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
    (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; 

Proof state:
case a
A : Type u
inst✝⁵ : CommRing A
K : Type v
inst✝⁴ : Field K
inst✝³ : Algebra A K
inst✝² : IsDomain A
inst✝¹ : ValuationRing A
inst✝ : IsFractionRing A K
x✝¹ x✝ : A
⊢ ↑((fun a => { val := (algebraMap A K) a, property := (_ : (algebraMap A K) a ∈ Valuation.integer (valuation A K)) })
        (x✝¹ * x✝)) =
    ↑((fun a => { val := (algebraMap A K) a, property := (_ : (algebraMap A K) a ∈ Valuation.integer (valuation A K)) })
          x✝¹ *
        (fun a =>
            { val := (algebraMap A K) a, property := (_ : (algebraMap A K) a ∈ Valuation.integer (valuation A K)) })
          x✝)

Next tactic:
exact (algebraMap A K).map_mul _ _
/-- 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
    (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 

Proof state:
A : Type u
inst✝⁵ : CommRing A
K : Type v
inst✝⁴ : Field K
inst✝³ : Algebra A K
inst✝² : IsDomain A
inst✝¹ : ValuationRing A
inst✝ : IsFractionRing A K
⊢ MulHom.toFun
      {
        toFun := fun a =>
          { val := (algebraMap A K) a, property := (_ : (algebraMap A K) a ∈ Valuation.integer (valuation A K)) },
        map_mul' :=
          (_ :
            ∀ (x x_1 : A),
              (fun a =>
                    { val := (algebraMap A K) a,
                      property := (_ : (algebraMap A K) a ∈ Valuation.integer (valuation A K)) })
                  (x * x_1) =
                (fun a =>
                      { val := (algebraMap A K) a,
                        property := (_ : (algebraMap A K) a ∈ Valuation.integer (valuation A K)) })
                    x *
                  (fun a =>
                      { val := (algebraMap A K) a,
                        property := (_ : (algebraMap A K) a ∈ Valuation.integer (valuation A K)) })
                    x_1) }
      0 =
    0

Next tactic:
ext1
/-- 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
    (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; 

Proof state:
case a
A : Type u
inst✝⁵ : CommRing A
K : Type v
inst✝⁴ : Field K
inst✝³ : Algebra A K
inst✝² : IsDomain A
inst✝¹ : ValuationRing A
inst✝ : IsFractionRing A K
⊢ ↑(MulHom.toFun
        {
          toFun := fun a =>
            { val := (algebraMap A K) a, property := (_ : (algebraMap A K) a ∈ Valuation.integer (valuation A K)) },
          map_mul' :=
            (_ :
              ∀ (x x_1 : A),
                (fun a =>
                      { val := (algebraMap A K) a,
                        property := (_ : (algebraMap A K) a ∈ Valuation.integer (valuation A K)) })
                    (x * x_1) =
                  (fun a =>
                        { val := (algebraMap A K) a,
                          property := (_ : (algebraMap A K) a ∈ Valuation.integer (valuation A K)) })
                      x *
                    (fun a =>
                        { val := (algebraMap A K) a,
                          property := (_ : (algebraMap A K) a ∈ Valuation.integer (valuation A K)) })
                      x_1) }
        0) =
    ↑0

Next tactic:
exact (algebraMap A K).map_zero
theorem range_algebraMap_eq : (valuation A K).integer = (algebraMap A K).range := by
  

Proof state:
A : Type u
inst✝⁵ : CommRing A
K : Type v
inst✝⁴ : Field K
inst✝³ : Algebra A K
inst✝² : IsDomain A
inst✝¹ : ValuationRing A
inst✝ : IsFractionRing A K
⊢ Valuation.integer (valuation A K) = RingHom.range (algebraMap A K)

Next tactic:
ext
theorem range_algebraMap_eq : (valuation A K).integer = (algebraMap A K).range := by
  ext; 

Proof state:
case h
A : Type u
inst✝⁵ : CommRing A
K : Type v
inst✝⁴ : Field K
inst✝³ : Algebra A K
inst✝² : IsDomain A
inst✝¹ : ValuationRing A
inst✝ : IsFractionRing A K
x✝ : K
⊢ x✝ ∈ Valuation.integer (valuation A K) ↔ x✝ ∈ RingHom.range (algebraMap A K)

Next tactic:
exact mem_integer_iff _ _ _
instance (priority := 100) localRing : LocalRing A :=
  LocalRing.of_isUnit_or_isUnit_one_sub_self
    (by
      

Proof state:
A : Type u
inst✝² : CommRing A
inst✝¹ : IsDomain A
inst✝ : ValuationRing A
⊢ ∀ (a : A), IsUnit a ∨ IsUnit (1 - a)

Next tactic:
intro a
instance (priority := 100) localRing : LocalRing A :=
  LocalRing.of_isUnit_or_isUnit_one_sub_self
    (by
      intro a
      

Proof state:
A : Type u
inst✝² : CommRing A
inst✝¹ : IsDomain A
inst✝ : ValuationRing A
a : A
⊢ IsUnit a ∨ IsUnit (1 - a)

Next tactic:
obtain ⟨c, h | h⟩ := ValuationRing.cond a (1 - a)
instance (priority := 100) localRing : LocalRing A :=
  LocalRing.of_isUnit_or_isUnit_one_sub_self
    (by
      intro a
      obtain ⟨c, h | h⟩ := ValuationRing.cond a (1 - a)
      · 

Proof state:
case intro.inl
A : Type u
inst✝² : CommRing A
inst✝¹ : IsDomain A
inst✝ : ValuationRing A
a c : A
h : a * c = 1 - a
⊢ IsUnit a ∨ IsUnit (1 - a)

Next tactic:
left
instance (priority := 100) localRing : LocalRing A :=
  LocalRing.of_isUnit_or_isUnit_one_sub_self
    (by
      intro a
      obtain ⟨c, h | h⟩ := ValuationRing.cond a (1 - a)
      · left
        

Proof state:
case intro.inl.h
A : Type u
inst✝² : CommRing A
inst✝¹ : IsDomain A
inst✝ : ValuationRing A
a c : A
h : a * c = 1 - a
⊢ IsUnit a

Next tactic:
apply isUnit_of_mul_eq_one _ (c + 1)
instance (priority := 100) localRing : LocalRing A :=
  LocalRing.of_isUnit_or_isUnit_one_sub_self
    (by
      intro a
      obtain ⟨c, h | h⟩ := ValuationRing.cond a (1 - a)
      · left
        apply isUnit_of_mul_eq_one _ (c + 1)
        

Proof state:
case intro.inl.h
A : Type u
inst✝² : CommRing A
inst✝¹ : IsDomain A
inst✝ : ValuationRing A
a c : A
h : a * c = 1 - a
⊢ a * (c + 1) = 1

Next tactic:
simp [mul_add, h]
instance (priority := 100) localRing : LocalRing A :=
  LocalRing.of_isUnit_or_isUnit_one_sub_self
    (by
      intro a
      obtain ⟨c, h | h⟩ := ValuationRing.cond a (1 - a)
      · left
        apply isUnit_of_mul_eq_one _ (c + 1)
        simp [mul_add, h]
      · 

Proof state:
case intro.inr
A : Type u
inst✝² : CommRing A
inst✝¹ : IsDomain A
inst✝ : ValuationRing A
a c : A
h : (1 - a) * c = a
⊢ IsUnit a ∨ IsUnit (1 - a)

Next tactic:
right
instance (priority := 100) localRing : LocalRing A :=
  LocalRing.of_isUnit_or_isUnit_one_sub_self
    (by
      intro a
      obtain ⟨c, h | h⟩ := ValuationRing.cond a (1 - a)
      · left
        apply isUnit_of_mul_eq_one _ (c + 1)
        simp [mul_add, h]
      · right
        

Proof state:
case intro.inr.h
A : Type u
inst✝² : CommRing A
inst✝¹ : IsDomain A
inst✝ : ValuationRing A
a c : A
h : (1 - a) * c = a
⊢ IsUnit (1 - a)

Next tactic:
apply isUnit_of_mul_eq_one _ (c + 1)
instance (priority := 100) localRing : LocalRing A :=
  LocalRing.of_isUnit_or_isUnit_one_sub_self
    (by
      intro a
      obtain ⟨c, h | h⟩ := ValuationRing.cond a (1 - a)
      · left
        apply isUnit_of_mul_eq_one _ (c + 1)
        simp [mul_add, h]
      · right
        apply isUnit_of_mul_eq_one _ (c + 1)
        

Proof state:
case intro.inr.h
A : Type u
inst✝² : CommRing A
inst✝¹ : IsDomain A
inst✝ : ValuationRing A
a c : A
h : (1 - a) * c = a
⊢ (1 - a) * (c + 1) = 1

Next tactic:
simp [mul_add, h]
instance [DecidableRel ((· ≤ ·) : Ideal A → Ideal A → Prop)] : LinearOrder (Ideal A) :=
  { (inferInstance : CompleteLattice (Ideal A)) with
    le_total := by
      

Proof state:
A : Type u
inst✝³ : CommRing A
inst✝² : IsDomain A
inst✝¹ : ValuationRing A
inst✝ : DecidableRel fun x x_1 => x ≤ x_1
src✝ : CompleteLattice (Ideal A) := inferInstance
⊢ ∀ (a b : Ideal A), a ≤ b ∨ b ≤ a

Next tactic:
intro α β
instance [DecidableRel ((· ≤ ·) : Ideal A → Ideal A → Prop)] : LinearOrder (Ideal A) :=
  { (inferInstance : CompleteLattice (Ideal A)) with
    le_total := by
      intro α β
      

Proof state:
A : Type u
inst✝³ : CommRing A
inst✝² : IsDomain A
inst✝¹ : ValuationRing A
inst✝ : DecidableRel fun x x_1 => x ≤ x_1
src✝ : CompleteLattice (Ideal A) := inferInstance
α β : Ideal A
⊢ α ≤ β ∨ β ≤ α

Next tactic:
by_cases h : α ≤ β
instance [DecidableRel ((· ≤ ·) : Ideal A → Ideal A → Prop)] : LinearOrder (Ideal A) :=
  { (inferInstance : CompleteLattice (Ideal A)) with
    le_total := by
      intro α β
      by_cases h : α ≤ β; · 

Proof state:
case pos
A : Type u
inst✝³ : CommRing A
inst✝² : IsDomain A
inst✝¹ : ValuationRing A
inst✝ : DecidableRel fun x x_1 => x ≤ x_1
src✝ : CompleteLattice (Ideal A) := inferInstance
α β : Ideal A
h : α ≤ β
⊢ α ≤ β ∨ β ≤ α

Next tactic:
exact Or.inl h
instance [DecidableRel ((· ≤ ·) : Ideal A → Ideal A → Prop)] : LinearOrder (Ideal A) :=
  { (inferInstance : CompleteLattice (Ideal A)) with
    le_total := by
      intro α β
      by_cases h : α ≤ β; · exact Or.inl h
      

Proof state:
case neg
A : Type u
inst✝³ : CommRing A
inst✝² : IsDomain A
inst✝¹ : ValuationRing A
inst✝ : DecidableRel fun x x_1 => x ≤ x_1
src✝ : CompleteLattice (Ideal A) := inferInstance
α β : Ideal A
h : ¬α ≤ β
⊢ α ≤ β ∨ β ≤ α

Next tactic:
erw [not_forall] at h
instance [DecidableRel ((· ≤ ·) : Ideal A → Ideal A → Prop)] : LinearOrder (Ideal A) :=
  { (inferInstance : CompleteLattice (Ideal A)) with
    le_total := by
      intro α β
      by_cases h : α ≤ β; · exact Or.inl h
      erw [not_forall] at h
      

Proof state:
case neg
A : Type u
inst✝³ : CommRing A
inst✝² : IsDomain A
inst✝¹ : ValuationRing A
inst✝ : DecidableRel fun x x_1 => x ≤ x_1
src✝ : CompleteLattice (Ideal A) := inferInstance
α β : Ideal A
h : ∃ x, ¬(x ∈ α → x ∈ β)
⊢ α ≤ β ∨ β ≤ α

Next tactic:
push_neg at h
instance [DecidableRel ((· ≤ ·) : Ideal A → Ideal A → Prop)] : LinearOrder (Ideal A) :=
  { (inferInstance : CompleteLattice (Ideal A)) with
    le_total := by
      intro α β
      by_cases h : α ≤ β; · exact Or.inl h
      erw [not_forall] at h
      push_neg at h
      

Proof state:
case neg
A : Type u
inst✝³ : CommRing A
inst✝² : IsDomain A
inst✝¹ : ValuationRing A
inst✝ : DecidableRel fun x x_1 => x ≤ x_1
src✝ : CompleteLattice (Ideal A) := inferInstance
α β : Ideal A
h : ∃ x ∈ α, x ∉ β
⊢ α ≤ β ∨ β ≤ α

Next tactic:
obtain ⟨a, h₁, h₂⟩ := h
instance [DecidableRel ((· ≤ ·) : Ideal A → Ideal A → Prop)] : LinearOrder (Ideal A) :=
  { (inferInstance : CompleteLattice (Ideal A)) with
    le_total := by
      intro α β
      by_cases h : α ≤ β; · exact Or.inl h
      erw [not_forall] at h
      push_neg at h
      obtain ⟨a, h₁, h₂⟩ := h
      

Proof state:
case neg.intro.intro
A : Type u
inst✝³ : CommRing A
inst✝² : IsDomain A
inst✝¹ : ValuationRing A
inst✝ : DecidableRel fun x x_1 => x ≤ x_1
src✝ : CompleteLattice (Ideal A) := inferInstance
α β : Ideal A
a : A
h₁ : a ∈ α
h₂ : a ∉ β
⊢ α ≤ β ∨ β ≤ α

Next tactic:
right
instance [DecidableRel ((· ≤ ·) : Ideal A → Ideal A → Prop)] : LinearOrder (Ideal A) :=
  { (inferInstance : CompleteLattice (Ideal A)) with
    le_total := by
      intro α β
      by_cases h : α ≤ β; · exact Or.inl h
      erw [not_forall] at h
      push_neg at h
      obtain ⟨a, h₁, h₂⟩ := h
      right
      

Proof state:
case neg.intro.intro.h
A : Type u
inst✝³ : CommRing A
inst✝² : IsDomain A
inst✝¹ : ValuationRing A
inst✝ : DecidableRel fun x x_1 => x ≤ x_1
src✝ : CompleteLattice (Ideal A) := inferInstance
α β : Ideal A
a : A
h₁ : a ∈ α
h₂ : a ∉ β
⊢ β ≤ α

Next tactic:
intro b hb
instance [DecidableRel ((· ≤ ·) : Ideal A → Ideal A → Prop)] : LinearOrder (Ideal A) :=
  { (inferInstance : CompleteLattice (Ideal A)) with
    le_total := by
      intro α β
      by_cases h : α ≤ β; · exact Or.inl h
      erw [not_forall] at h
      push_neg at h
      obtain ⟨a, h₁, h₂⟩ := h
      right
      intro b hb
      

Proof state:
case neg.intro.intro.h
A : Type u
inst✝³ : CommRing A
inst✝² : IsDomain A
inst✝¹ : ValuationRing A
inst✝ : DecidableRel fun x x_1 => x ≤ x_1
src✝ : CompleteLattice (Ideal A) := inferInstance
α β : Ideal A
a : A
h₁ : a ∈ α
h₂ : a ∉ β
b : A
hb : b ∈ β
⊢ b ∈ α

Next tactic:
obtain ⟨c, h | h⟩ := ValuationRing.cond a b
instance [DecidableRel ((· ≤ ·) : Ideal A → Ideal A → Prop)] : LinearOrder (Ideal A) :=
  { (inferInstance : CompleteLattice (Ideal A)) with
    le_total := by
      intro α β
      by_cases h : α ≤ β; · exact Or.inl h
      erw [not_forall] at h
      push_neg at h
      obtain ⟨a, h₁, h₂⟩ := h
      right
      intro b hb
      obtain ⟨c, h | h⟩ := ValuationRing.cond a b
      · 

Proof state:
case neg.intro.intro.h.intro.inl
A : Type u
inst✝³ : CommRing A
inst✝² : IsDomain A
inst✝¹ : ValuationRing A
inst✝ : DecidableRel fun x x_1 => x ≤ x_1
src✝ : CompleteLattice (Ideal A) := inferInstance
α β : Ideal A
a : A
h₁ : a ∈ α
h₂ : a ∉ β
b : A
hb : b ∈ β
c : A
h : a * c = b
⊢ b ∈ α

Next tactic:
rw [← h]
instance [DecidableRel ((· ≤ ·) : Ideal A → Ideal A → Prop)] : LinearOrder (Ideal A) :=
  { (inferInstance : CompleteLattice (Ideal A)) with
    le_total := by
      intro α β
      by_cases h : α ≤ β; · exact Or.inl h
      erw [not_forall] at h
      push_neg at h
      obtain ⟨a, h₁, h₂⟩ := h
      right
      intro b hb
      obtain ⟨c, h | h⟩ := ValuationRing.cond a b
      · rw [← h]
        

Proof state:
case neg.intro.intro.h.intro.inl
A : Type u
inst✝³ : CommRing A
inst✝² : IsDomain A
inst✝¹ : ValuationRing A
inst✝ : DecidableRel fun x x_1 => x ≤ x_1
src✝ : CompleteLattice (Ideal A) := inferInstance
α β : Ideal A
a : A
h₁ : a ∈ α
h₂ : a ∉ β
b : A
hb : b ∈ β
c : A
h : a * c = b
⊢ a * c ∈ α

Next tactic:
exact Ideal.mul_mem_right _ _ h₁
instance [DecidableRel ((· ≤ ·) : Ideal A → Ideal A → Prop)] : LinearOrder (Ideal A) :=
  { (inferInstance : CompleteLattice (Ideal A)) with
    le_total := by
      intro α β
      by_cases h : α ≤ β; · exact Or.inl h
      erw [not_forall] at h
      push_neg at h
      obtain ⟨a, h₁, h₂⟩ := h
      right
      intro b hb
      obtain ⟨c, h | h⟩ := ValuationRing.cond a b
      · rw [← h]
        exact Ideal.mul_mem_right _ _ h₁
      · 

Proof state:
case neg.intro.intro.h.intro.inr
A : Type u
inst✝³ : CommRing A
inst✝² : IsDomain A
inst✝¹ : ValuationRing A
inst✝ : DecidableRel fun x x_1 => x ≤ x_1
src✝ : CompleteLattice (Ideal A) := inferInstance
α β : Ideal A
a : A
h₁ : a ∈ α
h₂ : a ∉ β
b : A
hb : b ∈ β
c : A
h : b * c = a
⊢ b ∈ α

Next tactic:
exfalso
instance [DecidableRel ((· ≤ ·) : Ideal A → Ideal A → Prop)] : LinearOrder (Ideal A) :=
  { (inferInstance : CompleteLattice (Ideal A)) with
    le_total := by
      intro α β
      by_cases h : α ≤ β; · exact Or.inl h
      erw [not_forall] at h
      push_neg at h
      obtain ⟨a, h₁, h₂⟩ := h
      right
      intro b hb
      obtain ⟨c, h | h⟩ := ValuationRing.cond a b
      · rw [← h]
        exact Ideal.mul_mem_right _ _ h₁
      · exfalso; 

Proof state:
case neg.intro.intro.h.intro.inr.h
A : Type u
inst✝³ : CommRing A
inst✝² : IsDomain A
inst✝¹ : ValuationRing A
inst✝ : DecidableRel fun x x_1 => x ≤ x_1
src✝ : CompleteLattice (Ideal A) := inferInstance
α β : Ideal A
a : A
h₁ : a ∈ α
h₂ : a ∉ β
b : A
hb : b ∈ β
c : A
h : b * c = a
⊢ False

Next tactic:
apply h₂
instance [DecidableRel ((· ≤ ·) : Ideal A → Ideal A → Prop)] : LinearOrder (Ideal A) :=
  { (inferInstance : CompleteLattice (Ideal A)) with
    le_total := by
      intro α β
      by_cases h : α ≤ β; · exact Or.inl h
      erw [not_forall] at h
      push_neg at h
      obtain ⟨a, h₁, h₂⟩ := h
      right
      intro b hb
      obtain ⟨c, h | h⟩ := ValuationRing.cond a b
      · rw [← h]
        exact Ideal.mul_mem_right _ _ h₁
      · exfalso; apply h₂; 

Proof state:
case neg.intro.intro.h.intro.inr.h
A : Type u
inst✝³ : CommRing A
inst✝² : IsDomain A
inst✝¹ : ValuationRing A
inst✝ : DecidableRel fun x x_1 => x ≤ x_1
src✝ : CompleteLattice (Ideal A) := inferInstance
α β : Ideal A
a : A
h₁ : a ∈ α
h₂ : a ∉ β
b : A
hb : b ∈ β
c : A
h : b * c = a
⊢ a ∈ β

Next tactic:
rw [← h]
instance [DecidableRel ((· ≤ ·) : Ideal A → Ideal A → Prop)] : LinearOrder (Ideal A) :=
  { (inferInstance : CompleteLattice (Ideal A)) with
    le_total := by
      intro α β
      by_cases h : α ≤ β; · exact Or.inl h
      erw [not_forall] at h
      push_neg at h
      obtain ⟨a, h₁, h₂⟩ := h
      right
      intro b hb
      obtain ⟨c, h | h⟩ := ValuationRing.cond a b
      · rw [← h]
        exact Ideal.mul_mem_right _ _ h₁
      · exfalso; apply h₂; rw [← h]
        

Proof state:
case neg.intro.intro.h.intro.inr.h
A : Type u
inst✝³ : CommRing A
inst✝² : IsDomain A
inst✝¹ : ValuationRing A
inst✝ : DecidableRel fun x x_1 => x ≤ x_1
src✝ : CompleteLattice (Ideal A) := inferInstance
α β : Ideal A
a : A
h₁ : a ∈ α
h₂ : a ∉ β
b : A
hb : b ∈ β
c : A
h : b * c = a
⊢ b * c ∈ β

Next tactic:
apply Ideal.mul_mem_right _ _ hb
theorem iff_dvd_total : ValuationRing R ↔ IsTotal R (· ∣ ·) := by
  

Proof state:
R : Type u_1
inst✝⁴ : CommRing R
inst✝³ : IsDomain R
K : Type u_2
inst✝² : Field K
inst✝¹ : Algebra R K
inst✝ : IsFractionRing R K
⊢ ValuationRing R ↔ IsTotal R fun x x_1 => x ∣ x_1

Next tactic:
classical
  refine ⟨fun H => ⟨fun a b => ?_⟩, fun H => ⟨fun a b => ?_⟩⟩
  · obtain ⟨c, rfl | rfl⟩ := ValuationRing.cond 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
  

Proof state:
R : Type u_1
inst✝⁴ : CommRing R
inst✝³ : IsDomain R
K : Type u_2
inst✝² : Field K
inst✝¹ : Algebra R K
inst✝ : IsFractionRing R K
⊢ ValuationRing R ↔ IsTotal R fun x x_1 => x ∣ x_1

Next tactic:
refine ⟨fun H => ⟨fun a b => ?_⟩, fun H => ⟨fun a b => ?_⟩⟩
theorem iff_dvd_total : ValuationRing R ↔ IsTotal R (· ∣ ·) := by
  classical
  refine ⟨fun H => ⟨fun a b => ?_⟩, fun H => ⟨fun a b => ?_⟩⟩
  · 

Proof state:
case refine_1
R : Type u_1
inst✝⁴ : CommRing R
inst✝³ : IsDomain R
K : Type u_2
inst✝² : Field K
inst✝¹ : Algebra R K
inst✝ : IsFractionRing R K
H : ValuationRing R
a b : R
⊢ a ∣ b ∨ b ∣ a

Next tactic:
obtain ⟨c, rfl | rfl⟩ := ValuationRing.cond a b
theorem iff_dvd_total : ValuationRing R ↔ IsTotal R (· ∣ ·) := by
  classical
  refine ⟨fun H => ⟨fun a b => ?_⟩, fun H => ⟨fun a b => ?_⟩⟩
  · obtain ⟨c, rfl | rfl⟩ := ValuationRing.cond a b <;> 

Proof state:
case refine_1.intro.inl
R : Type u_1
inst✝⁴ : CommRing R
inst✝³ : IsDomain R
K : Type u_2
inst✝² : Field K
inst✝¹ : Algebra R K
inst✝ : IsFractionRing R K
H : ValuationRing R
a c : R
⊢ a ∣ a * c ∨ a * c ∣ a

Next tactic:
simp
theorem iff_dvd_total : ValuationRing R ↔ IsTotal R (· ∣ ·) := by
  classical
  refine ⟨fun H => ⟨fun a b => ?_⟩, fun H => ⟨fun a b => ?_⟩⟩
  · obtain ⟨c, rfl | rfl⟩ := ValuationRing.cond a b <;> 

Proof state:
case refine_1.intro.inr
R : Type u_1
inst✝⁴ : CommRing R
inst✝³ : IsDomain R
K : Type u_2
inst✝² : Field K
inst✝¹ : Algebra R K
inst✝ : IsFractionRing R K
H : ValuationRing R
b c : R
⊢ b * c ∣ b ∨ b ∣ b * c

Next tactic:
simp
theorem iff_dvd_total : ValuationRing R ↔ IsTotal R (· ∣ ·) := by
  classical
  refine ⟨fun H => ⟨fun a b => ?_⟩, fun H => ⟨fun a b => ?_⟩⟩
  · obtain ⟨c, rfl | rfl⟩ := ValuationRing.cond a b <;> simp
  · 

Proof state:
case refine_2
R : Type u_1
inst✝⁴ : CommRing R
inst✝³ : IsDomain R
K : Type u_2
inst✝² : Field K
inst✝¹ : Algebra R K
inst✝ : IsFractionRing R K
H : IsTotal R fun x x_1 => x ∣ x_1
a b : R
⊢ ∃ c, a * c = b ∨ b * c = a

Next tactic:
obtain ⟨c, rfl⟩ | ⟨c, rfl⟩ := @IsTotal.total _ _ H a b
theorem iff_dvd_total : ValuationRing R ↔ IsTotal R (· ∣ ·) := by
  classical
  refine ⟨fun H => ⟨fun a b => ?_⟩, fun H => ⟨fun a b => ?_⟩⟩
  · obtain ⟨c, rfl | rfl⟩ := ValuationRing.cond a b <;> simp
  · obtain ⟨c, rfl⟩ | ⟨c, rfl⟩ := @IsTotal.total _ _ H a b <;> 

Proof state:
case refine_2.inl.intro
R : Type u_1
inst✝⁴ : CommRing R
inst✝³ : IsDomain R
K : Type u_2
inst✝² : Field K
inst✝¹ : Algebra R K
inst✝ : IsFractionRing R K
H : IsTotal R fun x x_1 => x ∣ x_1
a c : R
⊢ ∃ c_1, a * c_1 = a * c ∨ a * c * c_1 = a

Next tactic:
use c
theorem iff_dvd_total : ValuationRing R ↔ IsTotal R (· ∣ ·) := by
  classical
  refine ⟨fun H => ⟨fun a b => ?_⟩, fun H => ⟨fun a b => ?_⟩⟩
  · obtain ⟨c, rfl | rfl⟩ := ValuationRing.cond a b <;> simp
  · obtain ⟨c, rfl⟩ | ⟨c, rfl⟩ := @IsTotal.total _ _ H a b <;> 

Proof state:
case refine_2.inr.intro
R : Type u_1
inst✝⁴ : CommRing R
inst✝³ : IsDomain R
K : Type u_2
inst✝² : Field K
inst✝¹ : Algebra R K
inst✝ : IsFractionRing R K
H : IsTotal R fun x x_1 => x ∣ x_1
b c : R
⊢ ∃ c_1, b * c * c_1 = b ∨ b * c_1 = b * c

Next tactic:
use c
theorem iff_dvd_total : ValuationRing R ↔ IsTotal R (· ∣ ·) := by
  classical
  refine ⟨fun H => ⟨fun a b => ?_⟩, fun H => ⟨fun a b => ?_⟩⟩
  · obtain ⟨c, rfl | rfl⟩ := ValuationRing.cond a b <;> simp
  · obtain ⟨c, rfl⟩ | ⟨c, rfl⟩ := @IsTotal.total _ _ H a b <;> use c <;> 

Proof state:
case h
R : Type u_1
inst✝⁴ : CommRing R
inst✝³ : IsDomain R
K : Type u_2
inst✝² : Field K
inst✝¹ : Algebra R K
inst✝ : IsFractionRing R K
H : IsTotal R fun x x_1 => x ∣ x_1
a c : R
⊢ a * c = a * c ∨ a * c * c = a

Next tactic:
simp
theorem iff_dvd_total : ValuationRing R ↔ IsTotal R (· ∣ ·) := by
  classical
  refine ⟨fun H => ⟨fun a b => ?_⟩, fun H => ⟨fun a b => ?_⟩⟩
  · obtain ⟨c, rfl | rfl⟩ := ValuationRing.cond a b <;> simp
  · obtain ⟨c, rfl⟩ | ⟨c, rfl⟩ := @IsTotal.total _ _ H a b <;> use c <;> 

Proof state:
case h
R : Type u_1
inst✝⁴ : CommRing R
inst✝³ : IsDomain R
K : Type u_2
inst✝² : Field K
inst✝¹ : Algebra R K
inst✝ : IsFractionRing R K
H : IsTotal R fun x x_1 => x ∣ x_1
b c : R
⊢ b * c * c = b ∨ b * c = b * c

Next tactic:
simp
theorem iff_ideal_total : ValuationRing R ↔ IsTotal (Ideal R) (· ≤ ·) := by
  

Proof state:
R : Type u_1
inst✝⁴ : CommRing R
inst✝³ : IsDomain R
K : Type u_2
inst✝² : Field K
inst✝¹ : Algebra R K
inst✝ : IsFractionRing R K
⊢ ValuationRing R ↔ IsTotal (Ideal R) fun x x_1 => x ≤ x_1

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

Proof state:
R : Type u_1
inst✝⁴ : CommRing R
inst✝³ : IsDomain R
K : Type u_2
inst✝² : Field K
inst✝¹ : Algebra R K
inst✝ : IsFractionRing R K
⊢ ValuationRing R ↔ IsTotal (Ideal R) fun x x_1 => x ≤ x_1

Next tactic:
refine' ⟨fun _ => ⟨le_total⟩, fun H => iff_dvd_total.mpr ⟨fun a b => _⟩⟩
theorem iff_ideal_total : ValuationRing R ↔ IsTotal (Ideal R) (· ≤ ·) := by
  classical
  refine' ⟨fun _ => ⟨le_total⟩, fun H => iff_dvd_total.mpr ⟨fun a b => _⟩⟩
  

Proof state:
R : Type u_1
inst✝⁴ : CommRing R
inst✝³ : IsDomain R
K : Type u_2
inst✝² : Field K
inst✝¹ : Algebra R K
inst✝ : IsFractionRing R K
H : IsTotal (Ideal R) fun x x_1 => x ≤ x_1
a b : R
⊢ a ∣ b ∨ b ∣ a

Next tactic:
have := @IsTotal.total _ _ H (Ideal.span {a}) (Ideal.span {b})
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})
  

Proof state:
R : Type u_1
inst✝⁴ : CommRing R
inst✝³ : IsDomain R
K : Type u_2
inst✝² : Field K
inst✝¹ : Algebra R K
inst✝ : IsFractionRing R K
H : IsTotal (Ideal R) fun x x_1 => x ≤ x_1
a b : R
this : Ideal.span {a} ≤ Ideal.span {b} ∨ Ideal.span {b} ≤ Ideal.span {a}
⊢ a ∣ b ∨ b ∣ a

Next tactic:
simp_rw [Ideal.span_singleton_le_span_singleton] at this