data.rat.star
⟷
Mathlib.Data.Rat.Star
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.
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(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)
mathlib commit https://github.com/leanprover-community/mathlib/commit/65a1391a0106c9204fe45bc73a039f056558cb83
@@ -30,7 +30,7 @@ instance : StarRing ℚ where
instance : TrivialStar ℚ where star_trivial _ := rfl
instance : StarOrderedRing ℚ :=
- StarOrderedRing.ofNonnegIff (fun _ _ => add_le_add_left) fun x =>
+ StarOrderedRing.of_nonneg_iff (fun _ _ => add_le_add_left) fun x =>
by
refine'
⟨fun hx => _, fun hx =>
@@ -52,7 +52,7 @@ instance : StarOrderedRing ℚ :=
simp only [Int.cast_mul, Int.cast_natCast, coe_int_eq_mk, coe_nat_eq_mk]
rw [mul_assoc, ← mul_assoc (mk (x.denom : ℤ) 1), mk_mul_mk_cancel one_ne_zero, ←
one_mul (x.denom : ℤ), div_mk_div_cancel_left (by simpa using x.pos.ne' : (x.denom : ℤ) ≠ 0),
- one_mul, mk_one_one, one_mul, mk_mul_mk_cancel one_ne_zero, Rat.num_den]
+ one_mul, mk_one_one, one_mul, mk_mul_mk_cancel one_ne_zero, Rat.num_divInt_den]
end Rat
mathlib commit https://github.com/leanprover-community/mathlib/commit/65a1391a0106c9204fe45bc73a039f056558cb83
@@ -47,9 +47,9 @@ instance : StarOrderedRing ℚ :=
x
by exact this ▸ sum_mem fun n hn => AddSubmonoid.subset_closure ⟨_, rfl⟩
simp only [Function.const_apply, Finset.sum_const, Finset.card_range, nsmul_eq_mul, mk_pnat_eq]
- rw [← Int.cast_ofNat, Int.ofNat_mul, Int.natCast_natAbs,
- abs_of_nonneg (num_nonneg_iff_zero_le.mpr hx), Int.cast_mul, Int.cast_ofNat]
- simp only [Int.cast_mul, Int.cast_ofNat, coe_int_eq_mk, coe_nat_eq_mk]
+ rw [← Int.cast_natCast, Int.ofNat_mul, Int.natCast_natAbs,
+ abs_of_nonneg (num_nonneg_iff_zero_le.mpr hx), Int.cast_mul, Int.cast_natCast]
+ simp only [Int.cast_mul, Int.cast_natCast, coe_int_eq_mk, coe_nat_eq_mk]
rw [mul_assoc, ← mul_assoc (mk (x.denom : ℤ) 1), mk_mul_mk_cancel one_ne_zero, ←
one_mul (x.denom : ℤ), div_mk_div_cancel_left (by simpa using x.pos.ne' : (x.denom : ℤ) ≠ 0),
one_mul, mk_one_one, one_mul, mk_mul_mk_cancel one_ne_zero, Rat.num_den]
mathlib commit https://github.com/leanprover-community/mathlib/commit/65a1391a0106c9204fe45bc73a039f056558cb83
@@ -47,7 +47,7 @@ instance : StarOrderedRing ℚ :=
x
by exact this ▸ sum_mem fun n hn => AddSubmonoid.subset_closure ⟨_, rfl⟩
simp only [Function.const_apply, Finset.sum_const, Finset.card_range, nsmul_eq_mul, mk_pnat_eq]
- rw [← Int.cast_ofNat, Int.ofNat_mul, Int.coe_natAbs,
+ rw [← Int.cast_ofNat, Int.ofNat_mul, Int.natCast_natAbs,
abs_of_nonneg (num_nonneg_iff_zero_le.mpr hx), Int.cast_mul, Int.cast_ofNat]
simp only [Int.cast_mul, Int.cast_ofNat, coe_int_eq_mk, coe_nat_eq_mk]
rw [mul_assoc, ← mul_assoc (mk (x.denom : ℤ) 1), mk_mul_mk_cancel one_ne_zero, ←
mathlib commit https://github.com/leanprover-community/mathlib/commit/65a1391a0106c9204fe45bc73a039f056558cb83
@@ -34,7 +34,7 @@ instance : StarOrderedRing ℚ :=
by
refine'
⟨fun hx => _, fun hx =>
- AddSubmonoid.closure_induction hx (by rintro - ⟨s, rfl⟩; exact mul_self_nonneg s) le_rfl
+ AddSubmonoid.closure_induction hx (by rintro - ⟨s, rfl⟩; exact hMul_self_nonneg s) le_rfl
fun _ _ => add_nonneg⟩
/- If `x = p / q`, then, since `0 ≤ x`, we have `p q : ℕ`, and `p / q` is the sum of `p * q`
copies of `(1 / q) ^ 2`, and so `x` lies in the `add_submonoid` generated by square elements.
mathlib commit https://github.com/leanprover-community/mathlib/commit/ce64cd319bb6b3e82f31c2d38e79080d377be451
@@ -3,9 +3,9 @@ Copyright (c) 2023 Jireh Loreaux. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jireh Loreaux
-/
-import Mathbin.Algebra.Star.Order
-import Mathbin.Data.Rat.Lemmas
-import Mathbin.GroupTheory.Submonoid.Membership
+import Algebra.Star.Order
+import Data.Rat.Lemmas
+import GroupTheory.Submonoid.Membership
#align_import data.rat.star from "leanprover-community/mathlib"@"6b31d1eebd64eab86d5bd9936bfaada6ca8b5842"
mathlib commit https://github.com/leanprover-community/mathlib/commit/32a7e535287f9c73f2e4d2aef306a39190f0b504
@@ -24,7 +24,7 @@ namespace Rat
instance : StarRing ℚ where
unit := id
star_involutive _ := rfl
- star_mul _ _ := mul_comm _ _
+ star_hMul _ _ := mul_comm _ _
star_add _ _ := rfl
instance : TrivialStar ℚ where star_trivial _ := rfl
mathlib commit https://github.com/leanprover-community/mathlib/commit/8ea5598db6caeddde6cb734aa179cc2408dbd345
@@ -2,16 +2,13 @@
Copyright (c) 2023 Jireh Loreaux. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jireh Loreaux
-
-! This file was ported from Lean 3 source module data.rat.star
-! leanprover-community/mathlib commit 6b31d1eebd64eab86d5bd9936bfaada6ca8b5842
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
-/
import Mathbin.Algebra.Star.Order
import Mathbin.Data.Rat.Lemmas
import Mathbin.GroupTheory.Submonoid.Membership
+#align_import data.rat.star from "leanprover-community/mathlib"@"6b31d1eebd64eab86d5bd9936bfaada6ca8b5842"
+
/-! # Star order structure on ℚ
> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.
mathlib commit https://github.com/leanprover-community/mathlib/commit/a3e83f0fa4391c8740f7d773a7a9b74e311ae2a3
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jireh Loreaux
! This file was ported from Lean 3 source module data.rat.star
-! leanprover-community/mathlib commit 31c24aa72e7b3e5ed97a8412470e904f82b81004
+! leanprover-community/mathlib commit 6b31d1eebd64eab86d5bd9936bfaada6ca8b5842
! Please do not edit these lines, except to modify the commit id
! if you have ported upstream changes.
-/
@@ -14,6 +14,9 @@ import Mathbin.GroupTheory.Submonoid.Membership
/-! # Star order structure on ℚ
+> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.
+> Any changes to this file require a corresponding PR to mathlib4.
+
Here we put the trivial `star` operation on `ℚ` for convenience and show that it is a
`star_ordered_ring`. In particular, this means that every element of `ℚ` is a sum of squares.
-/
mathlib commit https://github.com/leanprover-community/mathlib/commit/31c24aa72e7b3e5ed97a8412470e904f82b81004
ℕ
, ℤ
and ℚ≥0
are star-ordered rings (#10633)
Also golf the existing instance for ℚ
and rename Rat.num_nonneg_iff_zero_le
to Rat.num_nonneg
, Rat.num_pos_iff_pos
to Rat.num_pos
.
From LeanAPAP
@@ -1,52 +1,64 @@
/-
Copyright (c) 2023 Jireh Loreaux. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
-Authors: Jireh Loreaux
+Authors: Jireh Loreaux, Yaël Dillies
-/
+import Mathlib.Algebra.GroupWithZero.Power
+import Mathlib.Algebra.Parity
import Mathlib.Algebra.Star.Order
-import Mathlib.Data.Rat.Lemmas
-import Mathlib.Data.Rat.Order
-import Mathlib.GroupTheory.Submonoid.Membership
+import Mathlib.Data.NNRat.Lemmas
+import Mathlib.GroupTheory.Submonoid.Order
+import Mathlib.Tactic.FieldSimp
#align_import data.rat.star from "leanprover-community/mathlib"@"31c24aa72e7b3e5ed97a8412470e904f82b81004"
-/-! # Star order structure on ℚ
+/-!
+# Star ordered ring structures on `ℚ` and `ℚ≥0`
-Here we put the trivial `star` operation on `ℚ` for convenience and show that it is a
-`StarOrderedRing`. In particular, this means that every element of `ℚ` is a sum of squares.
+This file shows that `ℚ` and `ℚ≥0` are `StarOrderedRing`s. In particular, this means that every
+nonnegative rational number is a sum of squares.
-/
+open AddSubmonoid Set
+open scoped NNRat
+
+namespace NNRat
+
+@[simp] lemma addSubmonoid_closure_range_pow {n : ℕ} (hn₀ : n ≠ 0) :
+ closure (range fun x : ℚ≥0 ↦ x ^ n) = ⊤ := by
+ refine (eq_top_iff' _).2 fun x ↦ ?_
+ suffices x = (x.num * x.den ^ (n - 1)) • (x.den : ℚ≥0)⁻¹ ^ n by
+ rw [this]
+ exact nsmul_mem (subset_closure <| mem_range_self _) _
+ rw [nsmul_eq_mul]
+ push_cast
+ rw [mul_assoc, pow_sub₀, pow_one, mul_right_comm, ← mul_pow, mul_inv_cancel, one_pow, one_mul,
+ ← div_eq_mul_inv, num_div_den]
+ all_goals simp [x.den_pos.ne', Nat.one_le_iff_ne_zero, *]
+
+@[simp] lemma addSubmonoid_closure_range_mul_self : closure (range fun x : ℚ≥0 ↦ x * x) = ⊤ := by
+ simpa only [sq] using addSubmonoid_closure_range_pow two_ne_zero
+
+instance instStarOrderedRing : StarOrderedRing ℚ≥0 where
+ le_iff a b := by simp [le_iff_exists_nonneg_add a b]
+
+end NNRat
namespace Rat
-instance : StarRing ℚ where
- star := id
- star_involutive _ := rfl
- star_mul _ _ := mul_comm _ _
- star_add _ _ := rfl
-
-instance : TrivialStar ℚ where star_trivial _ := rfl
-
-instance : StarOrderedRing ℚ :=
- StarOrderedRing.ofNonnegIff (fun {_ _} => add_le_add_left) fun x => by
- refine'
- ⟨fun hx => _, fun hx =>
- AddSubmonoid.closure_induction hx (by rintro - ⟨s, rfl⟩; exact mul_self_nonneg s) le_rfl
- fun _ _ => add_nonneg⟩
- /- If `x = p / q`, then, since `0 ≤ x`, we have `p q : ℕ`, and `p / q` is the sum of `p * q`
- copies of `(1 / q) ^ 2`, and so `x` lies in the `AddSubmonoid` generated by square elements.
-
- Note: it's possible to rephrase this argument as `x = (p * q) • (1 / q) ^ 2`, but this would
- be somewhat challenging without increasing import requirements. -/
- -- Porting note: rewrote proof to avoid removed constructor rat.mk_pnat
- suffices
- (Finset.range (x.num.natAbs * x.den)).sum
- (Function.const ℕ ((1 : ℚ) / x.den * ((1 : ℚ) / x.den))) =
- x
- by exact this ▸ sum_mem fun n _ => AddSubmonoid.subset_closure ⟨_, rfl⟩
- simp only [Function.const_apply, Finset.sum_const, Finset.card_range, nsmul_eq_mul]
- rw [← Int.cast_ofNat, Int.ofNat_mul, Int.coe_natAbs,
- abs_of_nonneg (num_nonneg.mpr hx), Int.cast_mul, Int.cast_ofNat]
- rw [← mul_assoc, mul_assoc (x.num : ℚ), mul_one_div_cancel (Nat.cast_ne_zero.mpr x.pos.ne'),
- mul_one, mul_one_div, Rat.num_div_den]
+@[simp] lemma addSubmonoid_closure_range_pow {n : ℕ} (hn₀ : n ≠ 0) (hn : Even n) :
+ closure (range fun x : ℚ ↦ x ^ n) = nonneg _ := by
+ convert (AddMonoidHom.map_mclosure NNRat.coeHom <| range fun x ↦ x ^ n).symm
+ · have (x : ℚ) : ∃ y : ℚ≥0, y ^ n = x ^ n := ⟨x.nnabs, by simp [hn.pow_abs]⟩
+ simp [subset_antisymm_iff, range_subset_iff, this]
+ · ext
+ simp [NNRat.addSubmonoid_closure_range_pow hn₀, NNRat.exists]
+
+@[simp]
+lemma addSubmonoid_closure_range_mul_self : closure (range fun x : ℚ ↦ x * x) = nonneg _ := by
+ simpa only [sq] using addSubmonoid_closure_range_pow two_ne_zero even_two
+
+instance instStarOrderedRing : StarOrderedRing ℚ where
+ le_iff a b := by simp [le_iff_exists_nonneg_add a b]
+
end Rat
positivity
extension for Rat.num
, Rat.den
(#10218)
and rename num_nonneg_iff_zero_le
to num_nonneg
, num_pos_iff_pos
to num_pos
From LeanAPAP
@@ -46,7 +46,7 @@ instance : StarOrderedRing ℚ :=
by exact this ▸ sum_mem fun n _ => AddSubmonoid.subset_closure ⟨_, rfl⟩
simp only [Function.const_apply, Finset.sum_const, Finset.card_range, nsmul_eq_mul]
rw [← Int.cast_ofNat, Int.ofNat_mul, Int.coe_natAbs,
- abs_of_nonneg (num_nonneg_iff_zero_le.mpr hx), Int.cast_mul, Int.cast_ofNat]
+ abs_of_nonneg (num_nonneg.mpr hx), Int.cast_mul, Int.cast_ofNat]
rw [← mul_assoc, mul_assoc (x.num : ℚ), mul_one_div_cancel (Nat.cast_ne_zero.mpr x.pos.ne'),
mul_one, mul_one_div, Rat.num_div_den]
end Rat
@@ -5,6 +5,7 @@ Authors: Jireh Loreaux
-/
import Mathlib.Algebra.Star.Order
import Mathlib.Data.Rat.Lemmas
+import Mathlib.Data.Rat.Order
import Mathlib.GroupTheory.Submonoid.Membership
#align_import data.rat.star from "leanprover-community/mathlib"@"31c24aa72e7b3e5ed97a8412470e904f82b81004"
@@ -46,7 +46,6 @@ instance : StarOrderedRing ℚ :=
simp only [Function.const_apply, Finset.sum_const, Finset.card_range, nsmul_eq_mul]
rw [← Int.cast_ofNat, Int.ofNat_mul, Int.coe_natAbs,
abs_of_nonneg (num_nonneg_iff_zero_le.mpr hx), Int.cast_mul, Int.cast_ofNat]
- simp only [Int.cast_mul, Int.cast_ofNat]
rw [← mul_assoc, mul_assoc (x.num : ℚ), mul_one_div_cancel (Nat.cast_ne_zero.mpr x.pos.ne'),
mul_one, mul_one_div, Rat.num_div_den]
end Rat
@@ -2,16 +2,13 @@
Copyright (c) 2023 Jireh Loreaux. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jireh Loreaux
-
-! This file was ported from Lean 3 source module data.rat.star
-! leanprover-community/mathlib commit 31c24aa72e7b3e5ed97a8412470e904f82b81004
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
-/
import Mathlib.Algebra.Star.Order
import Mathlib.Data.Rat.Lemmas
import Mathlib.GroupTheory.Submonoid.Membership
+#align_import data.rat.star from "leanprover-community/mathlib"@"31c24aa72e7b3e5ed97a8412470e904f82b81004"
+
/-! # Star order structure on ℚ
Here we put the trivial `star` operation on `ℚ` for convenience and show that it is a
The unported dependencies are