@@ -479,7 +479,7 @@ protected theorem sub_eq_zero_iff_le {a b : ordinal} : a - b = 0 ↔ a ≤ b :=
479479theorem sub_sub (a b c : ordinal) : a - b - c = a - (b + c) :=
480480eq_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 :=
483483by rw [← sub_sub, add_sub_cancel]
484484
485485theorem 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
805805theorem 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 :=
808810by simp only [mod_def, div_zero, zero_mul, sub_zero]
809811
841843theorem 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
846866There are two kinds of indexed families that naturally arise when dealing with ordinals: those
0 commit comments