@@ -5,9 +5,10 @@ Authors: Mario Carneiro
5
5
-/
6
6
import Mathlib.Data.Nat.Cast.Basic
7
7
import Mathlib.Algebra.CharZero.Defs
8
- import Mathlib.Algebra.Order.Group.Abs
8
+ import Mathlib.Algebra.Order.Monoid.Unbundled.Basic
9
9
import Mathlib.Data.Nat.Cast.NeZero
10
- import Mathlib.Algebra.Order.Ring.Nat
10
+ import Mathlib.Algebra.Order.ZeroLEOne
11
+ import Mathlib.Order.Hom.Basic
11
12
12
13
#align_import data.nat.cast.basic from "leanprover-community/mathlib" @"acebd8d49928f6ed8920e502a6c90674e75bd441"
13
14
@@ -16,6 +17,8 @@ import Mathlib.Algebra.Order.Ring.Nat
16
17
17
18
-/
18
19
20
+ assert_not_exists OrderedCommMonoid
21
+
19
22
variable {α β : Type *}
20
23
21
24
namespace Nat
@@ -45,34 +48,11 @@ theorem _root_.GCongr.natCast_le_natCast {a b : ℕ} (h : a ≤ b) : (a : α)
45
48
theorem cast_nonneg' (n : ℕ) : 0 ≤ (n : α) :=
46
49
@Nat.cast_zero α _ ▸ mono_cast (Nat.zero_le n)
47
50
48
- /-- Specialisation of `Nat.cast_nonneg'`, which seems to be easier for Lean to use. -/
49
- @[simp]
50
- theorem cast_nonneg {α} [OrderedSemiring α] (n : ℕ) : 0 ≤ (n : α) :=
51
- cast_nonneg' n
52
- #align nat.cast_nonneg Nat.cast_nonneg
53
-
54
51
/-- See also `Nat.ofNat_nonneg`, specialised for an `OrderedSemiring`. -/
55
52
-- See note [no_index around OfNat.ofNat]
56
53
@[simp low]
57
54
theorem ofNat_nonneg' (n : ℕ) [n.AtLeastTwo] : 0 ≤ (no_index (OfNat.ofNat n : α)) := cast_nonneg' n
58
55
59
- /-- Specialisation of `Nat.ofNat_nonneg'`, which seems to be easier for Lean to use. -/
60
- -- See note [no_index around OfNat.ofNat]
61
- @[simp]
62
- theorem ofNat_nonneg {α} [OrderedSemiring α] (n : ℕ) [n.AtLeastTwo] :
63
- 0 ≤ (no_index (OfNat.ofNat n : α)) :=
64
- ofNat_nonneg' n
65
-
66
- @[simp, norm_cast]
67
- theorem cast_min {α} [LinearOrderedSemiring α] {a b : ℕ} : ((min a b : ℕ) : α) = min (a : α) b :=
68
- (@mono_cast α _).map_min
69
- #align nat.cast_min Nat.cast_min
70
-
71
- @[simp, norm_cast]
72
- theorem cast_max {α} [LinearOrderedSemiring α] {a b : ℕ} : ((max a b : ℕ) : α) = max (a : α) b :=
73
- (@mono_cast α _).map_max
74
- #align nat.cast_max Nat.cast_max
75
-
76
56
section Nontrivial
77
57
78
58
variable [NeZero (1 : α)]
@@ -87,24 +67,6 @@ theorem cast_add_one_pos (n : ℕ) : 0 < (n : α) + 1 := by
87
67
@[simp low]
88
68
theorem cast_pos' {n : ℕ} : (0 : α) < n ↔ 0 < n := by cases n <;> simp [cast_add_one_pos]
89
69
90
- /-- Specialisation of `Nat.cast_pos'`, which seems to be easier for Lean to use. -/
91
- @[simp]
92
- theorem cast_pos {α} [OrderedSemiring α] [Nontrivial α] {n : ℕ} : (0 : α) < n ↔ 0 < n := cast_pos'
93
- #align nat.cast_pos Nat.cast_pos
94
-
95
- /-- See also `Nat.ofNat_pos`, specialised for an `OrderedSemiring`. -/
96
- -- See note [no_index around OfNat.ofNat]
97
- @[simp low]
98
- theorem ofNat_pos' {n : ℕ} [n.AtLeastTwo] : 0 < (no_index (OfNat.ofNat n : α)) :=
99
- cast_pos'.mpr (NeZero.pos n)
100
-
101
- /-- Specialisation of `Nat.ofNat_pos'`, which seems to be easier for Lean to use. -/
102
- -- See note [no_index around OfNat.ofNat]
103
- @[simp]
104
- theorem ofNat_pos {α} [OrderedSemiring α] [Nontrivial α] {n : ℕ} [n.AtLeastTwo] :
105
- 0 < (no_index (OfNat.ofNat n : α)) :=
106
- ofNat_pos'
107
-
108
70
end Nontrivial
109
71
110
72
variable [CharZero α] {m n : ℕ}
@@ -140,7 +102,7 @@ theorem one_le_cast : 1 ≤ (n : α) ↔ 1 ≤ n := by rw [← cast_one, cast_le
140
102
141
103
@[simp, norm_cast]
142
104
theorem cast_lt_one : (n : α) < 1 ↔ n = 0 := by
143
- rw [← cast_one, cast_lt, Nat.lt_succ_iff, ← bot_eq_zero, le_bot_iff ]
105
+ rw [← cast_one, cast_lt, Nat.lt_succ_iff, le_zero ]
144
106
#align nat.cast_lt_one Nat.cast_lt_one
145
107
146
108
@[simp, norm_cast]
@@ -149,7 +111,6 @@ theorem cast_le_one : (n : α) ≤ 1 ↔ n ≤ 1 := by rw [← cast_one, cast_le
149
111
150
112
variable [m.AtLeastTwo] [n.AtLeastTwo]
151
113
152
-
153
114
-- TODO: These lemmas need to be `@[simp]` for confluence in the presence of `cast_lt`, `cast_le`,
154
115
-- and `Nat.cast_ofNat`, but their LHSs match literally every inequality, so they're too expensive.
155
116
-- If lean4#2867 is fixed in a performant way, these can be made `@[simp]`.
@@ -210,29 +171,6 @@ theorem not_ofNat_lt_one : ¬(no_index (OfNat.ofNat n : α)) < 1 :=
210
171
211
172
end OrderedSemiring
212
173
213
- /-- A version of `Nat.cast_sub` that works for `ℝ≥0` and `ℚ≥0`. Note that this proof doesn't work
214
- for `ℕ∞` and `ℝ≥0∞`, so we use type-specific lemmas for these types. -/
215
- @[simp, norm_cast]
216
- theorem cast_tsub [CanonicallyOrderedCommSemiring α] [Sub α] [OrderedSub α]
217
- [ContravariantClass α α (· + ·) (· ≤ ·)] (m n : ℕ) : ↑(m - n) = (m - n : α) := by
218
- rcases le_total m n with h | h
219
- · rw [Nat.sub_eq_zero_of_le h, cast_zero, tsub_eq_zero_of_le]
220
- exact mono_cast h
221
- · rcases le_iff_exists_add'.mp h with ⟨m, rfl⟩
222
- rw [add_tsub_cancel_right, cast_add, add_tsub_cancel_right]
223
- #align nat.cast_tsub Nat.cast_tsub
224
-
225
- @[simp, norm_cast]
226
- theorem abs_cast [LinearOrderedRing α] (a : ℕ) : |(a : α)| = a :=
227
- abs_of_nonneg (cast_nonneg a)
228
- #align nat.abs_cast Nat.abs_cast
229
-
230
- -- See note [no_index around OfNat.ofNat]
231
- @[simp]
232
- theorem abs_ofNat [LinearOrderedRing α] (n : ℕ) [n.AtLeastTwo] :
233
- |(no_index (OfNat.ofNat n : α))| = OfNat.ofNat n :=
234
- abs_cast n
235
-
236
174
end Nat
237
175
238
176
instance [AddMonoidWithOne α] [CharZero α] : Nontrivial α where exists_pair_ne :=
0 commit comments