l3lab/ntp-mathlib huggingface dataset:
/-- When `R` is a non-unital ring, to construct a `StarOrderedRing` instance it suffices to
show that the nonnegative elements are precisely those elements in the `AddSubmonoid` generated
by `star s * s` for `s : R`. -/
@[reducible]
def ofNonnegIff [NonUnitalRing R] [PartialOrder R] [StarRing R]
    (h_add : ∀ {x y : R}, x ≤ y → ∀ z, z + x ≤ z + y)
    (h_nonneg_iff : ∀ x : R, 0 ≤ x ↔ x ∈ AddSubmonoid.closure (Set.range fun s : R => star s * s)) :
    StarOrderedRing R where
  le_iff x y := by
    haveI : CovariantClass R R (· + ·) (· ≤ ·) := ⟨fun _ _ _ h => h_add h _⟩
    

Proof state:
R : Type u
inst✝² : NonUnitalRing R
inst✝¹ : PartialOrder R
inst✝ : StarRing R
h_add : ∀ {x y : R}, x ≤ y → ∀ (z : R), z + x ≤ z + y
h_nonneg_iff : ∀ (x : R), 0 ≤ x ↔ x ∈ AddSubmonoid.closure (Set.range fun s => star s * s)
x y : R
this : CovariantClass R R (fun x x_1 => x + x_1) fun x x_1 => x ≤ x_1
⊢ x ≤ y ↔ ∃ p ∈ AddSubmonoid.closure (Set.range fun s => star s * s), y = x + p

Next tactic:
simpa only [← sub_eq_iff_eq_add', sub_nonneg, exists_eq_right'] using h_nonneg_iff (y - x)
/-- When `R` is a non-unital ring, to construct a `StarOrderedRing` instance it suffices to
show that the nonnegative elements are precisely those elements of the form `star s * s`
for `s : R`.

This is provided for convenience because it holds in many common scenarios (e.g.,`ℝ`, `ℂ`, or
any C⋆-algebra), and obviates the hassle of `AddSubmonoid.closure_induction` when creating those
instances. -/
@[reducible]
def ofNonnegIff' [NonUnitalRing R] [PartialOrder R] [StarRing R]
    (h_add : ∀ {x y : R}, x ≤ y → ∀ z, z + x ≤ z + y)
    (h_nonneg_iff : ∀ x : R, 0 ≤ x ↔ ∃ s, x = star s * s) : StarOrderedRing R :=
  ofLEIff <| by
    

Proof state:
R : Type u
inst✝² : NonUnitalRing R
inst✝¹ : PartialOrder R
inst✝ : StarRing R
h_add : ∀ {x y : R}, x ≤ y → ∀ (z : R), z + x ≤ z + y
h_nonneg_iff : ∀ (x : R), 0 ≤ x ↔ ∃ s, x = star s * s
⊢ ∀ (x y : R), x ≤ y ↔ ∃ s, y = x + star s * s

Next tactic:
haveI : CovariantClass R R (· + ·) (· ≤ ·) := ⟨fun _ _ _ h => h_add h _⟩
/-- When `R` is a non-unital ring, to construct a `StarOrderedRing` instance it suffices to
show that the nonnegative elements are precisely those elements of the form `star s * s`
for `s : R`.

This is provided for convenience because it holds in many common scenarios (e.g.,`ℝ`, `ℂ`, or
any C⋆-algebra), and obviates the hassle of `AddSubmonoid.closure_induction` when creating those
instances. -/
@[reducible]
def ofNonnegIff' [NonUnitalRing R] [PartialOrder R] [StarRing R]
    (h_add : ∀ {x y : R}, x ≤ y → ∀ z, z + x ≤ z + y)
    (h_nonneg_iff : ∀ x : R, 0 ≤ x ↔ ∃ s, x = star s * s) : StarOrderedRing R :=
  ofLEIff <| by
    haveI : CovariantClass R R (· + ·) (· ≤ ·) := ⟨fun _ _ _ h => h_add h _⟩
    

Proof state:
R : Type u
inst✝² : NonUnitalRing R
inst✝¹ : PartialOrder R
inst✝ : StarRing R
h_add : ∀ {x y : R}, x ≤ y → ∀ (z : R), z + x ≤ z + y
h_nonneg_iff : ∀ (x : R), 0 ≤ x ↔ ∃ s, x = star s * s
this : CovariantClass R R (fun x x_1 => x + x_1) fun x x_1 => x ≤ x_1
⊢ ∀ (x y : R), x ≤ y ↔ ∃ s, y = x + star s * s

