Skip to content

Commit 6b873c6

Browse files
bollualexkeizer
andcommitted
Update src/Init/Data/Int/DivMod/Lemmas.lean
Co-authored-by: Alex Keizer <[email protected]>
1 parent 368f235 commit 6b873c6

File tree

1 file changed

+13
-18
lines changed

1 file changed

+13
-18
lines changed

src/Init/Data/Int/DivMod/Lemmas.lean

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1344,24 +1344,19 @@ theorem sign_tdiv (a b : Int) : sign (a.tdiv b) = if natAbs a < natAbs b then 0
13441344
the absolute value of the numerator is less than the denominator.
13451345
-/
13461346
theorem tdiv_ofNat_eq_zero_iff_natAbs_lt_or_eq_zero {a : Int} {b : Nat} :
1347-
a.tdiv b = 0 ↔ (a.natAbs < b ∨ b = 0):= by
1348-
by_cases hb : b = 0
1349-
· simp [hb]
1350-
· simp only at hb
1351-
simp only [hb, or_false]
1352-
by_cases h : a < 0
1353-
· obtain ⟨n, hn⟩ := exists_eq_neg_ofNat (show a ≤ 0 by omega)
1354-
subst hn
1355-
simp only [Int.neg_tdiv, Int.neg_eq_zero, natAbs_neg, natAbs_natCast]
1356-
rw [Int.tdiv_eq_ediv_of_nonneg (by omega)]
1357-
norm_cast
1358-
apply Nat.div_eq_zero_iff_lt (by omega)
1359-
· simp only [Int.not_lt] at h;
1360-
obtain ⟨n, hn⟩ := Int.eq_ofNat_of_zero_le h
1361-
subst hn
1362-
rw [Int.tdiv_eq_ediv_of_nonneg (by omega)]
1363-
norm_cast
1364-
apply Nat.div_eq_zero_iff_lt (by omega)
1347+
a.tdiv b = 0 ↔ (a.natAbs < b ∨ b = 0) := by
1348+
rcases b with _|b
1349+
· simp
1350+
· simp only [natCast_add, cast_ofNat_Int, Nat.add_eq_zero, Nat.succ_ne_self, and_false, or_false]
1351+
suffices ∀ (a : Nat), (a : Int).tdiv (↑b + 1) = 0 ↔ a < b + 1 by
1352+
rcases a with _|a
1353+
· simpa using this _
1354+
· obtain ⟨n, hn⟩ := exists_eq_neg_ofNat (show -[a+1] ≤ 0 by omega)
1355+
simp [hn, this]
1356+
intro a
1357+
rw [Int.tdiv_eq_ediv_of_nonneg (by omega)]
1358+
norm_cast
1359+
apply Nat.div_eq_zero_iff_lt (by omega)
13651360

13661361
/-- T-divison equals zero iff the absolute value of the numerator is less
13671362
than the absolute value of the denominator, or the denominator is zero.

0 commit comments

Comments
 (0)