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

Commit b67044b

Browse files
committed
feat(set_theory/ordinal/arithmetic): miscellaneous arithmetic lemmas (#15990)
Will be used to prove statements about the Cantor Normal Form.
1 parent c227d10 commit b67044b

3 files changed

Lines changed: 33 additions & 7 deletions

File tree

src/set_theory/ordinal/arithmetic.lean

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ protected theorem sub_eq_zero_iff_le {a b : ordinal} : a - b = 0 ↔ a ≤ b :=
479479
theorem sub_sub (a b c : ordinal) : a - b - c = a - (b + c) :=
480480
eq_of_forall_ge_iff $ λ d, by rw [sub_le, sub_le, sub_le, add_assoc]
481481

482-
theorem add_sub_add_cancel (a b c : ordinal) : a + b - (a + c) = b - c :=
482+
@[simp] theorem add_sub_add_cancel (a b c : ordinal) : a + b - (a + c) = b - c :=
483483
by rw [← sub_sub, add_sub_cancel]
484484

485485
theorem sub_is_limit {a b} (l : is_limit a) (h : b < a) : is_limit (a - b) :=
@@ -804,6 +804,8 @@ instance : has_mod ordinal := ⟨λ a b, a - b * (a / b)⟩
804804

805805
theorem mod_def (a b : ordinal) : a % b = a - b * (a / b) := rfl
806806

807+
theorem mod_le (a b : ordinal) : a % b ≤ a := sub_le_self a _
808+
807809
@[simp] theorem mod_zero (a : ordinal) : a % 0 = a :=
808810
by simp only [mod_def, div_zero, zero_mul, sub_zero]
809811

@@ -841,6 +843,24 @@ end
841843
theorem dvd_iff_mod_eq_zero {a b : ordinal} : b ∣ a ↔ a % b = 0 :=
842844
⟨mod_eq_zero_of_dvd, dvd_of_mod_eq_zero⟩
843845

846+
@[simp] theorem mul_add_mod_self (x y z : ordinal) : (x * y + z) % x = z % x :=
847+
begin
848+
rcases eq_or_ne x 0 with rfl | hx,
849+
{ simp },
850+
{ rwa [mod_def, mul_add_div, mul_add, ←sub_sub, add_sub_cancel, mod_def] }
851+
end
852+
853+
@[simp] theorem mul_mod (x y : ordinal) : x * y % x = 0 := by simpa using mul_add_mod_self x y 0
854+
855+
theorem mod_mod_of_dvd (a : ordinal) {b c : ordinal} (h : c ∣ b) : a % b % c = a % c :=
856+
begin
857+
nth_rewrite_rhs 0 ←div_add_mod a b,
858+
rcases h with ⟨d, rfl⟩,
859+
rw [mul_assoc, mul_add_mod_self]
860+
end
861+
862+
@[simp] theorem mod_mod (a b : ordinal) : a % b % b = a % b := mod_mod_of_dvd a dvd_rfl
863+
844864
/-! ### Families of ordinals
845865
846866
There are two kinds of indexed families that naturally arise when dealing with ordinals: those

src/set_theory/ordinal/exponential.lean

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -190,12 +190,10 @@ end
190190
theorem opow_one_add (a b : ordinal) : a ^ (1 + b) = a * a ^ b :=
191191
by rw [opow_add, opow_one]
192192

193-
theorem opow_dvd_opow (a) {b c : ordinal}
194-
(h : b ≤ c) : a ^ b ∣ a ^ c :=
195-
by { rw [← ordinal.add_sub_cancel_of_le h, opow_add], apply dvd_mul_right }
193+
theorem opow_dvd_opow (a) {b c : ordinal} (h : b ≤ c) : a ^ b ∣ a ^ c :=
194+
⟨a ^ (c - b), by rw [←opow_add, ordinal.add_sub_cancel_of_le h] ⟩
196195

197-
theorem opow_dvd_opow_iff {a b c : ordinal}
198-
(a1 : 1 < a) : a ^ b ∣ a ^ c ↔ b ≤ c :=
196+
theorem opow_dvd_opow_iff {a b c : ordinal} (a1 : 1 < a) : a ^ b ∣ a ^ c ↔ b ≤ c :=
199197
⟨λ h, le_of_not_lt $ λ hn,
200198
not_le_of_lt ((opow_lt_opow_iff_right a1).2 hn) $
201199
le_of_dvd (opow_ne_zero _ $ one_le_iff_ne_zero.1 $ a1.le) h,
@@ -385,6 +383,14 @@ begin
385383
rw [add_zero, mul_one]
386384
end
387385

386+
theorem div_opow_log_pos (b : ordinal) {o : ordinal} (ho : o ≠ 0) : 0 < o / b ^ log b o :=
387+
begin
388+
rcases eq_zero_or_pos b with (rfl | hb),
389+
{ simpa using ordinal.pos_iff_ne_zero.2 ho },
390+
{ rw div_pos (opow_ne_zero _ hb.ne'),
391+
exact opow_log_le_self b ho }
392+
end
393+
388394
theorem div_opow_log_lt {b : ordinal} (o : ordinal) (hb : 1 < b) : o / b ^ log b o < b :=
389395
begin
390396
rw [div_lt (opow_pos _ (zero_lt_one.trans hb)).ne', ←opow_succ],

src/set_theory/ordinal/notation.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ instance sub_NF (o₁ o₂) : ∀ [NF o₁] [NF o₂], NF (o₁ - o₂)
428428
{ change e₁ = e₂ at ee, substI e₂, unfold sub._match_1,
429429
cases mn : (n₁:ℕ) - n₂; dsimp only [sub._match_2],
430430
{ by_cases en : n₁ = n₂,
431-
{ simp [en], rwa [add_sub_add_cancel] },
431+
{ simpa [en] },
432432
{ simp [en, -repr],
433433
exact (ordinal.sub_eq_zero_iff_le.2 $ le_of_lt $ oadd_lt_oadd_2 h₁ $
434434
lt_of_le_of_ne (tsub_eq_zero_iff_le.1 mn) (mt pnat.eq en)).symm } },

0 commit comments

Comments
 (0)