@@ -11,8 +11,6 @@ namespace Rat
1111
1212variable (x y a b c q : Rat)
1313
14- protected def abs (x : Rat) := if x < 0 then -x else x
15-
1614instance : NatPow Rat where
1715 pow := Rat.pow
1816
@@ -58,14 +56,6 @@ theorem mk'_zero (d) (h : d ≠ 0) (w) : mk' 0 d h w = 0 := by
5856 congr
5957 apply Nat.coprime_zero_left d |>.mp w
6058
61- theorem eq_iff_mul_eq_mul {p q : Rat} : p = q ↔ p.num * q.den = q.num * p.den := by
62- conv =>
63- lhs
64- rw [← num_divInt_den p, ← num_divInt_den q]
65- apply Rat.divInt_eq_divInt_iff <;>
66- · rw [← Int.natCast_zero, Ne, Int.ofNat_inj]
67- apply den_nz
68-
6959protected theorem lt_iff_blt {x y : Rat} : x < y ↔ x.blt y := by
7060 simp only [LT.lt]
7161
@@ -103,11 +93,6 @@ protected theorem mul_eq_zero_iff : a * b = 0 ↔ a = 0 ∨ b = 0 := by
10393protected theorem mul_ne_zero_iff : a * b ≠ 0 ↔ a ≠ 0 ∧ b ≠ 0 := by
10494 simp only [not_congr (Rat.mul_eq_zero_iff a b), not_or, ne_eq]
10595
106- @[simp]
107- theorem neg_neg : - -q = q := by
108- rewrite [← Rat.mkRat_self q, Rat.neg_mkRat, Rat.neg_mkRat]
109- simp
110-
11196theorem num_ne_zero : q.num ≠ 0 ↔ q ≠ 0 := not_congr num_eq_zero
11297
11398theorem nonneg_iff_sub_nonpos : 0 ≤ q ↔ -q ≤ 0 := by
@@ -158,14 +143,8 @@ theorem num_neg : q.num < 0 ↔ q < 0 := by
158143theorem num_neg_eq_neg_num (q : Rat) : (-q).num = -q.num :=
159144 rfl
160145
161- @[simp]
162- protected theorem sub_self : x - x = 0 :=
163- numDenCasesOn' x fun nx dx h_dx => by
164- rw [Rat.divInt_sub_divInt _ _ (Int.natCast_ne_zero.mpr h_dx) (Int.natCast_ne_zero.mpr h_dx)]
165- simp
166-
167146protected theorem add_neg_self : x + -x = 0 :=
168- Rat.sub_eq_add_neg x x ▸ Rat.sub_self x
147+ Rat.sub_eq_add_neg x x ▸ Rat.sub_self
169148
170149protected theorem eq_neg_of_add_eq_zero_left : x + y = 0 → x = - y :=
171150 numDenCasesOn'' x fun nx dx h_dx h_dx_red =>
@@ -205,7 +184,7 @@ protected theorem divInt_le_divInt
205184
206185theorem cast_lt1 {a b : Int} : Rat.ofInt a < Rat.ofInt b -> a < b := by
207186 intro h
208- simp [Rat.instLT , Rat.ofInt] at h
187+ simp [Rat.lt_iff_blt , Rat.ofInt] at h
209188 simp [Rat.blt] at h
210189 cases h with
211190 | inl h =>
@@ -220,7 +199,7 @@ theorem cast_lt1 {a b : Int} : Rat.ofInt a < Rat.ofInt b -> a < b := by
220199
221200theorem cast_lt2 {a b : Int} : a < b → Rat.ofInt a < Rat.ofInt b := by
222201 intro h
223- simp only [instLT , ofInt, mk_den_one]
202+ simp only [Rat.lt_iff_blt , ofInt, mk_den_one]
224203 simp [Rat.blt]
225204 cases Classical.em (a = 0 ) with
226205 | inl ha => simp [ha]; rw [ha] at h; exact h
@@ -236,7 +215,7 @@ theorem cast_lt' {a b : Int} : a < b ↔ Rat.ofInt a < Rat.ofInt b :=
236215
237216theorem cast_le1 {a b : Int} : Rat.ofInt a ≤ Rat.ofInt b -> a ≤ b := by
238217 intro h
239- simp only [instLE , ofInt, mk_den_one] at h
218+ simp only [Rat.le_iff_blt , ofInt, mk_den_one] at h
240219 simp [Rat.blt] at h
241220 cases Classical.em (b = 0 ) with
242221 | inl hb =>
@@ -260,7 +239,7 @@ theorem cast_le1 {a b : Int} : Rat.ofInt a ≤ Rat.ofInt b -> a ≤ b := by
260239
261240theorem cast_le2 {a b : Int} : a ≤ b → Rat.ofInt a ≤ Rat.ofInt b := by
262241 intro h
263- simp [Rat.instLE , Rat.ofInt]
242+ simp [Rat.le_iff_blt , Rat.ofInt]
264243 simp [Rat.blt]
265244 cases Classical.em (b = 0 ) with
266245 | inl hb =>
@@ -303,13 +282,6 @@ theorem le_floor {z : Int} : ∀ {r : Rat}, z ≤ Rat.floor r ↔ (z : Rat) ≤
303282 rw [Rat.intCast_eq_divInt, Rat.divInt_le_divInt Int.zero_lt_one h', Int.mul_one]
304283 exact Int.le_ediv_iff_mul_le h'
305284
306- @[simp]
307- protected theorem neg_zero : -(0 :Rat) = 0 := rfl
308-
309- protected theorem neg_add (a b : Rat) : -(a + b) = -a + -b := by
310- rw [←Rat.sub_eq_add_neg, ←Rat.neg_neg b, ←Rat.sub_eq_add_neg, Rat.neg_sub]
311- simp [Rat.sub_eq_add_neg, Rat.add_comm, Rat.neg_neg]
312-
313285theorem neg_eq_neg_one_mul (a : Rat) : -a = -1 * a :=
314286 numDenCasesOn a fun n d h h1 => by
315287 simp [Rat.neg_mkRat, Rat.mul_def, Rat.normalize_eq_mkRat]
0 commit comments