Skip to content

Commit 75d7f7e

Browse files
kim-emclaude
andauthored
feat: add Nat.ext_div_mod and Int.ext_ediv_emod (#12258)
This PR adds theorems that directly state that div and mod form an injective pair: if `a / n = b / n` and `a % n = b % n` then `a = b`. These complement existing div/mod lemmas and are useful for extension arguments. Upstreaming from leanprover-community/mathlib4#34201 🤖 Prepared with Claude Code Co-authored-by: Claude Opus 4.5 <[email protected]>
1 parent 5eeea8c commit 75d7f7e

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3000,4 +3000,10 @@ protected theorem dvd_eq_false_of_mod_ne_zero {a b : Int} (h : b % a != 0) : (a
30003000
simp [eq_of_beq] at h
30013001
simp [Int.dvd_iff_emod_eq_zero, h]
30023002

3003+
theorem ext_ediv_emod {n a b : Int} (h0 : a / n = b / n) (h1 : a % n = b % n) : a = b :=
3004+
(mul_ediv_add_emod a n).symm.trans (h0 ▸ h1 ▸ mul_ediv_add_emod b n)
3005+
3006+
theorem ext_ediv_emod_iff (n a b : Int) : a = b ↔ a / n = b / n ∧ a % n = b % n :=
3007+
fun h => ⟨h ▸ rfl, h ▸ rfl⟩, fun ⟨h0, h1⟩ => ext_ediv_emod h0 h1⟩
3008+
30033009
end Int

src/Init/Data/Nat/Div/Lemmas.lean

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,4 +241,10 @@ theorem mod_eq_mod_iff {x y z : Nat} :
241241
replace h := congrArg (· % z) h
242242
simpa using h
243243

244+
theorem ext_div_mod {n a b : Nat} (h0 : a / n = b / n) (h1 : a % n = b % n) : a = b :=
245+
(div_add_mod a n).symm.trans (h0 ▸ h1 ▸ div_add_mod b n)
246+
247+
theorem ext_div_mod_iff (n a b : Nat) : a = b ↔ a / n = b / n ∧ a % n = b % n :=
248+
fun h => ⟨h ▸ rfl, h ▸ rfl⟩, fun ⟨h0, h1⟩ => ext_div_mod h0 h1⟩
249+
244250
end Nat

0 commit comments

Comments
 (0)