Skip to content

Commit

Permalink
Improve modCore_eq_mod
Browse files Browse the repository at this point in the history
  • Loading branch information
nomeata committed May 7, 2024
1 parent d2017ce commit 7254574
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions src/Init/Data/Nat/Div.lean
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,9 @@ protected theorem modCore_eq_mod (x y : Nat) : Nat.modCore x y = x % y := by
| 0, y =>
rw [Nat.modCore]
exact if_neg fun ⟨hlt, hle⟩ => Nat.lt_irrefl _ (Nat.lt_of_lt_of_le hlt hle)
| 1, 0 =>
rw [Nat.modCore]
exact if_neg fun ⟨hlt, _⟩ => Nat.lt_irrefl _ hlt
| 1, 1 =>
rw [Nat.modCore]
exact if_pos ⟨Nat.one_pos, Nat.le_refl _⟩
| 1, (y+2) =>
rw [Nat.modCore]
exact if_neg fun ⟨_, hle⟩ => Nat.not_succ_le_zero _ (Nat.le_of_succ_le_succ hle)
| 1, 0 => rw [Nat.modCore]; rfl
| 1, 1 => rw [Nat.modCore, Nat.modCore]; rfl
| 1, (y+2) => rw [Nat.modCore]; rfl
| (_ + 2), _ => rfl

theorem mod_eq (x y : Nat) : x % y = if 0 < y ∧ y ≤ x then (x - y) % y else x := by
Expand Down

0 comments on commit 7254574

Please sign in to comment.