@@ -16,7 +16,7 @@ class floor_ring (α) extends linear_ordered_ring α :=
16
16
(le_floor : ∀ (z : ℤ) (x : α), z ≤ floor x ↔ (z : α) ≤ x)
17
17
18
18
instance : floor_ring ℤ :=
19
- { floor := id, le_floor := by simp ,
19
+ { floor := id, le_floor := λ _ _, by rw int.cast_id; refl ,
20
20
..linear_ordered_comm_ring.to_linear_ordered_ring ℤ }
21
21
22
22
instance : floor_ring ℚ :=
@@ -40,13 +40,13 @@ theorem floor_le (x : α) : (⌊x⌋ : α) ≤ x :=
40
40
le_floor.1 (le_refl _)
41
41
42
42
theorem floor_nonneg {x : α} : 0 ≤ ⌊x⌋ ↔ 0 ≤ x :=
43
- by simpa using @ le_floor _ _ 0 x
43
+ by rw [ le_floor]; refl
44
44
45
45
theorem lt_succ_floor (x : α) : x < ⌊x⌋.succ :=
46
46
floor_lt.1 $ int.lt_succ_self _
47
47
48
48
theorem lt_floor_add_one (x : α) : x < ⌊x⌋ + 1 :=
49
- by simpa [int.succ] using lt_succ_floor x
49
+ by simpa only [int.succ, int.cast_add, int.cast_one ] using lt_succ_floor x
50
50
51
51
theorem sub_one_lt_floor (x : α) : x - 1 < ⌊x⌋ :=
52
52
sub_lt_iff_lt_add.2 (lt_floor_add_one x)
@@ -108,9 +108,7 @@ lemma ceil_pos {a : α} : 0 < ⌈a⌉ ↔ 0 < a :=
108
108
109
109
lemma ceil_nonneg [decidable_rel ((<) : α → α → Prop )] {q : α} (hq : q ≥ 0 ) : ⌈q⌉ ≥ 0 :=
110
110
if h : q > 0 then le_of_lt $ ceil_pos.2 h
111
- else
112
- have h' : q = 0 , from le_antisymm (le_of_not_lt h) hq,
113
- by simp [h']
111
+ else by rw [le_antisymm (le_of_not_lt h) hq, ceil_zero]; trivial
114
112
115
113
end
116
114
@@ -120,7 +118,7 @@ class archimedean (α) [ordered_comm_monoid α] : Prop :=
120
118
theorem exists_nat_gt [linear_ordered_semiring α] [archimedean α]
121
119
(x : α) : ∃ n : ℕ, x < n :=
122
120
let ⟨n, h⟩ := archimedean.arch x zero_lt_one in
123
- ⟨n+1 , lt_of_le_of_lt (by simpa using h )
121
+ ⟨n+1 , lt_of_le_of_lt (by rwa ← add_monoid.smul_one )
124
122
(nat.cast_lt.2 (nat.lt_succ_self _))⟩
125
123
126
124
section linear_ordered_ring
@@ -135,10 +133,10 @@ let ⟨n, h⟩ := archimedean.arch x hy0 in
135
133
... ≤ y ^ n : pow_ge_one_add_sub_mul (le_of_lt hy1) _⟩
136
134
137
135
theorem exists_int_gt (x : α) : ∃ n : ℤ, x < n :=
138
- let ⟨n, h⟩ := exists_nat_gt x in ⟨n, by simp [h] ⟩
136
+ let ⟨n, h⟩ := exists_nat_gt x in ⟨n, by rwa ← coe_coe ⟩
139
137
140
138
theorem exists_int_lt (x : α) : ∃ n : ℤ, (n : α) < x :=
141
- let ⟨n, h⟩ := exists_int_gt (-x) in ⟨-n, by simp [ neg_lt.1 h] ⟩
139
+ let ⟨n, h⟩ := exists_int_gt (-x) in ⟨-n, by rw int.cast_neg; exact neg_lt.1 h⟩
142
140
143
141
theorem exists_floor (x : α) :
144
142
∃ (fl : ℤ), ∀ (z : ℤ), z ≤ fl ↔ (z : α) ≤ x :=
@@ -157,15 +155,12 @@ end
157
155
end linear_ordered_ring
158
156
159
157
instance : archimedean ℕ :=
160
- ⟨λ n m m0, ⟨n, by simpa using nat.mul_le_mul_left n m0⟩⟩
158
+ ⟨λ n m m0, ⟨n, by simpa only [mul_one, nat.smul_eq_mul] using nat.mul_le_mul_left n m0⟩⟩
161
159
162
160
instance : archimedean ℤ :=
163
- ⟨λ n m m0, ⟨n.to_nat, begin
164
- simp [add_monoid.smul_eq_mul],
165
- refine le_trans (int.le_to_nat _) _,
166
- simpa using mul_le_mul_of_nonneg_left
167
- (int.add_one_le_iff.2 m0) (int.coe_zero_le n.to_nat),
168
- end ⟩⟩
161
+ ⟨λ n m m0, ⟨n.to_nat, le_trans (int.le_to_nat _) $
162
+ by simpa only [add_monoid.smul_eq_mul, int.nat_cast_eq_coe_nat, zero_add, mul_one] using mul_le_mul_of_nonneg_left
163
+ (int.add_one_le_iff.2 m0) (int.coe_zero_le n.to_nat)⟩⟩
169
164
170
165
noncomputable def archimedean.floor_ring (α)
171
166
[linear_ordered_ring α] [archimedean α] : floor_ring α :=
@@ -189,15 +184,15 @@ archimedean_iff_nat_lt.trans
189
184
lt_of_le_of_lt h (nat.cast_lt.2 (lt_add_one _))⟩⟩
190
185
191
186
theorem exists_rat_gt [archimedean α] (x : α) : ∃ q : ℚ, x < q :=
192
- let ⟨n, h⟩ := exists_nat_gt x in ⟨n, by simp [h] ⟩
187
+ let ⟨n, h⟩ := exists_nat_gt x in ⟨n, by rwa rat.cast_coe_nat ⟩
193
188
194
189
theorem archimedean_iff_rat_lt :
195
190
archimedean α ↔ ∀ x : α, ∃ q : ℚ, x < q :=
196
191
⟨@exists_rat_gt α _,
197
192
λ H, archimedean_iff_nat_lt.2 $ λ x,
198
193
let ⟨q, h⟩ := H x in
199
194
⟨rat.nat_ceil q, lt_of_lt_of_le h $
200
- by simpa using (@rat.cast_le α _ _ _).2 (rat.le_nat_ceil _)⟩⟩
195
+ by simpa only [rat.cast_coe_nat] using (@rat.cast_le α _ _ _).2 (rat.le_nat_ceil _)⟩⟩
201
196
202
197
theorem archimedean_iff_rat_le :
203
198
archimedean α ↔ ∀ x : α, ∃ q : ℚ, x ≤ q :=
@@ -209,30 +204,25 @@ archimedean_iff_rat_lt.trans
209
204
variable [archimedean α]
210
205
211
206
theorem exists_rat_lt (x : α) : ∃ q : ℚ, (q : α) < x :=
212
- let ⟨n, h⟩ := exists_int_lt x in ⟨n, by simp [h]⟩
213
-
214
- theorem exists_pos_rat_lt {x : α} (x0 : 0 < x) : ∃ q : ℚ, 0 < q ∧ (q : α) < x :=
215
- let ⟨n, h⟩ := exists_nat_gt x⁻¹ in begin
216
- have n0 := nat.cast_pos.1 (lt_trans (inv_pos x0) h),
217
- refine ⟨n⁻¹, inv_pos (nat.cast_pos.2 n0), _⟩,
218
- simpa [rat.cast_inv_of_ne_zero, ne_of_gt n0] using
219
- (inv_lt x0 (nat.cast_pos.2 n0)).1 h
220
- end
207
+ let ⟨n, h⟩ := exists_int_lt x in ⟨n, by rwa rat.cast_coe_int⟩
221
208
222
209
theorem exists_rat_btwn {x y : α} (h : x < y) : ∃ q : ℚ, x < q ∧ (q:α) < y :=
223
210
begin
224
211
cases exists_nat_gt (y - x)⁻¹ with n nh,
225
212
cases exists_floor (x * n) with z zh,
226
213
refine ⟨(z + 1 : ℤ) / n, _⟩,
227
214
have n0 := nat.cast_pos.1 (lt_trans (inv_pos (sub_pos.2 h)) nh),
228
- simp [rat.cast_div_of_ne_zero, -int.cast_add, ne_of_gt n0],
229
215
have n0' := (@nat.cast_pos α _ _).2 n0,
216
+ rw [rat.cast_div_of_ne_zero, rat.cast_coe_nat, rat.cast_coe_int, div_lt_iff n0'],
230
217
refine ⟨(lt_div_iff n0').2 $
231
218
(le_iff_le_iff_lt_iff_lt.1 (zh _)).1 (lt_add_one _), _⟩,
232
- simp [div_lt_iff n0', -add_comm ],
219
+ rw [int.cast_add, int.cast_one ],
233
220
refine lt_of_le_of_lt (add_le_add_right ((zh _).1 (le_refl _)) _) _,
234
221
rwa [← lt_sub_iff_add_lt', ← sub_mul,
235
- ← div_lt_iff' (sub_pos.2 h), one_div_eq_inv]
222
+ ← div_lt_iff' (sub_pos.2 h), one_div_eq_inv],
223
+ { rw [rat.coe_int_denom, nat.cast_one], exact one_ne_zero },
224
+ { intro H, rw [rat.coe_nat_num, ← coe_coe, nat.cast_eq_zero] at H, subst H, cases n0 },
225
+ { rw [rat.coe_nat_denom, nat.cast_one], exact one_ne_zero }
236
226
end
237
227
238
228
theorem exists_nat_one_div_lt {ε : α} (hε : ε > 0 ) : ∃ n : ℕ, 1 / (n + 1 : α) < ε :=
@@ -247,6 +237,9 @@ begin
247
237
{ simp [zero_lt_one] }}
248
238
end
249
239
240
+ theorem exists_pos_rat_lt {x : α} (x0 : 0 < x) : ∃ q : ℚ, 0 < q ∧ (q : α) < x :=
241
+ by simpa only [rat.cast_pos] using exists_rat_btwn x0
242
+
250
243
include α
251
244
@[simp] theorem rat.cast_floor (x : ℚ) :
252
245
by haveI := archimedean.floor_ring α; exact ⌊(x:α)⌋ = ⌊x⌋ :=
@@ -273,4 +266,4 @@ let ⟨q, h₁, h₂⟩ := exists_rat_btwn $
273
266
end
274
267
275
268
instance : archimedean ℚ :=
276
- archimedean_iff_rat_le.2 $ λ q, ⟨q, by simp ⟩
269
+ archimedean_iff_rat_le.2 $ λ q, ⟨q, by rw rat.cast_id ⟩
0 commit comments