Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

Commit cc75e4e

Browse files
committed
chore(data/nat/cast): a few simp/norm_cast lemmas (#4549)
1 parent f6836c1 commit cc75e4e

File tree

1 file changed

+22
-8
lines changed

1 file changed

+22
-8
lines changed

src/data/nat/cast.lean

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -125,22 +125,34 @@ lemma commute_cast [semiring α] (x : α) (n : ℕ) : commute x n :=
125125
| 0 := le_refl _
126126
| (n+1) := add_nonneg (cast_nonneg n) zero_le_one
127127

128-
@[simp, norm_cast] theorem cast_le [linear_ordered_semiring α] : ∀ {m n : ℕ}, (m : α) ≤ n ↔ m ≤ n
129-
| 0 n := by simp [zero_le]
130-
| (m+1) 0 := by simpa [not_succ_le_zero] using
131-
lt_add_of_nonneg_of_lt (@cast_nonneg α _ m) zero_lt_one
132-
| (m+1) (n+1) := (add_le_add_iff_right 1).trans $
133-
(@cast_le m n).trans $ (add_le_add_iff_right 1).symm
128+
theorem strict_mono_cast [linear_ordered_semiring α] : strict_mono (coe : ℕα) :=
129+
λ m n h, nat.le_induction (lt_add_of_pos_right _ zero_lt_one)
130+
(λ n _ h, lt_add_of_lt_of_pos h zero_lt_one) _ h
131+
132+
@[simp, norm_cast] theorem cast_le [linear_ordered_semiring α] {m n : ℕ} : (m : α) ≤ n ↔ m ≤ n :=
133+
strict_mono_cast.le_iff_le
134134

135135
@[simp, norm_cast] theorem cast_lt [linear_ordered_semiring α] {m n : ℕ} : (m : α) < n ↔ m < n :=
136-
by simpa [-cast_le] using not_congr (@cast_le α _ n m)
136+
strict_mono_cast.lt_iff_lt
137137

138138
@[simp] theorem cast_pos [linear_ordered_semiring α] {n : ℕ} : (0 : α) < n ↔ 0 < n :=
139139
by rw [← cast_zero, cast_lt]
140140

141141
lemma cast_add_one_pos [linear_ordered_semiring α] (n : ℕ) : 0 < (n : α) + 1 :=
142142
add_pos_of_nonneg_of_pos n.cast_nonneg zero_lt_one
143143

144+
@[simp, norm_cast] theorem one_lt_cast [linear_ordered_semiring α] {n : ℕ} : 1 < (n : α) ↔ 1 < n :=
145+
by rw [← cast_one, cast_lt]
146+
147+
@[simp, norm_cast] theorem one_le_cast [linear_ordered_semiring α] {n : ℕ} : 1 ≤ (n : α) ↔ 1 ≤ n :=
148+
by rw [← cast_one, cast_le]
149+
150+
@[simp, norm_cast] theorem cast_lt_one [linear_ordered_semiring α] {n : ℕ} : (n : α) < 1 ↔ n = 0 :=
151+
by rw [← cast_one, cast_lt, lt_succ_iff, le_zero_iff]
152+
153+
@[simp, norm_cast] theorem cast_le_one [linear_ordered_semiring α] {n : ℕ} : (n : α) ≤ 1 ↔ n ≤ 1 :=
154+
by rw [← cast_one, cast_le]
155+
144156
@[simp, norm_cast] theorem cast_min [decidable_linear_ordered_semiring α] {a b : ℕ} :
145157
(↑(min a b) : α) = min a b :=
146158
by by_cases a ≤ b; simp [h, min]
@@ -153,10 +165,12 @@ by by_cases a ≤ b; simp [h, max]
153165
abs (a : α) = a :=
154166
abs_of_nonneg (cast_nonneg a)
155167

156-
lemma coe_nat_dvd [comm_semiring α] (m n : ℕ) (h : m ∣ n) :
168+
lemma coe_nat_dvd [comm_semiring α] {m n : ℕ} (h : m ∣ n) :
157169
(m : α) ∣ (n : α) :=
158170
ring_hom.map_dvd (nat.cast_ring_hom α) h
159171

172+
alias coe_nat_dvd ← has_dvd.dvd.nat_cast
173+
160174
section linear_ordered_field
161175
variables [linear_ordered_field α]
162176

0 commit comments

Comments
 (0)