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

Commit b05d845

Browse files
committed
feat(data/nat/basic): add a few lemmas (#14718)
Add a few lemmas about sub and mod.
1 parent 3feb151 commit b05d845

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/algebra/order/sub.lean

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,9 @@ end
439439
lemma tsub_tsub_tsub_cancel_right (h : c ≤ b) : (a - c) - (b - c) = a - b :=
440440
by rw [tsub_tsub, add_tsub_cancel_of_le h]
441441

442+
lemma tsub_lt_of_lt (h : a < b) : a - c < b :=
443+
lt_of_le_of_lt tsub_le_self h
444+
442445
/-! ### Lemmas that assume that an element is `add_le_cancellable`. -/
443446

444447
namespace add_le_cancellable

src/data/nat/basic.lean

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1289,6 +1289,15 @@ lemma dvd_left_injective : function.injective ((∣) : ℕ → ℕ → Prop) :=
12891289
lemma div_lt_div_of_lt_of_dvd {a b d : ℕ} (hdb : d ∣ b) (h : a < b) : a / d < b / d :=
12901290
by { rw nat.lt_div_iff_mul_lt hdb, exact lt_of_le_of_lt (mul_div_le a d) h }
12911291

1292+
lemma mul_add_mod (a b c : ℕ) : (a * b + c) % b = c % b :=
1293+
by simp [nat.add_mod]
1294+
1295+
lemma mul_add_mod_of_lt {a b c : ℕ} (h : c < b) : (a * b + c) % b = c :=
1296+
by rw [nat.mul_add_mod, nat.mod_eq_of_lt h]
1297+
1298+
lemma pred_eq_self_iff {n : ℕ} : n.pred = n ↔ n = 0 :=
1299+
by { cases n; simp [(nat.succ_ne_self _).symm] }
1300+
12921301
/-! ### `find` -/
12931302
section find
12941303

0 commit comments

Comments
 (0)