Next tactic:
simpa [sub_eq_iff_eq_add', sub_nonneg] using fun x y => h_nonneg_iff (y - x)
theorem nonneg_iff [NonUnitalSemiring R] [PartialOrder R] [StarOrderedRing R] {x : R} :
    0 ≤ x ↔ x ∈ AddSubmonoid.closure (Set.range fun s : R => star s * s) := by
  

Proof state:
R : Type u
inst✝² : NonUnitalSemiring R
inst✝¹ : PartialOrder R
inst✝ : StarOrderedRing R
x : R
⊢ 0 ≤ x ↔ x ∈ AddSubmonoid.closure (Set.range fun s => star s * s)

Next tactic:
simp only [le_iff, zero_add, exists_eq_right']
theorem mul_star_self_nonneg (r : R) : 0 ≤ r * star r := by
  

Proof state:
R : Type u
inst✝² : NonUnitalSemiring R
inst✝¹ : PartialOrder R
inst✝ : StarOrderedRing R
r : R
⊢ 0 ≤ r * star r

Next tactic:
simpa only [star_star] using star_mul_self_nonneg (star r)
theorem conjugate_nonneg {a : R} (ha : 0 ≤ a) (c : R) : 0 ≤ star c * a * c := by
  

Proof state:
R : Type u
inst✝² : NonUnitalSemiring R
inst✝¹ : PartialOrder R
inst✝ : StarOrderedRing R
a : R
ha : 0 ≤ a
c : R
⊢ 0 ≤ star c * a * c

Next tactic:
rw [StarOrderedRing.nonneg_iff] at ha
theorem conjugate_nonneg {a : R} (ha : 0 ≤ a) (c : R) : 0 ≤ star c * a * c := by
  rw [StarOrderedRing.nonneg_iff] at ha
  

Proof state:
R : Type u
inst✝² : NonUnitalSemiring R
inst✝¹ : PartialOrder R
inst✝ : StarOrderedRing R
a : R
ha : a ∈ AddSubmonoid.closure (Set.range fun s => star s * s)
c : R
⊢ 0 ≤ star c * a * c

Next tactic:
refine' AddSubmonoid.closure_induction ha (fun x hx => _)
    (by rw [mul_zero, zero_mul]) fun x y hx hy => _
theorem conjugate_nonneg {a : R} (ha : 0 ≤ a) (c : R) : 0 ≤ star c * a * c := by
  rw [StarOrderedRing.nonneg_iff] at ha
  refine' AddSubmonoid.closure_induction ha (fun x hx => _)
    (by 

Proof state:
R : Type u
inst✝² : NonUnitalSemiring R
inst✝¹ : PartialOrder R
inst✝ : StarOrderedRing R
a : R
ha : a ∈ AddSubmonoid.closure (Set.range fun s => star s * s)
c : R
⊢ 0 ≤ star c * 0 * c

Next tactic:
rw [mul_zero, zero_mul]
theorem conjugate_nonneg {a : R} (ha : 0 ≤ a) (c : R) : 0 ≤ star c * a * c := by
  rw [StarOrderedRing.nonneg_iff] at ha
  refine' AddSubmonoid.closure_induction ha (fun x hx => _)
    (by rw [mul_zero, zero_mul]) fun x y hx hy => _
  · 

Proof state:
case refine'_1
R : Type u
inst✝² : NonUnitalSemiring R
inst✝¹ : PartialOrder R
inst✝ : StarOrderedRing R
a : R
ha : a ∈ AddSubmonoid.closure (Set.range fun s => star s * s)
c x : R
hx : x ∈ Set.range fun s => star s * s
⊢ 0 ≤ star c * x * c

Next tactic:
obtain ⟨x, rfl⟩ := hx
theorem conjugate_nonneg {a : R} (ha : 0 ≤ a) (c : R) : 0 ≤ star c * a * c := by
  rw [StarOrderedRing.nonneg_iff] at ha
  refine' AddSubmonoid.closure_induction ha (fun x hx => _)
    (by rw [mul_zero, zero_mul]) fun x y hx hy => _
  · obtain ⟨x, rfl⟩ := hx
    

Proof state:
case refine'_1.intro
R : Type u
inst✝² : NonUnitalSemiring R
inst✝¹ : PartialOrder R
inst✝ : StarOrderedRing R
a : R
ha : a ∈ AddSubmonoid.closure (Set.range fun s => star s * s)
c x : R
⊢ 0 ≤ star c * (fun s => star s * s) x * c

Next tactic:
convert star_mul_self_nonneg (x * c) using 1
theorem conjugate_nonneg {a : R} (ha : 0 ≤ a) (c : R) : 0 ≤ star c * a * c := by
  rw [StarOrderedRing.nonneg_iff] at ha
  refine' AddSubmonoid.closure_induction ha (fun x hx => _)
    (by rw [mul_zero, zero_mul]) fun x y hx hy => _
  · obtain ⟨x, rfl⟩ := hx
    convert star_mul_self_nonneg (x * c) using 1
    

Proof state:
case h.e'_4
R : Type u
inst✝² : NonUnitalSemiring R
inst✝¹ : PartialOrder R
inst✝ : StarOrderedRing R
a : R
ha : a ∈ AddSubmonoid.closure (Set.range fun s => star s * s)
c x : R
⊢ star c * (fun s => star s * s) x * c = star (x * c) * (x * c)

Next tactic:
rw [star_mul, ← mul_assoc, mul_assoc _ _ c]
theorem conjugate_nonneg {a : R} (ha : 0 ≤ a) (c : R) : 0 ≤ star c * a * c := by
  rw [StarOrderedRing.nonneg_iff] at ha
  refine' AddSubmonoid.closure_induction ha (fun x hx => _)
    (by rw [mul_zero, zero_mul]) fun x y hx hy => _
  · obtain ⟨x, rfl⟩ := hx
    convert star_mul_self_nonneg (x * c) using 1
    rw [star_mul, ← mul_assoc, mul_assoc _ _ c]
  · 

Proof state:
case refine'_2
R : Type u
inst✝² : NonUnitalSemiring R
inst✝¹ : PartialOrder R
inst✝ : StarOrderedRing R
a : R
ha : a ∈ AddSubmonoid.closure (Set.range fun s => star s * s)
c x y : R
hx : 0 ≤ star c * x * c
hy : 0 ≤ star c * y * c
⊢ 0 ≤ star c * (x + y) * c

Next tactic:
calc
      0 ≤ star c * x * c + 0 := by rw [add_zero]; exact hx
      _ ≤ star c * x * c + star c * y * c := add_le_add_left hy _
      _ ≤ _ := by rw [mul_add, add_mul]
theorem conjugate_nonneg {a : R} (ha : 0 ≤ a) (c : R) : 0 ≤ star c * a * c := by
  rw [StarOrderedRing.nonneg_iff] at ha
  refine' AddSubmonoid.closure_induction ha (fun x hx => _)
    (by rw [mul_zero, zero_mul]) fun x y hx hy => _
  · obtain ⟨x, rfl⟩ := hx
    convert star_mul_self_nonneg (x * c) using 1
    rw [star_mul, ← mul_assoc, mul_assoc _ _ c]
  · calc
      0 ≤ star c * x * c + 0 := by 

Proof state:
R : Type u
inst✝² : NonUnitalSemiring R
inst✝¹ : PartialOrder R
inst✝ : StarOrderedRing R
a : R
ha : a ∈ AddSubmonoid.closure (Set.range fun s => star s * s)
c x y : R
hx : 0 ≤ star c * x * c
hy : 0 ≤ star c * y * c
⊢ 0 ≤ star c * x * c + 0

Next tactic:
rw [add_zero]
theorem conjugate_nonneg {a : R} (ha : 0 ≤ a) (c : R) : 0 ≤ star c * a * c := by
  rw [StarOrderedRing.nonneg_iff] at ha
  refine' AddSubmonoid.closure_induction ha (fun x hx => _)
    (by rw [mul_zero, zero_mul]) fun x y hx hy => _
  · obtain ⟨x, rfl⟩ := hx
    convert star_mul_self_nonneg (x * c) using 1
    rw [star_mul, ← mul_assoc, mul_assoc _ _ c]
  · calc
      0 ≤ star c * x * c + 0 := by rw [add_zero]; 

Proof state:
R : Type u
inst✝² : NonUnitalSemiring R
inst✝¹ : PartialOrder R
inst✝ : StarOrderedRing R
a : R
ha : a ∈ AddSubmonoid.closure (Set.range fun s => star s * s)
c x y : R
hx : 0 ≤ star c * x * c
hy : 0 ≤ star c * y * c
⊢ 0 ≤ star c * x * c

Next tactic:
exact hx
theorem conjugate_nonneg {a : R} (ha : 0 ≤ a) (c : R) : 0 ≤ star c * a * c := by
  rw [StarOrderedRing.nonneg_iff] at ha
  refine' AddSubmonoid.closure_induction ha (fun x hx => _)
    (by rw [mul_zero, zero_mul]) fun x y hx hy => _
  · obtain ⟨x, rfl⟩ := hx
    convert star_mul_self_nonneg (x * c) using 1
    rw [star_mul, ← mul_assoc, mul_assoc _ _ c]
  · calc
      0 ≤ star c * x * c + 0 := by rw [add_zero]; exact hx
      _ ≤ star c * x * c + star c * y * c := add_le_add_left hy _
      _ ≤ _ := by 

Proof state:
R : Type u
inst✝² : NonUnitalSemiring R
inst✝¹ : PartialOrder R
inst✝ : StarOrderedRing R
a : R
ha : a ∈ AddSubmonoid.closure (Set.range fun s => star s * s)
c x y : R
hx : 0 ≤ star c * x * c
hy : 0 ≤ star c * y * c
⊢ star c * x * c + star c * y * c ≤ star c * (x + y) * c

Next tactic:
rw [mul_add, add_mul]
theorem conjugate_nonneg' {a : R} (ha : 0 ≤ a) (c : R) : 0 ≤ c * a * star c := by
  

Proof state:
R : Type u
inst✝² : NonUnitalSemiring R
inst✝¹ : PartialOrder R
inst✝ : StarOrderedRing R
a : R
ha : 0 ≤ a
c : R
⊢ 0 ≤ c * a * star c

Next tactic:
simpa only [star_star] using conjugate_nonneg ha (star c)
theorem conjugate_le_conjugate {a b : R} (hab : a ≤ b) (c : R) :
    star c * a * c ≤ star c * b * c := by
  

Proof state:
R : Type u
inst✝² : NonUnitalSemiring R
inst✝¹ : PartialOrder R
inst✝ : StarOrderedRing R
a b : R
hab : a ≤ b
c : R
⊢ star c * a * c ≤ star c * b * c

Next tactic:
rw [StarOrderedRing.le_iff] at hab ⊢
theorem conjugate_le_conjugate {a b : R} (hab : a ≤ b) (c : R) :
    star c * a * c ≤ star c * b * c := by
  rw [StarOrderedRing.le_iff] at hab ⊢
  

Proof state:
R : Type u
inst✝² : NonUnitalSemiring R
inst✝¹ : PartialOrder R
inst✝ : StarOrderedRing R
a b : R
hab : ∃ p ∈ AddSubmonoid.closure (Set.range fun s => star s * s), b = a + p
c : R
⊢ ∃ p ∈ AddSubmonoid.closure (Set.range fun s => star s * s), star c * b * c = star c * a * c + p

Next tactic:
obtain ⟨p, hp, rfl⟩ := hab
theorem conjugate_le_conjugate {a b : R} (hab : a ≤ b) (c : R) :
    star c * a * c ≤ star c * b * c := by
  rw [StarOrderedRing.le_iff] at hab ⊢
  obtain ⟨p, hp, rfl⟩ := hab
  

Proof state:
case intro.intro
R : Type u
inst✝² : NonUnitalSemiring R
inst✝¹ : PartialOrder R
inst✝ : StarOrderedRing R
a c p : R
hp : p ∈ AddSubmonoid.closure (Set.range fun s => star s * s)
⊢ ∃ p_1 ∈ AddSubmonoid.closure (Set.range fun s => star s * s), star c * (a + p) * c = star c * a * c + p_1

Next tactic:
simp_rw [← StarOrderedRing.nonneg_iff] at hp ⊢
theorem conjugate_le_conjugate {a b : R} (hab : a ≤ b) (c : R) :
    star c * a * c ≤ star c * b * c := by
  rw [StarOrderedRing.le_iff] at hab ⊢
  obtain ⟨p, hp, rfl⟩ := hab
  simp_rw [← StarOrderedRing.nonneg_iff] at hp ⊢
  

Proof state:
case intro.intro
R : Type u
inst✝² : NonUnitalSemiring R
inst✝¹ : PartialOrder R
inst✝ : StarOrderedRing R
a c p : R
hp : 0 ≤ p
⊢ ∃ p_1, 0 ≤ p_1 ∧ star c * (a + p) * c = star c * a * c + p_1

Next tactic:
exact ⟨star c * p * c, conjugate_nonneg hp c, by simp only [add_mul, mul_add]⟩
theorem conjugate_le_conjugate {a b : R} (hab : a ≤ b) (c : R) :
    star c * a * c ≤ star c * b * c := by
  rw [StarOrderedRing.le_iff] at hab ⊢
  obtain ⟨p, hp, rfl⟩ := hab
  simp_rw [← StarOrderedRing.nonneg_iff] at hp ⊢
  exact ⟨star c * p * c, conjugate_nonneg hp c, by 

Proof state:
R : Type u
inst✝² : NonUnitalSemiring R
inst✝¹ : PartialOrder R
inst✝ : StarOrderedRing R
a c p : R
hp : 0 ≤ p
⊢ star c * (a + p) * c = star c * a * c + star c * p * c

Next tactic:
simp only [add_mul, mul_add]
theorem conjugate_le_conjugate' {a b : R} (hab : a ≤ b) (c : R) : c * a * star c ≤ c * b * star c :=
  by 

Proof state:
R : Type u
inst✝² : NonUnitalSemiring R
inst✝¹ : PartialOrder R
inst✝ : StarOrderedRing R
a b : R
hab : a ≤ b
c : R
⊢ c * a * star c ≤ c * b * star c

Next tactic:
simpa only [star_star] using conjugate_le_conjugate hab (star c)
@[simp]
lemma star_le_star_iff {x y : R} : star x ≤ star y ↔ x ≤ y := by
  

Proof state:
R : Type u
inst✝² : NonUnitalSemiring R
inst✝¹ : PartialOrder R
inst✝ : StarOrderedRing R
x y : R
⊢ star x ≤ star y ↔ x ≤ y

Next tactic:
suffices ∀ x y, x ≤ y → star x ≤ star y from
    ⟨by simpa only [star_star] using this (star x) (star y), this x y⟩
@[simp]
lemma star_le_star_iff {x y : R} : star x ≤ star y ↔ x ≤ y := by
  suffices ∀ x y, x ≤ y → star x ≤ star y from
    ⟨by 

Proof state:
R : Type u
inst✝² : NonUnitalSemiring R
inst✝¹ : PartialOrder R
inst✝ : StarOrderedRing R
x y : R
this : ∀ (x y : R), x ≤ y → star x ≤ star y
⊢ star x ≤ star y → x ≤ y

Next tactic:
simpa only [star_star] using this (star x) (star y)
@[simp]
lemma star_le_star_iff {x y : R} : star x ≤ star y ↔ x ≤ y := by
  suffices ∀ x y, x ≤ y → star x ≤ star y from
    ⟨by simpa only [star_star] using this (star x) (star y), this x y⟩
  

Proof state:
R : Type u
inst✝² : NonUnitalSemiring R
inst✝¹ : PartialOrder R
inst✝ : StarOrderedRing R
x y : R
⊢ ∀ (x y : R), x ≤ y → star x ≤ star y

Next tactic:
intro x y h
@[simp]
lemma star_le_star_iff {x y : R} : star x ≤ star y ↔ x ≤ y := by
  suffices ∀ x y, x ≤ y → star x ≤ star y from
    ⟨by simpa only [star_star] using this (star x) (star y), this x y⟩
  intro x y h
  

Proof state:
R : Type u
inst✝² : NonUnitalSemiring R
inst✝¹ : PartialOrder R
inst✝ : StarOrderedRing R
x✝ y✝ x y : R
h : x ≤ y
⊢ star x ≤ star y

Next tactic:
rw [StarOrderedRing.le_iff] at h ⊢
@[simp]
lemma star_le_star_iff {x y : R} : star x ≤ star y ↔ x ≤ y := by
  suffices ∀ x y, x ≤ y → star x ≤ star y from
    ⟨by simpa only [star_star] using this (star x) (star y), this x y⟩
  intro x y h
  rw [StarOrderedRing.le_iff] at h ⊢
  

Proof state:
R : Type u
inst✝² : NonUnitalSemiring R
inst✝¹ : PartialOrder R
inst✝ : StarOrderedRing R
x✝ y✝ x y : R
h : ∃ p ∈ AddSubmonoid.closure (Set.range fun s => star s * s), y = x + p
⊢ ∃ p ∈ AddSubmonoid.closure (Set.range fun s => star s * s), star y = star x + p

Next tactic:
obtain ⟨d, hd, rfl⟩ := h
@[simp]
lemma star_le_star_iff {x y : R} : star x ≤ star y ↔ x ≤ y := by
  suffices ∀ x y, x ≤ y → star x ≤ star y from
    ⟨by simpa only [star_star] using this (star x) (star y), this x y⟩
  intro x y h
  rw [StarOrderedRing.le_iff] at h ⊢
  obtain ⟨d, hd, rfl⟩ := h
  

Proof state:
case intro.intro
R : Type u
inst✝² : NonUnitalSemiring R
inst✝¹ : PartialOrder R
inst✝ : StarOrderedRing R
x✝ y x d : R
hd : d ∈ AddSubmonoid.closure (Set.range fun s => star s * s)
⊢ ∃ p ∈ AddSubmonoid.closure (Set.range fun s => star s * s), star (x + d) = star x + p

Next tactic:
refine ⟨starAddEquiv d, ?_, star_add _ _⟩
@[simp]
lemma star_le_star_iff {x y : R} : star x ≤ star y ↔ x ≤ y := by
  suffices ∀ x y, x ≤ y → star x ≤ star y from
    ⟨by simpa only [star_star] using this (star x) (star y), this x y⟩
  intro x y h
  rw [StarOrderedRing.le_iff] at h ⊢
  obtain ⟨d, hd, rfl⟩ := h
  refine ⟨starAddEquiv d, ?_, star_add _ _⟩
  

Proof state:
case intro.intro
R : Type u
inst✝² : NonUnitalSemiring R
inst✝¹ : PartialOrder R
inst✝ : StarOrderedRing R
x✝ y x d : R
hd : d ∈ AddSubmonoid.closure (Set.range fun s => star s * s)
⊢ starAddEquiv d ∈ AddSubmonoid.closure (Set.range fun s => star s * s)

Next tactic:
refine AddMonoidHom.mclosure_preimage_le _ _ <| AddSubmonoid.closure_mono ?_ hd
@[simp]
lemma star_le_star_iff {x y : R} : star x ≤ star y ↔ x ≤ y := by
  suffices ∀ x y, x ≤ y → star x ≤ star y from
    ⟨by simpa only [star_star] using this (star x) (star y), this x y⟩
  intro x y h
  rw [StarOrderedRing.le_iff] at h ⊢
  obtain ⟨d, hd, rfl⟩ := h
  refine ⟨starAddEquiv d, ?_, star_add _ _⟩
  refine AddMonoidHom.mclosure_preimage_le _ _ <| AddSubmonoid.closure_mono ?_ hd
  

Proof state:
case intro.intro
R : Type u
inst✝² : NonUnitalSemiring R
inst✝¹ : PartialOrder R
inst✝ : StarOrderedRing R
x✝ y x d : R
hd : d ∈ AddSubmonoid.closure (Set.range fun s => star s * s)
⊢ (Set.range fun s => star s * s) ⊆ ⇑starAddEquiv ⁻¹' Set.range fun s => star s * s

Next tactic:
rintro - ⟨s, rfl⟩
@[simp]
lemma star_le_star_iff {x y : R} : star x ≤ star y ↔ x ≤ y := by
  suffices ∀ x y, x ≤ y → star x ≤ star y from
    ⟨by simpa only [star_star] using this (star x) (star y), this x y⟩
  intro x y h
  rw [StarOrderedRing.le_iff] at h ⊢
  obtain ⟨d, hd, rfl⟩ := h
  refine ⟨starAddEquiv d, ?_, star_add _ _⟩
  refine AddMonoidHom.mclosure_preimage_le _ _ <| AddSubmonoid.closure_mono ?_ hd
  rintro - ⟨s, rfl⟩
  

Proof state:
case intro.intro.intro
R : Type u
inst✝² : NonUnitalSemiring R
inst✝¹ : PartialOrder R
inst✝ : StarOrderedRing R
x✝ y x d : R
hd : d ∈ AddSubmonoid.closure (Set.range fun s => star s * s)
s : R
⊢ (fun s => star s * s) s ∈ ⇑starAddEquiv ⁻¹' Set.range fun s => star s * s

Next tactic:
exact ⟨s, by simp⟩
@[simp]
lemma star_le_star_iff {x y : R} : star x ≤ star y ↔ x ≤ y := by
  suffices ∀ x y, x ≤ y → star x ≤ star y from
    ⟨by simpa only [star_star] using this (star x) (star y), this x y⟩
  intro x y h
  rw [StarOrderedRing.le_iff] at h ⊢
  obtain ⟨d, hd, rfl⟩ := h
  refine ⟨starAddEquiv d, ?_, star_add _ _⟩
  refine AddMonoidHom.mclosure_preimage_le _ _ <| AddSubmonoid.closure_mono ?_ hd
  rintro - ⟨s, rfl⟩
  exact ⟨s, by 

Proof state:
R : Type u
inst✝² : NonUnitalSemiring R
inst✝¹ : PartialOrder R
inst✝ : StarOrderedRing R
x✝ y x d : R
hd : d ∈ AddSubmonoid.closure (Set.range fun s => star s * s)
s : R
⊢ (fun s => star s * s) s = starAddEquiv ((fun s => star s * s) s)

Next tactic:
simp
@[simp]
lemma star_lt_star_iff {x y : R} : star x < star y ↔ x < y := by
  

Proof state:
R : Type u
inst✝² : NonUnitalSemiring R
inst✝¹ : PartialOrder R
inst✝ : StarOrderedRing R
x y : R
⊢ star x < star y ↔ x < y

Next tactic:
by_cases h : x = y
@[simp]
lemma star_lt_star_iff {x y : R} : star x < star y ↔ x < y := by
  by_cases h : x = y
  · 

Proof state:
case pos
R : Type u
inst✝² : NonUnitalSemiring R
inst✝¹ : PartialOrder R
inst✝ : StarOrderedRing R
x y : R
h : x = y
⊢ star x < star y ↔ x < y

Next tactic:
simp [h]
@[simp]
lemma star_lt_star_iff {x y : R} : star x < star y ↔ x < y := by
  by_cases h : x = y
  · simp [h]
  · 

Proof state:
case neg
R : Type u
inst✝² : NonUnitalSemiring R
inst✝¹ : PartialOrder R
inst✝ : StarOrderedRing R
x y : R
h : ¬x = y
⊢ star x < star y ↔ x < y

Next tactic:
simpa [le_iff_lt_or_eq, h] using star_le_star_iff (x := x) (y := y)
lemma star_le_iff {x y : R} : star x ≤ y ↔ x ≤ star y := by 

Proof state:
R : Type u
inst✝² : NonUnitalSemiring R
inst✝¹ : PartialOrder R
inst✝ : StarOrderedRing R
x y : R
⊢ star x ≤ y ↔ x ≤ star y

Next tactic:
rw [← star_le_star_iff, star_star]
lemma star_lt_iff {x y : R} : star x < y ↔ x < star y := by 

Proof state:
R : Type u
inst✝² : NonUnitalSemiring R
inst✝¹ : PartialOrder R
inst✝ : StarOrderedRing R
x y : R
⊢ star x < y ↔ x < star y

Next tactic:
rw [← star_lt_star_iff, star_star]
@[simp]
lemma star_nonneg_iff {x : R} : 0 ≤ star x ↔ 0 ≤ x := by
  

Proof state:
R : Type u
inst✝² : NonUnitalSemiring R
inst✝¹ : PartialOrder R
inst✝ : StarOrderedRing R
x : R
⊢ 0 ≤ star x ↔ 0 ≤ x

Next tactic:
simpa using star_le_star_iff (x := 0) (y := x)
@[simp]
lemma star_nonpos_iff {x : R} : star x ≤ 0 ↔ x ≤ 0 := by
  

Proof state:
R : Type u
inst✝² : NonUnitalSemiring R
inst✝¹ : PartialOrder R
inst✝ : StarOrderedRing R
x : R
⊢ star x ≤ 0 ↔ x ≤ 0

Next tactic:
simpa using star_le_star_iff (x := x) (y := 0)
@[simp]
lemma star_pos_iff {x : R} : 0 < star x ↔ 0 < x := by
  

Proof state:
R : Type u
inst✝² : NonUnitalSemiring R
inst✝¹ : PartialOrder R
inst✝ : StarOrderedRing R
x : R
⊢ 0 < star x ↔ 0 < x

Next tactic:
simpa using star_lt_star_iff (x := 0) (y := x)
@[simp]
lemma star_neg_iff {x : R} : star x < 0 ↔ x < 0 := by
  

Proof state:
R : Type u
inst✝² : NonUnitalSemiring R
inst✝¹ : PartialOrder R
inst✝ : StarOrderedRing R
x : R
⊢ star x < 0 ↔ x < 0

Next tactic:
simpa using star_lt_star_iff (x := x) (y := 0)
lemma IsSelfAdjoint.mono {x y : R} (h : x ≤ y) (hx : IsSelfAdjoint x) : IsSelfAdjoint y := by
  

Proof state:
R : Type u
inst✝² : NonUnitalSemiring R
inst✝¹ : PartialOrder R
inst✝ : StarOrderedRing R
x y : R
h : x ≤ y
hx : IsSelfAdjoint x
⊢ IsSelfAdjoint y

Next tactic:
rw [StarOrderedRing.le_iff] at h
lemma IsSelfAdjoint.mono {x y : R} (h : x ≤ y) (hx : IsSelfAdjoint x) : IsSelfAdjoint y := by
  rw [StarOrderedRing.le_iff] at h
  

Proof state:
R : Type u
inst✝² : NonUnitalSemiring R
inst✝¹ : PartialOrder R
inst✝ : StarOrderedRing R
x y : R
h : ∃ p ∈ AddSubmonoid.closure (Set.range fun s => star s * s), y = x + p
hx : IsSelfAdjoint x
⊢ IsSelfAdjoint y

Next tactic:
obtain ⟨d, hd, rfl⟩ := h
lemma IsSelfAdjoint.mono {x y : R} (h : x ≤ y) (hx : IsSelfAdjoint x) : IsSelfAdjoint y := by
  rw [StarOrderedRing.le_iff] at h
  obtain ⟨d, hd, rfl⟩ := h
  

Proof state:
case intro.intro
R : Type u
inst✝² : NonUnitalSemiring R
inst✝¹ : PartialOrder R
inst✝ : StarOrderedRing R
x : R
hx : IsSelfAdjoint x
d : R
hd : d ∈ AddSubmonoid.closure (Set.range fun s => star s * s)
⊢ IsSelfAdjoint (x + d)

Next tactic:
rw [IsSelfAdjoint, star_add, hx.star_eq]
lemma IsSelfAdjoint.mono {x y : R} (h : x ≤ y) (hx : IsSelfAdjoint x) : IsSelfAdjoint y := by
  rw [StarOrderedRing.le_iff] at h
  obtain ⟨d, hd, rfl⟩ := h
  rw [IsSelfAdjoint, star_add, hx.star_eq]
  

Proof state:
case intro.intro
R : Type u
inst✝² : NonUnitalSemiring R
inst✝¹ : PartialOrder R
inst✝ : StarOrderedRing R
x : R
hx : IsSelfAdjoint x
d : R
hd : d ∈ AddSubmonoid.closure (Set.range fun s => star s * s)
⊢ x + star d = x + d

Next tactic:
congr
lemma IsSelfAdjoint.mono {x y : R} (h : x ≤ y) (hx : IsSelfAdjoint x) : IsSelfAdjoint y := by
  rw [StarOrderedRing.le_iff] at h
  obtain ⟨d, hd, rfl⟩ := h
  rw [IsSelfAdjoint, star_add, hx.star_eq]
  congr
  

Proof state:
case intro.intro.e_a
R : Type u
inst✝² : NonUnitalSemiring R
inst✝¹ : PartialOrder R
inst✝ : StarOrderedRing R
x : R
hx : IsSelfAdjoint x
d : R
hd : d ∈ AddSubmonoid.closure (Set.range fun s => star s * s)
⊢ star d = d

Next tactic:
refine AddMonoidHom.eqOn_closureM (f := starAddEquiv (R := R)) (g := .id R) ?_ hd
lemma IsSelfAdjoint.mono {x y : R} (h : x ≤ y) (hx : IsSelfAdjoint x) : IsSelfAdjoint y := by
  rw [StarOrderedRing.le_iff] at h
  obtain ⟨d, hd, rfl⟩ := h
  rw [IsSelfAdjoint, star_add, hx.star_eq]
  congr
  refine AddMonoidHom.eqOn_closureM (f := starAddEquiv (R := R)) (g := .id R) ?_ hd
  

Proof state:
case intro.intro.e_a
R : Type u
inst✝² : NonUnitalSemiring R
inst✝¹ : PartialOrder R
inst✝ : StarOrderedRing R
x : R
hx : IsSelfAdjoint x
d : R
hd : d ∈ AddSubmonoid.closure (Set.range fun s => star s * s)
⊢ Set.EqOn (⇑↑starAddEquiv) (⇑(AddMonoidHom.id R)) (Set.range fun s => star s * s)

Next tactic:
rintro - ⟨s, rfl⟩
lemma IsSelfAdjoint.mono {x y : R} (h : x ≤ y) (hx : IsSelfAdjoint x) : IsSelfAdjoint y := by
  rw [StarOrderedRing.le_iff] at h
  obtain ⟨d, hd, rfl⟩ := h
  rw [IsSelfAdjoint, star_add, hx.star_eq]
  congr
  refine AddMonoidHom.eqOn_closureM (f := starAddEquiv (R := R)) (g := .id R) ?_ hd
  rintro - ⟨s, rfl⟩
  

Proof state:
case intro.intro.e_a.intro
R : Type u
inst✝² : NonUnitalSemiring R
inst✝¹ : PartialOrder R
inst✝ : StarOrderedRing R
x : R
hx : IsSelfAdjoint x
d : R
hd : d ∈ AddSubmonoid.closure (Set.range fun s => star s * s)
s : R
⊢ ↑starAddEquiv ((fun s => star s * s) s) = (AddMonoidHom.id R) ((fun s => star s * s) s)

Next tactic:
simp
@[simp]
lemma one_le_star_iff {x : R} : 1 ≤ star x ↔ 1 ≤ x := by
  

Proof state:
R : Type u
inst✝² : Semiring R
inst✝¹ : PartialOrder R
inst✝ : StarOrderedRing R
x : R
⊢ 1 ≤ star x ↔ 1 ≤ x

Next tactic:
simpa using star_le_star_iff (x := 1) (y := x)