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

Commit 7a89b1a

Browse files
feat(data/int/cast/lemmas): a.nat_mod b < b (#17896)
The modulus of an integer by a natural is strictly less than the natural. Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
1 parent 18a5306 commit 7a89b1a

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

src/data/int/cast/lemmas.lean

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ def of_nat_hom : ℕ →+* ℤ := ⟨coe, rfl, int.of_nat_mul, rfl, int.of_nat_a
3636

3737
lemma coe_nat_succ_pos (n : ℕ) : 0 < (n.succ : ℤ) := int.coe_nat_pos.2 (succ_pos n)
3838

39+
lemma to_nat_lt {a : ℤ} {b : ℕ} (hb : b ≠ 0) : a.to_nat < b ↔ a < b :=
40+
by { rw [←to_nat_lt_to_nat, to_nat_coe_nat], exact coe_nat_pos.2 hb.bot_lt }
41+
42+
lemma nat_mod_lt {a : ℤ} {b : ℕ} (hb : b ≠ 0) : a.nat_mod b < b :=
43+
(to_nat_lt hb).2 $ mod_lt_of_pos _ $ coe_nat_pos.2 hb.bot_lt
44+
3945
section cast
4046

4147
@[simp, norm_cast] theorem cast_mul [non_assoc_ring α] : ∀ m n, ((m * n : ℤ) : α) = m * n :=

0 commit comments

Comments
 (0)