Skip to content

Commit ac0b829

Browse files
authored
chore: add variant of Rat.ofScientific_def for grind (#10534)
1 parent d8219a3 commit ac0b829

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/Init/Data/Rat/Lemmas.lean

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -600,6 +600,7 @@ theorem ofScientific_true_def : Rat.ofScientific m true e = mkRat m (10 ^ e) :=
600600
theorem ofScientific_false_def : Rat.ofScientific m false e = (m * 10 ^ e : Nat) := by
601601
unfold Rat.ofScientific; rfl
602602

603+
-- See also `ofScientific_def'` below.
603604
theorem ofScientific_def : Rat.ofScientific m s e =
604605
if s then mkRat m (10 ^ e) else (m * 10 ^ e : Nat) := by
605606
cases s; exact ofScientific_false_def; exact ofScientific_true_def
@@ -1007,6 +1008,21 @@ theorem intCast_neg_iff {a : Int} :
10071008
(a : Rat) < 0 ↔ a < 0 :=
10081009
Rat.intCast_lt_intCast
10091010

1011+
/--
1012+
Alternative statement of `ofScientific_def`.
1013+
-/
1014+
@[grind =]
1015+
theorem ofScientific_def' :
1016+
(OfScientific.ofScientific m s e : Rat) = m * (10 ^ (if s then -e else e : Int)) := by
1017+
change Rat.ofScientific _ _ _ = _
1018+
rw [ofScientific_def]
1019+
split
1020+
· rw [Rat.zpow_neg, ← Rat.div_def, Rat.zpow_natCast, mkRat_eq_div]
1021+
push_cast
1022+
rfl
1023+
· push_cast
1024+
rfl
1025+
10101026
theorem floor_def (a : Rat) : a.floor = a.num / a.den := by
10111027
rw [Rat.floor]
10121028
split <;> simp_all

0 commit comments

Comments
 (0)