Skip to content

Commit 10307cb

Browse files
committed
chore: add Nat.self_sub_mod lemma
1 parent 325a058 commit 10307cb

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/Init/Data/Nat/Lemmas.lean

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -577,6 +577,15 @@ theorem mul_mod (a b n : Nat) : a * b % n = (a % n) * (b % n) % n := by
577577
theorem add_mod (a b n : Nat) : (a + b) % n = ((a % n) + (b % n)) % n := by
578578
rw [add_mod_mod, mod_add_mod]
579579

580+
@[simp] theorem self_sub_mod (n k : Nat) [NeZero k] : (n - k) % n = n - k := by
581+
cases n with
582+
| zero => simp
583+
| succ n =>
584+
rw [mod_eq_of_lt]
585+
cases k with
586+
| zero => simp_all
587+
| succ k => omega
588+
580589
/-! ### pow -/
581590

582591
theorem pow_succ' {m n : Nat} : m ^ n.succ = m * m ^ n := by

0 commit comments

Comments
 (0)