Context
stringlengths
57
6.04k
file_name
stringlengths
21
79
start
int64
14
1.49k
end
int64
18
1.5k
theorem
stringlengths
25
1.55k
proof
stringlengths
5
7.36k
rank
int64
0
2.4k
import Mathlib.Algebra.Order.Ring.Abs #align_import data.int.order.units from "leanprover-community/mathlib"@"d012cd09a9b256d870751284dd6a29882b0be105" namespace Int theorem isUnit_iff_abs_eq {x : ℤ} : IsUnit x ↔ abs x = 1 := by rw [isUnit_iff_natAbs_eq, abs_eq_natAbs, ← Int.ofNat_one, natCast_inj] #align int.is_unit_iff_abs_eq Int.isUnit_iff_abs_eq theorem isUnit_sq {a : ℤ} (ha : IsUnit a) : a ^ 2 = 1 := by rw [sq, isUnit_mul_self ha] #align int.is_unit_sq Int.isUnit_sq @[simp] theorem units_sq (u : ℤˣ) : u ^ 2 = 1 := by rw [Units.ext_iff, Units.val_pow_eq_pow_val, Units.val_one, isUnit_sq u.isUnit] #align int.units_sq Int.units_sq alias units_pow_two := units_sq #align int.units_pow_two Int.units_pow_two @[simp] theorem units_mul_self (u : ℤˣ) : u * u = 1 := by rw [← sq, units_sq] #align int.units_mul_self Int.units_mul_self @[simp] theorem units_inv_eq_self (u : ℤˣ) : u⁻¹ = u := by rw [inv_eq_iff_mul_eq_one, units_mul_self] #align int.units_inv_eq_self Int.units_inv_eq_self theorem units_div_eq_mul (u₁ u₂ : ℤˣ) : u₁ / u₂ = u₁ * u₂ := by rw [div_eq_mul_inv, units_inv_eq_self] -- `Units.val_mul` is a "wrong turn" for the simplifier, this undoes it and simplifies further @[simp]
Mathlib/Data/Int/Order/Units.lean
45
46
theorem units_coe_mul_self (u : ℤˣ) : (u * u : ℤ) = 1 := by
rw [← Units.val_mul, units_mul_self, Units.val_one]
234
import Mathlib.Algebra.Order.Ring.Abs #align_import data.int.order.units from "leanprover-community/mathlib"@"d012cd09a9b256d870751284dd6a29882b0be105" namespace Int theorem isUnit_iff_abs_eq {x : ℤ} : IsUnit x ↔ abs x = 1 := by rw [isUnit_iff_natAbs_eq, abs_eq_natAbs, ← Int.ofNat_one, natCast_inj] #align int.is_unit_iff_abs_eq Int.isUnit_iff_abs_eq theorem isUnit_sq {a : ℤ} (ha : IsUnit a) : a ^ 2 = 1 := by rw [sq, isUnit_mul_self ha] #align int.is_unit_sq Int.isUnit_sq @[simp] theorem units_sq (u : ℤˣ) : u ^ 2 = 1 := by rw [Units.ext_iff, Units.val_pow_eq_pow_val, Units.val_one, isUnit_sq u.isUnit] #align int.units_sq Int.units_sq alias units_pow_two := units_sq #align int.units_pow_two Int.units_pow_two @[simp] theorem units_mul_self (u : ℤˣ) : u * u = 1 := by rw [← sq, units_sq] #align int.units_mul_self Int.units_mul_self @[simp] theorem units_inv_eq_self (u : ℤˣ) : u⁻¹ = u := by rw [inv_eq_iff_mul_eq_one, units_mul_self] #align int.units_inv_eq_self Int.units_inv_eq_self theorem units_div_eq_mul (u₁ u₂ : ℤˣ) : u₁ / u₂ = u₁ * u₂ := by rw [div_eq_mul_inv, units_inv_eq_self] -- `Units.val_mul` is a "wrong turn" for the simplifier, this undoes it and simplifies further @[simp] theorem units_coe_mul_self (u : ℤˣ) : (u * u : ℤ) = 1 := by rw [← Units.val_mul, units_mul_self, Units.val_one] #align int.units_coe_mul_self Int.units_coe_mul_self
Mathlib/Data/Int/Order/Units.lean
49
49
theorem neg_one_pow_ne_zero {n : ℕ} : (-1 : ℤ) ^ n ≠ 0 := by
simp
234
import Mathlib.Algebra.Order.Ring.Abs #align_import data.int.order.units from "leanprover-community/mathlib"@"d012cd09a9b256d870751284dd6a29882b0be105" namespace Int theorem isUnit_iff_abs_eq {x : ℤ} : IsUnit x ↔ abs x = 1 := by rw [isUnit_iff_natAbs_eq, abs_eq_natAbs, ← Int.ofNat_one, natCast_inj] #align int.is_unit_iff_abs_eq Int.isUnit_iff_abs_eq theorem isUnit_sq {a : ℤ} (ha : IsUnit a) : a ^ 2 = 1 := by rw [sq, isUnit_mul_self ha] #align int.is_unit_sq Int.isUnit_sq @[simp] theorem units_sq (u : ℤˣ) : u ^ 2 = 1 := by rw [Units.ext_iff, Units.val_pow_eq_pow_val, Units.val_one, isUnit_sq u.isUnit] #align int.units_sq Int.units_sq alias units_pow_two := units_sq #align int.units_pow_two Int.units_pow_two @[simp] theorem units_mul_self (u : ℤˣ) : u * u = 1 := by rw [← sq, units_sq] #align int.units_mul_self Int.units_mul_self @[simp] theorem units_inv_eq_self (u : ℤˣ) : u⁻¹ = u := by rw [inv_eq_iff_mul_eq_one, units_mul_self] #align int.units_inv_eq_self Int.units_inv_eq_self theorem units_div_eq_mul (u₁ u₂ : ℤˣ) : u₁ / u₂ = u₁ * u₂ := by rw [div_eq_mul_inv, units_inv_eq_self] -- `Units.val_mul` is a "wrong turn" for the simplifier, this undoes it and simplifies further @[simp] theorem units_coe_mul_self (u : ℤˣ) : (u * u : ℤ) = 1 := by rw [← Units.val_mul, units_mul_self, Units.val_one] #align int.units_coe_mul_self Int.units_coe_mul_self theorem neg_one_pow_ne_zero {n : ℕ} : (-1 : ℤ) ^ n ≠ 0 := by simp #align int.neg_one_pow_ne_zero Int.neg_one_pow_ne_zero theorem sq_eq_one_of_sq_lt_four {x : ℤ} (h1 : x ^ 2 < 4) (h2 : x ≠ 0) : x ^ 2 = 1 := sq_eq_one_iff.mpr ((abs_eq (zero_le_one' ℤ)).mp (le_antisymm (lt_add_one_iff.mp (abs_lt_of_sq_lt_sq h1 zero_le_two)) (sub_one_lt_iff.mp (abs_pos.mpr h2)))) #align int.sq_eq_one_of_sq_lt_four Int.sq_eq_one_of_sq_lt_four theorem sq_eq_one_of_sq_le_three {x : ℤ} (h1 : x ^ 2 ≤ 3) (h2 : x ≠ 0) : x ^ 2 = 1 := sq_eq_one_of_sq_lt_four (lt_of_le_of_lt h1 (lt_add_one (3 : ℤ))) h2 #align int.sq_eq_one_of_sq_le_three Int.sq_eq_one_of_sq_le_three
Mathlib/Data/Int/Order/Units.lean
63
67
theorem units_pow_eq_pow_mod_two (u : ℤˣ) (n : ℕ) : u ^ n = u ^ (n % 2) := by
conv => lhs rw [← Nat.mod_add_div n 2]; rw [pow_add, pow_mul, units_sq, one_pow, mul_one]
234
import Mathlib.Algebra.Order.Ring.Abs #align_import data.int.order.lemmas from "leanprover-community/mathlib"@"fc2ed6f838ce7c9b7c7171e58d78eaf7b438fb0e" open Function Nat namespace Int variable {a b : ℤ} {n : ℕ}
Mathlib/Data/Int/Order/Lemmas.lean
28
30
theorem natAbs_eq_iff_mul_self_eq {a b : ℤ} : a.natAbs = b.natAbs ↔ a * a = b * b := by
rw [← abs_eq_iff_mul_self_eq, abs_eq_natAbs, abs_eq_natAbs] exact Int.natCast_inj.symm
235
import Mathlib.Algebra.Order.Ring.Abs #align_import data.int.order.lemmas from "leanprover-community/mathlib"@"fc2ed6f838ce7c9b7c7171e58d78eaf7b438fb0e" open Function Nat namespace Int variable {a b : ℤ} {n : ℕ} theorem natAbs_eq_iff_mul_self_eq {a b : ℤ} : a.natAbs = b.natAbs ↔ a * a = b * b := by rw [← abs_eq_iff_mul_self_eq, abs_eq_natAbs, abs_eq_natAbs] exact Int.natCast_inj.symm #align int.nat_abs_eq_iff_mul_self_eq Int.natAbs_eq_iff_mul_self_eq #align int.eq_nat_abs_iff_mul_eq_zero Int.eq_natAbs_iff_mul_eq_zero
Mathlib/Data/Int/Order/Lemmas.lean
35
37
theorem natAbs_lt_iff_mul_self_lt {a b : ℤ} : a.natAbs < b.natAbs ↔ a * a < b * b := by
rw [← abs_lt_iff_mul_self_lt, abs_eq_natAbs, abs_eq_natAbs] exact Int.ofNat_lt.symm
235
import Mathlib.Algebra.Order.Ring.Abs #align_import data.int.order.lemmas from "leanprover-community/mathlib"@"fc2ed6f838ce7c9b7c7171e58d78eaf7b438fb0e" open Function Nat namespace Int variable {a b : ℤ} {n : ℕ} theorem natAbs_eq_iff_mul_self_eq {a b : ℤ} : a.natAbs = b.natAbs ↔ a * a = b * b := by rw [← abs_eq_iff_mul_self_eq, abs_eq_natAbs, abs_eq_natAbs] exact Int.natCast_inj.symm #align int.nat_abs_eq_iff_mul_self_eq Int.natAbs_eq_iff_mul_self_eq #align int.eq_nat_abs_iff_mul_eq_zero Int.eq_natAbs_iff_mul_eq_zero theorem natAbs_lt_iff_mul_self_lt {a b : ℤ} : a.natAbs < b.natAbs ↔ a * a < b * b := by rw [← abs_lt_iff_mul_self_lt, abs_eq_natAbs, abs_eq_natAbs] exact Int.ofNat_lt.symm #align int.nat_abs_lt_iff_mul_self_lt Int.natAbs_lt_iff_mul_self_lt
Mathlib/Data/Int/Order/Lemmas.lean
40
42
theorem natAbs_le_iff_mul_self_le {a b : ℤ} : a.natAbs ≤ b.natAbs ↔ a * a ≤ b * b := by
rw [← abs_le_iff_mul_self_le, abs_eq_natAbs, abs_eq_natAbs] exact Int.ofNat_le.symm
235
import Mathlib.Algebra.Order.Ring.Abs #align_import data.int.order.lemmas from "leanprover-community/mathlib"@"fc2ed6f838ce7c9b7c7171e58d78eaf7b438fb0e" open Function Nat namespace Int variable {a b : ℤ} {n : ℕ} theorem natAbs_eq_iff_mul_self_eq {a b : ℤ} : a.natAbs = b.natAbs ↔ a * a = b * b := by rw [← abs_eq_iff_mul_self_eq, abs_eq_natAbs, abs_eq_natAbs] exact Int.natCast_inj.symm #align int.nat_abs_eq_iff_mul_self_eq Int.natAbs_eq_iff_mul_self_eq #align int.eq_nat_abs_iff_mul_eq_zero Int.eq_natAbs_iff_mul_eq_zero theorem natAbs_lt_iff_mul_self_lt {a b : ℤ} : a.natAbs < b.natAbs ↔ a * a < b * b := by rw [← abs_lt_iff_mul_self_lt, abs_eq_natAbs, abs_eq_natAbs] exact Int.ofNat_lt.symm #align int.nat_abs_lt_iff_mul_self_lt Int.natAbs_lt_iff_mul_self_lt theorem natAbs_le_iff_mul_self_le {a b : ℤ} : a.natAbs ≤ b.natAbs ↔ a * a ≤ b * b := by rw [← abs_le_iff_mul_self_le, abs_eq_natAbs, abs_eq_natAbs] exact Int.ofNat_le.symm #align int.nat_abs_le_iff_mul_self_le Int.natAbs_le_iff_mul_self_le
Mathlib/Data/Int/Order/Lemmas.lean
45
50
theorem dvd_div_of_mul_dvd {a b c : ℤ} (h : a * b ∣ c) : b ∣ c / a := by
rcases eq_or_ne a 0 with (rfl | ha) · simp only [Int.ediv_zero, Int.dvd_zero] rcases h with ⟨d, rfl⟩ refine ⟨d, ?_⟩ rw [mul_assoc, Int.mul_ediv_cancel_left _ ha]
235
import Mathlib.Algebra.Order.Ring.Abs #align_import data.int.order.lemmas from "leanprover-community/mathlib"@"fc2ed6f838ce7c9b7c7171e58d78eaf7b438fb0e" open Function Nat namespace Int variable {a b : ℤ} {n : ℕ} theorem natAbs_eq_iff_mul_self_eq {a b : ℤ} : a.natAbs = b.natAbs ↔ a * a = b * b := by rw [← abs_eq_iff_mul_self_eq, abs_eq_natAbs, abs_eq_natAbs] exact Int.natCast_inj.symm #align int.nat_abs_eq_iff_mul_self_eq Int.natAbs_eq_iff_mul_self_eq #align int.eq_nat_abs_iff_mul_eq_zero Int.eq_natAbs_iff_mul_eq_zero theorem natAbs_lt_iff_mul_self_lt {a b : ℤ} : a.natAbs < b.natAbs ↔ a * a < b * b := by rw [← abs_lt_iff_mul_self_lt, abs_eq_natAbs, abs_eq_natAbs] exact Int.ofNat_lt.symm #align int.nat_abs_lt_iff_mul_self_lt Int.natAbs_lt_iff_mul_self_lt theorem natAbs_le_iff_mul_self_le {a b : ℤ} : a.natAbs ≤ b.natAbs ↔ a * a ≤ b * b := by rw [← abs_le_iff_mul_self_le, abs_eq_natAbs, abs_eq_natAbs] exact Int.ofNat_le.symm #align int.nat_abs_le_iff_mul_self_le Int.natAbs_le_iff_mul_self_le theorem dvd_div_of_mul_dvd {a b c : ℤ} (h : a * b ∣ c) : b ∣ c / a := by rcases eq_or_ne a 0 with (rfl | ha) · simp only [Int.ediv_zero, Int.dvd_zero] rcases h with ⟨d, rfl⟩ refine ⟨d, ?_⟩ rw [mul_assoc, Int.mul_ediv_cancel_left _ ha] #align int.dvd_div_of_mul_dvd Int.dvd_div_of_mul_dvd lemma pow_right_injective (h : 1 < a.natAbs) : Injective ((a ^ ·) : ℕ → ℤ) := by refine (?_ : Injective (natAbs ∘ (a ^ · : ℕ → ℤ))).of_comp convert Nat.pow_right_injective h using 2 rw [Function.comp_apply, natAbs_pow] #align int.pow_right_injective Int.pow_right_injective
Mathlib/Data/Int/Order/Lemmas.lean
62
68
theorem eq_zero_of_abs_lt_dvd {m x : ℤ} (h1 : m ∣ x) (h2 : |x| < m) : x = 0 := by
obtain rfl | hm := eq_or_ne m 0 · exact Int.zero_dvd.1 h1 rcases h1 with ⟨d, rfl⟩ apply mul_eq_zero_of_right rw [← abs_lt_one_iff, ← mul_lt_iff_lt_one_right (abs_pos.mpr hm), ← abs_mul] exact lt_of_lt_of_le h2 (le_abs_self m)
235
import Mathlib.Algebra.Group.Basic import Mathlib.Algebra.Group.Hom.Defs import Mathlib.Algebra.GroupWithZero.NeZero import Mathlib.Algebra.Opposites import Mathlib.Algebra.Ring.Defs #align_import algebra.ring.basic from "leanprover-community/mathlib"@"2ed7e4aec72395b6a7c3ac4ac7873a7a43ead17c" variable {R : Type*} open Function namespace AddHom @[simps (config := .asFn)] def mulLeft [Distrib R] (r : R) : AddHom R R where toFun := (r * ·) map_add' := mul_add r #align add_hom.mul_left AddHom.mulLeft #align add_hom.mul_left_apply AddHom.mulLeft_apply @[simps (config := .asFn)] def mulRight [Distrib R] (r : R) : AddHom R R where toFun a := a * r map_add' _ _ := add_mul _ _ r #align add_hom.mul_right AddHom.mulRight #align add_hom.mul_right_apply AddHom.mulRight_apply end AddHom section HasDistribNeg section Group variable {α : Type*} [Group α] [HasDistribNeg α] @[simp]
Mathlib/Algebra/Ring/Basic.lean
112
113
theorem inv_neg' (a : α) : (-a)⁻¹ = -a⁻¹ := by
rw [eq_comm, eq_inv_iff_mul_eq_one, neg_mul, mul_neg, neg_neg, mul_left_inv]
236
import Mathlib.Algebra.Group.Basic import Mathlib.Algebra.Group.Hom.Defs import Mathlib.Algebra.GroupWithZero.NeZero import Mathlib.Algebra.Opposites import Mathlib.Algebra.Ring.Defs #align_import algebra.ring.basic from "leanprover-community/mathlib"@"2ed7e4aec72395b6a7c3ac4ac7873a7a43ead17c" variable {R : Type*} open Function namespace AddHom @[simps (config := .asFn)] def mulLeft [Distrib R] (r : R) : AddHom R R where toFun := (r * ·) map_add' := mul_add r #align add_hom.mul_left AddHom.mulLeft #align add_hom.mul_left_apply AddHom.mulLeft_apply @[simps (config := .asFn)] def mulRight [Distrib R] (r : R) : AddHom R R where toFun a := a * r map_add' _ _ := add_mul _ _ r #align add_hom.mul_right AddHom.mulRight #align add_hom.mul_right_apply AddHom.mulRight_apply end AddHom section HasDistribNeg section NonUnitalCommRing variable {α : Type*} [NonUnitalCommRing α] {a b c : α} attribute [local simp] add_assoc add_comm add_left_comm mul_comm
Mathlib/Algebra/Ring/Basic.lean
130
134
theorem vieta_formula_quadratic {b c x : α} (h : x * x - b * x + c = 0) : ∃ y : α, y * y - b * y + c = 0 ∧ x + y = b ∧ x * y = c := by
have : c = x * (b - x) := (eq_neg_of_add_eq_zero_right h).trans (by simp [mul_sub, mul_comm]) refine ⟨b - x, ?_, by simp, by rw [this]⟩ rw [this, sub_add, ← sub_mul, sub_self]
236
import Mathlib.Algebra.Group.Semiconj.Defs import Mathlib.Algebra.Ring.Defs #align_import algebra.ring.semiconj from "leanprover-community/mathlib"@"70d50ecfd4900dd6d328da39ab7ebd516abe4025" universe u v w x variable {α : Type u} {β : Type v} {γ : Type w} {R : Type x} open Function namespace SemiconjBy @[simp]
Mathlib/Algebra/Ring/Semiconj.lean
33
35
theorem add_right [Distrib R] {a x y x' y' : R} (h : SemiconjBy a x y) (h' : SemiconjBy a x' y') : SemiconjBy a (x + x') (y + y') := by
simp only [SemiconjBy, left_distrib, right_distrib, h.eq, h'.eq]
237
import Mathlib.Algebra.Group.Semiconj.Defs import Mathlib.Algebra.Ring.Defs #align_import algebra.ring.semiconj from "leanprover-community/mathlib"@"70d50ecfd4900dd6d328da39ab7ebd516abe4025" universe u v w x variable {α : Type u} {β : Type v} {γ : Type w} {R : Type x} open Function namespace SemiconjBy @[simp] theorem add_right [Distrib R] {a x y x' y' : R} (h : SemiconjBy a x y) (h' : SemiconjBy a x' y') : SemiconjBy a (x + x') (y + y') := by simp only [SemiconjBy, left_distrib, right_distrib, h.eq, h'.eq] #align semiconj_by.add_right SemiconjBy.add_right @[simp]
Mathlib/Algebra/Ring/Semiconj.lean
39
41
theorem add_left [Distrib R] {a b x y : R} (ha : SemiconjBy a x y) (hb : SemiconjBy b x y) : SemiconjBy (a + b) x y := by
simp only [SemiconjBy, left_distrib, right_distrib, ha.eq, hb.eq]
237
import Mathlib.Algebra.Group.Semiconj.Defs import Mathlib.Algebra.Ring.Defs #align_import algebra.ring.semiconj from "leanprover-community/mathlib"@"70d50ecfd4900dd6d328da39ab7ebd516abe4025" universe u v w x variable {α : Type u} {β : Type v} {γ : Type w} {R : Type x} open Function namespace SemiconjBy @[simp] theorem add_right [Distrib R] {a x y x' y' : R} (h : SemiconjBy a x y) (h' : SemiconjBy a x' y') : SemiconjBy a (x + x') (y + y') := by simp only [SemiconjBy, left_distrib, right_distrib, h.eq, h'.eq] #align semiconj_by.add_right SemiconjBy.add_right @[simp] theorem add_left [Distrib R] {a b x y : R} (ha : SemiconjBy a x y) (hb : SemiconjBy b x y) : SemiconjBy (a + b) x y := by simp only [SemiconjBy, left_distrib, right_distrib, ha.eq, hb.eq] #align semiconj_by.add_left SemiconjBy.add_left section variable [Mul R] [HasDistribNeg R] {a x y : R}
Mathlib/Algebra/Ring/Semiconj.lean
48
49
theorem neg_right (h : SemiconjBy a x y) : SemiconjBy a (-x) (-y) := by
simp only [SemiconjBy, h.eq, neg_mul, mul_neg]
237
import Mathlib.Algebra.Group.Semiconj.Defs import Mathlib.Algebra.Ring.Defs #align_import algebra.ring.semiconj from "leanprover-community/mathlib"@"70d50ecfd4900dd6d328da39ab7ebd516abe4025" universe u v w x variable {α : Type u} {β : Type v} {γ : Type w} {R : Type x} open Function namespace SemiconjBy @[simp] theorem add_right [Distrib R] {a x y x' y' : R} (h : SemiconjBy a x y) (h' : SemiconjBy a x' y') : SemiconjBy a (x + x') (y + y') := by simp only [SemiconjBy, left_distrib, right_distrib, h.eq, h'.eq] #align semiconj_by.add_right SemiconjBy.add_right @[simp] theorem add_left [Distrib R] {a b x y : R} (ha : SemiconjBy a x y) (hb : SemiconjBy b x y) : SemiconjBy (a + b) x y := by simp only [SemiconjBy, left_distrib, right_distrib, ha.eq, hb.eq] #align semiconj_by.add_left SemiconjBy.add_left section variable [Mul R] [HasDistribNeg R] {a x y : R} theorem neg_right (h : SemiconjBy a x y) : SemiconjBy a (-x) (-y) := by simp only [SemiconjBy, h.eq, neg_mul, mul_neg] #align semiconj_by.neg_right SemiconjBy.neg_right @[simp] theorem neg_right_iff : SemiconjBy a (-x) (-y) ↔ SemiconjBy a x y := ⟨fun h => neg_neg x ▸ neg_neg y ▸ h.neg_right, SemiconjBy.neg_right⟩ #align semiconj_by.neg_right_iff SemiconjBy.neg_right_iff
Mathlib/Algebra/Ring/Semiconj.lean
57
58
theorem neg_left (h : SemiconjBy a x y) : SemiconjBy (-a) x y := by
simp only [SemiconjBy, h.eq, neg_mul, mul_neg]
237
import Mathlib.Algebra.Group.Semiconj.Defs import Mathlib.Algebra.Ring.Defs #align_import algebra.ring.semiconj from "leanprover-community/mathlib"@"70d50ecfd4900dd6d328da39ab7ebd516abe4025" universe u v w x variable {α : Type u} {β : Type v} {γ : Type w} {R : Type x} open Function namespace SemiconjBy @[simp] theorem add_right [Distrib R] {a x y x' y' : R} (h : SemiconjBy a x y) (h' : SemiconjBy a x' y') : SemiconjBy a (x + x') (y + y') := by simp only [SemiconjBy, left_distrib, right_distrib, h.eq, h'.eq] #align semiconj_by.add_right SemiconjBy.add_right @[simp] theorem add_left [Distrib R] {a b x y : R} (ha : SemiconjBy a x y) (hb : SemiconjBy b x y) : SemiconjBy (a + b) x y := by simp only [SemiconjBy, left_distrib, right_distrib, ha.eq, hb.eq] #align semiconj_by.add_left SemiconjBy.add_left section variable [Mul R] [HasDistribNeg R] {a x y : R} theorem neg_right (h : SemiconjBy a x y) : SemiconjBy a (-x) (-y) := by simp only [SemiconjBy, h.eq, neg_mul, mul_neg] #align semiconj_by.neg_right SemiconjBy.neg_right @[simp] theorem neg_right_iff : SemiconjBy a (-x) (-y) ↔ SemiconjBy a x y := ⟨fun h => neg_neg x ▸ neg_neg y ▸ h.neg_right, SemiconjBy.neg_right⟩ #align semiconj_by.neg_right_iff SemiconjBy.neg_right_iff theorem neg_left (h : SemiconjBy a x y) : SemiconjBy (-a) x y := by simp only [SemiconjBy, h.eq, neg_mul, mul_neg] #align semiconj_by.neg_left SemiconjBy.neg_left @[simp] theorem neg_left_iff : SemiconjBy (-a) x y ↔ SemiconjBy a x y := ⟨fun h => neg_neg a ▸ h.neg_left, SemiconjBy.neg_left⟩ #align semiconj_by.neg_left_iff SemiconjBy.neg_left_iff end section variable [MulOneClass R] [HasDistribNeg R] {a x y : R} -- Porting note: `simpNF` told me to remove `simp` attribute theorem neg_one_right (a : R) : SemiconjBy a (-1) (-1) := (one_right a).neg_right #align semiconj_by.neg_one_right SemiconjBy.neg_one_right -- Porting note: `simpNF` told me to remove `simp` attribute theorem neg_one_left (x : R) : SemiconjBy (-1) x x := (SemiconjBy.one_left x).neg_left #align semiconj_by.neg_one_left SemiconjBy.neg_one_left end section variable [NonUnitalNonAssocRing R] {a b x y x' y' : R} @[simp]
Mathlib/Algebra/Ring/Semiconj.lean
89
91
theorem sub_right (h : SemiconjBy a x y) (h' : SemiconjBy a x' y') : SemiconjBy a (x - x') (y - y') := by
simpa only [sub_eq_add_neg] using h.add_right h'.neg_right
237
import Mathlib.Algebra.Group.Semiconj.Defs import Mathlib.Algebra.Ring.Defs #align_import algebra.ring.semiconj from "leanprover-community/mathlib"@"70d50ecfd4900dd6d328da39ab7ebd516abe4025" universe u v w x variable {α : Type u} {β : Type v} {γ : Type w} {R : Type x} open Function namespace SemiconjBy @[simp] theorem add_right [Distrib R] {a x y x' y' : R} (h : SemiconjBy a x y) (h' : SemiconjBy a x' y') : SemiconjBy a (x + x') (y + y') := by simp only [SemiconjBy, left_distrib, right_distrib, h.eq, h'.eq] #align semiconj_by.add_right SemiconjBy.add_right @[simp] theorem add_left [Distrib R] {a b x y : R} (ha : SemiconjBy a x y) (hb : SemiconjBy b x y) : SemiconjBy (a + b) x y := by simp only [SemiconjBy, left_distrib, right_distrib, ha.eq, hb.eq] #align semiconj_by.add_left SemiconjBy.add_left section variable [Mul R] [HasDistribNeg R] {a x y : R} theorem neg_right (h : SemiconjBy a x y) : SemiconjBy a (-x) (-y) := by simp only [SemiconjBy, h.eq, neg_mul, mul_neg] #align semiconj_by.neg_right SemiconjBy.neg_right @[simp] theorem neg_right_iff : SemiconjBy a (-x) (-y) ↔ SemiconjBy a x y := ⟨fun h => neg_neg x ▸ neg_neg y ▸ h.neg_right, SemiconjBy.neg_right⟩ #align semiconj_by.neg_right_iff SemiconjBy.neg_right_iff theorem neg_left (h : SemiconjBy a x y) : SemiconjBy (-a) x y := by simp only [SemiconjBy, h.eq, neg_mul, mul_neg] #align semiconj_by.neg_left SemiconjBy.neg_left @[simp] theorem neg_left_iff : SemiconjBy (-a) x y ↔ SemiconjBy a x y := ⟨fun h => neg_neg a ▸ h.neg_left, SemiconjBy.neg_left⟩ #align semiconj_by.neg_left_iff SemiconjBy.neg_left_iff end section variable [MulOneClass R] [HasDistribNeg R] {a x y : R} -- Porting note: `simpNF` told me to remove `simp` attribute theorem neg_one_right (a : R) : SemiconjBy a (-1) (-1) := (one_right a).neg_right #align semiconj_by.neg_one_right SemiconjBy.neg_one_right -- Porting note: `simpNF` told me to remove `simp` attribute theorem neg_one_left (x : R) : SemiconjBy (-1) x x := (SemiconjBy.one_left x).neg_left #align semiconj_by.neg_one_left SemiconjBy.neg_one_left end section variable [NonUnitalNonAssocRing R] {a b x y x' y' : R} @[simp] theorem sub_right (h : SemiconjBy a x y) (h' : SemiconjBy a x' y') : SemiconjBy a (x - x') (y - y') := by simpa only [sub_eq_add_neg] using h.add_right h'.neg_right #align semiconj_by.sub_right SemiconjBy.sub_right @[simp]
Mathlib/Algebra/Ring/Semiconj.lean
95
97
theorem sub_left (ha : SemiconjBy a x y) (hb : SemiconjBy b x y) : SemiconjBy (a - b) x y := by
simpa only [sub_eq_add_neg] using ha.add_left hb.neg_left
237
import Mathlib.Algebra.Ring.Defs import Mathlib.Algebra.Group.Ext local macro:max "local_hAdd[" type:term ", " inst:term "]" : term => `(term| (letI := $inst; HAdd.hAdd : $type → $type → $type)) local macro:max "local_hMul[" type:term ", " inst:term "]" : term => `(term| (letI := $inst; HMul.hMul : $type → $type → $type)) universe u variable {R : Type u} namespace NonUnitalNonAssocSemiring @[ext] theorem ext ⦃inst₁ inst₂ : NonUnitalNonAssocSemiring R⦄ (h_add : local_hAdd[R, inst₁] = local_hAdd[R, inst₂]) (h_mul : local_hMul[R, inst₁] = local_hMul[R, inst₂]) : inst₁ = inst₂ := by -- Split into `AddMonoid` instance, `mul` function and properties. rcases inst₁ with @⟨_, ⟨⟩⟩ rcases inst₂ with @⟨_, ⟨⟩⟩ -- Prove equality of parts using already-proved extensionality lemmas. congr; ext : 1; assumption
Mathlib/Algebra/Ring/Ext.lean
73
77
theorem toDistrib_injective : Function.Injective (@toDistrib R) := by
intro _ _ h ext x y · exact congrArg (·.toAdd.add x y) h · exact congrArg (·.toMul.mul x y) h
238
import Mathlib.Algebra.Ring.Defs import Mathlib.Algebra.Group.Ext local macro:max "local_hAdd[" type:term ", " inst:term "]" : term => `(term| (letI := $inst; HAdd.hAdd : $type → $type → $type)) local macro:max "local_hMul[" type:term ", " inst:term "]" : term => `(term| (letI := $inst; HMul.hMul : $type → $type → $type)) universe u variable {R : Type u} namespace NonUnitalSemiring
Mathlib/Algebra/Ring/Ext.lean
90
92
theorem toNonUnitalNonAssocSemiring_injective : Function.Injective (@toNonUnitalNonAssocSemiring R) := by
rintro ⟨⟩ ⟨⟩ _; congr
238
import Mathlib.Algebra.Ring.Defs import Mathlib.Algebra.Group.Ext local macro:max "local_hAdd[" type:term ", " inst:term "]" : term => `(term| (letI := $inst; HAdd.hAdd : $type → $type → $type)) local macro:max "local_hMul[" type:term ", " inst:term "]" : term => `(term| (letI := $inst; HMul.hMul : $type → $type → $type)) universe u variable {R : Type u} @[ext] theorem AddMonoidWithOne.ext ⦃inst₁ inst₂ : AddMonoidWithOne R⦄ (h_add : local_hAdd[R, inst₁] = local_hAdd[R, inst₂]) (h_one : (letI := inst₁; One.one : R) = (letI := inst₂; One.one : R)) : inst₁ = inst₂ := by have h_monoid : inst₁.toAddMonoid = inst₂.toAddMonoid := by ext : 1; exact h_add have h_zero' : inst₁.toZero = inst₂.toZero := congrArg (·.toZero) h_monoid have h_one' : inst₁.toOne = inst₂.toOne := congrArg One.mk h_one have h_natCast : inst₁.toNatCast.natCast = inst₂.toNatCast.natCast := by funext n; induction n with | zero => rewrite [inst₁.natCast_zero, inst₂.natCast_zero] exact congrArg (@Zero.zero R) h_zero' | succ n h => rw [inst₁.natCast_succ, inst₂.natCast_succ, h_add] exact congrArg₂ _ h h_one rcases inst₁ with @⟨⟨⟩⟩; rcases inst₂ with @⟨⟨⟩⟩ congr
Mathlib/Algebra/Ring/Ext.lean
133
135
theorem AddCommMonoidWithOne.toAddMonoidWithOne_injective : Function.Injective (@AddCommMonoidWithOne.toAddMonoidWithOne R) := by
rintro ⟨⟩ ⟨⟩ _; congr
238
import Mathlib.Algebra.Ring.Defs import Mathlib.Algebra.Group.Ext local macro:max "local_hAdd[" type:term ", " inst:term "]" : term => `(term| (letI := $inst; HAdd.hAdd : $type → $type → $type)) local macro:max "local_hMul[" type:term ", " inst:term "]" : term => `(term| (letI := $inst; HMul.hMul : $type → $type → $type)) universe u variable {R : Type u} @[ext] theorem AddMonoidWithOne.ext ⦃inst₁ inst₂ : AddMonoidWithOne R⦄ (h_add : local_hAdd[R, inst₁] = local_hAdd[R, inst₂]) (h_one : (letI := inst₁; One.one : R) = (letI := inst₂; One.one : R)) : inst₁ = inst₂ := by have h_monoid : inst₁.toAddMonoid = inst₂.toAddMonoid := by ext : 1; exact h_add have h_zero' : inst₁.toZero = inst₂.toZero := congrArg (·.toZero) h_monoid have h_one' : inst₁.toOne = inst₂.toOne := congrArg One.mk h_one have h_natCast : inst₁.toNatCast.natCast = inst₂.toNatCast.natCast := by funext n; induction n with | zero => rewrite [inst₁.natCast_zero, inst₂.natCast_zero] exact congrArg (@Zero.zero R) h_zero' | succ n h => rw [inst₁.natCast_succ, inst₂.natCast_succ, h_add] exact congrArg₂ _ h h_one rcases inst₁ with @⟨⟨⟩⟩; rcases inst₂ with @⟨⟨⟩⟩ congr theorem AddCommMonoidWithOne.toAddMonoidWithOne_injective : Function.Injective (@AddCommMonoidWithOne.toAddMonoidWithOne R) := by rintro ⟨⟩ ⟨⟩ _; congr @[ext] theorem AddCommMonoidWithOne.ext ⦃inst₁ inst₂ : AddCommMonoidWithOne R⦄ (h_add : local_hAdd[R, inst₁] = local_hAdd[R, inst₂]) (h_one : (letI := inst₁; One.one : R) = (letI := inst₂; One.one : R)) : inst₁ = inst₂ := AddCommMonoidWithOne.toAddMonoidWithOne_injective <| AddMonoidWithOne.ext h_add h_one namespace NonUnitalNonAssocRing @[ext] theorem ext ⦃inst₁ inst₂ : NonUnitalNonAssocRing R⦄ (h_add : local_hAdd[R, inst₁] = local_hAdd[R, inst₂]) (h_mul : local_hMul[R, inst₁] = local_hMul[R, inst₂]) : inst₁ = inst₂ := by -- Split into `AddCommGroup` instance, `mul` function and properties. rcases inst₁ with @⟨_, ⟨⟩⟩; rcases inst₂ with @⟨_, ⟨⟩⟩ congr; (ext : 1; assumption)
Mathlib/Algebra/Ring/Ext.lean
195
201
theorem toNonUnitalNonAssocSemiring_injective : Function.Injective (@toNonUnitalNonAssocSemiring R) := by
intro _ _ h -- Use above extensionality lemma to prove injectivity by showing that `h_add` and `h_mul` hold. ext x y · exact congrArg (·.toAdd.add x y) h · exact congrArg (·.toMul.mul x y) h
238
import Mathlib.Algebra.Ring.Defs import Mathlib.Algebra.Group.Ext local macro:max "local_hAdd[" type:term ", " inst:term "]" : term => `(term| (letI := $inst; HAdd.hAdd : $type → $type → $type)) local macro:max "local_hMul[" type:term ", " inst:term "]" : term => `(term| (letI := $inst; HMul.hMul : $type → $type → $type)) universe u variable {R : Type u} @[ext] theorem AddMonoidWithOne.ext ⦃inst₁ inst₂ : AddMonoidWithOne R⦄ (h_add : local_hAdd[R, inst₁] = local_hAdd[R, inst₂]) (h_one : (letI := inst₁; One.one : R) = (letI := inst₂; One.one : R)) : inst₁ = inst₂ := by have h_monoid : inst₁.toAddMonoid = inst₂.toAddMonoid := by ext : 1; exact h_add have h_zero' : inst₁.toZero = inst₂.toZero := congrArg (·.toZero) h_monoid have h_one' : inst₁.toOne = inst₂.toOne := congrArg One.mk h_one have h_natCast : inst₁.toNatCast.natCast = inst₂.toNatCast.natCast := by funext n; induction n with | zero => rewrite [inst₁.natCast_zero, inst₂.natCast_zero] exact congrArg (@Zero.zero R) h_zero' | succ n h => rw [inst₁.natCast_succ, inst₂.natCast_succ, h_add] exact congrArg₂ _ h h_one rcases inst₁ with @⟨⟨⟩⟩; rcases inst₂ with @⟨⟨⟩⟩ congr theorem AddCommMonoidWithOne.toAddMonoidWithOne_injective : Function.Injective (@AddCommMonoidWithOne.toAddMonoidWithOne R) := by rintro ⟨⟩ ⟨⟩ _; congr @[ext] theorem AddCommMonoidWithOne.ext ⦃inst₁ inst₂ : AddCommMonoidWithOne R⦄ (h_add : local_hAdd[R, inst₁] = local_hAdd[R, inst₂]) (h_one : (letI := inst₁; One.one : R) = (letI := inst₂; One.one : R)) : inst₁ = inst₂ := AddCommMonoidWithOne.toAddMonoidWithOne_injective <| AddMonoidWithOne.ext h_add h_one @[ext] theorem AddGroupWithOne.ext ⦃inst₁ inst₂ : AddGroupWithOne R⦄ (h_add : local_hAdd[R, inst₁] = local_hAdd[R, inst₂]) (h_one : (letI := inst₁; One.one : R) = (letI := inst₂; One.one)) : inst₁ = inst₂ := by have : inst₁.toAddMonoidWithOne = inst₂.toAddMonoidWithOne := AddMonoidWithOne.ext h_add h_one have : inst₁.toNatCast = inst₂.toNatCast := congrArg (·.toNatCast) this have h_group : inst₁.toAddGroup = inst₂.toAddGroup := by ext : 1; exact h_add -- Extract equality of necessary substructures from h_group injection h_group with h_group; injection h_group have : inst₁.toIntCast.intCast = inst₂.toIntCast.intCast := by funext n; cases n with | ofNat n => rewrite [Int.ofNat_eq_coe, inst₁.intCast_ofNat, inst₂.intCast_ofNat]; congr | negSucc n => rewrite [inst₁.intCast_negSucc, inst₂.intCast_negSucc]; congr rcases inst₁ with @⟨⟨⟩⟩; rcases inst₂ with @⟨⟨⟩⟩ congr @[ext] theorem AddCommGroupWithOne.ext ⦃inst₁ inst₂ : AddCommGroupWithOne R⦄ (h_add : local_hAdd[R, inst₁] = local_hAdd[R, inst₂]) (h_one : (letI := inst₁; One.one : R) = (letI := inst₂; One.one)) : inst₁ = inst₂ := by have : inst₁.toAddCommGroup = inst₂.toAddCommGroup := AddCommGroup.ext h_add have : inst₁.toAddGroupWithOne = inst₂.toAddGroupWithOne := AddGroupWithOne.ext h_add h_one injection this with _ h_addMonoidWithOne; injection h_addMonoidWithOne cases inst₁; cases inst₂ congr namespace NonUnitalNonAssocCommSemiring
Mathlib/Algebra/Ring/Ext.lean
405
407
theorem toNonUnitalNonAssocSemiring_injective : Function.Injective (@toNonUnitalNonAssocSemiring R) := by
rintro ⟨⟩ ⟨⟩ _; congr
238
import Mathlib.Algebra.Ring.Defs import Mathlib.Algebra.Group.Ext local macro:max "local_hAdd[" type:term ", " inst:term "]" : term => `(term| (letI := $inst; HAdd.hAdd : $type → $type → $type)) local macro:max "local_hMul[" type:term ", " inst:term "]" : term => `(term| (letI := $inst; HMul.hMul : $type → $type → $type)) universe u variable {R : Type u} @[ext] theorem AddMonoidWithOne.ext ⦃inst₁ inst₂ : AddMonoidWithOne R⦄ (h_add : local_hAdd[R, inst₁] = local_hAdd[R, inst₂]) (h_one : (letI := inst₁; One.one : R) = (letI := inst₂; One.one : R)) : inst₁ = inst₂ := by have h_monoid : inst₁.toAddMonoid = inst₂.toAddMonoid := by ext : 1; exact h_add have h_zero' : inst₁.toZero = inst₂.toZero := congrArg (·.toZero) h_monoid have h_one' : inst₁.toOne = inst₂.toOne := congrArg One.mk h_one have h_natCast : inst₁.toNatCast.natCast = inst₂.toNatCast.natCast := by funext n; induction n with | zero => rewrite [inst₁.natCast_zero, inst₂.natCast_zero] exact congrArg (@Zero.zero R) h_zero' | succ n h => rw [inst₁.natCast_succ, inst₂.natCast_succ, h_add] exact congrArg₂ _ h h_one rcases inst₁ with @⟨⟨⟩⟩; rcases inst₂ with @⟨⟨⟩⟩ congr theorem AddCommMonoidWithOne.toAddMonoidWithOne_injective : Function.Injective (@AddCommMonoidWithOne.toAddMonoidWithOne R) := by rintro ⟨⟩ ⟨⟩ _; congr @[ext] theorem AddCommMonoidWithOne.ext ⦃inst₁ inst₂ : AddCommMonoidWithOne R⦄ (h_add : local_hAdd[R, inst₁] = local_hAdd[R, inst₂]) (h_one : (letI := inst₁; One.one : R) = (letI := inst₂; One.one : R)) : inst₁ = inst₂ := AddCommMonoidWithOne.toAddMonoidWithOne_injective <| AddMonoidWithOne.ext h_add h_one @[ext] theorem AddGroupWithOne.ext ⦃inst₁ inst₂ : AddGroupWithOne R⦄ (h_add : local_hAdd[R, inst₁] = local_hAdd[R, inst₂]) (h_one : (letI := inst₁; One.one : R) = (letI := inst₂; One.one)) : inst₁ = inst₂ := by have : inst₁.toAddMonoidWithOne = inst₂.toAddMonoidWithOne := AddMonoidWithOne.ext h_add h_one have : inst₁.toNatCast = inst₂.toNatCast := congrArg (·.toNatCast) this have h_group : inst₁.toAddGroup = inst₂.toAddGroup := by ext : 1; exact h_add -- Extract equality of necessary substructures from h_group injection h_group with h_group; injection h_group have : inst₁.toIntCast.intCast = inst₂.toIntCast.intCast := by funext n; cases n with | ofNat n => rewrite [Int.ofNat_eq_coe, inst₁.intCast_ofNat, inst₂.intCast_ofNat]; congr | negSucc n => rewrite [inst₁.intCast_negSucc, inst₂.intCast_negSucc]; congr rcases inst₁ with @⟨⟨⟩⟩; rcases inst₂ with @⟨⟨⟩⟩ congr @[ext] theorem AddCommGroupWithOne.ext ⦃inst₁ inst₂ : AddCommGroupWithOne R⦄ (h_add : local_hAdd[R, inst₁] = local_hAdd[R, inst₂]) (h_one : (letI := inst₁; One.one : R) = (letI := inst₂; One.one)) : inst₁ = inst₂ := by have : inst₁.toAddCommGroup = inst₂.toAddCommGroup := AddCommGroup.ext h_add have : inst₁.toAddGroupWithOne = inst₂.toAddGroupWithOne := AddGroupWithOne.ext h_add h_one injection this with _ h_addMonoidWithOne; injection h_addMonoidWithOne cases inst₁; cases inst₂ congr namespace NonUnitalCommSemiring
Mathlib/Algebra/Ring/Ext.lean
427
429
theorem toNonUnitalSemiring_injective : Function.Injective (@toNonUnitalSemiring R) := by
rintro ⟨⟩ ⟨⟩ _; congr
238
import Mathlib.Algebra.Ring.Defs import Mathlib.Algebra.Group.Ext local macro:max "local_hAdd[" type:term ", " inst:term "]" : term => `(term| (letI := $inst; HAdd.hAdd : $type → $type → $type)) local macro:max "local_hMul[" type:term ", " inst:term "]" : term => `(term| (letI := $inst; HMul.hMul : $type → $type → $type)) universe u variable {R : Type u} @[ext] theorem AddMonoidWithOne.ext ⦃inst₁ inst₂ : AddMonoidWithOne R⦄ (h_add : local_hAdd[R, inst₁] = local_hAdd[R, inst₂]) (h_one : (letI := inst₁; One.one : R) = (letI := inst₂; One.one : R)) : inst₁ = inst₂ := by have h_monoid : inst₁.toAddMonoid = inst₂.toAddMonoid := by ext : 1; exact h_add have h_zero' : inst₁.toZero = inst₂.toZero := congrArg (·.toZero) h_monoid have h_one' : inst₁.toOne = inst₂.toOne := congrArg One.mk h_one have h_natCast : inst₁.toNatCast.natCast = inst₂.toNatCast.natCast := by funext n; induction n with | zero => rewrite [inst₁.natCast_zero, inst₂.natCast_zero] exact congrArg (@Zero.zero R) h_zero' | succ n h => rw [inst₁.natCast_succ, inst₂.natCast_succ, h_add] exact congrArg₂ _ h h_one rcases inst₁ with @⟨⟨⟩⟩; rcases inst₂ with @⟨⟨⟩⟩ congr theorem AddCommMonoidWithOne.toAddMonoidWithOne_injective : Function.Injective (@AddCommMonoidWithOne.toAddMonoidWithOne R) := by rintro ⟨⟩ ⟨⟩ _; congr @[ext] theorem AddCommMonoidWithOne.ext ⦃inst₁ inst₂ : AddCommMonoidWithOne R⦄ (h_add : local_hAdd[R, inst₁] = local_hAdd[R, inst₂]) (h_one : (letI := inst₁; One.one : R) = (letI := inst₂; One.one : R)) : inst₁ = inst₂ := AddCommMonoidWithOne.toAddMonoidWithOne_injective <| AddMonoidWithOne.ext h_add h_one @[ext] theorem AddGroupWithOne.ext ⦃inst₁ inst₂ : AddGroupWithOne R⦄ (h_add : local_hAdd[R, inst₁] = local_hAdd[R, inst₂]) (h_one : (letI := inst₁; One.one : R) = (letI := inst₂; One.one)) : inst₁ = inst₂ := by have : inst₁.toAddMonoidWithOne = inst₂.toAddMonoidWithOne := AddMonoidWithOne.ext h_add h_one have : inst₁.toNatCast = inst₂.toNatCast := congrArg (·.toNatCast) this have h_group : inst₁.toAddGroup = inst₂.toAddGroup := by ext : 1; exact h_add -- Extract equality of necessary substructures from h_group injection h_group with h_group; injection h_group have : inst₁.toIntCast.intCast = inst₂.toIntCast.intCast := by funext n; cases n with | ofNat n => rewrite [Int.ofNat_eq_coe, inst₁.intCast_ofNat, inst₂.intCast_ofNat]; congr | negSucc n => rewrite [inst₁.intCast_negSucc, inst₂.intCast_negSucc]; congr rcases inst₁ with @⟨⟨⟩⟩; rcases inst₂ with @⟨⟨⟩⟩ congr @[ext] theorem AddCommGroupWithOne.ext ⦃inst₁ inst₂ : AddCommGroupWithOne R⦄ (h_add : local_hAdd[R, inst₁] = local_hAdd[R, inst₂]) (h_one : (letI := inst₁; One.one : R) = (letI := inst₂; One.one)) : inst₁ = inst₂ := by have : inst₁.toAddCommGroup = inst₂.toAddCommGroup := AddCommGroup.ext h_add have : inst₁.toAddGroupWithOne = inst₂.toAddGroupWithOne := AddGroupWithOne.ext h_add h_one injection this with _ h_addMonoidWithOne; injection h_addMonoidWithOne cases inst₁; cases inst₂ congr -- At present, there is no `NonAssocCommSemiring` in Mathlib. namespace NonUnitalNonAssocCommRing
Mathlib/Algebra/Ring/Ext.lean
451
453
theorem toNonUnitalNonAssocRing_injective : Function.Injective (@toNonUnitalNonAssocRing R) := by
rintro ⟨⟩ ⟨⟩ _; congr
238
import Mathlib.Algebra.Ring.Defs import Mathlib.Algebra.Group.Ext local macro:max "local_hAdd[" type:term ", " inst:term "]" : term => `(term| (letI := $inst; HAdd.hAdd : $type → $type → $type)) local macro:max "local_hMul[" type:term ", " inst:term "]" : term => `(term| (letI := $inst; HMul.hMul : $type → $type → $type)) universe u variable {R : Type u} @[ext] theorem AddMonoidWithOne.ext ⦃inst₁ inst₂ : AddMonoidWithOne R⦄ (h_add : local_hAdd[R, inst₁] = local_hAdd[R, inst₂]) (h_one : (letI := inst₁; One.one : R) = (letI := inst₂; One.one : R)) : inst₁ = inst₂ := by have h_monoid : inst₁.toAddMonoid = inst₂.toAddMonoid := by ext : 1; exact h_add have h_zero' : inst₁.toZero = inst₂.toZero := congrArg (·.toZero) h_monoid have h_one' : inst₁.toOne = inst₂.toOne := congrArg One.mk h_one have h_natCast : inst₁.toNatCast.natCast = inst₂.toNatCast.natCast := by funext n; induction n with | zero => rewrite [inst₁.natCast_zero, inst₂.natCast_zero] exact congrArg (@Zero.zero R) h_zero' | succ n h => rw [inst₁.natCast_succ, inst₂.natCast_succ, h_add] exact congrArg₂ _ h h_one rcases inst₁ with @⟨⟨⟩⟩; rcases inst₂ with @⟨⟨⟩⟩ congr theorem AddCommMonoidWithOne.toAddMonoidWithOne_injective : Function.Injective (@AddCommMonoidWithOne.toAddMonoidWithOne R) := by rintro ⟨⟩ ⟨⟩ _; congr @[ext] theorem AddCommMonoidWithOne.ext ⦃inst₁ inst₂ : AddCommMonoidWithOne R⦄ (h_add : local_hAdd[R, inst₁] = local_hAdd[R, inst₂]) (h_one : (letI := inst₁; One.one : R) = (letI := inst₂; One.one : R)) : inst₁ = inst₂ := AddCommMonoidWithOne.toAddMonoidWithOne_injective <| AddMonoidWithOne.ext h_add h_one @[ext] theorem AddGroupWithOne.ext ⦃inst₁ inst₂ : AddGroupWithOne R⦄ (h_add : local_hAdd[R, inst₁] = local_hAdd[R, inst₂]) (h_one : (letI := inst₁; One.one : R) = (letI := inst₂; One.one)) : inst₁ = inst₂ := by have : inst₁.toAddMonoidWithOne = inst₂.toAddMonoidWithOne := AddMonoidWithOne.ext h_add h_one have : inst₁.toNatCast = inst₂.toNatCast := congrArg (·.toNatCast) this have h_group : inst₁.toAddGroup = inst₂.toAddGroup := by ext : 1; exact h_add -- Extract equality of necessary substructures from h_group injection h_group with h_group; injection h_group have : inst₁.toIntCast.intCast = inst₂.toIntCast.intCast := by funext n; cases n with | ofNat n => rewrite [Int.ofNat_eq_coe, inst₁.intCast_ofNat, inst₂.intCast_ofNat]; congr | negSucc n => rewrite [inst₁.intCast_negSucc, inst₂.intCast_negSucc]; congr rcases inst₁ with @⟨⟨⟩⟩; rcases inst₂ with @⟨⟨⟩⟩ congr @[ext] theorem AddCommGroupWithOne.ext ⦃inst₁ inst₂ : AddCommGroupWithOne R⦄ (h_add : local_hAdd[R, inst₁] = local_hAdd[R, inst₂]) (h_one : (letI := inst₁; One.one : R) = (letI := inst₂; One.one)) : inst₁ = inst₂ := by have : inst₁.toAddCommGroup = inst₂.toAddCommGroup := AddCommGroup.ext h_add have : inst₁.toAddGroupWithOne = inst₂.toAddGroupWithOne := AddGroupWithOne.ext h_add h_one injection this with _ h_addMonoidWithOne; injection h_addMonoidWithOne cases inst₁; cases inst₂ congr -- At present, there is no `NonAssocCommSemiring` in Mathlib. namespace NonUnitalCommRing
Mathlib/Algebra/Ring/Ext.lean
473
475
theorem toNonUnitalRing_injective : Function.Injective (@toNonUnitalRing R) := by
rintro ⟨⟩ ⟨⟩ _; congr
238
import Mathlib.Algebra.Ring.Defs import Mathlib.Algebra.Group.Ext local macro:max "local_hAdd[" type:term ", " inst:term "]" : term => `(term| (letI := $inst; HAdd.hAdd : $type → $type → $type)) local macro:max "local_hMul[" type:term ", " inst:term "]" : term => `(term| (letI := $inst; HMul.hMul : $type → $type → $type)) universe u variable {R : Type u} @[ext] theorem AddMonoidWithOne.ext ⦃inst₁ inst₂ : AddMonoidWithOne R⦄ (h_add : local_hAdd[R, inst₁] = local_hAdd[R, inst₂]) (h_one : (letI := inst₁; One.one : R) = (letI := inst₂; One.one : R)) : inst₁ = inst₂ := by have h_monoid : inst₁.toAddMonoid = inst₂.toAddMonoid := by ext : 1; exact h_add have h_zero' : inst₁.toZero = inst₂.toZero := congrArg (·.toZero) h_monoid have h_one' : inst₁.toOne = inst₂.toOne := congrArg One.mk h_one have h_natCast : inst₁.toNatCast.natCast = inst₂.toNatCast.natCast := by funext n; induction n with | zero => rewrite [inst₁.natCast_zero, inst₂.natCast_zero] exact congrArg (@Zero.zero R) h_zero' | succ n h => rw [inst₁.natCast_succ, inst₂.natCast_succ, h_add] exact congrArg₂ _ h h_one rcases inst₁ with @⟨⟨⟩⟩; rcases inst₂ with @⟨⟨⟩⟩ congr theorem AddCommMonoidWithOne.toAddMonoidWithOne_injective : Function.Injective (@AddCommMonoidWithOne.toAddMonoidWithOne R) := by rintro ⟨⟩ ⟨⟩ _; congr @[ext] theorem AddCommMonoidWithOne.ext ⦃inst₁ inst₂ : AddCommMonoidWithOne R⦄ (h_add : local_hAdd[R, inst₁] = local_hAdd[R, inst₂]) (h_one : (letI := inst₁; One.one : R) = (letI := inst₂; One.one : R)) : inst₁ = inst₂ := AddCommMonoidWithOne.toAddMonoidWithOne_injective <| AddMonoidWithOne.ext h_add h_one @[ext] theorem AddGroupWithOne.ext ⦃inst₁ inst₂ : AddGroupWithOne R⦄ (h_add : local_hAdd[R, inst₁] = local_hAdd[R, inst₂]) (h_one : (letI := inst₁; One.one : R) = (letI := inst₂; One.one)) : inst₁ = inst₂ := by have : inst₁.toAddMonoidWithOne = inst₂.toAddMonoidWithOne := AddMonoidWithOne.ext h_add h_one have : inst₁.toNatCast = inst₂.toNatCast := congrArg (·.toNatCast) this have h_group : inst₁.toAddGroup = inst₂.toAddGroup := by ext : 1; exact h_add -- Extract equality of necessary substructures from h_group injection h_group with h_group; injection h_group have : inst₁.toIntCast.intCast = inst₂.toIntCast.intCast := by funext n; cases n with | ofNat n => rewrite [Int.ofNat_eq_coe, inst₁.intCast_ofNat, inst₂.intCast_ofNat]; congr | negSucc n => rewrite [inst₁.intCast_negSucc, inst₂.intCast_negSucc]; congr rcases inst₁ with @⟨⟨⟩⟩; rcases inst₂ with @⟨⟨⟩⟩ congr @[ext] theorem AddCommGroupWithOne.ext ⦃inst₁ inst₂ : AddCommGroupWithOne R⦄ (h_add : local_hAdd[R, inst₁] = local_hAdd[R, inst₂]) (h_one : (letI := inst₁; One.one : R) = (letI := inst₂; One.one)) : inst₁ = inst₂ := by have : inst₁.toAddCommGroup = inst₂.toAddCommGroup := AddCommGroup.ext h_add have : inst₁.toAddGroupWithOne = inst₂.toAddGroupWithOne := AddGroupWithOne.ext h_add h_one injection this with _ h_addMonoidWithOne; injection h_addMonoidWithOne cases inst₁; cases inst₂ congr -- At present, there is no `NonAssocCommSemiring` in Mathlib. -- At present, there is no `NonAssocCommRing` in Mathlib. namespace CommSemiring
Mathlib/Algebra/Ring/Ext.lean
497
499
theorem toSemiring_injective : Function.Injective (@toSemiring R) := by
rintro ⟨⟩ ⟨⟩ _; congr
238
import Mathlib.Algebra.Ring.Defs import Mathlib.Algebra.Group.Ext local macro:max "local_hAdd[" type:term ", " inst:term "]" : term => `(term| (letI := $inst; HAdd.hAdd : $type → $type → $type)) local macro:max "local_hMul[" type:term ", " inst:term "]" : term => `(term| (letI := $inst; HMul.hMul : $type → $type → $type)) universe u variable {R : Type u} @[ext] theorem AddMonoidWithOne.ext ⦃inst₁ inst₂ : AddMonoidWithOne R⦄ (h_add : local_hAdd[R, inst₁] = local_hAdd[R, inst₂]) (h_one : (letI := inst₁; One.one : R) = (letI := inst₂; One.one : R)) : inst₁ = inst₂ := by have h_monoid : inst₁.toAddMonoid = inst₂.toAddMonoid := by ext : 1; exact h_add have h_zero' : inst₁.toZero = inst₂.toZero := congrArg (·.toZero) h_monoid have h_one' : inst₁.toOne = inst₂.toOne := congrArg One.mk h_one have h_natCast : inst₁.toNatCast.natCast = inst₂.toNatCast.natCast := by funext n; induction n with | zero => rewrite [inst₁.natCast_zero, inst₂.natCast_zero] exact congrArg (@Zero.zero R) h_zero' | succ n h => rw [inst₁.natCast_succ, inst₂.natCast_succ, h_add] exact congrArg₂ _ h h_one rcases inst₁ with @⟨⟨⟩⟩; rcases inst₂ with @⟨⟨⟩⟩ congr theorem AddCommMonoidWithOne.toAddMonoidWithOne_injective : Function.Injective (@AddCommMonoidWithOne.toAddMonoidWithOne R) := by rintro ⟨⟩ ⟨⟩ _; congr @[ext] theorem AddCommMonoidWithOne.ext ⦃inst₁ inst₂ : AddCommMonoidWithOne R⦄ (h_add : local_hAdd[R, inst₁] = local_hAdd[R, inst₂]) (h_one : (letI := inst₁; One.one : R) = (letI := inst₂; One.one : R)) : inst₁ = inst₂ := AddCommMonoidWithOne.toAddMonoidWithOne_injective <| AddMonoidWithOne.ext h_add h_one @[ext] theorem AddGroupWithOne.ext ⦃inst₁ inst₂ : AddGroupWithOne R⦄ (h_add : local_hAdd[R, inst₁] = local_hAdd[R, inst₂]) (h_one : (letI := inst₁; One.one : R) = (letI := inst₂; One.one)) : inst₁ = inst₂ := by have : inst₁.toAddMonoidWithOne = inst₂.toAddMonoidWithOne := AddMonoidWithOne.ext h_add h_one have : inst₁.toNatCast = inst₂.toNatCast := congrArg (·.toNatCast) this have h_group : inst₁.toAddGroup = inst₂.toAddGroup := by ext : 1; exact h_add -- Extract equality of necessary substructures from h_group injection h_group with h_group; injection h_group have : inst₁.toIntCast.intCast = inst₂.toIntCast.intCast := by funext n; cases n with | ofNat n => rewrite [Int.ofNat_eq_coe, inst₁.intCast_ofNat, inst₂.intCast_ofNat]; congr | negSucc n => rewrite [inst₁.intCast_negSucc, inst₂.intCast_negSucc]; congr rcases inst₁ with @⟨⟨⟩⟩; rcases inst₂ with @⟨⟨⟩⟩ congr @[ext] theorem AddCommGroupWithOne.ext ⦃inst₁ inst₂ : AddCommGroupWithOne R⦄ (h_add : local_hAdd[R, inst₁] = local_hAdd[R, inst₂]) (h_one : (letI := inst₁; One.one : R) = (letI := inst₂; One.one)) : inst₁ = inst₂ := by have : inst₁.toAddCommGroup = inst₂.toAddCommGroup := AddCommGroup.ext h_add have : inst₁.toAddGroupWithOne = inst₂.toAddGroupWithOne := AddGroupWithOne.ext h_add h_one injection this with _ h_addMonoidWithOne; injection h_addMonoidWithOne cases inst₁; cases inst₂ congr -- At present, there is no `NonAssocCommSemiring` in Mathlib. -- At present, there is no `NonAssocCommRing` in Mathlib. namespace CommRing
Mathlib/Algebra/Ring/Ext.lean
519
520
theorem toRing_injective : Function.Injective (@toRing R) := by
rintro ⟨⟩ ⟨⟩ _; congr
238
import Mathlib.Algebra.Quaternion import Mathlib.Tactic.Ring #align_import algebra.quaternion_basis from "leanprover-community/mathlib"@"3aa5b8a9ed7a7cabd36e6e1d022c9858ab8a8c2d" open Quaternion namespace QuaternionAlgebra structure Basis {R : Type*} (A : Type*) [CommRing R] [Ring A] [Algebra R A] (c₁ c₂ : R) where (i j k : A) i_mul_i : i * i = c₁ • (1 : A) j_mul_j : j * j = c₂ • (1 : A) i_mul_j : i * j = k j_mul_i : j * i = -k #align quaternion_algebra.basis QuaternionAlgebra.Basis variable {R : Type*} {A B : Type*} [CommRing R] [Ring A] [Ring B] [Algebra R A] [Algebra R B] variable {c₁ c₂ : R} namespace Basis @[ext] protected theorem ext ⦃q₁ q₂ : Basis A c₁ c₂⦄ (hi : q₁.i = q₂.i) (hj : q₁.j = q₂.j) : q₁ = q₂ := by cases q₁; rename_i q₁_i_mul_j _ cases q₂; rename_i q₂_i_mul_j _ congr rw [← q₁_i_mul_j, ← q₂_i_mul_j] congr #align quaternion_algebra.basis.ext QuaternionAlgebra.Basis.ext variable (R) @[simps i j k] protected def self : Basis ℍ[R,c₁,c₂] c₁ c₂ where i := ⟨0, 1, 0, 0⟩ i_mul_i := by ext <;> simp j := ⟨0, 0, 1, 0⟩ j_mul_j := by ext <;> simp k := ⟨0, 0, 0, 1⟩ i_mul_j := by ext <;> simp j_mul_i := by ext <;> simp #align quaternion_algebra.basis.self QuaternionAlgebra.Basis.self variable {R} instance : Inhabited (Basis ℍ[R,c₁,c₂] c₁ c₂) := ⟨Basis.self R⟩ variable (q : Basis A c₁ c₂) attribute [simp] i_mul_i j_mul_j i_mul_j j_mul_i @[simp]
Mathlib/Algebra/QuaternionBasis.lean
84
85
theorem i_mul_k : q.i * q.k = c₁ • q.j := by
rw [← i_mul_j, ← mul_assoc, i_mul_i, smul_mul_assoc, one_mul]
239
import Mathlib.Algebra.Quaternion import Mathlib.Tactic.Ring #align_import algebra.quaternion_basis from "leanprover-community/mathlib"@"3aa5b8a9ed7a7cabd36e6e1d022c9858ab8a8c2d" open Quaternion namespace QuaternionAlgebra structure Basis {R : Type*} (A : Type*) [CommRing R] [Ring A] [Algebra R A] (c₁ c₂ : R) where (i j k : A) i_mul_i : i * i = c₁ • (1 : A) j_mul_j : j * j = c₂ • (1 : A) i_mul_j : i * j = k j_mul_i : j * i = -k #align quaternion_algebra.basis QuaternionAlgebra.Basis variable {R : Type*} {A B : Type*} [CommRing R] [Ring A] [Ring B] [Algebra R A] [Algebra R B] variable {c₁ c₂ : R} namespace Basis @[ext] protected theorem ext ⦃q₁ q₂ : Basis A c₁ c₂⦄ (hi : q₁.i = q₂.i) (hj : q₁.j = q₂.j) : q₁ = q₂ := by cases q₁; rename_i q₁_i_mul_j _ cases q₂; rename_i q₂_i_mul_j _ congr rw [← q₁_i_mul_j, ← q₂_i_mul_j] congr #align quaternion_algebra.basis.ext QuaternionAlgebra.Basis.ext variable (R) @[simps i j k] protected def self : Basis ℍ[R,c₁,c₂] c₁ c₂ where i := ⟨0, 1, 0, 0⟩ i_mul_i := by ext <;> simp j := ⟨0, 0, 1, 0⟩ j_mul_j := by ext <;> simp k := ⟨0, 0, 0, 1⟩ i_mul_j := by ext <;> simp j_mul_i := by ext <;> simp #align quaternion_algebra.basis.self QuaternionAlgebra.Basis.self variable {R} instance : Inhabited (Basis ℍ[R,c₁,c₂] c₁ c₂) := ⟨Basis.self R⟩ variable (q : Basis A c₁ c₂) attribute [simp] i_mul_i j_mul_j i_mul_j j_mul_i @[simp] theorem i_mul_k : q.i * q.k = c₁ • q.j := by rw [← i_mul_j, ← mul_assoc, i_mul_i, smul_mul_assoc, one_mul] #align quaternion_algebra.basis.i_mul_k QuaternionAlgebra.Basis.i_mul_k @[simp]
Mathlib/Algebra/QuaternionBasis.lean
89
90
theorem k_mul_i : q.k * q.i = -c₁ • q.j := by
rw [← i_mul_j, mul_assoc, j_mul_i, mul_neg, i_mul_k, neg_smul]
239
import Mathlib.Algebra.Quaternion import Mathlib.Tactic.Ring #align_import algebra.quaternion_basis from "leanprover-community/mathlib"@"3aa5b8a9ed7a7cabd36e6e1d022c9858ab8a8c2d" open Quaternion namespace QuaternionAlgebra structure Basis {R : Type*} (A : Type*) [CommRing R] [Ring A] [Algebra R A] (c₁ c₂ : R) where (i j k : A) i_mul_i : i * i = c₁ • (1 : A) j_mul_j : j * j = c₂ • (1 : A) i_mul_j : i * j = k j_mul_i : j * i = -k #align quaternion_algebra.basis QuaternionAlgebra.Basis variable {R : Type*} {A B : Type*} [CommRing R] [Ring A] [Ring B] [Algebra R A] [Algebra R B] variable {c₁ c₂ : R} namespace Basis @[ext] protected theorem ext ⦃q₁ q₂ : Basis A c₁ c₂⦄ (hi : q₁.i = q₂.i) (hj : q₁.j = q₂.j) : q₁ = q₂ := by cases q₁; rename_i q₁_i_mul_j _ cases q₂; rename_i q₂_i_mul_j _ congr rw [← q₁_i_mul_j, ← q₂_i_mul_j] congr #align quaternion_algebra.basis.ext QuaternionAlgebra.Basis.ext variable (R) @[simps i j k] protected def self : Basis ℍ[R,c₁,c₂] c₁ c₂ where i := ⟨0, 1, 0, 0⟩ i_mul_i := by ext <;> simp j := ⟨0, 0, 1, 0⟩ j_mul_j := by ext <;> simp k := ⟨0, 0, 0, 1⟩ i_mul_j := by ext <;> simp j_mul_i := by ext <;> simp #align quaternion_algebra.basis.self QuaternionAlgebra.Basis.self variable {R} instance : Inhabited (Basis ℍ[R,c₁,c₂] c₁ c₂) := ⟨Basis.self R⟩ variable (q : Basis A c₁ c₂) attribute [simp] i_mul_i j_mul_j i_mul_j j_mul_i @[simp] theorem i_mul_k : q.i * q.k = c₁ • q.j := by rw [← i_mul_j, ← mul_assoc, i_mul_i, smul_mul_assoc, one_mul] #align quaternion_algebra.basis.i_mul_k QuaternionAlgebra.Basis.i_mul_k @[simp] theorem k_mul_i : q.k * q.i = -c₁ • q.j := by rw [← i_mul_j, mul_assoc, j_mul_i, mul_neg, i_mul_k, neg_smul] #align quaternion_algebra.basis.k_mul_i QuaternionAlgebra.Basis.k_mul_i @[simp]
Mathlib/Algebra/QuaternionBasis.lean
94
95
theorem k_mul_j : q.k * q.j = c₂ • q.i := by
rw [← i_mul_j, mul_assoc, j_mul_j, mul_smul_comm, mul_one]
239
import Mathlib.Algebra.Quaternion import Mathlib.Tactic.Ring #align_import algebra.quaternion_basis from "leanprover-community/mathlib"@"3aa5b8a9ed7a7cabd36e6e1d022c9858ab8a8c2d" open Quaternion namespace QuaternionAlgebra structure Basis {R : Type*} (A : Type*) [CommRing R] [Ring A] [Algebra R A] (c₁ c₂ : R) where (i j k : A) i_mul_i : i * i = c₁ • (1 : A) j_mul_j : j * j = c₂ • (1 : A) i_mul_j : i * j = k j_mul_i : j * i = -k #align quaternion_algebra.basis QuaternionAlgebra.Basis variable {R : Type*} {A B : Type*} [CommRing R] [Ring A] [Ring B] [Algebra R A] [Algebra R B] variable {c₁ c₂ : R} namespace Basis @[ext] protected theorem ext ⦃q₁ q₂ : Basis A c₁ c₂⦄ (hi : q₁.i = q₂.i) (hj : q₁.j = q₂.j) : q₁ = q₂ := by cases q₁; rename_i q₁_i_mul_j _ cases q₂; rename_i q₂_i_mul_j _ congr rw [← q₁_i_mul_j, ← q₂_i_mul_j] congr #align quaternion_algebra.basis.ext QuaternionAlgebra.Basis.ext variable (R) @[simps i j k] protected def self : Basis ℍ[R,c₁,c₂] c₁ c₂ where i := ⟨0, 1, 0, 0⟩ i_mul_i := by ext <;> simp j := ⟨0, 0, 1, 0⟩ j_mul_j := by ext <;> simp k := ⟨0, 0, 0, 1⟩ i_mul_j := by ext <;> simp j_mul_i := by ext <;> simp #align quaternion_algebra.basis.self QuaternionAlgebra.Basis.self variable {R} instance : Inhabited (Basis ℍ[R,c₁,c₂] c₁ c₂) := ⟨Basis.self R⟩ variable (q : Basis A c₁ c₂) attribute [simp] i_mul_i j_mul_j i_mul_j j_mul_i @[simp] theorem i_mul_k : q.i * q.k = c₁ • q.j := by rw [← i_mul_j, ← mul_assoc, i_mul_i, smul_mul_assoc, one_mul] #align quaternion_algebra.basis.i_mul_k QuaternionAlgebra.Basis.i_mul_k @[simp] theorem k_mul_i : q.k * q.i = -c₁ • q.j := by rw [← i_mul_j, mul_assoc, j_mul_i, mul_neg, i_mul_k, neg_smul] #align quaternion_algebra.basis.k_mul_i QuaternionAlgebra.Basis.k_mul_i @[simp] theorem k_mul_j : q.k * q.j = c₂ • q.i := by rw [← i_mul_j, mul_assoc, j_mul_j, mul_smul_comm, mul_one] #align quaternion_algebra.basis.k_mul_j QuaternionAlgebra.Basis.k_mul_j @[simp]
Mathlib/Algebra/QuaternionBasis.lean
99
100
theorem j_mul_k : q.j * q.k = -c₂ • q.i := by
rw [← i_mul_j, ← mul_assoc, j_mul_i, neg_mul, k_mul_j, neg_smul]
239
import Mathlib.Algebra.Quaternion import Mathlib.Tactic.Ring #align_import algebra.quaternion_basis from "leanprover-community/mathlib"@"3aa5b8a9ed7a7cabd36e6e1d022c9858ab8a8c2d" open Quaternion namespace QuaternionAlgebra structure Basis {R : Type*} (A : Type*) [CommRing R] [Ring A] [Algebra R A] (c₁ c₂ : R) where (i j k : A) i_mul_i : i * i = c₁ • (1 : A) j_mul_j : j * j = c₂ • (1 : A) i_mul_j : i * j = k j_mul_i : j * i = -k #align quaternion_algebra.basis QuaternionAlgebra.Basis variable {R : Type*} {A B : Type*} [CommRing R] [Ring A] [Ring B] [Algebra R A] [Algebra R B] variable {c₁ c₂ : R} namespace Basis @[ext] protected theorem ext ⦃q₁ q₂ : Basis A c₁ c₂⦄ (hi : q₁.i = q₂.i) (hj : q₁.j = q₂.j) : q₁ = q₂ := by cases q₁; rename_i q₁_i_mul_j _ cases q₂; rename_i q₂_i_mul_j _ congr rw [← q₁_i_mul_j, ← q₂_i_mul_j] congr #align quaternion_algebra.basis.ext QuaternionAlgebra.Basis.ext variable (R) @[simps i j k] protected def self : Basis ℍ[R,c₁,c₂] c₁ c₂ where i := ⟨0, 1, 0, 0⟩ i_mul_i := by ext <;> simp j := ⟨0, 0, 1, 0⟩ j_mul_j := by ext <;> simp k := ⟨0, 0, 0, 1⟩ i_mul_j := by ext <;> simp j_mul_i := by ext <;> simp #align quaternion_algebra.basis.self QuaternionAlgebra.Basis.self variable {R} instance : Inhabited (Basis ℍ[R,c₁,c₂] c₁ c₂) := ⟨Basis.self R⟩ variable (q : Basis A c₁ c₂) attribute [simp] i_mul_i j_mul_j i_mul_j j_mul_i @[simp] theorem i_mul_k : q.i * q.k = c₁ • q.j := by rw [← i_mul_j, ← mul_assoc, i_mul_i, smul_mul_assoc, one_mul] #align quaternion_algebra.basis.i_mul_k QuaternionAlgebra.Basis.i_mul_k @[simp] theorem k_mul_i : q.k * q.i = -c₁ • q.j := by rw [← i_mul_j, mul_assoc, j_mul_i, mul_neg, i_mul_k, neg_smul] #align quaternion_algebra.basis.k_mul_i QuaternionAlgebra.Basis.k_mul_i @[simp] theorem k_mul_j : q.k * q.j = c₂ • q.i := by rw [← i_mul_j, mul_assoc, j_mul_j, mul_smul_comm, mul_one] #align quaternion_algebra.basis.k_mul_j QuaternionAlgebra.Basis.k_mul_j @[simp] theorem j_mul_k : q.j * q.k = -c₂ • q.i := by rw [← i_mul_j, ← mul_assoc, j_mul_i, neg_mul, k_mul_j, neg_smul] #align quaternion_algebra.basis.j_mul_k QuaternionAlgebra.Basis.j_mul_k @[simp]
Mathlib/Algebra/QuaternionBasis.lean
104
106
theorem k_mul_k : q.k * q.k = -((c₁ * c₂) • (1 : A)) := by
rw [← i_mul_j, mul_assoc, ← mul_assoc q.j _ _, j_mul_i, ← i_mul_j, ← mul_assoc, mul_neg, ← mul_assoc, i_mul_i, smul_mul_assoc, one_mul, neg_mul, smul_mul_assoc, j_mul_j, smul_smul]
239
import Mathlib.Algebra.Quaternion import Mathlib.Tactic.Ring #align_import algebra.quaternion_basis from "leanprover-community/mathlib"@"3aa5b8a9ed7a7cabd36e6e1d022c9858ab8a8c2d" open Quaternion namespace QuaternionAlgebra structure Basis {R : Type*} (A : Type*) [CommRing R] [Ring A] [Algebra R A] (c₁ c₂ : R) where (i j k : A) i_mul_i : i * i = c₁ • (1 : A) j_mul_j : j * j = c₂ • (1 : A) i_mul_j : i * j = k j_mul_i : j * i = -k #align quaternion_algebra.basis QuaternionAlgebra.Basis variable {R : Type*} {A B : Type*} [CommRing R] [Ring A] [Ring B] [Algebra R A] [Algebra R B] variable {c₁ c₂ : R} namespace Basis @[ext] protected theorem ext ⦃q₁ q₂ : Basis A c₁ c₂⦄ (hi : q₁.i = q₂.i) (hj : q₁.j = q₂.j) : q₁ = q₂ := by cases q₁; rename_i q₁_i_mul_j _ cases q₂; rename_i q₂_i_mul_j _ congr rw [← q₁_i_mul_j, ← q₂_i_mul_j] congr #align quaternion_algebra.basis.ext QuaternionAlgebra.Basis.ext variable (R) @[simps i j k] protected def self : Basis ℍ[R,c₁,c₂] c₁ c₂ where i := ⟨0, 1, 0, 0⟩ i_mul_i := by ext <;> simp j := ⟨0, 0, 1, 0⟩ j_mul_j := by ext <;> simp k := ⟨0, 0, 0, 1⟩ i_mul_j := by ext <;> simp j_mul_i := by ext <;> simp #align quaternion_algebra.basis.self QuaternionAlgebra.Basis.self variable {R} instance : Inhabited (Basis ℍ[R,c₁,c₂] c₁ c₂) := ⟨Basis.self R⟩ variable (q : Basis A c₁ c₂) attribute [simp] i_mul_i j_mul_j i_mul_j j_mul_i @[simp] theorem i_mul_k : q.i * q.k = c₁ • q.j := by rw [← i_mul_j, ← mul_assoc, i_mul_i, smul_mul_assoc, one_mul] #align quaternion_algebra.basis.i_mul_k QuaternionAlgebra.Basis.i_mul_k @[simp] theorem k_mul_i : q.k * q.i = -c₁ • q.j := by rw [← i_mul_j, mul_assoc, j_mul_i, mul_neg, i_mul_k, neg_smul] #align quaternion_algebra.basis.k_mul_i QuaternionAlgebra.Basis.k_mul_i @[simp] theorem k_mul_j : q.k * q.j = c₂ • q.i := by rw [← i_mul_j, mul_assoc, j_mul_j, mul_smul_comm, mul_one] #align quaternion_algebra.basis.k_mul_j QuaternionAlgebra.Basis.k_mul_j @[simp] theorem j_mul_k : q.j * q.k = -c₂ • q.i := by rw [← i_mul_j, ← mul_assoc, j_mul_i, neg_mul, k_mul_j, neg_smul] #align quaternion_algebra.basis.j_mul_k QuaternionAlgebra.Basis.j_mul_k @[simp] theorem k_mul_k : q.k * q.k = -((c₁ * c₂) • (1 : A)) := by rw [← i_mul_j, mul_assoc, ← mul_assoc q.j _ _, j_mul_i, ← i_mul_j, ← mul_assoc, mul_neg, ← mul_assoc, i_mul_i, smul_mul_assoc, one_mul, neg_mul, smul_mul_assoc, j_mul_j, smul_smul] #align quaternion_algebra.basis.k_mul_k QuaternionAlgebra.Basis.k_mul_k def lift (x : ℍ[R,c₁,c₂]) : A := algebraMap R _ x.re + x.imI • q.i + x.imJ • q.j + x.imK • q.k #align quaternion_algebra.basis.lift QuaternionAlgebra.Basis.lift
Mathlib/Algebra/QuaternionBasis.lean
114
114
theorem lift_zero : q.lift (0 : ℍ[R,c₁,c₂]) = 0 := by
simp [lift]
239
import Mathlib.Algebra.Quaternion import Mathlib.Tactic.Ring #align_import algebra.quaternion_basis from "leanprover-community/mathlib"@"3aa5b8a9ed7a7cabd36e6e1d022c9858ab8a8c2d" open Quaternion namespace QuaternionAlgebra structure Basis {R : Type*} (A : Type*) [CommRing R] [Ring A] [Algebra R A] (c₁ c₂ : R) where (i j k : A) i_mul_i : i * i = c₁ • (1 : A) j_mul_j : j * j = c₂ • (1 : A) i_mul_j : i * j = k j_mul_i : j * i = -k #align quaternion_algebra.basis QuaternionAlgebra.Basis variable {R : Type*} {A B : Type*} [CommRing R] [Ring A] [Ring B] [Algebra R A] [Algebra R B] variable {c₁ c₂ : R} namespace Basis @[ext] protected theorem ext ⦃q₁ q₂ : Basis A c₁ c₂⦄ (hi : q₁.i = q₂.i) (hj : q₁.j = q₂.j) : q₁ = q₂ := by cases q₁; rename_i q₁_i_mul_j _ cases q₂; rename_i q₂_i_mul_j _ congr rw [← q₁_i_mul_j, ← q₂_i_mul_j] congr #align quaternion_algebra.basis.ext QuaternionAlgebra.Basis.ext variable (R) @[simps i j k] protected def self : Basis ℍ[R,c₁,c₂] c₁ c₂ where i := ⟨0, 1, 0, 0⟩ i_mul_i := by ext <;> simp j := ⟨0, 0, 1, 0⟩ j_mul_j := by ext <;> simp k := ⟨0, 0, 0, 1⟩ i_mul_j := by ext <;> simp j_mul_i := by ext <;> simp #align quaternion_algebra.basis.self QuaternionAlgebra.Basis.self variable {R} instance : Inhabited (Basis ℍ[R,c₁,c₂] c₁ c₂) := ⟨Basis.self R⟩ variable (q : Basis A c₁ c₂) attribute [simp] i_mul_i j_mul_j i_mul_j j_mul_i @[simp] theorem i_mul_k : q.i * q.k = c₁ • q.j := by rw [← i_mul_j, ← mul_assoc, i_mul_i, smul_mul_assoc, one_mul] #align quaternion_algebra.basis.i_mul_k QuaternionAlgebra.Basis.i_mul_k @[simp] theorem k_mul_i : q.k * q.i = -c₁ • q.j := by rw [← i_mul_j, mul_assoc, j_mul_i, mul_neg, i_mul_k, neg_smul] #align quaternion_algebra.basis.k_mul_i QuaternionAlgebra.Basis.k_mul_i @[simp] theorem k_mul_j : q.k * q.j = c₂ • q.i := by rw [← i_mul_j, mul_assoc, j_mul_j, mul_smul_comm, mul_one] #align quaternion_algebra.basis.k_mul_j QuaternionAlgebra.Basis.k_mul_j @[simp] theorem j_mul_k : q.j * q.k = -c₂ • q.i := by rw [← i_mul_j, ← mul_assoc, j_mul_i, neg_mul, k_mul_j, neg_smul] #align quaternion_algebra.basis.j_mul_k QuaternionAlgebra.Basis.j_mul_k @[simp] theorem k_mul_k : q.k * q.k = -((c₁ * c₂) • (1 : A)) := by rw [← i_mul_j, mul_assoc, ← mul_assoc q.j _ _, j_mul_i, ← i_mul_j, ← mul_assoc, mul_neg, ← mul_assoc, i_mul_i, smul_mul_assoc, one_mul, neg_mul, smul_mul_assoc, j_mul_j, smul_smul] #align quaternion_algebra.basis.k_mul_k QuaternionAlgebra.Basis.k_mul_k def lift (x : ℍ[R,c₁,c₂]) : A := algebraMap R _ x.re + x.imI • q.i + x.imJ • q.j + x.imK • q.k #align quaternion_algebra.basis.lift QuaternionAlgebra.Basis.lift theorem lift_zero : q.lift (0 : ℍ[R,c₁,c₂]) = 0 := by simp [lift] #align quaternion_algebra.basis.lift_zero QuaternionAlgebra.Basis.lift_zero
Mathlib/Algebra/QuaternionBasis.lean
117
117
theorem lift_one : q.lift (1 : ℍ[R,c₁,c₂]) = 1 := by
simp [lift]
239
import Mathlib.Algebra.Quaternion import Mathlib.Tactic.Ring #align_import algebra.quaternion_basis from "leanprover-community/mathlib"@"3aa5b8a9ed7a7cabd36e6e1d022c9858ab8a8c2d" open Quaternion namespace QuaternionAlgebra structure Basis {R : Type*} (A : Type*) [CommRing R] [Ring A] [Algebra R A] (c₁ c₂ : R) where (i j k : A) i_mul_i : i * i = c₁ • (1 : A) j_mul_j : j * j = c₂ • (1 : A) i_mul_j : i * j = k j_mul_i : j * i = -k #align quaternion_algebra.basis QuaternionAlgebra.Basis variable {R : Type*} {A B : Type*} [CommRing R] [Ring A] [Ring B] [Algebra R A] [Algebra R B] variable {c₁ c₂ : R} namespace Basis @[ext] protected theorem ext ⦃q₁ q₂ : Basis A c₁ c₂⦄ (hi : q₁.i = q₂.i) (hj : q₁.j = q₂.j) : q₁ = q₂ := by cases q₁; rename_i q₁_i_mul_j _ cases q₂; rename_i q₂_i_mul_j _ congr rw [← q₁_i_mul_j, ← q₂_i_mul_j] congr #align quaternion_algebra.basis.ext QuaternionAlgebra.Basis.ext variable (R) @[simps i j k] protected def self : Basis ℍ[R,c₁,c₂] c₁ c₂ where i := ⟨0, 1, 0, 0⟩ i_mul_i := by ext <;> simp j := ⟨0, 0, 1, 0⟩ j_mul_j := by ext <;> simp k := ⟨0, 0, 0, 1⟩ i_mul_j := by ext <;> simp j_mul_i := by ext <;> simp #align quaternion_algebra.basis.self QuaternionAlgebra.Basis.self variable {R} instance : Inhabited (Basis ℍ[R,c₁,c₂] c₁ c₂) := ⟨Basis.self R⟩ variable (q : Basis A c₁ c₂) attribute [simp] i_mul_i j_mul_j i_mul_j j_mul_i @[simp] theorem i_mul_k : q.i * q.k = c₁ • q.j := by rw [← i_mul_j, ← mul_assoc, i_mul_i, smul_mul_assoc, one_mul] #align quaternion_algebra.basis.i_mul_k QuaternionAlgebra.Basis.i_mul_k @[simp] theorem k_mul_i : q.k * q.i = -c₁ • q.j := by rw [← i_mul_j, mul_assoc, j_mul_i, mul_neg, i_mul_k, neg_smul] #align quaternion_algebra.basis.k_mul_i QuaternionAlgebra.Basis.k_mul_i @[simp] theorem k_mul_j : q.k * q.j = c₂ • q.i := by rw [← i_mul_j, mul_assoc, j_mul_j, mul_smul_comm, mul_one] #align quaternion_algebra.basis.k_mul_j QuaternionAlgebra.Basis.k_mul_j @[simp] theorem j_mul_k : q.j * q.k = -c₂ • q.i := by rw [← i_mul_j, ← mul_assoc, j_mul_i, neg_mul, k_mul_j, neg_smul] #align quaternion_algebra.basis.j_mul_k QuaternionAlgebra.Basis.j_mul_k @[simp] theorem k_mul_k : q.k * q.k = -((c₁ * c₂) • (1 : A)) := by rw [← i_mul_j, mul_assoc, ← mul_assoc q.j _ _, j_mul_i, ← i_mul_j, ← mul_assoc, mul_neg, ← mul_assoc, i_mul_i, smul_mul_assoc, one_mul, neg_mul, smul_mul_assoc, j_mul_j, smul_smul] #align quaternion_algebra.basis.k_mul_k QuaternionAlgebra.Basis.k_mul_k def lift (x : ℍ[R,c₁,c₂]) : A := algebraMap R _ x.re + x.imI • q.i + x.imJ • q.j + x.imK • q.k #align quaternion_algebra.basis.lift QuaternionAlgebra.Basis.lift theorem lift_zero : q.lift (0 : ℍ[R,c₁,c₂]) = 0 := by simp [lift] #align quaternion_algebra.basis.lift_zero QuaternionAlgebra.Basis.lift_zero theorem lift_one : q.lift (1 : ℍ[R,c₁,c₂]) = 1 := by simp [lift] #align quaternion_algebra.basis.lift_one QuaternionAlgebra.Basis.lift_one
Mathlib/Algebra/QuaternionBasis.lean
120
122
theorem lift_add (x y : ℍ[R,c₁,c₂]) : q.lift (x + y) = q.lift x + q.lift y := by
simp only [lift, add_re, map_add, add_imI, add_smul, add_imJ, add_imK] abel
239
import Mathlib.Algebra.Quaternion import Mathlib.Tactic.Ring #align_import algebra.quaternion_basis from "leanprover-community/mathlib"@"3aa5b8a9ed7a7cabd36e6e1d022c9858ab8a8c2d" open Quaternion namespace QuaternionAlgebra structure Basis {R : Type*} (A : Type*) [CommRing R] [Ring A] [Algebra R A] (c₁ c₂ : R) where (i j k : A) i_mul_i : i * i = c₁ • (1 : A) j_mul_j : j * j = c₂ • (1 : A) i_mul_j : i * j = k j_mul_i : j * i = -k #align quaternion_algebra.basis QuaternionAlgebra.Basis variable {R : Type*} {A B : Type*} [CommRing R] [Ring A] [Ring B] [Algebra R A] [Algebra R B] variable {c₁ c₂ : R} namespace Basis @[ext] protected theorem ext ⦃q₁ q₂ : Basis A c₁ c₂⦄ (hi : q₁.i = q₂.i) (hj : q₁.j = q₂.j) : q₁ = q₂ := by cases q₁; rename_i q₁_i_mul_j _ cases q₂; rename_i q₂_i_mul_j _ congr rw [← q₁_i_mul_j, ← q₂_i_mul_j] congr #align quaternion_algebra.basis.ext QuaternionAlgebra.Basis.ext variable (R) @[simps i j k] protected def self : Basis ℍ[R,c₁,c₂] c₁ c₂ where i := ⟨0, 1, 0, 0⟩ i_mul_i := by ext <;> simp j := ⟨0, 0, 1, 0⟩ j_mul_j := by ext <;> simp k := ⟨0, 0, 0, 1⟩ i_mul_j := by ext <;> simp j_mul_i := by ext <;> simp #align quaternion_algebra.basis.self QuaternionAlgebra.Basis.self variable {R} instance : Inhabited (Basis ℍ[R,c₁,c₂] c₁ c₂) := ⟨Basis.self R⟩ variable (q : Basis A c₁ c₂) attribute [simp] i_mul_i j_mul_j i_mul_j j_mul_i @[simp] theorem i_mul_k : q.i * q.k = c₁ • q.j := by rw [← i_mul_j, ← mul_assoc, i_mul_i, smul_mul_assoc, one_mul] #align quaternion_algebra.basis.i_mul_k QuaternionAlgebra.Basis.i_mul_k @[simp] theorem k_mul_i : q.k * q.i = -c₁ • q.j := by rw [← i_mul_j, mul_assoc, j_mul_i, mul_neg, i_mul_k, neg_smul] #align quaternion_algebra.basis.k_mul_i QuaternionAlgebra.Basis.k_mul_i @[simp] theorem k_mul_j : q.k * q.j = c₂ • q.i := by rw [← i_mul_j, mul_assoc, j_mul_j, mul_smul_comm, mul_one] #align quaternion_algebra.basis.k_mul_j QuaternionAlgebra.Basis.k_mul_j @[simp] theorem j_mul_k : q.j * q.k = -c₂ • q.i := by rw [← i_mul_j, ← mul_assoc, j_mul_i, neg_mul, k_mul_j, neg_smul] #align quaternion_algebra.basis.j_mul_k QuaternionAlgebra.Basis.j_mul_k @[simp] theorem k_mul_k : q.k * q.k = -((c₁ * c₂) • (1 : A)) := by rw [← i_mul_j, mul_assoc, ← mul_assoc q.j _ _, j_mul_i, ← i_mul_j, ← mul_assoc, mul_neg, ← mul_assoc, i_mul_i, smul_mul_assoc, one_mul, neg_mul, smul_mul_assoc, j_mul_j, smul_smul] #align quaternion_algebra.basis.k_mul_k QuaternionAlgebra.Basis.k_mul_k def lift (x : ℍ[R,c₁,c₂]) : A := algebraMap R _ x.re + x.imI • q.i + x.imJ • q.j + x.imK • q.k #align quaternion_algebra.basis.lift QuaternionAlgebra.Basis.lift theorem lift_zero : q.lift (0 : ℍ[R,c₁,c₂]) = 0 := by simp [lift] #align quaternion_algebra.basis.lift_zero QuaternionAlgebra.Basis.lift_zero theorem lift_one : q.lift (1 : ℍ[R,c₁,c₂]) = 1 := by simp [lift] #align quaternion_algebra.basis.lift_one QuaternionAlgebra.Basis.lift_one theorem lift_add (x y : ℍ[R,c₁,c₂]) : q.lift (x + y) = q.lift x + q.lift y := by simp only [lift, add_re, map_add, add_imI, add_smul, add_imJ, add_imK] abel #align quaternion_algebra.basis.lift_add QuaternionAlgebra.Basis.lift_add
Mathlib/Algebra/QuaternionBasis.lean
125
135
theorem lift_mul (x y : ℍ[R,c₁,c₂]) : q.lift (x * y) = q.lift x * q.lift y := by
simp only [lift, Algebra.algebraMap_eq_smul_one] simp_rw [add_mul, mul_add, smul_mul_assoc, mul_smul_comm, one_mul, mul_one, smul_smul] simp only [i_mul_i, j_mul_j, i_mul_j, j_mul_i, i_mul_k, k_mul_i, k_mul_j, j_mul_k, k_mul_k] simp only [smul_smul, smul_neg, sub_eq_add_neg, add_smul, ← add_assoc, mul_neg, neg_smul] simp only [mul_right_comm _ _ (c₁ * c₂), mul_comm _ (c₁ * c₂)] simp only [mul_comm _ c₁, mul_right_comm _ _ c₁] simp only [mul_comm _ c₂, mul_right_comm _ _ c₂] simp only [← mul_comm c₁ c₂, ← mul_assoc] simp only [mul_re, sub_eq_add_neg, add_smul, neg_smul, mul_imI, ← add_assoc, mul_imJ, mul_imK] abel
239
import Mathlib.Algebra.Quaternion import Mathlib.Tactic.Ring #align_import algebra.quaternion_basis from "leanprover-community/mathlib"@"3aa5b8a9ed7a7cabd36e6e1d022c9858ab8a8c2d" open Quaternion namespace QuaternionAlgebra structure Basis {R : Type*} (A : Type*) [CommRing R] [Ring A] [Algebra R A] (c₁ c₂ : R) where (i j k : A) i_mul_i : i * i = c₁ • (1 : A) j_mul_j : j * j = c₂ • (1 : A) i_mul_j : i * j = k j_mul_i : j * i = -k #align quaternion_algebra.basis QuaternionAlgebra.Basis variable {R : Type*} {A B : Type*} [CommRing R] [Ring A] [Ring B] [Algebra R A] [Algebra R B] variable {c₁ c₂ : R} namespace Basis @[ext] protected theorem ext ⦃q₁ q₂ : Basis A c₁ c₂⦄ (hi : q₁.i = q₂.i) (hj : q₁.j = q₂.j) : q₁ = q₂ := by cases q₁; rename_i q₁_i_mul_j _ cases q₂; rename_i q₂_i_mul_j _ congr rw [← q₁_i_mul_j, ← q₂_i_mul_j] congr #align quaternion_algebra.basis.ext QuaternionAlgebra.Basis.ext variable (R) @[simps i j k] protected def self : Basis ℍ[R,c₁,c₂] c₁ c₂ where i := ⟨0, 1, 0, 0⟩ i_mul_i := by ext <;> simp j := ⟨0, 0, 1, 0⟩ j_mul_j := by ext <;> simp k := ⟨0, 0, 0, 1⟩ i_mul_j := by ext <;> simp j_mul_i := by ext <;> simp #align quaternion_algebra.basis.self QuaternionAlgebra.Basis.self variable {R} instance : Inhabited (Basis ℍ[R,c₁,c₂] c₁ c₂) := ⟨Basis.self R⟩ variable (q : Basis A c₁ c₂) attribute [simp] i_mul_i j_mul_j i_mul_j j_mul_i @[simp] theorem i_mul_k : q.i * q.k = c₁ • q.j := by rw [← i_mul_j, ← mul_assoc, i_mul_i, smul_mul_assoc, one_mul] #align quaternion_algebra.basis.i_mul_k QuaternionAlgebra.Basis.i_mul_k @[simp] theorem k_mul_i : q.k * q.i = -c₁ • q.j := by rw [← i_mul_j, mul_assoc, j_mul_i, mul_neg, i_mul_k, neg_smul] #align quaternion_algebra.basis.k_mul_i QuaternionAlgebra.Basis.k_mul_i @[simp] theorem k_mul_j : q.k * q.j = c₂ • q.i := by rw [← i_mul_j, mul_assoc, j_mul_j, mul_smul_comm, mul_one] #align quaternion_algebra.basis.k_mul_j QuaternionAlgebra.Basis.k_mul_j @[simp] theorem j_mul_k : q.j * q.k = -c₂ • q.i := by rw [← i_mul_j, ← mul_assoc, j_mul_i, neg_mul, k_mul_j, neg_smul] #align quaternion_algebra.basis.j_mul_k QuaternionAlgebra.Basis.j_mul_k @[simp] theorem k_mul_k : q.k * q.k = -((c₁ * c₂) • (1 : A)) := by rw [← i_mul_j, mul_assoc, ← mul_assoc q.j _ _, j_mul_i, ← i_mul_j, ← mul_assoc, mul_neg, ← mul_assoc, i_mul_i, smul_mul_assoc, one_mul, neg_mul, smul_mul_assoc, j_mul_j, smul_smul] #align quaternion_algebra.basis.k_mul_k QuaternionAlgebra.Basis.k_mul_k def lift (x : ℍ[R,c₁,c₂]) : A := algebraMap R _ x.re + x.imI • q.i + x.imJ • q.j + x.imK • q.k #align quaternion_algebra.basis.lift QuaternionAlgebra.Basis.lift theorem lift_zero : q.lift (0 : ℍ[R,c₁,c₂]) = 0 := by simp [lift] #align quaternion_algebra.basis.lift_zero QuaternionAlgebra.Basis.lift_zero theorem lift_one : q.lift (1 : ℍ[R,c₁,c₂]) = 1 := by simp [lift] #align quaternion_algebra.basis.lift_one QuaternionAlgebra.Basis.lift_one theorem lift_add (x y : ℍ[R,c₁,c₂]) : q.lift (x + y) = q.lift x + q.lift y := by simp only [lift, add_re, map_add, add_imI, add_smul, add_imJ, add_imK] abel #align quaternion_algebra.basis.lift_add QuaternionAlgebra.Basis.lift_add theorem lift_mul (x y : ℍ[R,c₁,c₂]) : q.lift (x * y) = q.lift x * q.lift y := by simp only [lift, Algebra.algebraMap_eq_smul_one] simp_rw [add_mul, mul_add, smul_mul_assoc, mul_smul_comm, one_mul, mul_one, smul_smul] simp only [i_mul_i, j_mul_j, i_mul_j, j_mul_i, i_mul_k, k_mul_i, k_mul_j, j_mul_k, k_mul_k] simp only [smul_smul, smul_neg, sub_eq_add_neg, add_smul, ← add_assoc, mul_neg, neg_smul] simp only [mul_right_comm _ _ (c₁ * c₂), mul_comm _ (c₁ * c₂)] simp only [mul_comm _ c₁, mul_right_comm _ _ c₁] simp only [mul_comm _ c₂, mul_right_comm _ _ c₂] simp only [← mul_comm c₁ c₂, ← mul_assoc] simp only [mul_re, sub_eq_add_neg, add_smul, neg_smul, mul_imI, ← add_assoc, mul_imJ, mul_imK] abel #align quaternion_algebra.basis.lift_mul QuaternionAlgebra.Basis.lift_mul
Mathlib/Algebra/QuaternionBasis.lean
138
139
theorem lift_smul (r : R) (x : ℍ[R,c₁,c₂]) : q.lift (r • x) = r • q.lift x := by
simp [lift, mul_smul, ← Algebra.smul_def]
239
import Mathlib.Algebra.Homology.HomologicalComplex import Mathlib.CategoryTheory.DifferentialObject #align_import algebra.homology.differential_object from "leanprover-community/mathlib"@"b535c2d5d996acd9b0554b76395d9c920e186f4f" open CategoryTheory CategoryTheory.Limits open scoped Classical noncomputable section namespace CategoryTheory.DifferentialObject variable {β : Type*} [AddCommGroup β] {b : β} variable {V : Type*} [Category V] [HasZeroMorphisms V] variable (X : DifferentialObject ℤ (GradedObjectWithShift b V)) abbrev objEqToHom {i j : β} (h : i = j) : X.obj i ⟶ X.obj j := eqToHom (congr_arg X.obj h) set_option linter.uppercaseLean3 false in #align category_theory.differential_object.X_eq_to_hom CategoryTheory.DifferentialObject.objEqToHom @[simp] theorem objEqToHom_refl (i : β) : X.objEqToHom (refl i) = 𝟙 _ := rfl set_option linter.uppercaseLean3 false in #align category_theory.differential_object.X_eq_to_hom_refl CategoryTheory.DifferentialObject.objEqToHom_refl @[reassoc (attr := simp)]
Mathlib/Algebra/Homology/DifferentialObject.lean
53
54
theorem objEqToHom_d {x y : β} (h : x = y) : X.objEqToHom h ≫ X.d y = X.d x ≫ X.objEqToHom (by cases h; rfl) := by
cases h; dsimp; simp
240
import Mathlib.Algebra.Homology.HomologicalComplex import Mathlib.CategoryTheory.DifferentialObject #align_import algebra.homology.differential_object from "leanprover-community/mathlib"@"b535c2d5d996acd9b0554b76395d9c920e186f4f" open CategoryTheory CategoryTheory.Limits open scoped Classical noncomputable section namespace CategoryTheory.DifferentialObject variable {β : Type*} [AddCommGroup β] {b : β} variable {V : Type*} [Category V] [HasZeroMorphisms V] variable (X : DifferentialObject ℤ (GradedObjectWithShift b V)) abbrev objEqToHom {i j : β} (h : i = j) : X.obj i ⟶ X.obj j := eqToHom (congr_arg X.obj h) set_option linter.uppercaseLean3 false in #align category_theory.differential_object.X_eq_to_hom CategoryTheory.DifferentialObject.objEqToHom @[simp] theorem objEqToHom_refl (i : β) : X.objEqToHom (refl i) = 𝟙 _ := rfl set_option linter.uppercaseLean3 false in #align category_theory.differential_object.X_eq_to_hom_refl CategoryTheory.DifferentialObject.objEqToHom_refl @[reassoc (attr := simp)] theorem objEqToHom_d {x y : β} (h : x = y) : X.objEqToHom h ≫ X.d y = X.d x ≫ X.objEqToHom (by cases h; rfl) := by cases h; dsimp; simp #align homological_complex.eq_to_hom_d CategoryTheory.DifferentialObject.objEqToHom_d @[reassoc (attr := simp)] theorem d_squared_apply {x : β} : X.d x ≫ X.d _ = 0 := congr_fun X.d_squared _ @[reassoc (attr := simp)]
Mathlib/Algebra/Homology/DifferentialObject.lean
61
62
theorem eqToHom_f' {X Y : DifferentialObject ℤ (GradedObjectWithShift b V)} (f : X ⟶ Y) {x y : β} (h : x = y) : X.objEqToHom h ≫ f.f y = f.f x ≫ Y.objEqToHom h := by
cases h; simp
240
import Mathlib.Algebra.Homology.HomologicalComplex import Mathlib.CategoryTheory.DifferentialObject #align_import algebra.homology.differential_object from "leanprover-community/mathlib"@"b535c2d5d996acd9b0554b76395d9c920e186f4f" open CategoryTheory CategoryTheory.Limits open scoped Classical noncomputable section open CategoryTheory.DifferentialObject namespace HomologicalComplex variable {β : Type*} [AddCommGroup β] (b : β) variable (V : Type*) [Category V] [HasZeroMorphisms V] -- Porting note: this should be moved to an earlier file. -- Porting note: simpNF linter silenced, both `d_eqToHom` and its `_assoc` version -- do not simplify under themselves @[reassoc (attr := simp, nolint simpNF)]
Mathlib/Algebra/Homology/DifferentialObject.lean
78
79
theorem d_eqToHom (X : HomologicalComplex V (ComplexShape.up' b)) {x y z : β} (h : y = z) : X.d x y ≫ eqToHom (congr_arg X.X h) = X.d x z := by
cases h; simp
240
import Mathlib.Algebra.Ring.Prod import Mathlib.GroupTheory.OrderOfElement import Mathlib.Tactic.FinCases #align_import data.zmod.basic from "leanprover-community/mathlib"@"74ad1c88c77e799d2fea62801d1dbbd698cff1b7" assert_not_exists Submodule open Function namespace ZMod instance charZero : CharZero (ZMod 0) := inferInstanceAs (CharZero ℤ) def val : ∀ {n : ℕ}, ZMod n → ℕ | 0 => Int.natAbs | n + 1 => ((↑) : Fin (n + 1) → ℕ) #align zmod.val ZMod.val
Mathlib/Data/ZMod/Basic.lean
52
55
theorem val_lt {n : ℕ} [NeZero n] (a : ZMod n) : a.val < n := by
cases n · cases NeZero.ne 0 rfl exact Fin.is_lt a
241
import Mathlib.Algebra.Ring.Prod import Mathlib.GroupTheory.OrderOfElement import Mathlib.Tactic.FinCases #align_import data.zmod.basic from "leanprover-community/mathlib"@"74ad1c88c77e799d2fea62801d1dbbd698cff1b7" assert_not_exists Submodule open Function namespace ZMod instance charZero : CharZero (ZMod 0) := inferInstanceAs (CharZero ℤ) def val : ∀ {n : ℕ}, ZMod n → ℕ | 0 => Int.natAbs | n + 1 => ((↑) : Fin (n + 1) → ℕ) #align zmod.val ZMod.val theorem val_lt {n : ℕ} [NeZero n] (a : ZMod n) : a.val < n := by cases n · cases NeZero.ne 0 rfl exact Fin.is_lt a #align zmod.val_lt ZMod.val_lt theorem val_le {n : ℕ} [NeZero n] (a : ZMod n) : a.val ≤ n := a.val_lt.le #align zmod.val_le ZMod.val_le @[simp] theorem val_zero : ∀ {n}, (0 : ZMod n).val = 0 | 0 => rfl | _ + 1 => rfl #align zmod.val_zero ZMod.val_zero @[simp] theorem val_one' : (1 : ZMod 0).val = 1 := rfl #align zmod.val_one' ZMod.val_one' @[simp] theorem val_neg' {n : ZMod 0} : (-n).val = n.val := Int.natAbs_neg n #align zmod.val_neg' ZMod.val_neg' @[simp] theorem val_mul' {m n : ZMod 0} : (m * n).val = m.val * n.val := Int.natAbs_mul m n #align zmod.val_mul' ZMod.val_mul' @[simp]
Mathlib/Data/ZMod/Basic.lean
84
88
theorem val_natCast {n : ℕ} (a : ℕ) : (a : ZMod n).val = a % n := by
cases n · rw [Nat.mod_zero] exact Int.natAbs_ofNat a · apply Fin.val_natCast
241
import Mathlib.Algebra.Ring.Prod import Mathlib.GroupTheory.OrderOfElement import Mathlib.Tactic.FinCases #align_import data.zmod.basic from "leanprover-community/mathlib"@"74ad1c88c77e799d2fea62801d1dbbd698cff1b7" assert_not_exists Submodule open Function namespace ZMod instance charZero : CharZero (ZMod 0) := inferInstanceAs (CharZero ℤ) def val : ∀ {n : ℕ}, ZMod n → ℕ | 0 => Int.natAbs | n + 1 => ((↑) : Fin (n + 1) → ℕ) #align zmod.val ZMod.val theorem val_lt {n : ℕ} [NeZero n] (a : ZMod n) : a.val < n := by cases n · cases NeZero.ne 0 rfl exact Fin.is_lt a #align zmod.val_lt ZMod.val_lt theorem val_le {n : ℕ} [NeZero n] (a : ZMod n) : a.val ≤ n := a.val_lt.le #align zmod.val_le ZMod.val_le @[simp] theorem val_zero : ∀ {n}, (0 : ZMod n).val = 0 | 0 => rfl | _ + 1 => rfl #align zmod.val_zero ZMod.val_zero @[simp] theorem val_one' : (1 : ZMod 0).val = 1 := rfl #align zmod.val_one' ZMod.val_one' @[simp] theorem val_neg' {n : ZMod 0} : (-n).val = n.val := Int.natAbs_neg n #align zmod.val_neg' ZMod.val_neg' @[simp] theorem val_mul' {m n : ZMod 0} : (m * n).val = m.val * n.val := Int.natAbs_mul m n #align zmod.val_mul' ZMod.val_mul' @[simp] theorem val_natCast {n : ℕ} (a : ℕ) : (a : ZMod n).val = a % n := by cases n · rw [Nat.mod_zero] exact Int.natAbs_ofNat a · apply Fin.val_natCast #align zmod.val_nat_cast ZMod.val_natCast @[deprecated (since := "2024-04-17")] alias val_nat_cast := val_natCast
Mathlib/Data/ZMod/Basic.lean
94
96
theorem val_unit' {n : ZMod 0} : IsUnit n ↔ n.val = 1 := by
simp only [val] rw [Int.isUnit_iff, Int.natAbs_eq_iff, Nat.cast_one]
241
import Mathlib.Algebra.Ring.Prod import Mathlib.GroupTheory.OrderOfElement import Mathlib.Tactic.FinCases #align_import data.zmod.basic from "leanprover-community/mathlib"@"74ad1c88c77e799d2fea62801d1dbbd698cff1b7" assert_not_exists Submodule open Function namespace ZMod instance charZero : CharZero (ZMod 0) := inferInstanceAs (CharZero ℤ) def val : ∀ {n : ℕ}, ZMod n → ℕ | 0 => Int.natAbs | n + 1 => ((↑) : Fin (n + 1) → ℕ) #align zmod.val ZMod.val theorem val_lt {n : ℕ} [NeZero n] (a : ZMod n) : a.val < n := by cases n · cases NeZero.ne 0 rfl exact Fin.is_lt a #align zmod.val_lt ZMod.val_lt theorem val_le {n : ℕ} [NeZero n] (a : ZMod n) : a.val ≤ n := a.val_lt.le #align zmod.val_le ZMod.val_le @[simp] theorem val_zero : ∀ {n}, (0 : ZMod n).val = 0 | 0 => rfl | _ + 1 => rfl #align zmod.val_zero ZMod.val_zero @[simp] theorem val_one' : (1 : ZMod 0).val = 1 := rfl #align zmod.val_one' ZMod.val_one' @[simp] theorem val_neg' {n : ZMod 0} : (-n).val = n.val := Int.natAbs_neg n #align zmod.val_neg' ZMod.val_neg' @[simp] theorem val_mul' {m n : ZMod 0} : (m * n).val = m.val * n.val := Int.natAbs_mul m n #align zmod.val_mul' ZMod.val_mul' @[simp] theorem val_natCast {n : ℕ} (a : ℕ) : (a : ZMod n).val = a % n := by cases n · rw [Nat.mod_zero] exact Int.natAbs_ofNat a · apply Fin.val_natCast #align zmod.val_nat_cast ZMod.val_natCast @[deprecated (since := "2024-04-17")] alias val_nat_cast := val_natCast theorem val_unit' {n : ZMod 0} : IsUnit n ↔ n.val = 1 := by simp only [val] rw [Int.isUnit_iff, Int.natAbs_eq_iff, Nat.cast_one] lemma eq_one_of_isUnit_natCast {n : ℕ} (h : IsUnit (n : ZMod 0)) : n = 1 := by rw [← Nat.mod_zero n, ← val_natCast, val_unit'.mp h]
Mathlib/Data/ZMod/Basic.lean
101
102
theorem val_natCast_of_lt {n a : ℕ} (h : a < n) : (a : ZMod n).val = a := by
rwa [val_natCast, Nat.mod_eq_of_lt]
241
import Mathlib.Algebra.Ring.Prod import Mathlib.GroupTheory.OrderOfElement import Mathlib.Tactic.FinCases #align_import data.zmod.basic from "leanprover-community/mathlib"@"74ad1c88c77e799d2fea62801d1dbbd698cff1b7" assert_not_exists Submodule open Function namespace ZMod instance charZero : CharZero (ZMod 0) := inferInstanceAs (CharZero ℤ) def val : ∀ {n : ℕ}, ZMod n → ℕ | 0 => Int.natAbs | n + 1 => ((↑) : Fin (n + 1) → ℕ) #align zmod.val ZMod.val theorem val_lt {n : ℕ} [NeZero n] (a : ZMod n) : a.val < n := by cases n · cases NeZero.ne 0 rfl exact Fin.is_lt a #align zmod.val_lt ZMod.val_lt theorem val_le {n : ℕ} [NeZero n] (a : ZMod n) : a.val ≤ n := a.val_lt.le #align zmod.val_le ZMod.val_le @[simp] theorem val_zero : ∀ {n}, (0 : ZMod n).val = 0 | 0 => rfl | _ + 1 => rfl #align zmod.val_zero ZMod.val_zero @[simp] theorem val_one' : (1 : ZMod 0).val = 1 := rfl #align zmod.val_one' ZMod.val_one' @[simp] theorem val_neg' {n : ZMod 0} : (-n).val = n.val := Int.natAbs_neg n #align zmod.val_neg' ZMod.val_neg' @[simp] theorem val_mul' {m n : ZMod 0} : (m * n).val = m.val * n.val := Int.natAbs_mul m n #align zmod.val_mul' ZMod.val_mul' @[simp] theorem val_natCast {n : ℕ} (a : ℕ) : (a : ZMod n).val = a % n := by cases n · rw [Nat.mod_zero] exact Int.natAbs_ofNat a · apply Fin.val_natCast #align zmod.val_nat_cast ZMod.val_natCast @[deprecated (since := "2024-04-17")] alias val_nat_cast := val_natCast theorem val_unit' {n : ZMod 0} : IsUnit n ↔ n.val = 1 := by simp only [val] rw [Int.isUnit_iff, Int.natAbs_eq_iff, Nat.cast_one] lemma eq_one_of_isUnit_natCast {n : ℕ} (h : IsUnit (n : ZMod 0)) : n = 1 := by rw [← Nat.mod_zero n, ← val_natCast, val_unit'.mp h] theorem val_natCast_of_lt {n a : ℕ} (h : a < n) : (a : ZMod n).val = a := by rwa [val_natCast, Nat.mod_eq_of_lt] @[deprecated (since := "2024-04-17")] alias val_nat_cast_of_lt := val_natCast_of_lt instance charP (n : ℕ) : CharP (ZMod n) n where cast_eq_zero_iff' := by intro k cases' n with n · simp [zero_dvd_iff, Int.natCast_eq_zero, Nat.zero_eq] · exact Fin.natCast_eq_zero @[simp] theorem addOrderOf_one (n : ℕ) : addOrderOf (1 : ZMod n) = n := CharP.eq _ (CharP.addOrderOf_one _) (ZMod.charP n) #align zmod.add_order_of_one ZMod.addOrderOf_one @[simp]
Mathlib/Data/ZMod/Basic.lean
122
126
theorem addOrderOf_coe (a : ℕ) {n : ℕ} (n0 : n ≠ 0) : addOrderOf (a : ZMod n) = n / n.gcd a := by
cases' a with a · simp only [Nat.zero_eq, Nat.cast_zero, addOrderOf_zero, Nat.gcd_zero_right, Nat.pos_of_ne_zero n0, Nat.div_self] rw [← Nat.smul_one_eq_cast, addOrderOf_nsmul' _ a.succ_ne_zero, ZMod.addOrderOf_one]
241
import Mathlib.Algebra.Ring.Prod import Mathlib.GroupTheory.OrderOfElement import Mathlib.Tactic.FinCases #align_import data.zmod.basic from "leanprover-community/mathlib"@"74ad1c88c77e799d2fea62801d1dbbd698cff1b7" assert_not_exists Submodule open Function namespace ZMod instance charZero : CharZero (ZMod 0) := inferInstanceAs (CharZero ℤ) def val : ∀ {n : ℕ}, ZMod n → ℕ | 0 => Int.natAbs | n + 1 => ((↑) : Fin (n + 1) → ℕ) #align zmod.val ZMod.val theorem val_lt {n : ℕ} [NeZero n] (a : ZMod n) : a.val < n := by cases n · cases NeZero.ne 0 rfl exact Fin.is_lt a #align zmod.val_lt ZMod.val_lt theorem val_le {n : ℕ} [NeZero n] (a : ZMod n) : a.val ≤ n := a.val_lt.le #align zmod.val_le ZMod.val_le @[simp] theorem val_zero : ∀ {n}, (0 : ZMod n).val = 0 | 0 => rfl | _ + 1 => rfl #align zmod.val_zero ZMod.val_zero @[simp] theorem val_one' : (1 : ZMod 0).val = 1 := rfl #align zmod.val_one' ZMod.val_one' @[simp] theorem val_neg' {n : ZMod 0} : (-n).val = n.val := Int.natAbs_neg n #align zmod.val_neg' ZMod.val_neg' @[simp] theorem val_mul' {m n : ZMod 0} : (m * n).val = m.val * n.val := Int.natAbs_mul m n #align zmod.val_mul' ZMod.val_mul' @[simp] theorem val_natCast {n : ℕ} (a : ℕ) : (a : ZMod n).val = a % n := by cases n · rw [Nat.mod_zero] exact Int.natAbs_ofNat a · apply Fin.val_natCast #align zmod.val_nat_cast ZMod.val_natCast @[deprecated (since := "2024-04-17")] alias val_nat_cast := val_natCast theorem val_unit' {n : ZMod 0} : IsUnit n ↔ n.val = 1 := by simp only [val] rw [Int.isUnit_iff, Int.natAbs_eq_iff, Nat.cast_one] lemma eq_one_of_isUnit_natCast {n : ℕ} (h : IsUnit (n : ZMod 0)) : n = 1 := by rw [← Nat.mod_zero n, ← val_natCast, val_unit'.mp h] theorem val_natCast_of_lt {n a : ℕ} (h : a < n) : (a : ZMod n).val = a := by rwa [val_natCast, Nat.mod_eq_of_lt] @[deprecated (since := "2024-04-17")] alias val_nat_cast_of_lt := val_natCast_of_lt instance charP (n : ℕ) : CharP (ZMod n) n where cast_eq_zero_iff' := by intro k cases' n with n · simp [zero_dvd_iff, Int.natCast_eq_zero, Nat.zero_eq] · exact Fin.natCast_eq_zero @[simp] theorem addOrderOf_one (n : ℕ) : addOrderOf (1 : ZMod n) = n := CharP.eq _ (CharP.addOrderOf_one _) (ZMod.charP n) #align zmod.add_order_of_one ZMod.addOrderOf_one @[simp] theorem addOrderOf_coe (a : ℕ) {n : ℕ} (n0 : n ≠ 0) : addOrderOf (a : ZMod n) = n / n.gcd a := by cases' a with a · simp only [Nat.zero_eq, Nat.cast_zero, addOrderOf_zero, Nat.gcd_zero_right, Nat.pos_of_ne_zero n0, Nat.div_self] rw [← Nat.smul_one_eq_cast, addOrderOf_nsmul' _ a.succ_ne_zero, ZMod.addOrderOf_one] #align zmod.add_order_of_coe ZMod.addOrderOf_coe @[simp]
Mathlib/Data/ZMod/Basic.lean
132
133
theorem addOrderOf_coe' {a : ℕ} (n : ℕ) (a0 : a ≠ 0) : addOrderOf (a : ZMod n) = n / n.gcd a := by
rw [← Nat.smul_one_eq_cast, addOrderOf_nsmul' _ a0, ZMod.addOrderOf_one]
241
import Mathlib.Algebra.Ring.Prod import Mathlib.GroupTheory.OrderOfElement import Mathlib.Tactic.FinCases #align_import data.zmod.basic from "leanprover-community/mathlib"@"74ad1c88c77e799d2fea62801d1dbbd698cff1b7" assert_not_exists Submodule open Function namespace ZMod instance charZero : CharZero (ZMod 0) := inferInstanceAs (CharZero ℤ) def val : ∀ {n : ℕ}, ZMod n → ℕ | 0 => Int.natAbs | n + 1 => ((↑) : Fin (n + 1) → ℕ) #align zmod.val ZMod.val theorem val_lt {n : ℕ} [NeZero n] (a : ZMod n) : a.val < n := by cases n · cases NeZero.ne 0 rfl exact Fin.is_lt a #align zmod.val_lt ZMod.val_lt theorem val_le {n : ℕ} [NeZero n] (a : ZMod n) : a.val ≤ n := a.val_lt.le #align zmod.val_le ZMod.val_le @[simp] theorem val_zero : ∀ {n}, (0 : ZMod n).val = 0 | 0 => rfl | _ + 1 => rfl #align zmod.val_zero ZMod.val_zero @[simp] theorem val_one' : (1 : ZMod 0).val = 1 := rfl #align zmod.val_one' ZMod.val_one' @[simp] theorem val_neg' {n : ZMod 0} : (-n).val = n.val := Int.natAbs_neg n #align zmod.val_neg' ZMod.val_neg' @[simp] theorem val_mul' {m n : ZMod 0} : (m * n).val = m.val * n.val := Int.natAbs_mul m n #align zmod.val_mul' ZMod.val_mul' @[simp] theorem val_natCast {n : ℕ} (a : ℕ) : (a : ZMod n).val = a % n := by cases n · rw [Nat.mod_zero] exact Int.natAbs_ofNat a · apply Fin.val_natCast #align zmod.val_nat_cast ZMod.val_natCast @[deprecated (since := "2024-04-17")] alias val_nat_cast := val_natCast theorem val_unit' {n : ZMod 0} : IsUnit n ↔ n.val = 1 := by simp only [val] rw [Int.isUnit_iff, Int.natAbs_eq_iff, Nat.cast_one] lemma eq_one_of_isUnit_natCast {n : ℕ} (h : IsUnit (n : ZMod 0)) : n = 1 := by rw [← Nat.mod_zero n, ← val_natCast, val_unit'.mp h] theorem val_natCast_of_lt {n a : ℕ} (h : a < n) : (a : ZMod n).val = a := by rwa [val_natCast, Nat.mod_eq_of_lt] @[deprecated (since := "2024-04-17")] alias val_nat_cast_of_lt := val_natCast_of_lt instance charP (n : ℕ) : CharP (ZMod n) n where cast_eq_zero_iff' := by intro k cases' n with n · simp [zero_dvd_iff, Int.natCast_eq_zero, Nat.zero_eq] · exact Fin.natCast_eq_zero @[simp] theorem addOrderOf_one (n : ℕ) : addOrderOf (1 : ZMod n) = n := CharP.eq _ (CharP.addOrderOf_one _) (ZMod.charP n) #align zmod.add_order_of_one ZMod.addOrderOf_one @[simp] theorem addOrderOf_coe (a : ℕ) {n : ℕ} (n0 : n ≠ 0) : addOrderOf (a : ZMod n) = n / n.gcd a := by cases' a with a · simp only [Nat.zero_eq, Nat.cast_zero, addOrderOf_zero, Nat.gcd_zero_right, Nat.pos_of_ne_zero n0, Nat.div_self] rw [← Nat.smul_one_eq_cast, addOrderOf_nsmul' _ a.succ_ne_zero, ZMod.addOrderOf_one] #align zmod.add_order_of_coe ZMod.addOrderOf_coe @[simp] theorem addOrderOf_coe' {a : ℕ} (n : ℕ) (a0 : a ≠ 0) : addOrderOf (a : ZMod n) = n / n.gcd a := by rw [← Nat.smul_one_eq_cast, addOrderOf_nsmul' _ a0, ZMod.addOrderOf_one] #align zmod.add_order_of_coe' ZMod.addOrderOf_coe'
Mathlib/Data/ZMod/Basic.lean
137
139
theorem ringChar_zmod_n (n : ℕ) : ringChar (ZMod n) = n := by
rw [ringChar.eq_iff] exact ZMod.charP n
241
import Mathlib.Algebra.Ring.Prod import Mathlib.GroupTheory.OrderOfElement import Mathlib.Tactic.FinCases #align_import data.zmod.basic from "leanprover-community/mathlib"@"74ad1c88c77e799d2fea62801d1dbbd698cff1b7" assert_not_exists Submodule open Function namespace ZMod instance charZero : CharZero (ZMod 0) := inferInstanceAs (CharZero ℤ) def val : ∀ {n : ℕ}, ZMod n → ℕ | 0 => Int.natAbs | n + 1 => ((↑) : Fin (n + 1) → ℕ) #align zmod.val ZMod.val theorem val_lt {n : ℕ} [NeZero n] (a : ZMod n) : a.val < n := by cases n · cases NeZero.ne 0 rfl exact Fin.is_lt a #align zmod.val_lt ZMod.val_lt theorem val_le {n : ℕ} [NeZero n] (a : ZMod n) : a.val ≤ n := a.val_lt.le #align zmod.val_le ZMod.val_le @[simp] theorem val_zero : ∀ {n}, (0 : ZMod n).val = 0 | 0 => rfl | _ + 1 => rfl #align zmod.val_zero ZMod.val_zero @[simp] theorem val_one' : (1 : ZMod 0).val = 1 := rfl #align zmod.val_one' ZMod.val_one' @[simp] theorem val_neg' {n : ZMod 0} : (-n).val = n.val := Int.natAbs_neg n #align zmod.val_neg' ZMod.val_neg' @[simp] theorem val_mul' {m n : ZMod 0} : (m * n).val = m.val * n.val := Int.natAbs_mul m n #align zmod.val_mul' ZMod.val_mul' @[simp] theorem val_natCast {n : ℕ} (a : ℕ) : (a : ZMod n).val = a % n := by cases n · rw [Nat.mod_zero] exact Int.natAbs_ofNat a · apply Fin.val_natCast #align zmod.val_nat_cast ZMod.val_natCast @[deprecated (since := "2024-04-17")] alias val_nat_cast := val_natCast theorem val_unit' {n : ZMod 0} : IsUnit n ↔ n.val = 1 := by simp only [val] rw [Int.isUnit_iff, Int.natAbs_eq_iff, Nat.cast_one] lemma eq_one_of_isUnit_natCast {n : ℕ} (h : IsUnit (n : ZMod 0)) : n = 1 := by rw [← Nat.mod_zero n, ← val_natCast, val_unit'.mp h] theorem val_natCast_of_lt {n a : ℕ} (h : a < n) : (a : ZMod n).val = a := by rwa [val_natCast, Nat.mod_eq_of_lt] @[deprecated (since := "2024-04-17")] alias val_nat_cast_of_lt := val_natCast_of_lt instance charP (n : ℕ) : CharP (ZMod n) n where cast_eq_zero_iff' := by intro k cases' n with n · simp [zero_dvd_iff, Int.natCast_eq_zero, Nat.zero_eq] · exact Fin.natCast_eq_zero @[simp] theorem addOrderOf_one (n : ℕ) : addOrderOf (1 : ZMod n) = n := CharP.eq _ (CharP.addOrderOf_one _) (ZMod.charP n) #align zmod.add_order_of_one ZMod.addOrderOf_one @[simp] theorem addOrderOf_coe (a : ℕ) {n : ℕ} (n0 : n ≠ 0) : addOrderOf (a : ZMod n) = n / n.gcd a := by cases' a with a · simp only [Nat.zero_eq, Nat.cast_zero, addOrderOf_zero, Nat.gcd_zero_right, Nat.pos_of_ne_zero n0, Nat.div_self] rw [← Nat.smul_one_eq_cast, addOrderOf_nsmul' _ a.succ_ne_zero, ZMod.addOrderOf_one] #align zmod.add_order_of_coe ZMod.addOrderOf_coe @[simp] theorem addOrderOf_coe' {a : ℕ} (n : ℕ) (a0 : a ≠ 0) : addOrderOf (a : ZMod n) = n / n.gcd a := by rw [← Nat.smul_one_eq_cast, addOrderOf_nsmul' _ a0, ZMod.addOrderOf_one] #align zmod.add_order_of_coe' ZMod.addOrderOf_coe' theorem ringChar_zmod_n (n : ℕ) : ringChar (ZMod n) = n := by rw [ringChar.eq_iff] exact ZMod.charP n #align zmod.ring_char_zmod_n ZMod.ringChar_zmod_n -- @[simp] -- Porting note (#10618): simp can prove this theorem natCast_self (n : ℕ) : (n : ZMod n) = 0 := CharP.cast_eq_zero (ZMod n) n #align zmod.nat_cast_self ZMod.natCast_self @[deprecated (since := "2024-04-17")] alias nat_cast_self := natCast_self @[simp]
Mathlib/Data/ZMod/Basic.lean
151
152
theorem natCast_self' (n : ℕ) : (n + 1 : ZMod (n + 1)) = 0 := by
rw [← Nat.cast_add_one, natCast_self (n + 1)]
241
import Mathlib.Algebra.Ring.Prod import Mathlib.GroupTheory.OrderOfElement import Mathlib.Tactic.FinCases #align_import data.zmod.basic from "leanprover-community/mathlib"@"74ad1c88c77e799d2fea62801d1dbbd698cff1b7" assert_not_exists Submodule open Function namespace ZMod instance charZero : CharZero (ZMod 0) := inferInstanceAs (CharZero ℤ) def val : ∀ {n : ℕ}, ZMod n → ℕ | 0 => Int.natAbs | n + 1 => ((↑) : Fin (n + 1) → ℕ) #align zmod.val ZMod.val theorem val_lt {n : ℕ} [NeZero n] (a : ZMod n) : a.val < n := by cases n · cases NeZero.ne 0 rfl exact Fin.is_lt a #align zmod.val_lt ZMod.val_lt theorem val_le {n : ℕ} [NeZero n] (a : ZMod n) : a.val ≤ n := a.val_lt.le #align zmod.val_le ZMod.val_le @[simp] theorem val_zero : ∀ {n}, (0 : ZMod n).val = 0 | 0 => rfl | _ + 1 => rfl #align zmod.val_zero ZMod.val_zero @[simp] theorem val_one' : (1 : ZMod 0).val = 1 := rfl #align zmod.val_one' ZMod.val_one' @[simp] theorem val_neg' {n : ZMod 0} : (-n).val = n.val := Int.natAbs_neg n #align zmod.val_neg' ZMod.val_neg' @[simp] theorem val_mul' {m n : ZMod 0} : (m * n).val = m.val * n.val := Int.natAbs_mul m n #align zmod.val_mul' ZMod.val_mul' @[simp] theorem val_natCast {n : ℕ} (a : ℕ) : (a : ZMod n).val = a % n := by cases n · rw [Nat.mod_zero] exact Int.natAbs_ofNat a · apply Fin.val_natCast #align zmod.val_nat_cast ZMod.val_natCast @[deprecated (since := "2024-04-17")] alias val_nat_cast := val_natCast theorem val_unit' {n : ZMod 0} : IsUnit n ↔ n.val = 1 := by simp only [val] rw [Int.isUnit_iff, Int.natAbs_eq_iff, Nat.cast_one] lemma eq_one_of_isUnit_natCast {n : ℕ} (h : IsUnit (n : ZMod 0)) : n = 1 := by rw [← Nat.mod_zero n, ← val_natCast, val_unit'.mp h] theorem val_natCast_of_lt {n a : ℕ} (h : a < n) : (a : ZMod n).val = a := by rwa [val_natCast, Nat.mod_eq_of_lt] @[deprecated (since := "2024-04-17")] alias val_nat_cast_of_lt := val_natCast_of_lt instance charP (n : ℕ) : CharP (ZMod n) n where cast_eq_zero_iff' := by intro k cases' n with n · simp [zero_dvd_iff, Int.natCast_eq_zero, Nat.zero_eq] · exact Fin.natCast_eq_zero @[simp] theorem addOrderOf_one (n : ℕ) : addOrderOf (1 : ZMod n) = n := CharP.eq _ (CharP.addOrderOf_one _) (ZMod.charP n) #align zmod.add_order_of_one ZMod.addOrderOf_one @[simp] theorem addOrderOf_coe (a : ℕ) {n : ℕ} (n0 : n ≠ 0) : addOrderOf (a : ZMod n) = n / n.gcd a := by cases' a with a · simp only [Nat.zero_eq, Nat.cast_zero, addOrderOf_zero, Nat.gcd_zero_right, Nat.pos_of_ne_zero n0, Nat.div_self] rw [← Nat.smul_one_eq_cast, addOrderOf_nsmul' _ a.succ_ne_zero, ZMod.addOrderOf_one] #align zmod.add_order_of_coe ZMod.addOrderOf_coe @[simp] theorem addOrderOf_coe' {a : ℕ} (n : ℕ) (a0 : a ≠ 0) : addOrderOf (a : ZMod n) = n / n.gcd a := by rw [← Nat.smul_one_eq_cast, addOrderOf_nsmul' _ a0, ZMod.addOrderOf_one] #align zmod.add_order_of_coe' ZMod.addOrderOf_coe' theorem ringChar_zmod_n (n : ℕ) : ringChar (ZMod n) = n := by rw [ringChar.eq_iff] exact ZMod.charP n #align zmod.ring_char_zmod_n ZMod.ringChar_zmod_n -- @[simp] -- Porting note (#10618): simp can prove this theorem natCast_self (n : ℕ) : (n : ZMod n) = 0 := CharP.cast_eq_zero (ZMod n) n #align zmod.nat_cast_self ZMod.natCast_self @[deprecated (since := "2024-04-17")] alias nat_cast_self := natCast_self @[simp] theorem natCast_self' (n : ℕ) : (n + 1 : ZMod (n + 1)) = 0 := by rw [← Nat.cast_add_one, natCast_self (n + 1)] #align zmod.nat_cast_self' ZMod.natCast_self' @[deprecated (since := "2024-04-17")] alias nat_cast_self' := natCast_self' section UniversalProperty variable {n : ℕ} {R : Type*} section variable [AddGroupWithOne R] def cast : ∀ {n : ℕ}, ZMod n → R | 0 => Int.cast | _ + 1 => fun i => i.val #align zmod.cast ZMod.cast @[simp]
Mathlib/Data/ZMod/Basic.lean
176
180
theorem cast_zero : (cast (0 : ZMod n) : R) = 0 := by
delta ZMod.cast cases n · exact Int.cast_zero · simp
241
import Mathlib.Algebra.Ring.Prod import Mathlib.GroupTheory.OrderOfElement import Mathlib.Tactic.FinCases #align_import data.zmod.basic from "leanprover-community/mathlib"@"74ad1c88c77e799d2fea62801d1dbbd698cff1b7" assert_not_exists Submodule open Function namespace ZMod instance charZero : CharZero (ZMod 0) := inferInstanceAs (CharZero ℤ) def val : ∀ {n : ℕ}, ZMod n → ℕ | 0 => Int.natAbs | n + 1 => ((↑) : Fin (n + 1) → ℕ) #align zmod.val ZMod.val theorem val_lt {n : ℕ} [NeZero n] (a : ZMod n) : a.val < n := by cases n · cases NeZero.ne 0 rfl exact Fin.is_lt a #align zmod.val_lt ZMod.val_lt theorem val_le {n : ℕ} [NeZero n] (a : ZMod n) : a.val ≤ n := a.val_lt.le #align zmod.val_le ZMod.val_le @[simp] theorem val_zero : ∀ {n}, (0 : ZMod n).val = 0 | 0 => rfl | _ + 1 => rfl #align zmod.val_zero ZMod.val_zero @[simp] theorem val_one' : (1 : ZMod 0).val = 1 := rfl #align zmod.val_one' ZMod.val_one' @[simp] theorem val_neg' {n : ZMod 0} : (-n).val = n.val := Int.natAbs_neg n #align zmod.val_neg' ZMod.val_neg' @[simp] theorem val_mul' {m n : ZMod 0} : (m * n).val = m.val * n.val := Int.natAbs_mul m n #align zmod.val_mul' ZMod.val_mul' @[simp] theorem val_natCast {n : ℕ} (a : ℕ) : (a : ZMod n).val = a % n := by cases n · rw [Nat.mod_zero] exact Int.natAbs_ofNat a · apply Fin.val_natCast #align zmod.val_nat_cast ZMod.val_natCast @[deprecated (since := "2024-04-17")] alias val_nat_cast := val_natCast theorem val_unit' {n : ZMod 0} : IsUnit n ↔ n.val = 1 := by simp only [val] rw [Int.isUnit_iff, Int.natAbs_eq_iff, Nat.cast_one] lemma eq_one_of_isUnit_natCast {n : ℕ} (h : IsUnit (n : ZMod 0)) : n = 1 := by rw [← Nat.mod_zero n, ← val_natCast, val_unit'.mp h] theorem val_natCast_of_lt {n a : ℕ} (h : a < n) : (a : ZMod n).val = a := by rwa [val_natCast, Nat.mod_eq_of_lt] @[deprecated (since := "2024-04-17")] alias val_nat_cast_of_lt := val_natCast_of_lt instance charP (n : ℕ) : CharP (ZMod n) n where cast_eq_zero_iff' := by intro k cases' n with n · simp [zero_dvd_iff, Int.natCast_eq_zero, Nat.zero_eq] · exact Fin.natCast_eq_zero @[simp] theorem addOrderOf_one (n : ℕ) : addOrderOf (1 : ZMod n) = n := CharP.eq _ (CharP.addOrderOf_one _) (ZMod.charP n) #align zmod.add_order_of_one ZMod.addOrderOf_one @[simp] theorem addOrderOf_coe (a : ℕ) {n : ℕ} (n0 : n ≠ 0) : addOrderOf (a : ZMod n) = n / n.gcd a := by cases' a with a · simp only [Nat.zero_eq, Nat.cast_zero, addOrderOf_zero, Nat.gcd_zero_right, Nat.pos_of_ne_zero n0, Nat.div_self] rw [← Nat.smul_one_eq_cast, addOrderOf_nsmul' _ a.succ_ne_zero, ZMod.addOrderOf_one] #align zmod.add_order_of_coe ZMod.addOrderOf_coe @[simp] theorem addOrderOf_coe' {a : ℕ} (n : ℕ) (a0 : a ≠ 0) : addOrderOf (a : ZMod n) = n / n.gcd a := by rw [← Nat.smul_one_eq_cast, addOrderOf_nsmul' _ a0, ZMod.addOrderOf_one] #align zmod.add_order_of_coe' ZMod.addOrderOf_coe' theorem ringChar_zmod_n (n : ℕ) : ringChar (ZMod n) = n := by rw [ringChar.eq_iff] exact ZMod.charP n #align zmod.ring_char_zmod_n ZMod.ringChar_zmod_n -- @[simp] -- Porting note (#10618): simp can prove this theorem natCast_self (n : ℕ) : (n : ZMod n) = 0 := CharP.cast_eq_zero (ZMod n) n #align zmod.nat_cast_self ZMod.natCast_self @[deprecated (since := "2024-04-17")] alias nat_cast_self := natCast_self @[simp] theorem natCast_self' (n : ℕ) : (n + 1 : ZMod (n + 1)) = 0 := by rw [← Nat.cast_add_one, natCast_self (n + 1)] #align zmod.nat_cast_self' ZMod.natCast_self' @[deprecated (since := "2024-04-17")] alias nat_cast_self' := natCast_self' section UniversalProperty variable {n : ℕ} {R : Type*} section variable [AddGroupWithOne R] def cast : ∀ {n : ℕ}, ZMod n → R | 0 => Int.cast | _ + 1 => fun i => i.val #align zmod.cast ZMod.cast @[simp] theorem cast_zero : (cast (0 : ZMod n) : R) = 0 := by delta ZMod.cast cases n · exact Int.cast_zero · simp #align zmod.cast_zero ZMod.cast_zero
Mathlib/Data/ZMod/Basic.lean
183
186
theorem cast_eq_val [NeZero n] (a : ZMod n) : (cast a : R) = a.val := by
cases n · cases NeZero.ne 0 rfl rfl
241
import Mathlib.Algebra.Ring.Prod import Mathlib.GroupTheory.OrderOfElement import Mathlib.Tactic.FinCases #align_import data.zmod.basic from "leanprover-community/mathlib"@"74ad1c88c77e799d2fea62801d1dbbd698cff1b7" assert_not_exists Submodule open Function namespace ZMod instance charZero : CharZero (ZMod 0) := inferInstanceAs (CharZero ℤ) def val : ∀ {n : ℕ}, ZMod n → ℕ | 0 => Int.natAbs | n + 1 => ((↑) : Fin (n + 1) → ℕ) #align zmod.val ZMod.val theorem val_lt {n : ℕ} [NeZero n] (a : ZMod n) : a.val < n := by cases n · cases NeZero.ne 0 rfl exact Fin.is_lt a #align zmod.val_lt ZMod.val_lt theorem val_le {n : ℕ} [NeZero n] (a : ZMod n) : a.val ≤ n := a.val_lt.le #align zmod.val_le ZMod.val_le @[simp] theorem val_zero : ∀ {n}, (0 : ZMod n).val = 0 | 0 => rfl | _ + 1 => rfl #align zmod.val_zero ZMod.val_zero @[simp] theorem val_one' : (1 : ZMod 0).val = 1 := rfl #align zmod.val_one' ZMod.val_one' @[simp] theorem val_neg' {n : ZMod 0} : (-n).val = n.val := Int.natAbs_neg n #align zmod.val_neg' ZMod.val_neg' @[simp] theorem val_mul' {m n : ZMod 0} : (m * n).val = m.val * n.val := Int.natAbs_mul m n #align zmod.val_mul' ZMod.val_mul' @[simp] theorem val_natCast {n : ℕ} (a : ℕ) : (a : ZMod n).val = a % n := by cases n · rw [Nat.mod_zero] exact Int.natAbs_ofNat a · apply Fin.val_natCast #align zmod.val_nat_cast ZMod.val_natCast @[deprecated (since := "2024-04-17")] alias val_nat_cast := val_natCast theorem val_unit' {n : ZMod 0} : IsUnit n ↔ n.val = 1 := by simp only [val] rw [Int.isUnit_iff, Int.natAbs_eq_iff, Nat.cast_one] lemma eq_one_of_isUnit_natCast {n : ℕ} (h : IsUnit (n : ZMod 0)) : n = 1 := by rw [← Nat.mod_zero n, ← val_natCast, val_unit'.mp h] theorem val_natCast_of_lt {n a : ℕ} (h : a < n) : (a : ZMod n).val = a := by rwa [val_natCast, Nat.mod_eq_of_lt] @[deprecated (since := "2024-04-17")] alias val_nat_cast_of_lt := val_natCast_of_lt instance charP (n : ℕ) : CharP (ZMod n) n where cast_eq_zero_iff' := by intro k cases' n with n · simp [zero_dvd_iff, Int.natCast_eq_zero, Nat.zero_eq] · exact Fin.natCast_eq_zero @[simp] theorem addOrderOf_one (n : ℕ) : addOrderOf (1 : ZMod n) = n := CharP.eq _ (CharP.addOrderOf_one _) (ZMod.charP n) #align zmod.add_order_of_one ZMod.addOrderOf_one @[simp] theorem addOrderOf_coe (a : ℕ) {n : ℕ} (n0 : n ≠ 0) : addOrderOf (a : ZMod n) = n / n.gcd a := by cases' a with a · simp only [Nat.zero_eq, Nat.cast_zero, addOrderOf_zero, Nat.gcd_zero_right, Nat.pos_of_ne_zero n0, Nat.div_self] rw [← Nat.smul_one_eq_cast, addOrderOf_nsmul' _ a.succ_ne_zero, ZMod.addOrderOf_one] #align zmod.add_order_of_coe ZMod.addOrderOf_coe @[simp] theorem addOrderOf_coe' {a : ℕ} (n : ℕ) (a0 : a ≠ 0) : addOrderOf (a : ZMod n) = n / n.gcd a := by rw [← Nat.smul_one_eq_cast, addOrderOf_nsmul' _ a0, ZMod.addOrderOf_one] #align zmod.add_order_of_coe' ZMod.addOrderOf_coe' theorem ringChar_zmod_n (n : ℕ) : ringChar (ZMod n) = n := by rw [ringChar.eq_iff] exact ZMod.charP n #align zmod.ring_char_zmod_n ZMod.ringChar_zmod_n -- @[simp] -- Porting note (#10618): simp can prove this theorem natCast_self (n : ℕ) : (n : ZMod n) = 0 := CharP.cast_eq_zero (ZMod n) n #align zmod.nat_cast_self ZMod.natCast_self @[deprecated (since := "2024-04-17")] alias nat_cast_self := natCast_self @[simp] theorem natCast_self' (n : ℕ) : (n + 1 : ZMod (n + 1)) = 0 := by rw [← Nat.cast_add_one, natCast_self (n + 1)] #align zmod.nat_cast_self' ZMod.natCast_self' @[deprecated (since := "2024-04-17")] alias nat_cast_self' := natCast_self' section UniversalProperty variable {n : ℕ} {R : Type*} section variable [AddGroupWithOne R] def cast : ∀ {n : ℕ}, ZMod n → R | 0 => Int.cast | _ + 1 => fun i => i.val #align zmod.cast ZMod.cast @[simp] theorem cast_zero : (cast (0 : ZMod n) : R) = 0 := by delta ZMod.cast cases n · exact Int.cast_zero · simp #align zmod.cast_zero ZMod.cast_zero theorem cast_eq_val [NeZero n] (a : ZMod n) : (cast a : R) = a.val := by cases n · cases NeZero.ne 0 rfl rfl #align zmod.cast_eq_val ZMod.cast_eq_val variable {S : Type*} [AddGroupWithOne S] @[simp]
Mathlib/Data/ZMod/Basic.lean
192
195
theorem _root_.Prod.fst_zmod_cast (a : ZMod n) : (cast a : R × S).fst = cast a := by
cases n · rfl · simp [ZMod.cast]
241
import Mathlib.Algebra.Order.Ring.Abs import Mathlib.Data.ZMod.Basic #align_import data.zmod.parity from "leanprover-community/mathlib"@"048240e809f04e2bde02482ab44bc230744cc6c9" namespace ZMod theorem eq_zero_iff_even {n : ℕ} : (n : ZMod 2) = 0 ↔ Even n := (CharP.cast_eq_zero_iff (ZMod 2) 2 n).trans even_iff_two_dvd.symm #align zmod.eq_zero_iff_even ZMod.eq_zero_iff_even
Mathlib/Data/ZMod/Parity.lean
28
29
theorem eq_one_iff_odd {n : ℕ} : (n : ZMod 2) = 1 ↔ Odd n := by
rw [← @Nat.cast_one (ZMod 2), ZMod.eq_iff_modEq_nat, Nat.odd_iff, Nat.ModEq]
242
import Mathlib.Algebra.Order.Ring.Abs import Mathlib.Data.ZMod.Basic #align_import data.zmod.parity from "leanprover-community/mathlib"@"048240e809f04e2bde02482ab44bc230744cc6c9" namespace ZMod theorem eq_zero_iff_even {n : ℕ} : (n : ZMod 2) = 0 ↔ Even n := (CharP.cast_eq_zero_iff (ZMod 2) 2 n).trans even_iff_two_dvd.symm #align zmod.eq_zero_iff_even ZMod.eq_zero_iff_even theorem eq_one_iff_odd {n : ℕ} : (n : ZMod 2) = 1 ↔ Odd n := by rw [← @Nat.cast_one (ZMod 2), ZMod.eq_iff_modEq_nat, Nat.odd_iff, Nat.ModEq] #align zmod.eq_one_iff_odd ZMod.eq_one_iff_odd
Mathlib/Data/ZMod/Parity.lean
32
35
theorem ne_zero_iff_odd {n : ℕ} : (n : ZMod 2) ≠ 0 ↔ Odd n := by
constructor <;> · contrapose simp [eq_zero_iff_even]
242
import Mathlib.Algebra.Order.Group.Basic import Mathlib.Algebra.Order.Ring.Abs import Mathlib.Algebra.Order.Ring.Basic import Mathlib.Algebra.Ring.Nat import Mathlib.Data.ZMod.Basic import Mathlib.GroupTheory.OrderOfElement import Mathlib.RingTheory.Fintype import Mathlib.Tactic.IntervalCases #align_import number_theory.lucas_lehmer from "leanprover-community/mathlib"@"10b4e499f43088dd3bb7b5796184ad5216648ab1" def mersenne (p : ℕ) : ℕ := 2 ^ p - 1 #align mersenne mersenne theorem strictMono_mersenne : StrictMono mersenne := fun m n h ↦ (Nat.sub_lt_sub_iff_right <| Nat.one_le_pow _ _ two_pos).2 <| by gcongr; norm_num1 @[simp] theorem mersenne_lt_mersenne {p q : ℕ} : mersenne p < mersenne q ↔ p < q := strictMono_mersenne.lt_iff_lt @[gcongr] protected alias ⟨_, GCongr.mersenne_lt_mersenne⟩ := mersenne_lt_mersenne @[simp] theorem mersenne_le_mersenne {p q : ℕ} : mersenne p ≤ mersenne q ↔ p ≤ q := strictMono_mersenne.le_iff_le @[gcongr] protected alias ⟨_, GCongr.mersenne_le_mersenne⟩ := mersenne_le_mersenne @[simp] theorem mersenne_zero : mersenne 0 = 0 := rfl @[simp] theorem mersenne_pos {p : ℕ} : 0 < mersenne p ↔ 0 < p := mersenne_lt_mersenne (p := 0) #align mersenne_pos mersenne_pos @[simp] theorem one_lt_mersenne {p : ℕ} : 1 < mersenne p ↔ 1 < p := mersenne_lt_mersenne (p := 1) @[simp]
Mathlib/NumberTheory/LucasLehmer.lean
93
95
theorem succ_mersenne (k : ℕ) : mersenne k + 1 = 2 ^ k := by
rw [mersenne, tsub_add_cancel_of_le] exact one_le_pow_of_one_le (by norm_num) k
243
import Mathlib.Algebra.Order.Group.Basic import Mathlib.Algebra.Order.Ring.Abs import Mathlib.Algebra.Order.Ring.Basic import Mathlib.Algebra.Ring.Nat import Mathlib.Data.ZMod.Basic import Mathlib.GroupTheory.OrderOfElement import Mathlib.RingTheory.Fintype import Mathlib.Tactic.IntervalCases #align_import number_theory.lucas_lehmer from "leanprover-community/mathlib"@"10b4e499f43088dd3bb7b5796184ad5216648ab1" def mersenne (p : ℕ) : ℕ := 2 ^ p - 1 #align mersenne mersenne theorem strictMono_mersenne : StrictMono mersenne := fun m n h ↦ (Nat.sub_lt_sub_iff_right <| Nat.one_le_pow _ _ two_pos).2 <| by gcongr; norm_num1 @[simp] theorem mersenne_lt_mersenne {p q : ℕ} : mersenne p < mersenne q ↔ p < q := strictMono_mersenne.lt_iff_lt @[gcongr] protected alias ⟨_, GCongr.mersenne_lt_mersenne⟩ := mersenne_lt_mersenne @[simp] theorem mersenne_le_mersenne {p q : ℕ} : mersenne p ≤ mersenne q ↔ p ≤ q := strictMono_mersenne.le_iff_le @[gcongr] protected alias ⟨_, GCongr.mersenne_le_mersenne⟩ := mersenne_le_mersenne @[simp] theorem mersenne_zero : mersenne 0 = 0 := rfl @[simp] theorem mersenne_pos {p : ℕ} : 0 < mersenne p ↔ 0 < p := mersenne_lt_mersenne (p := 0) #align mersenne_pos mersenne_pos @[simp] theorem one_lt_mersenne {p : ℕ} : 1 < mersenne p ↔ 1 < p := mersenne_lt_mersenne (p := 1) @[simp] theorem succ_mersenne (k : ℕ) : mersenne k + 1 = 2 ^ k := by rw [mersenne, tsub_add_cancel_of_le] exact one_le_pow_of_one_le (by norm_num) k #align succ_mersenne succ_mersenne namespace LucasLehmer open Nat def s : ℕ → ℤ | 0 => 4 | i + 1 => s i ^ 2 - 2 #align lucas_lehmer.s LucasLehmer.s def sZMod (p : ℕ) : ℕ → ZMod (2 ^ p - 1) | 0 => 4 | i + 1 => sZMod p i ^ 2 - 2 #align lucas_lehmer.s_zmod LucasLehmer.sZMod def sMod (p : ℕ) : ℕ → ℤ | 0 => 4 % (2 ^ p - 1) | i + 1 => (sMod p i ^ 2 - 2) % (2 ^ p - 1) #align lucas_lehmer.s_mod LucasLehmer.sMod theorem mersenne_int_pos {p : ℕ} (hp : p ≠ 0) : (0 : ℤ) < 2 ^ p - 1 := sub_pos.2 <| mod_cast Nat.one_lt_two_pow hp theorem mersenne_int_ne_zero (p : ℕ) (hp : p ≠ 0) : (2 ^ p - 1 : ℤ) ≠ 0 := (mersenne_int_pos hp).ne' #align lucas_lehmer.mersenne_int_ne_zero LucasLehmer.mersenne_int_ne_zero
Mathlib/NumberTheory/LucasLehmer.lean
138
142
theorem sMod_nonneg (p : ℕ) (hp : p ≠ 0) (i : ℕ) : 0 ≤ sMod p i := by
cases i <;> dsimp [sMod] · exact sup_eq_right.mp rfl · apply Int.emod_nonneg exact mersenne_int_ne_zero p hp
243
import Mathlib.Algebra.Order.Group.Basic import Mathlib.Algebra.Order.Ring.Abs import Mathlib.Algebra.Order.Ring.Basic import Mathlib.Algebra.Ring.Nat import Mathlib.Data.ZMod.Basic import Mathlib.GroupTheory.OrderOfElement import Mathlib.RingTheory.Fintype import Mathlib.Tactic.IntervalCases #align_import number_theory.lucas_lehmer from "leanprover-community/mathlib"@"10b4e499f43088dd3bb7b5796184ad5216648ab1" def mersenne (p : ℕ) : ℕ := 2 ^ p - 1 #align mersenne mersenne theorem strictMono_mersenne : StrictMono mersenne := fun m n h ↦ (Nat.sub_lt_sub_iff_right <| Nat.one_le_pow _ _ two_pos).2 <| by gcongr; norm_num1 @[simp] theorem mersenne_lt_mersenne {p q : ℕ} : mersenne p < mersenne q ↔ p < q := strictMono_mersenne.lt_iff_lt @[gcongr] protected alias ⟨_, GCongr.mersenne_lt_mersenne⟩ := mersenne_lt_mersenne @[simp] theorem mersenne_le_mersenne {p q : ℕ} : mersenne p ≤ mersenne q ↔ p ≤ q := strictMono_mersenne.le_iff_le @[gcongr] protected alias ⟨_, GCongr.mersenne_le_mersenne⟩ := mersenne_le_mersenne @[simp] theorem mersenne_zero : mersenne 0 = 0 := rfl @[simp] theorem mersenne_pos {p : ℕ} : 0 < mersenne p ↔ 0 < p := mersenne_lt_mersenne (p := 0) #align mersenne_pos mersenne_pos @[simp] theorem one_lt_mersenne {p : ℕ} : 1 < mersenne p ↔ 1 < p := mersenne_lt_mersenne (p := 1) @[simp] theorem succ_mersenne (k : ℕ) : mersenne k + 1 = 2 ^ k := by rw [mersenne, tsub_add_cancel_of_le] exact one_le_pow_of_one_le (by norm_num) k #align succ_mersenne succ_mersenne namespace LucasLehmer open Nat def s : ℕ → ℤ | 0 => 4 | i + 1 => s i ^ 2 - 2 #align lucas_lehmer.s LucasLehmer.s def sZMod (p : ℕ) : ℕ → ZMod (2 ^ p - 1) | 0 => 4 | i + 1 => sZMod p i ^ 2 - 2 #align lucas_lehmer.s_zmod LucasLehmer.sZMod def sMod (p : ℕ) : ℕ → ℤ | 0 => 4 % (2 ^ p - 1) | i + 1 => (sMod p i ^ 2 - 2) % (2 ^ p - 1) #align lucas_lehmer.s_mod LucasLehmer.sMod theorem mersenne_int_pos {p : ℕ} (hp : p ≠ 0) : (0 : ℤ) < 2 ^ p - 1 := sub_pos.2 <| mod_cast Nat.one_lt_two_pow hp theorem mersenne_int_ne_zero (p : ℕ) (hp : p ≠ 0) : (2 ^ p - 1 : ℤ) ≠ 0 := (mersenne_int_pos hp).ne' #align lucas_lehmer.mersenne_int_ne_zero LucasLehmer.mersenne_int_ne_zero theorem sMod_nonneg (p : ℕ) (hp : p ≠ 0) (i : ℕ) : 0 ≤ sMod p i := by cases i <;> dsimp [sMod] · exact sup_eq_right.mp rfl · apply Int.emod_nonneg exact mersenne_int_ne_zero p hp #align lucas_lehmer.s_mod_nonneg LucasLehmer.sMod_nonneg
Mathlib/NumberTheory/LucasLehmer.lean
145
145
theorem sMod_mod (p i : ℕ) : sMod p i % (2 ^ p - 1) = sMod p i := by
cases i <;> simp [sMod]
243
import Mathlib.Algebra.Order.Group.Basic import Mathlib.Algebra.Order.Ring.Abs import Mathlib.Algebra.Order.Ring.Basic import Mathlib.Algebra.Ring.Nat import Mathlib.Data.ZMod.Basic import Mathlib.GroupTheory.OrderOfElement import Mathlib.RingTheory.Fintype import Mathlib.Tactic.IntervalCases #align_import number_theory.lucas_lehmer from "leanprover-community/mathlib"@"10b4e499f43088dd3bb7b5796184ad5216648ab1" def mersenne (p : ℕ) : ℕ := 2 ^ p - 1 #align mersenne mersenne theorem strictMono_mersenne : StrictMono mersenne := fun m n h ↦ (Nat.sub_lt_sub_iff_right <| Nat.one_le_pow _ _ two_pos).2 <| by gcongr; norm_num1 @[simp] theorem mersenne_lt_mersenne {p q : ℕ} : mersenne p < mersenne q ↔ p < q := strictMono_mersenne.lt_iff_lt @[gcongr] protected alias ⟨_, GCongr.mersenne_lt_mersenne⟩ := mersenne_lt_mersenne @[simp] theorem mersenne_le_mersenne {p q : ℕ} : mersenne p ≤ mersenne q ↔ p ≤ q := strictMono_mersenne.le_iff_le @[gcongr] protected alias ⟨_, GCongr.mersenne_le_mersenne⟩ := mersenne_le_mersenne @[simp] theorem mersenne_zero : mersenne 0 = 0 := rfl @[simp] theorem mersenne_pos {p : ℕ} : 0 < mersenne p ↔ 0 < p := mersenne_lt_mersenne (p := 0) #align mersenne_pos mersenne_pos @[simp] theorem one_lt_mersenne {p : ℕ} : 1 < mersenne p ↔ 1 < p := mersenne_lt_mersenne (p := 1) @[simp] theorem succ_mersenne (k : ℕ) : mersenne k + 1 = 2 ^ k := by rw [mersenne, tsub_add_cancel_of_le] exact one_le_pow_of_one_le (by norm_num) k #align succ_mersenne succ_mersenne namespace LucasLehmer open Nat def s : ℕ → ℤ | 0 => 4 | i + 1 => s i ^ 2 - 2 #align lucas_lehmer.s LucasLehmer.s def sZMod (p : ℕ) : ℕ → ZMod (2 ^ p - 1) | 0 => 4 | i + 1 => sZMod p i ^ 2 - 2 #align lucas_lehmer.s_zmod LucasLehmer.sZMod def sMod (p : ℕ) : ℕ → ℤ | 0 => 4 % (2 ^ p - 1) | i + 1 => (sMod p i ^ 2 - 2) % (2 ^ p - 1) #align lucas_lehmer.s_mod LucasLehmer.sMod theorem mersenne_int_pos {p : ℕ} (hp : p ≠ 0) : (0 : ℤ) < 2 ^ p - 1 := sub_pos.2 <| mod_cast Nat.one_lt_two_pow hp theorem mersenne_int_ne_zero (p : ℕ) (hp : p ≠ 0) : (2 ^ p - 1 : ℤ) ≠ 0 := (mersenne_int_pos hp).ne' #align lucas_lehmer.mersenne_int_ne_zero LucasLehmer.mersenne_int_ne_zero theorem sMod_nonneg (p : ℕ) (hp : p ≠ 0) (i : ℕ) : 0 ≤ sMod p i := by cases i <;> dsimp [sMod] · exact sup_eq_right.mp rfl · apply Int.emod_nonneg exact mersenne_int_ne_zero p hp #align lucas_lehmer.s_mod_nonneg LucasLehmer.sMod_nonneg theorem sMod_mod (p i : ℕ) : sMod p i % (2 ^ p - 1) = sMod p i := by cases i <;> simp [sMod] #align lucas_lehmer.s_mod_mod LucasLehmer.sMod_mod
Mathlib/NumberTheory/LucasLehmer.lean
148
151
theorem sMod_lt (p : ℕ) (hp : p ≠ 0) (i : ℕ) : sMod p i < 2 ^ p - 1 := by
rw [← sMod_mod] refine (Int.emod_lt _ (mersenne_int_ne_zero p hp)).trans_eq ?_ exact abs_of_nonneg (mersenne_int_pos hp).le
243
import Mathlib.Algebra.Order.Group.Basic import Mathlib.Algebra.Order.Ring.Abs import Mathlib.Algebra.Order.Ring.Basic import Mathlib.Algebra.Ring.Nat import Mathlib.Data.ZMod.Basic import Mathlib.GroupTheory.OrderOfElement import Mathlib.RingTheory.Fintype import Mathlib.Tactic.IntervalCases #align_import number_theory.lucas_lehmer from "leanprover-community/mathlib"@"10b4e499f43088dd3bb7b5796184ad5216648ab1" def mersenne (p : ℕ) : ℕ := 2 ^ p - 1 #align mersenne mersenne theorem strictMono_mersenne : StrictMono mersenne := fun m n h ↦ (Nat.sub_lt_sub_iff_right <| Nat.one_le_pow _ _ two_pos).2 <| by gcongr; norm_num1 @[simp] theorem mersenne_lt_mersenne {p q : ℕ} : mersenne p < mersenne q ↔ p < q := strictMono_mersenne.lt_iff_lt @[gcongr] protected alias ⟨_, GCongr.mersenne_lt_mersenne⟩ := mersenne_lt_mersenne @[simp] theorem mersenne_le_mersenne {p q : ℕ} : mersenne p ≤ mersenne q ↔ p ≤ q := strictMono_mersenne.le_iff_le @[gcongr] protected alias ⟨_, GCongr.mersenne_le_mersenne⟩ := mersenne_le_mersenne @[simp] theorem mersenne_zero : mersenne 0 = 0 := rfl @[simp] theorem mersenne_pos {p : ℕ} : 0 < mersenne p ↔ 0 < p := mersenne_lt_mersenne (p := 0) #align mersenne_pos mersenne_pos @[simp] theorem one_lt_mersenne {p : ℕ} : 1 < mersenne p ↔ 1 < p := mersenne_lt_mersenne (p := 1) @[simp] theorem succ_mersenne (k : ℕ) : mersenne k + 1 = 2 ^ k := by rw [mersenne, tsub_add_cancel_of_le] exact one_le_pow_of_one_le (by norm_num) k #align succ_mersenne succ_mersenne namespace LucasLehmer open Nat def s : ℕ → ℤ | 0 => 4 | i + 1 => s i ^ 2 - 2 #align lucas_lehmer.s LucasLehmer.s def sZMod (p : ℕ) : ℕ → ZMod (2 ^ p - 1) | 0 => 4 | i + 1 => sZMod p i ^ 2 - 2 #align lucas_lehmer.s_zmod LucasLehmer.sZMod def sMod (p : ℕ) : ℕ → ℤ | 0 => 4 % (2 ^ p - 1) | i + 1 => (sMod p i ^ 2 - 2) % (2 ^ p - 1) #align lucas_lehmer.s_mod LucasLehmer.sMod theorem mersenne_int_pos {p : ℕ} (hp : p ≠ 0) : (0 : ℤ) < 2 ^ p - 1 := sub_pos.2 <| mod_cast Nat.one_lt_two_pow hp theorem mersenne_int_ne_zero (p : ℕ) (hp : p ≠ 0) : (2 ^ p - 1 : ℤ) ≠ 0 := (mersenne_int_pos hp).ne' #align lucas_lehmer.mersenne_int_ne_zero LucasLehmer.mersenne_int_ne_zero theorem sMod_nonneg (p : ℕ) (hp : p ≠ 0) (i : ℕ) : 0 ≤ sMod p i := by cases i <;> dsimp [sMod] · exact sup_eq_right.mp rfl · apply Int.emod_nonneg exact mersenne_int_ne_zero p hp #align lucas_lehmer.s_mod_nonneg LucasLehmer.sMod_nonneg theorem sMod_mod (p i : ℕ) : sMod p i % (2 ^ p - 1) = sMod p i := by cases i <;> simp [sMod] #align lucas_lehmer.s_mod_mod LucasLehmer.sMod_mod theorem sMod_lt (p : ℕ) (hp : p ≠ 0) (i : ℕ) : sMod p i < 2 ^ p - 1 := by rw [← sMod_mod] refine (Int.emod_lt _ (mersenne_int_ne_zero p hp)).trans_eq ?_ exact abs_of_nonneg (mersenne_int_pos hp).le #align lucas_lehmer.s_mod_lt LucasLehmer.sMod_lt
Mathlib/NumberTheory/LucasLehmer.lean
154
158
theorem sZMod_eq_s (p' : ℕ) (i : ℕ) : sZMod (p' + 2) i = (s i : ZMod (2 ^ (p' + 2) - 1)) := by
induction' i with i ih · dsimp [s, sZMod] norm_num · push_cast [s, sZMod, ih]; rfl
243
import Mathlib.Algebra.Order.Group.Basic import Mathlib.Algebra.Order.Ring.Abs import Mathlib.Algebra.Order.Ring.Basic import Mathlib.Algebra.Ring.Nat import Mathlib.Data.ZMod.Basic import Mathlib.GroupTheory.OrderOfElement import Mathlib.RingTheory.Fintype import Mathlib.Tactic.IntervalCases #align_import number_theory.lucas_lehmer from "leanprover-community/mathlib"@"10b4e499f43088dd3bb7b5796184ad5216648ab1" def mersenne (p : ℕ) : ℕ := 2 ^ p - 1 #align mersenne mersenne theorem strictMono_mersenne : StrictMono mersenne := fun m n h ↦ (Nat.sub_lt_sub_iff_right <| Nat.one_le_pow _ _ two_pos).2 <| by gcongr; norm_num1 @[simp] theorem mersenne_lt_mersenne {p q : ℕ} : mersenne p < mersenne q ↔ p < q := strictMono_mersenne.lt_iff_lt @[gcongr] protected alias ⟨_, GCongr.mersenne_lt_mersenne⟩ := mersenne_lt_mersenne @[simp] theorem mersenne_le_mersenne {p q : ℕ} : mersenne p ≤ mersenne q ↔ p ≤ q := strictMono_mersenne.le_iff_le @[gcongr] protected alias ⟨_, GCongr.mersenne_le_mersenne⟩ := mersenne_le_mersenne @[simp] theorem mersenne_zero : mersenne 0 = 0 := rfl @[simp] theorem mersenne_pos {p : ℕ} : 0 < mersenne p ↔ 0 < p := mersenne_lt_mersenne (p := 0) #align mersenne_pos mersenne_pos @[simp] theorem one_lt_mersenne {p : ℕ} : 1 < mersenne p ↔ 1 < p := mersenne_lt_mersenne (p := 1) @[simp] theorem succ_mersenne (k : ℕ) : mersenne k + 1 = 2 ^ k := by rw [mersenne, tsub_add_cancel_of_le] exact one_le_pow_of_one_le (by norm_num) k #align succ_mersenne succ_mersenne namespace LucasLehmer open Nat def s : ℕ → ℤ | 0 => 4 | i + 1 => s i ^ 2 - 2 #align lucas_lehmer.s LucasLehmer.s def sZMod (p : ℕ) : ℕ → ZMod (2 ^ p - 1) | 0 => 4 | i + 1 => sZMod p i ^ 2 - 2 #align lucas_lehmer.s_zmod LucasLehmer.sZMod def sMod (p : ℕ) : ℕ → ℤ | 0 => 4 % (2 ^ p - 1) | i + 1 => (sMod p i ^ 2 - 2) % (2 ^ p - 1) #align lucas_lehmer.s_mod LucasLehmer.sMod theorem mersenne_int_pos {p : ℕ} (hp : p ≠ 0) : (0 : ℤ) < 2 ^ p - 1 := sub_pos.2 <| mod_cast Nat.one_lt_two_pow hp theorem mersenne_int_ne_zero (p : ℕ) (hp : p ≠ 0) : (2 ^ p - 1 : ℤ) ≠ 0 := (mersenne_int_pos hp).ne' #align lucas_lehmer.mersenne_int_ne_zero LucasLehmer.mersenne_int_ne_zero theorem sMod_nonneg (p : ℕ) (hp : p ≠ 0) (i : ℕ) : 0 ≤ sMod p i := by cases i <;> dsimp [sMod] · exact sup_eq_right.mp rfl · apply Int.emod_nonneg exact mersenne_int_ne_zero p hp #align lucas_lehmer.s_mod_nonneg LucasLehmer.sMod_nonneg theorem sMod_mod (p i : ℕ) : sMod p i % (2 ^ p - 1) = sMod p i := by cases i <;> simp [sMod] #align lucas_lehmer.s_mod_mod LucasLehmer.sMod_mod theorem sMod_lt (p : ℕ) (hp : p ≠ 0) (i : ℕ) : sMod p i < 2 ^ p - 1 := by rw [← sMod_mod] refine (Int.emod_lt _ (mersenne_int_ne_zero p hp)).trans_eq ?_ exact abs_of_nonneg (mersenne_int_pos hp).le #align lucas_lehmer.s_mod_lt LucasLehmer.sMod_lt theorem sZMod_eq_s (p' : ℕ) (i : ℕ) : sZMod (p' + 2) i = (s i : ZMod (2 ^ (p' + 2) - 1)) := by induction' i with i ih · dsimp [s, sZMod] norm_num · push_cast [s, sZMod, ih]; rfl #align lucas_lehmer.s_zmod_eq_s LucasLehmer.sZMod_eq_s -- These next two don't make good `norm_cast` lemmas.
Mathlib/NumberTheory/LucasLehmer.lean
162
164
theorem Int.natCast_pow_pred (b p : ℕ) (w : 0 < b) : ((b ^ p - 1 : ℕ) : ℤ) = (b : ℤ) ^ p - 1 := by
have : 1 ≤ b ^ p := Nat.one_le_pow p b w norm_cast
243
import Mathlib.Algebra.Order.Group.Basic import Mathlib.Algebra.Order.Ring.Abs import Mathlib.Algebra.Order.Ring.Basic import Mathlib.Algebra.Ring.Nat import Mathlib.Data.ZMod.Basic import Mathlib.GroupTheory.OrderOfElement import Mathlib.RingTheory.Fintype import Mathlib.Tactic.IntervalCases #align_import number_theory.lucas_lehmer from "leanprover-community/mathlib"@"10b4e499f43088dd3bb7b5796184ad5216648ab1" def mersenne (p : ℕ) : ℕ := 2 ^ p - 1 #align mersenne mersenne theorem strictMono_mersenne : StrictMono mersenne := fun m n h ↦ (Nat.sub_lt_sub_iff_right <| Nat.one_le_pow _ _ two_pos).2 <| by gcongr; norm_num1 @[simp] theorem mersenne_lt_mersenne {p q : ℕ} : mersenne p < mersenne q ↔ p < q := strictMono_mersenne.lt_iff_lt @[gcongr] protected alias ⟨_, GCongr.mersenne_lt_mersenne⟩ := mersenne_lt_mersenne @[simp] theorem mersenne_le_mersenne {p q : ℕ} : mersenne p ≤ mersenne q ↔ p ≤ q := strictMono_mersenne.le_iff_le @[gcongr] protected alias ⟨_, GCongr.mersenne_le_mersenne⟩ := mersenne_le_mersenne @[simp] theorem mersenne_zero : mersenne 0 = 0 := rfl @[simp] theorem mersenne_pos {p : ℕ} : 0 < mersenne p ↔ 0 < p := mersenne_lt_mersenne (p := 0) #align mersenne_pos mersenne_pos @[simp] theorem one_lt_mersenne {p : ℕ} : 1 < mersenne p ↔ 1 < p := mersenne_lt_mersenne (p := 1) @[simp] theorem succ_mersenne (k : ℕ) : mersenne k + 1 = 2 ^ k := by rw [mersenne, tsub_add_cancel_of_le] exact one_le_pow_of_one_le (by norm_num) k #align succ_mersenne succ_mersenne namespace LucasLehmer open Nat def s : ℕ → ℤ | 0 => 4 | i + 1 => s i ^ 2 - 2 #align lucas_lehmer.s LucasLehmer.s def sZMod (p : ℕ) : ℕ → ZMod (2 ^ p - 1) | 0 => 4 | i + 1 => sZMod p i ^ 2 - 2 #align lucas_lehmer.s_zmod LucasLehmer.sZMod def sMod (p : ℕ) : ℕ → ℤ | 0 => 4 % (2 ^ p - 1) | i + 1 => (sMod p i ^ 2 - 2) % (2 ^ p - 1) #align lucas_lehmer.s_mod LucasLehmer.sMod theorem mersenne_int_pos {p : ℕ} (hp : p ≠ 0) : (0 : ℤ) < 2 ^ p - 1 := sub_pos.2 <| mod_cast Nat.one_lt_two_pow hp theorem mersenne_int_ne_zero (p : ℕ) (hp : p ≠ 0) : (2 ^ p - 1 : ℤ) ≠ 0 := (mersenne_int_pos hp).ne' #align lucas_lehmer.mersenne_int_ne_zero LucasLehmer.mersenne_int_ne_zero theorem sMod_nonneg (p : ℕ) (hp : p ≠ 0) (i : ℕ) : 0 ≤ sMod p i := by cases i <;> dsimp [sMod] · exact sup_eq_right.mp rfl · apply Int.emod_nonneg exact mersenne_int_ne_zero p hp #align lucas_lehmer.s_mod_nonneg LucasLehmer.sMod_nonneg theorem sMod_mod (p i : ℕ) : sMod p i % (2 ^ p - 1) = sMod p i := by cases i <;> simp [sMod] #align lucas_lehmer.s_mod_mod LucasLehmer.sMod_mod theorem sMod_lt (p : ℕ) (hp : p ≠ 0) (i : ℕ) : sMod p i < 2 ^ p - 1 := by rw [← sMod_mod] refine (Int.emod_lt _ (mersenne_int_ne_zero p hp)).trans_eq ?_ exact abs_of_nonneg (mersenne_int_pos hp).le #align lucas_lehmer.s_mod_lt LucasLehmer.sMod_lt theorem sZMod_eq_s (p' : ℕ) (i : ℕ) : sZMod (p' + 2) i = (s i : ZMod (2 ^ (p' + 2) - 1)) := by induction' i with i ih · dsimp [s, sZMod] norm_num · push_cast [s, sZMod, ih]; rfl #align lucas_lehmer.s_zmod_eq_s LucasLehmer.sZMod_eq_s -- These next two don't make good `norm_cast` lemmas. theorem Int.natCast_pow_pred (b p : ℕ) (w : 0 < b) : ((b ^ p - 1 : ℕ) : ℤ) = (b : ℤ) ^ p - 1 := by have : 1 ≤ b ^ p := Nat.one_le_pow p b w norm_cast #align lucas_lehmer.int.coe_nat_pow_pred LucasLehmer.Int.natCast_pow_pred @[deprecated (since := "2024-05-25")] alias Int.coe_nat_pow_pred := Int.natCast_pow_pred theorem Int.coe_nat_two_pow_pred (p : ℕ) : ((2 ^ p - 1 : ℕ) : ℤ) = (2 ^ p - 1 : ℤ) := Int.natCast_pow_pred 2 p (by decide) #align lucas_lehmer.int.coe_nat_two_pow_pred LucasLehmer.Int.coe_nat_two_pow_pred
Mathlib/NumberTheory/LucasLehmer.lean
173
174
theorem sZMod_eq_sMod (p : ℕ) (i : ℕ) : sZMod p i = (sMod p i : ZMod (2 ^ p - 1)) := by
induction i <;> push_cast [← Int.coe_nat_two_pow_pred p, sMod, sZMod, *] <;> rfl
243
import Mathlib.Data.ZMod.Basic import Mathlib.GroupTheory.Coxeter.Basic namespace CoxeterSystem open List Matrix Function Classical variable {B : Type*} variable {W : Type*} [Group W] variable {M : CoxeterMatrix B} (cs : CoxeterSystem M W) local prefix:100 "s" => cs.simple local prefix:100 "π" => cs.wordProd private theorem exists_word_with_prod (w : W) : ∃ n ω, ω.length = n ∧ π ω = w := by rcases cs.wordProd_surjective w with ⟨ω, rfl⟩ use ω.length, ω noncomputable def length (w : W) : ℕ := Nat.find (cs.exists_word_with_prod w) local prefix:100 "ℓ" => cs.length
Mathlib/GroupTheory/Coxeter/Length.lean
71
73
theorem exists_reduced_word (w : W) : ∃ ω, ω.length = ℓ w ∧ w = π ω := by
have := Nat.find_spec (cs.exists_word_with_prod w) tauto
244
import Mathlib.Data.ZMod.Basic import Mathlib.GroupTheory.Coxeter.Basic namespace CoxeterSystem open List Matrix Function Classical variable {B : Type*} variable {W : Type*} [Group W] variable {M : CoxeterMatrix B} (cs : CoxeterSystem M W) local prefix:100 "s" => cs.simple local prefix:100 "π" => cs.wordProd private theorem exists_word_with_prod (w : W) : ∃ n ω, ω.length = n ∧ π ω = w := by rcases cs.wordProd_surjective w with ⟨ω, rfl⟩ use ω.length, ω noncomputable def length (w : W) : ℕ := Nat.find (cs.exists_word_with_prod w) local prefix:100 "ℓ" => cs.length theorem exists_reduced_word (w : W) : ∃ ω, ω.length = ℓ w ∧ w = π ω := by have := Nat.find_spec (cs.exists_word_with_prod w) tauto theorem length_wordProd_le (ω : List B) : ℓ (π ω) ≤ ω.length := Nat.find_min' (cs.exists_word_with_prod (π ω)) ⟨ω, by tauto⟩ @[simp] theorem length_one : ℓ (1 : W) = 0 := Nat.eq_zero_of_le_zero (cs.length_wordProd_le []) @[simp]
Mathlib/GroupTheory/Coxeter/Length.lean
81
88
theorem length_eq_zero_iff {w : W} : ℓ w = 0 ↔ w = 1 := by
constructor · intro h rcases cs.exists_reduced_word w with ⟨ω, hω, rfl⟩ have : ω = [] := eq_nil_of_length_eq_zero (hω.trans h) rw [this, wordProd_nil] · rintro rfl exact cs.length_one
244
import Mathlib.Data.ZMod.Basic import Mathlib.GroupTheory.Coxeter.Basic namespace CoxeterSystem open List Matrix Function Classical variable {B : Type*} variable {W : Type*} [Group W] variable {M : CoxeterMatrix B} (cs : CoxeterSystem M W) local prefix:100 "s" => cs.simple local prefix:100 "π" => cs.wordProd private theorem exists_word_with_prod (w : W) : ∃ n ω, ω.length = n ∧ π ω = w := by rcases cs.wordProd_surjective w with ⟨ω, rfl⟩ use ω.length, ω noncomputable def length (w : W) : ℕ := Nat.find (cs.exists_word_with_prod w) local prefix:100 "ℓ" => cs.length theorem exists_reduced_word (w : W) : ∃ ω, ω.length = ℓ w ∧ w = π ω := by have := Nat.find_spec (cs.exists_word_with_prod w) tauto theorem length_wordProd_le (ω : List B) : ℓ (π ω) ≤ ω.length := Nat.find_min' (cs.exists_word_with_prod (π ω)) ⟨ω, by tauto⟩ @[simp] theorem length_one : ℓ (1 : W) = 0 := Nat.eq_zero_of_le_zero (cs.length_wordProd_le []) @[simp] theorem length_eq_zero_iff {w : W} : ℓ w = 0 ↔ w = 1 := by constructor · intro h rcases cs.exists_reduced_word w with ⟨ω, hω, rfl⟩ have : ω = [] := eq_nil_of_length_eq_zero (hω.trans h) rw [this, wordProd_nil] · rintro rfl exact cs.length_one @[simp]
Mathlib/GroupTheory/Coxeter/Length.lean
91
98
theorem length_inv (w : W) : ℓ (w⁻¹) = ℓ w := by
apply Nat.le_antisymm · rcases cs.exists_reduced_word w with ⟨ω, hω, rfl⟩ have := cs.length_wordProd_le (List.reverse ω) rwa [wordProd_reverse, length_reverse, hω] at this · rcases cs.exists_reduced_word w⁻¹ with ⟨ω, hω, h'ω⟩ have := cs.length_wordProd_le (List.reverse ω) rwa [wordProd_reverse, length_reverse, ← h'ω, hω, inv_inv] at this
244
import Mathlib.Data.ZMod.Basic import Mathlib.GroupTheory.Coxeter.Basic namespace CoxeterSystem open List Matrix Function Classical variable {B : Type*} variable {W : Type*} [Group W] variable {M : CoxeterMatrix B} (cs : CoxeterSystem M W) local prefix:100 "s" => cs.simple local prefix:100 "π" => cs.wordProd private theorem exists_word_with_prod (w : W) : ∃ n ω, ω.length = n ∧ π ω = w := by rcases cs.wordProd_surjective w with ⟨ω, rfl⟩ use ω.length, ω noncomputable def length (w : W) : ℕ := Nat.find (cs.exists_word_with_prod w) local prefix:100 "ℓ" => cs.length theorem exists_reduced_word (w : W) : ∃ ω, ω.length = ℓ w ∧ w = π ω := by have := Nat.find_spec (cs.exists_word_with_prod w) tauto theorem length_wordProd_le (ω : List B) : ℓ (π ω) ≤ ω.length := Nat.find_min' (cs.exists_word_with_prod (π ω)) ⟨ω, by tauto⟩ @[simp] theorem length_one : ℓ (1 : W) = 0 := Nat.eq_zero_of_le_zero (cs.length_wordProd_le []) @[simp] theorem length_eq_zero_iff {w : W} : ℓ w = 0 ↔ w = 1 := by constructor · intro h rcases cs.exists_reduced_word w with ⟨ω, hω, rfl⟩ have : ω = [] := eq_nil_of_length_eq_zero (hω.trans h) rw [this, wordProd_nil] · rintro rfl exact cs.length_one @[simp] theorem length_inv (w : W) : ℓ (w⁻¹) = ℓ w := by apply Nat.le_antisymm · rcases cs.exists_reduced_word w with ⟨ω, hω, rfl⟩ have := cs.length_wordProd_le (List.reverse ω) rwa [wordProd_reverse, length_reverse, hω] at this · rcases cs.exists_reduced_word w⁻¹ with ⟨ω, hω, h'ω⟩ have := cs.length_wordProd_le (List.reverse ω) rwa [wordProd_reverse, length_reverse, ← h'ω, hω, inv_inv] at this
Mathlib/GroupTheory/Coxeter/Length.lean
100
105
theorem length_mul_le (w₁ w₂ : W) : ℓ (w₁ * w₂) ≤ ℓ w₁ + ℓ w₂ := by
rcases cs.exists_reduced_word w₁ with ⟨ω₁, hω₁, rfl⟩ rcases cs.exists_reduced_word w₂ with ⟨ω₂, hω₂, rfl⟩ have := cs.length_wordProd_le (ω₁ ++ ω₂) simpa [hω₁, hω₂, wordProd_append] using this
244
import Mathlib.Data.ZMod.Basic import Mathlib.GroupTheory.Coxeter.Basic namespace CoxeterSystem open List Matrix Function Classical variable {B : Type*} variable {W : Type*} [Group W] variable {M : CoxeterMatrix B} (cs : CoxeterSystem M W) local prefix:100 "s" => cs.simple local prefix:100 "π" => cs.wordProd private theorem exists_word_with_prod (w : W) : ∃ n ω, ω.length = n ∧ π ω = w := by rcases cs.wordProd_surjective w with ⟨ω, rfl⟩ use ω.length, ω noncomputable def length (w : W) : ℕ := Nat.find (cs.exists_word_with_prod w) local prefix:100 "ℓ" => cs.length theorem exists_reduced_word (w : W) : ∃ ω, ω.length = ℓ w ∧ w = π ω := by have := Nat.find_spec (cs.exists_word_with_prod w) tauto theorem length_wordProd_le (ω : List B) : ℓ (π ω) ≤ ω.length := Nat.find_min' (cs.exists_word_with_prod (π ω)) ⟨ω, by tauto⟩ @[simp] theorem length_one : ℓ (1 : W) = 0 := Nat.eq_zero_of_le_zero (cs.length_wordProd_le []) @[simp] theorem length_eq_zero_iff {w : W} : ℓ w = 0 ↔ w = 1 := by constructor · intro h rcases cs.exists_reduced_word w with ⟨ω, hω, rfl⟩ have : ω = [] := eq_nil_of_length_eq_zero (hω.trans h) rw [this, wordProd_nil] · rintro rfl exact cs.length_one @[simp] theorem length_inv (w : W) : ℓ (w⁻¹) = ℓ w := by apply Nat.le_antisymm · rcases cs.exists_reduced_word w with ⟨ω, hω, rfl⟩ have := cs.length_wordProd_le (List.reverse ω) rwa [wordProd_reverse, length_reverse, hω] at this · rcases cs.exists_reduced_word w⁻¹ with ⟨ω, hω, h'ω⟩ have := cs.length_wordProd_le (List.reverse ω) rwa [wordProd_reverse, length_reverse, ← h'ω, hω, inv_inv] at this theorem length_mul_le (w₁ w₂ : W) : ℓ (w₁ * w₂) ≤ ℓ w₁ + ℓ w₂ := by rcases cs.exists_reduced_word w₁ with ⟨ω₁, hω₁, rfl⟩ rcases cs.exists_reduced_word w₂ with ⟨ω₂, hω₂, rfl⟩ have := cs.length_wordProd_le (ω₁ ++ ω₂) simpa [hω₁, hω₂, wordProd_append] using this
Mathlib/GroupTheory/Coxeter/Length.lean
107
109
theorem length_mul_ge_length_sub_length (w₁ w₂ : W) : ℓ w₁ - ℓ w₂ ≤ ℓ (w₁ * w₂) := by
simpa [Nat.sub_le_of_le_add] using cs.length_mul_le (w₁ * w₂) w₂⁻¹
244
import Mathlib.Data.ZMod.Basic import Mathlib.GroupTheory.Coxeter.Basic namespace CoxeterSystem open List Matrix Function Classical variable {B : Type*} variable {W : Type*} [Group W] variable {M : CoxeterMatrix B} (cs : CoxeterSystem M W) local prefix:100 "s" => cs.simple local prefix:100 "π" => cs.wordProd private theorem exists_word_with_prod (w : W) : ∃ n ω, ω.length = n ∧ π ω = w := by rcases cs.wordProd_surjective w with ⟨ω, rfl⟩ use ω.length, ω noncomputable def length (w : W) : ℕ := Nat.find (cs.exists_word_with_prod w) local prefix:100 "ℓ" => cs.length theorem exists_reduced_word (w : W) : ∃ ω, ω.length = ℓ w ∧ w = π ω := by have := Nat.find_spec (cs.exists_word_with_prod w) tauto theorem length_wordProd_le (ω : List B) : ℓ (π ω) ≤ ω.length := Nat.find_min' (cs.exists_word_with_prod (π ω)) ⟨ω, by tauto⟩ @[simp] theorem length_one : ℓ (1 : W) = 0 := Nat.eq_zero_of_le_zero (cs.length_wordProd_le []) @[simp] theorem length_eq_zero_iff {w : W} : ℓ w = 0 ↔ w = 1 := by constructor · intro h rcases cs.exists_reduced_word w with ⟨ω, hω, rfl⟩ have : ω = [] := eq_nil_of_length_eq_zero (hω.trans h) rw [this, wordProd_nil] · rintro rfl exact cs.length_one @[simp] theorem length_inv (w : W) : ℓ (w⁻¹) = ℓ w := by apply Nat.le_antisymm · rcases cs.exists_reduced_word w with ⟨ω, hω, rfl⟩ have := cs.length_wordProd_le (List.reverse ω) rwa [wordProd_reverse, length_reverse, hω] at this · rcases cs.exists_reduced_word w⁻¹ with ⟨ω, hω, h'ω⟩ have := cs.length_wordProd_le (List.reverse ω) rwa [wordProd_reverse, length_reverse, ← h'ω, hω, inv_inv] at this theorem length_mul_le (w₁ w₂ : W) : ℓ (w₁ * w₂) ≤ ℓ w₁ + ℓ w₂ := by rcases cs.exists_reduced_word w₁ with ⟨ω₁, hω₁, rfl⟩ rcases cs.exists_reduced_word w₂ with ⟨ω₂, hω₂, rfl⟩ have := cs.length_wordProd_le (ω₁ ++ ω₂) simpa [hω₁, hω₂, wordProd_append] using this theorem length_mul_ge_length_sub_length (w₁ w₂ : W) : ℓ w₁ - ℓ w₂ ≤ ℓ (w₁ * w₂) := by simpa [Nat.sub_le_of_le_add] using cs.length_mul_le (w₁ * w₂) w₂⁻¹
Mathlib/GroupTheory/Coxeter/Length.lean
111
113
theorem length_mul_ge_length_sub_length' (w₁ w₂ : W) : ℓ w₂ - ℓ w₁ ≤ ℓ (w₁ * w₂) := by
simpa [Nat.sub_le_of_le_add, add_comm] using cs.length_mul_le w₁⁻¹ (w₁ * w₂)
244
import Mathlib.Data.ZMod.Basic import Mathlib.GroupTheory.Coxeter.Basic namespace CoxeterSystem open List Matrix Function Classical variable {B : Type*} variable {W : Type*} [Group W] variable {M : CoxeterMatrix B} (cs : CoxeterSystem M W) local prefix:100 "s" => cs.simple local prefix:100 "π" => cs.wordProd private theorem exists_word_with_prod (w : W) : ∃ n ω, ω.length = n ∧ π ω = w := by rcases cs.wordProd_surjective w with ⟨ω, rfl⟩ use ω.length, ω noncomputable def length (w : W) : ℕ := Nat.find (cs.exists_word_with_prod w) local prefix:100 "ℓ" => cs.length theorem exists_reduced_word (w : W) : ∃ ω, ω.length = ℓ w ∧ w = π ω := by have := Nat.find_spec (cs.exists_word_with_prod w) tauto theorem length_wordProd_le (ω : List B) : ℓ (π ω) ≤ ω.length := Nat.find_min' (cs.exists_word_with_prod (π ω)) ⟨ω, by tauto⟩ @[simp] theorem length_one : ℓ (1 : W) = 0 := Nat.eq_zero_of_le_zero (cs.length_wordProd_le []) @[simp] theorem length_eq_zero_iff {w : W} : ℓ w = 0 ↔ w = 1 := by constructor · intro h rcases cs.exists_reduced_word w with ⟨ω, hω, rfl⟩ have : ω = [] := eq_nil_of_length_eq_zero (hω.trans h) rw [this, wordProd_nil] · rintro rfl exact cs.length_one @[simp] theorem length_inv (w : W) : ℓ (w⁻¹) = ℓ w := by apply Nat.le_antisymm · rcases cs.exists_reduced_word w with ⟨ω, hω, rfl⟩ have := cs.length_wordProd_le (List.reverse ω) rwa [wordProd_reverse, length_reverse, hω] at this · rcases cs.exists_reduced_word w⁻¹ with ⟨ω, hω, h'ω⟩ have := cs.length_wordProd_le (List.reverse ω) rwa [wordProd_reverse, length_reverse, ← h'ω, hω, inv_inv] at this theorem length_mul_le (w₁ w₂ : W) : ℓ (w₁ * w₂) ≤ ℓ w₁ + ℓ w₂ := by rcases cs.exists_reduced_word w₁ with ⟨ω₁, hω₁, rfl⟩ rcases cs.exists_reduced_word w₂ with ⟨ω₂, hω₂, rfl⟩ have := cs.length_wordProd_le (ω₁ ++ ω₂) simpa [hω₁, hω₂, wordProd_append] using this theorem length_mul_ge_length_sub_length (w₁ w₂ : W) : ℓ w₁ - ℓ w₂ ≤ ℓ (w₁ * w₂) := by simpa [Nat.sub_le_of_le_add] using cs.length_mul_le (w₁ * w₂) w₂⁻¹ theorem length_mul_ge_length_sub_length' (w₁ w₂ : W) : ℓ w₂ - ℓ w₁ ≤ ℓ (w₁ * w₂) := by simpa [Nat.sub_le_of_le_add, add_comm] using cs.length_mul_le w₁⁻¹ (w₁ * w₂) theorem length_mul_ge_max (w₁ w₂ : W) : max (ℓ w₁ - ℓ w₂) (ℓ w₂ - ℓ w₁) ≤ ℓ (w₁ * w₂) := max_le_iff.mpr ⟨length_mul_ge_length_sub_length _ _ _, length_mul_ge_length_sub_length' _ _ _⟩ def lengthParity : W →* Multiplicative (ZMod 2) := cs.lift ⟨fun _ ↦ Multiplicative.ofAdd 1, by simp_rw [CoxeterMatrix.IsLiftable, ← ofAdd_add, (by decide : (1 + 1 : ZMod 2) = 0)] simp⟩ theorem lengthParity_simple (i : B): cs.lengthParity (s i) = Multiplicative.ofAdd 1 := cs.lift_apply_simple _ _ theorem lengthParity_comp_simple : cs.lengthParity ∘ cs.simple = fun _ ↦ Multiplicative.ofAdd 1 := funext cs.lengthParity_simple
Mathlib/GroupTheory/Coxeter/Length.lean
131
135
theorem lengthParity_eq_ofAdd_length (w : W) : cs.lengthParity w = Multiplicative.ofAdd (↑(ℓ w)) := by
rcases cs.exists_reduced_word w with ⟨ω, hω, rfl⟩ rw [← hω, wordProd, map_list_prod, List.map_map, lengthParity_comp_simple, map_const', prod_replicate, ← ofAdd_nsmul, nsmul_one]
244
import Mathlib.Data.ZMod.Basic import Mathlib.GroupTheory.Coxeter.Basic namespace CoxeterSystem open List Matrix Function Classical variable {B : Type*} variable {W : Type*} [Group W] variable {M : CoxeterMatrix B} (cs : CoxeterSystem M W) local prefix:100 "s" => cs.simple local prefix:100 "π" => cs.wordProd private theorem exists_word_with_prod (w : W) : ∃ n ω, ω.length = n ∧ π ω = w := by rcases cs.wordProd_surjective w with ⟨ω, rfl⟩ use ω.length, ω noncomputable def length (w : W) : ℕ := Nat.find (cs.exists_word_with_prod w) local prefix:100 "ℓ" => cs.length theorem exists_reduced_word (w : W) : ∃ ω, ω.length = ℓ w ∧ w = π ω := by have := Nat.find_spec (cs.exists_word_with_prod w) tauto theorem length_wordProd_le (ω : List B) : ℓ (π ω) ≤ ω.length := Nat.find_min' (cs.exists_word_with_prod (π ω)) ⟨ω, by tauto⟩ @[simp] theorem length_one : ℓ (1 : W) = 0 := Nat.eq_zero_of_le_zero (cs.length_wordProd_le []) @[simp] theorem length_eq_zero_iff {w : W} : ℓ w = 0 ↔ w = 1 := by constructor · intro h rcases cs.exists_reduced_word w with ⟨ω, hω, rfl⟩ have : ω = [] := eq_nil_of_length_eq_zero (hω.trans h) rw [this, wordProd_nil] · rintro rfl exact cs.length_one @[simp] theorem length_inv (w : W) : ℓ (w⁻¹) = ℓ w := by apply Nat.le_antisymm · rcases cs.exists_reduced_word w with ⟨ω, hω, rfl⟩ have := cs.length_wordProd_le (List.reverse ω) rwa [wordProd_reverse, length_reverse, hω] at this · rcases cs.exists_reduced_word w⁻¹ with ⟨ω, hω, h'ω⟩ have := cs.length_wordProd_le (List.reverse ω) rwa [wordProd_reverse, length_reverse, ← h'ω, hω, inv_inv] at this theorem length_mul_le (w₁ w₂ : W) : ℓ (w₁ * w₂) ≤ ℓ w₁ + ℓ w₂ := by rcases cs.exists_reduced_word w₁ with ⟨ω₁, hω₁, rfl⟩ rcases cs.exists_reduced_word w₂ with ⟨ω₂, hω₂, rfl⟩ have := cs.length_wordProd_le (ω₁ ++ ω₂) simpa [hω₁, hω₂, wordProd_append] using this theorem length_mul_ge_length_sub_length (w₁ w₂ : W) : ℓ w₁ - ℓ w₂ ≤ ℓ (w₁ * w₂) := by simpa [Nat.sub_le_of_le_add] using cs.length_mul_le (w₁ * w₂) w₂⁻¹ theorem length_mul_ge_length_sub_length' (w₁ w₂ : W) : ℓ w₂ - ℓ w₁ ≤ ℓ (w₁ * w₂) := by simpa [Nat.sub_le_of_le_add, add_comm] using cs.length_mul_le w₁⁻¹ (w₁ * w₂) theorem length_mul_ge_max (w₁ w₂ : W) : max (ℓ w₁ - ℓ w₂) (ℓ w₂ - ℓ w₁) ≤ ℓ (w₁ * w₂) := max_le_iff.mpr ⟨length_mul_ge_length_sub_length _ _ _, length_mul_ge_length_sub_length' _ _ _⟩ def lengthParity : W →* Multiplicative (ZMod 2) := cs.lift ⟨fun _ ↦ Multiplicative.ofAdd 1, by simp_rw [CoxeterMatrix.IsLiftable, ← ofAdd_add, (by decide : (1 + 1 : ZMod 2) = 0)] simp⟩ theorem lengthParity_simple (i : B): cs.lengthParity (s i) = Multiplicative.ofAdd 1 := cs.lift_apply_simple _ _ theorem lengthParity_comp_simple : cs.lengthParity ∘ cs.simple = fun _ ↦ Multiplicative.ofAdd 1 := funext cs.lengthParity_simple theorem lengthParity_eq_ofAdd_length (w : W) : cs.lengthParity w = Multiplicative.ofAdd (↑(ℓ w)) := by rcases cs.exists_reduced_word w with ⟨ω, hω, rfl⟩ rw [← hω, wordProd, map_list_prod, List.map_map, lengthParity_comp_simple, map_const', prod_replicate, ← ofAdd_nsmul, nsmul_one]
Mathlib/GroupTheory/Coxeter/Length.lean
137
139
theorem length_mul_mod_two (w₁ w₂ : W) : ℓ (w₁ * w₂) % 2 = (ℓ w₁ + ℓ w₂) % 2 := by
rw [← ZMod.natCast_eq_natCast_iff', Nat.cast_add] simpa only [lengthParity_eq_ofAdd_length, ofAdd_add] using map_mul cs.lengthParity w₁ w₂
244
import Mathlib.Data.ZMod.Basic import Mathlib.GroupTheory.Coxeter.Basic namespace CoxeterSystem open List Matrix Function Classical variable {B : Type*} variable {W : Type*} [Group W] variable {M : CoxeterMatrix B} (cs : CoxeterSystem M W) local prefix:100 "s" => cs.simple local prefix:100 "π" => cs.wordProd private theorem exists_word_with_prod (w : W) : ∃ n ω, ω.length = n ∧ π ω = w := by rcases cs.wordProd_surjective w with ⟨ω, rfl⟩ use ω.length, ω noncomputable def length (w : W) : ℕ := Nat.find (cs.exists_word_with_prod w) local prefix:100 "ℓ" => cs.length theorem exists_reduced_word (w : W) : ∃ ω, ω.length = ℓ w ∧ w = π ω := by have := Nat.find_spec (cs.exists_word_with_prod w) tauto theorem length_wordProd_le (ω : List B) : ℓ (π ω) ≤ ω.length := Nat.find_min' (cs.exists_word_with_prod (π ω)) ⟨ω, by tauto⟩ @[simp] theorem length_one : ℓ (1 : W) = 0 := Nat.eq_zero_of_le_zero (cs.length_wordProd_le []) @[simp] theorem length_eq_zero_iff {w : W} : ℓ w = 0 ↔ w = 1 := by constructor · intro h rcases cs.exists_reduced_word w with ⟨ω, hω, rfl⟩ have : ω = [] := eq_nil_of_length_eq_zero (hω.trans h) rw [this, wordProd_nil] · rintro rfl exact cs.length_one @[simp] theorem length_inv (w : W) : ℓ (w⁻¹) = ℓ w := by apply Nat.le_antisymm · rcases cs.exists_reduced_word w with ⟨ω, hω, rfl⟩ have := cs.length_wordProd_le (List.reverse ω) rwa [wordProd_reverse, length_reverse, hω] at this · rcases cs.exists_reduced_word w⁻¹ with ⟨ω, hω, h'ω⟩ have := cs.length_wordProd_le (List.reverse ω) rwa [wordProd_reverse, length_reverse, ← h'ω, hω, inv_inv] at this theorem length_mul_le (w₁ w₂ : W) : ℓ (w₁ * w₂) ≤ ℓ w₁ + ℓ w₂ := by rcases cs.exists_reduced_word w₁ with ⟨ω₁, hω₁, rfl⟩ rcases cs.exists_reduced_word w₂ with ⟨ω₂, hω₂, rfl⟩ have := cs.length_wordProd_le (ω₁ ++ ω₂) simpa [hω₁, hω₂, wordProd_append] using this theorem length_mul_ge_length_sub_length (w₁ w₂ : W) : ℓ w₁ - ℓ w₂ ≤ ℓ (w₁ * w₂) := by simpa [Nat.sub_le_of_le_add] using cs.length_mul_le (w₁ * w₂) w₂⁻¹ theorem length_mul_ge_length_sub_length' (w₁ w₂ : W) : ℓ w₂ - ℓ w₁ ≤ ℓ (w₁ * w₂) := by simpa [Nat.sub_le_of_le_add, add_comm] using cs.length_mul_le w₁⁻¹ (w₁ * w₂) theorem length_mul_ge_max (w₁ w₂ : W) : max (ℓ w₁ - ℓ w₂) (ℓ w₂ - ℓ w₁) ≤ ℓ (w₁ * w₂) := max_le_iff.mpr ⟨length_mul_ge_length_sub_length _ _ _, length_mul_ge_length_sub_length' _ _ _⟩ def lengthParity : W →* Multiplicative (ZMod 2) := cs.lift ⟨fun _ ↦ Multiplicative.ofAdd 1, by simp_rw [CoxeterMatrix.IsLiftable, ← ofAdd_add, (by decide : (1 + 1 : ZMod 2) = 0)] simp⟩ theorem lengthParity_simple (i : B): cs.lengthParity (s i) = Multiplicative.ofAdd 1 := cs.lift_apply_simple _ _ theorem lengthParity_comp_simple : cs.lengthParity ∘ cs.simple = fun _ ↦ Multiplicative.ofAdd 1 := funext cs.lengthParity_simple theorem lengthParity_eq_ofAdd_length (w : W) : cs.lengthParity w = Multiplicative.ofAdd (↑(ℓ w)) := by rcases cs.exists_reduced_word w with ⟨ω, hω, rfl⟩ rw [← hω, wordProd, map_list_prod, List.map_map, lengthParity_comp_simple, map_const', prod_replicate, ← ofAdd_nsmul, nsmul_one] theorem length_mul_mod_two (w₁ w₂ : W) : ℓ (w₁ * w₂) % 2 = (ℓ w₁ + ℓ w₂) % 2 := by rw [← ZMod.natCast_eq_natCast_iff', Nat.cast_add] simpa only [lengthParity_eq_ofAdd_length, ofAdd_add] using map_mul cs.lengthParity w₁ w₂ @[simp]
Mathlib/GroupTheory/Coxeter/Length.lean
142
150
theorem length_simple (i : B) : ℓ (s i) = 1 := by
apply Nat.le_antisymm · simpa using cs.length_wordProd_le [i] · by_contra! length_lt_one have : cs.lengthParity (s i) = Multiplicative.ofAdd 0 := by rw [lengthParity_eq_ofAdd_length, Nat.lt_one_iff.mp length_lt_one, Nat.cast_zero] have : Multiplicative.ofAdd (0 : ZMod 2) = Multiplicative.ofAdd 1 := this.symm.trans (cs.lengthParity_simple i) contradiction
244
import Mathlib.Data.ZMod.Basic import Mathlib.GroupTheory.Coxeter.Basic namespace CoxeterSystem open List Matrix Function Classical variable {B : Type*} variable {W : Type*} [Group W] variable {M : CoxeterMatrix B} (cs : CoxeterSystem M W) local prefix:100 "s" => cs.simple local prefix:100 "π" => cs.wordProd private theorem exists_word_with_prod (w : W) : ∃ n ω, ω.length = n ∧ π ω = w := by rcases cs.wordProd_surjective w with ⟨ω, rfl⟩ use ω.length, ω noncomputable def length (w : W) : ℕ := Nat.find (cs.exists_word_with_prod w) local prefix:100 "ℓ" => cs.length theorem exists_reduced_word (w : W) : ∃ ω, ω.length = ℓ w ∧ w = π ω := by have := Nat.find_spec (cs.exists_word_with_prod w) tauto theorem length_wordProd_le (ω : List B) : ℓ (π ω) ≤ ω.length := Nat.find_min' (cs.exists_word_with_prod (π ω)) ⟨ω, by tauto⟩ @[simp] theorem length_one : ℓ (1 : W) = 0 := Nat.eq_zero_of_le_zero (cs.length_wordProd_le []) @[simp] theorem length_eq_zero_iff {w : W} : ℓ w = 0 ↔ w = 1 := by constructor · intro h rcases cs.exists_reduced_word w with ⟨ω, hω, rfl⟩ have : ω = [] := eq_nil_of_length_eq_zero (hω.trans h) rw [this, wordProd_nil] · rintro rfl exact cs.length_one @[simp] theorem length_inv (w : W) : ℓ (w⁻¹) = ℓ w := by apply Nat.le_antisymm · rcases cs.exists_reduced_word w with ⟨ω, hω, rfl⟩ have := cs.length_wordProd_le (List.reverse ω) rwa [wordProd_reverse, length_reverse, hω] at this · rcases cs.exists_reduced_word w⁻¹ with ⟨ω, hω, h'ω⟩ have := cs.length_wordProd_le (List.reverse ω) rwa [wordProd_reverse, length_reverse, ← h'ω, hω, inv_inv] at this theorem length_mul_le (w₁ w₂ : W) : ℓ (w₁ * w₂) ≤ ℓ w₁ + ℓ w₂ := by rcases cs.exists_reduced_word w₁ with ⟨ω₁, hω₁, rfl⟩ rcases cs.exists_reduced_word w₂ with ⟨ω₂, hω₂, rfl⟩ have := cs.length_wordProd_le (ω₁ ++ ω₂) simpa [hω₁, hω₂, wordProd_append] using this theorem length_mul_ge_length_sub_length (w₁ w₂ : W) : ℓ w₁ - ℓ w₂ ≤ ℓ (w₁ * w₂) := by simpa [Nat.sub_le_of_le_add] using cs.length_mul_le (w₁ * w₂) w₂⁻¹ theorem length_mul_ge_length_sub_length' (w₁ w₂ : W) : ℓ w₂ - ℓ w₁ ≤ ℓ (w₁ * w₂) := by simpa [Nat.sub_le_of_le_add, add_comm] using cs.length_mul_le w₁⁻¹ (w₁ * w₂) theorem length_mul_ge_max (w₁ w₂ : W) : max (ℓ w₁ - ℓ w₂) (ℓ w₂ - ℓ w₁) ≤ ℓ (w₁ * w₂) := max_le_iff.mpr ⟨length_mul_ge_length_sub_length _ _ _, length_mul_ge_length_sub_length' _ _ _⟩ def lengthParity : W →* Multiplicative (ZMod 2) := cs.lift ⟨fun _ ↦ Multiplicative.ofAdd 1, by simp_rw [CoxeterMatrix.IsLiftable, ← ofAdd_add, (by decide : (1 + 1 : ZMod 2) = 0)] simp⟩ theorem lengthParity_simple (i : B): cs.lengthParity (s i) = Multiplicative.ofAdd 1 := cs.lift_apply_simple _ _ theorem lengthParity_comp_simple : cs.lengthParity ∘ cs.simple = fun _ ↦ Multiplicative.ofAdd 1 := funext cs.lengthParity_simple theorem lengthParity_eq_ofAdd_length (w : W) : cs.lengthParity w = Multiplicative.ofAdd (↑(ℓ w)) := by rcases cs.exists_reduced_word w with ⟨ω, hω, rfl⟩ rw [← hω, wordProd, map_list_prod, List.map_map, lengthParity_comp_simple, map_const', prod_replicate, ← ofAdd_nsmul, nsmul_one] theorem length_mul_mod_two (w₁ w₂ : W) : ℓ (w₁ * w₂) % 2 = (ℓ w₁ + ℓ w₂) % 2 := by rw [← ZMod.natCast_eq_natCast_iff', Nat.cast_add] simpa only [lengthParity_eq_ofAdd_length, ofAdd_add] using map_mul cs.lengthParity w₁ w₂ @[simp] theorem length_simple (i : B) : ℓ (s i) = 1 := by apply Nat.le_antisymm · simpa using cs.length_wordProd_le [i] · by_contra! length_lt_one have : cs.lengthParity (s i) = Multiplicative.ofAdd 0 := by rw [lengthParity_eq_ofAdd_length, Nat.lt_one_iff.mp length_lt_one, Nat.cast_zero] have : Multiplicative.ofAdd (0 : ZMod 2) = Multiplicative.ofAdd 1 := this.symm.trans (cs.lengthParity_simple i) contradiction
Mathlib/GroupTheory/Coxeter/Length.lean
152
159
theorem length_eq_one_iff {w : W} : ℓ w = 1 ↔ ∃ i : B, w = s i := by
constructor · intro h rcases cs.exists_reduced_word w with ⟨ω, hω, rfl⟩ rcases List.length_eq_one.mp (hω.trans h) with ⟨i, rfl⟩ exact ⟨i, cs.wordProd_singleton i⟩ · rintro ⟨i, rfl⟩ exact cs.length_simple i
244
import Mathlib.Data.ZMod.Basic import Mathlib.GroupTheory.Coxeter.Basic namespace CoxeterSystem open List Matrix Function Classical variable {B : Type*} variable {W : Type*} [Group W] variable {M : CoxeterMatrix B} (cs : CoxeterSystem M W) local prefix:100 "s" => cs.simple local prefix:100 "π" => cs.wordProd private theorem exists_word_with_prod (w : W) : ∃ n ω, ω.length = n ∧ π ω = w := by rcases cs.wordProd_surjective w with ⟨ω, rfl⟩ use ω.length, ω noncomputable def length (w : W) : ℕ := Nat.find (cs.exists_word_with_prod w) local prefix:100 "ℓ" => cs.length theorem exists_reduced_word (w : W) : ∃ ω, ω.length = ℓ w ∧ w = π ω := by have := Nat.find_spec (cs.exists_word_with_prod w) tauto theorem length_wordProd_le (ω : List B) : ℓ (π ω) ≤ ω.length := Nat.find_min' (cs.exists_word_with_prod (π ω)) ⟨ω, by tauto⟩ @[simp] theorem length_one : ℓ (1 : W) = 0 := Nat.eq_zero_of_le_zero (cs.length_wordProd_le []) @[simp] theorem length_eq_zero_iff {w : W} : ℓ w = 0 ↔ w = 1 := by constructor · intro h rcases cs.exists_reduced_word w with ⟨ω, hω, rfl⟩ have : ω = [] := eq_nil_of_length_eq_zero (hω.trans h) rw [this, wordProd_nil] · rintro rfl exact cs.length_one @[simp] theorem length_inv (w : W) : ℓ (w⁻¹) = ℓ w := by apply Nat.le_antisymm · rcases cs.exists_reduced_word w with ⟨ω, hω, rfl⟩ have := cs.length_wordProd_le (List.reverse ω) rwa [wordProd_reverse, length_reverse, hω] at this · rcases cs.exists_reduced_word w⁻¹ with ⟨ω, hω, h'ω⟩ have := cs.length_wordProd_le (List.reverse ω) rwa [wordProd_reverse, length_reverse, ← h'ω, hω, inv_inv] at this theorem length_mul_le (w₁ w₂ : W) : ℓ (w₁ * w₂) ≤ ℓ w₁ + ℓ w₂ := by rcases cs.exists_reduced_word w₁ with ⟨ω₁, hω₁, rfl⟩ rcases cs.exists_reduced_word w₂ with ⟨ω₂, hω₂, rfl⟩ have := cs.length_wordProd_le (ω₁ ++ ω₂) simpa [hω₁, hω₂, wordProd_append] using this theorem length_mul_ge_length_sub_length (w₁ w₂ : W) : ℓ w₁ - ℓ w₂ ≤ ℓ (w₁ * w₂) := by simpa [Nat.sub_le_of_le_add] using cs.length_mul_le (w₁ * w₂) w₂⁻¹ theorem length_mul_ge_length_sub_length' (w₁ w₂ : W) : ℓ w₂ - ℓ w₁ ≤ ℓ (w₁ * w₂) := by simpa [Nat.sub_le_of_le_add, add_comm] using cs.length_mul_le w₁⁻¹ (w₁ * w₂) theorem length_mul_ge_max (w₁ w₂ : W) : max (ℓ w₁ - ℓ w₂) (ℓ w₂ - ℓ w₁) ≤ ℓ (w₁ * w₂) := max_le_iff.mpr ⟨length_mul_ge_length_sub_length _ _ _, length_mul_ge_length_sub_length' _ _ _⟩ def lengthParity : W →* Multiplicative (ZMod 2) := cs.lift ⟨fun _ ↦ Multiplicative.ofAdd 1, by simp_rw [CoxeterMatrix.IsLiftable, ← ofAdd_add, (by decide : (1 + 1 : ZMod 2) = 0)] simp⟩ theorem lengthParity_simple (i : B): cs.lengthParity (s i) = Multiplicative.ofAdd 1 := cs.lift_apply_simple _ _ theorem lengthParity_comp_simple : cs.lengthParity ∘ cs.simple = fun _ ↦ Multiplicative.ofAdd 1 := funext cs.lengthParity_simple theorem lengthParity_eq_ofAdd_length (w : W) : cs.lengthParity w = Multiplicative.ofAdd (↑(ℓ w)) := by rcases cs.exists_reduced_word w with ⟨ω, hω, rfl⟩ rw [← hω, wordProd, map_list_prod, List.map_map, lengthParity_comp_simple, map_const', prod_replicate, ← ofAdd_nsmul, nsmul_one] theorem length_mul_mod_two (w₁ w₂ : W) : ℓ (w₁ * w₂) % 2 = (ℓ w₁ + ℓ w₂) % 2 := by rw [← ZMod.natCast_eq_natCast_iff', Nat.cast_add] simpa only [lengthParity_eq_ofAdd_length, ofAdd_add] using map_mul cs.lengthParity w₁ w₂ @[simp] theorem length_simple (i : B) : ℓ (s i) = 1 := by apply Nat.le_antisymm · simpa using cs.length_wordProd_le [i] · by_contra! length_lt_one have : cs.lengthParity (s i) = Multiplicative.ofAdd 0 := by rw [lengthParity_eq_ofAdd_length, Nat.lt_one_iff.mp length_lt_one, Nat.cast_zero] have : Multiplicative.ofAdd (0 : ZMod 2) = Multiplicative.ofAdd 1 := this.symm.trans (cs.lengthParity_simple i) contradiction theorem length_eq_one_iff {w : W} : ℓ w = 1 ↔ ∃ i : B, w = s i := by constructor · intro h rcases cs.exists_reduced_word w with ⟨ω, hω, rfl⟩ rcases List.length_eq_one.mp (hω.trans h) with ⟨i, rfl⟩ exact ⟨i, cs.wordProd_singleton i⟩ · rintro ⟨i, rfl⟩ exact cs.length_simple i
Mathlib/GroupTheory/Coxeter/Length.lean
161
169
theorem length_mul_simple_ne (w : W) (i : B) : ℓ (w * s i) ≠ ℓ w := by
intro eq have length_mod_two := cs.length_mul_mod_two w (s i) rw [eq, length_simple] at length_mod_two rcases Nat.mod_two_eq_zero_or_one (ℓ w) with even | odd · rw [even, Nat.succ_mod_two_eq_one_iff.mpr even] at length_mod_two contradiction · rw [odd, Nat.succ_mod_two_eq_zero_iff.mpr odd] at length_mod_two contradiction
244
import Mathlib.GroupTheory.Coxeter.Length import Mathlib.Data.ZMod.Parity namespace CoxeterSystem open List Matrix Function variable {B : Type*} variable {W : Type*} [Group W] variable {M : CoxeterMatrix B} (cs : CoxeterSystem M W) local prefix:100 "s" => cs.simple local prefix:100 "π" => cs.wordProd local prefix:100 "ℓ" => cs.length def IsReflection (t : W) : Prop := ∃ w i, t = w * s i * w⁻¹
Mathlib/GroupTheory/Coxeter/Inversion.lean
61
61
theorem isReflection_simple (i : B) : cs.IsReflection (s i) := by
use 1, i; simp
245
import Mathlib.GroupTheory.Coxeter.Length import Mathlib.Data.ZMod.Parity namespace CoxeterSystem open List Matrix Function variable {B : Type*} variable {W : Type*} [Group W] variable {M : CoxeterMatrix B} (cs : CoxeterSystem M W) local prefix:100 "s" => cs.simple local prefix:100 "π" => cs.wordProd local prefix:100 "ℓ" => cs.length def IsReflection (t : W) : Prop := ∃ w i, t = w * s i * w⁻¹ theorem isReflection_simple (i : B) : cs.IsReflection (s i) := by use 1, i; simp namespace IsReflection variable {cs} variable {t : W} (ht : cs.IsReflection t)
Mathlib/GroupTheory/Coxeter/Inversion.lean
68
70
theorem pow_two : t ^ 2 = 1 := by
rcases ht with ⟨w, i, rfl⟩ simp
245
import Mathlib.GroupTheory.Coxeter.Length import Mathlib.Data.ZMod.Parity namespace CoxeterSystem open List Matrix Function variable {B : Type*} variable {W : Type*} [Group W] variable {M : CoxeterMatrix B} (cs : CoxeterSystem M W) local prefix:100 "s" => cs.simple local prefix:100 "π" => cs.wordProd local prefix:100 "ℓ" => cs.length def IsReflection (t : W) : Prop := ∃ w i, t = w * s i * w⁻¹ theorem isReflection_simple (i : B) : cs.IsReflection (s i) := by use 1, i; simp namespace IsReflection variable {cs} variable {t : W} (ht : cs.IsReflection t) theorem pow_two : t ^ 2 = 1 := by rcases ht with ⟨w, i, rfl⟩ simp
Mathlib/GroupTheory/Coxeter/Inversion.lean
72
74
theorem mul_self : t * t = 1 := by
rcases ht with ⟨w, i, rfl⟩ simp
245
import Mathlib.GroupTheory.Coxeter.Length import Mathlib.Data.ZMod.Parity namespace CoxeterSystem open List Matrix Function variable {B : Type*} variable {W : Type*} [Group W] variable {M : CoxeterMatrix B} (cs : CoxeterSystem M W) local prefix:100 "s" => cs.simple local prefix:100 "π" => cs.wordProd local prefix:100 "ℓ" => cs.length def IsReflection (t : W) : Prop := ∃ w i, t = w * s i * w⁻¹ theorem isReflection_simple (i : B) : cs.IsReflection (s i) := by use 1, i; simp namespace IsReflection variable {cs} variable {t : W} (ht : cs.IsReflection t) theorem pow_two : t ^ 2 = 1 := by rcases ht with ⟨w, i, rfl⟩ simp theorem mul_self : t * t = 1 := by rcases ht with ⟨w, i, rfl⟩ simp
Mathlib/GroupTheory/Coxeter/Inversion.lean
76
78
theorem inv : t⁻¹ = t := by
rcases ht with ⟨w, i, rfl⟩ simp [mul_assoc]
245
import Mathlib.GroupTheory.Coxeter.Length import Mathlib.Data.ZMod.Parity namespace CoxeterSystem open List Matrix Function variable {B : Type*} variable {W : Type*} [Group W] variable {M : CoxeterMatrix B} (cs : CoxeterSystem M W) local prefix:100 "s" => cs.simple local prefix:100 "π" => cs.wordProd local prefix:100 "ℓ" => cs.length def IsReflection (t : W) : Prop := ∃ w i, t = w * s i * w⁻¹ theorem isReflection_simple (i : B) : cs.IsReflection (s i) := by use 1, i; simp namespace IsReflection variable {cs} variable {t : W} (ht : cs.IsReflection t) theorem pow_two : t ^ 2 = 1 := by rcases ht with ⟨w, i, rfl⟩ simp theorem mul_self : t * t = 1 := by rcases ht with ⟨w, i, rfl⟩ simp theorem inv : t⁻¹ = t := by rcases ht with ⟨w, i, rfl⟩ simp [mul_assoc]
Mathlib/GroupTheory/Coxeter/Inversion.lean
80
80
theorem isReflection_inv : cs.IsReflection t⁻¹ := by
rwa [ht.inv]
245
import Mathlib.GroupTheory.Coxeter.Length import Mathlib.Data.ZMod.Parity namespace CoxeterSystem open List Matrix Function variable {B : Type*} variable {W : Type*} [Group W] variable {M : CoxeterMatrix B} (cs : CoxeterSystem M W) local prefix:100 "s" => cs.simple local prefix:100 "π" => cs.wordProd local prefix:100 "ℓ" => cs.length def IsReflection (t : W) : Prop := ∃ w i, t = w * s i * w⁻¹ theorem isReflection_simple (i : B) : cs.IsReflection (s i) := by use 1, i; simp namespace IsReflection variable {cs} variable {t : W} (ht : cs.IsReflection t) theorem pow_two : t ^ 2 = 1 := by rcases ht with ⟨w, i, rfl⟩ simp theorem mul_self : t * t = 1 := by rcases ht with ⟨w, i, rfl⟩ simp theorem inv : t⁻¹ = t := by rcases ht with ⟨w, i, rfl⟩ simp [mul_assoc] theorem isReflection_inv : cs.IsReflection t⁻¹ := by rwa [ht.inv]
Mathlib/GroupTheory/Coxeter/Inversion.lean
82
86
theorem odd_length : Odd (ℓ t) := by
suffices cs.lengthParity t = Multiplicative.ofAdd 1 by simpa [lengthParity_eq_ofAdd_length, ZMod.eq_one_iff_odd] rcases ht with ⟨w, i, rfl⟩ simp [lengthParity_simple]
245
import Mathlib.GroupTheory.Coxeter.Length import Mathlib.Data.ZMod.Parity namespace CoxeterSystem open List Matrix Function variable {B : Type*} variable {W : Type*} [Group W] variable {M : CoxeterMatrix B} (cs : CoxeterSystem M W) local prefix:100 "s" => cs.simple local prefix:100 "π" => cs.wordProd local prefix:100 "ℓ" => cs.length def IsReflection (t : W) : Prop := ∃ w i, t = w * s i * w⁻¹ theorem isReflection_simple (i : B) : cs.IsReflection (s i) := by use 1, i; simp namespace IsReflection variable {cs} variable {t : W} (ht : cs.IsReflection t) theorem pow_two : t ^ 2 = 1 := by rcases ht with ⟨w, i, rfl⟩ simp theorem mul_self : t * t = 1 := by rcases ht with ⟨w, i, rfl⟩ simp theorem inv : t⁻¹ = t := by rcases ht with ⟨w, i, rfl⟩ simp [mul_assoc] theorem isReflection_inv : cs.IsReflection t⁻¹ := by rwa [ht.inv] theorem odd_length : Odd (ℓ t) := by suffices cs.lengthParity t = Multiplicative.ofAdd 1 by simpa [lengthParity_eq_ofAdd_length, ZMod.eq_one_iff_odd] rcases ht with ⟨w, i, rfl⟩ simp [lengthParity_simple]
Mathlib/GroupTheory/Coxeter/Inversion.lean
88
93
theorem length_mul_left_ne (w : W) : ℓ (w * t) ≠ ℓ w := by
suffices cs.lengthParity (w * t) ≠ cs.lengthParity w by contrapose! this simp only [lengthParity_eq_ofAdd_length, this] rcases ht with ⟨w, i, rfl⟩ simp [lengthParity_simple]
245
import Mathlib.GroupTheory.Coxeter.Length import Mathlib.Data.ZMod.Parity namespace CoxeterSystem open List Matrix Function variable {B : Type*} variable {W : Type*} [Group W] variable {M : CoxeterMatrix B} (cs : CoxeterSystem M W) local prefix:100 "s" => cs.simple local prefix:100 "π" => cs.wordProd local prefix:100 "ℓ" => cs.length def IsReflection (t : W) : Prop := ∃ w i, t = w * s i * w⁻¹ theorem isReflection_simple (i : B) : cs.IsReflection (s i) := by use 1, i; simp namespace IsReflection variable {cs} variable {t : W} (ht : cs.IsReflection t) theorem pow_two : t ^ 2 = 1 := by rcases ht with ⟨w, i, rfl⟩ simp theorem mul_self : t * t = 1 := by rcases ht with ⟨w, i, rfl⟩ simp theorem inv : t⁻¹ = t := by rcases ht with ⟨w, i, rfl⟩ simp [mul_assoc] theorem isReflection_inv : cs.IsReflection t⁻¹ := by rwa [ht.inv] theorem odd_length : Odd (ℓ t) := by suffices cs.lengthParity t = Multiplicative.ofAdd 1 by simpa [lengthParity_eq_ofAdd_length, ZMod.eq_one_iff_odd] rcases ht with ⟨w, i, rfl⟩ simp [lengthParity_simple] theorem length_mul_left_ne (w : W) : ℓ (w * t) ≠ ℓ w := by suffices cs.lengthParity (w * t) ≠ cs.lengthParity w by contrapose! this simp only [lengthParity_eq_ofAdd_length, this] rcases ht with ⟨w, i, rfl⟩ simp [lengthParity_simple]
Mathlib/GroupTheory/Coxeter/Inversion.lean
95
100
theorem length_mul_right_ne (w : W) : ℓ (t * w) ≠ ℓ w := by
suffices cs.lengthParity (t * w) ≠ cs.lengthParity w by contrapose! this simp only [lengthParity_eq_ofAdd_length, this] rcases ht with ⟨w, i, rfl⟩ simp [lengthParity_simple]
245
import Mathlib.GroupTheory.Coxeter.Length import Mathlib.Data.ZMod.Parity namespace CoxeterSystem open List Matrix Function variable {B : Type*} variable {W : Type*} [Group W] variable {M : CoxeterMatrix B} (cs : CoxeterSystem M W) local prefix:100 "s" => cs.simple local prefix:100 "π" => cs.wordProd local prefix:100 "ℓ" => cs.length def IsReflection (t : W) : Prop := ∃ w i, t = w * s i * w⁻¹ theorem isReflection_simple (i : B) : cs.IsReflection (s i) := by use 1, i; simp namespace IsReflection variable {cs} variable {t : W} (ht : cs.IsReflection t) theorem pow_two : t ^ 2 = 1 := by rcases ht with ⟨w, i, rfl⟩ simp theorem mul_self : t * t = 1 := by rcases ht with ⟨w, i, rfl⟩ simp theorem inv : t⁻¹ = t := by rcases ht with ⟨w, i, rfl⟩ simp [mul_assoc] theorem isReflection_inv : cs.IsReflection t⁻¹ := by rwa [ht.inv] theorem odd_length : Odd (ℓ t) := by suffices cs.lengthParity t = Multiplicative.ofAdd 1 by simpa [lengthParity_eq_ofAdd_length, ZMod.eq_one_iff_odd] rcases ht with ⟨w, i, rfl⟩ simp [lengthParity_simple] theorem length_mul_left_ne (w : W) : ℓ (w * t) ≠ ℓ w := by suffices cs.lengthParity (w * t) ≠ cs.lengthParity w by contrapose! this simp only [lengthParity_eq_ofAdd_length, this] rcases ht with ⟨w, i, rfl⟩ simp [lengthParity_simple] theorem length_mul_right_ne (w : W) : ℓ (t * w) ≠ ℓ w := by suffices cs.lengthParity (t * w) ≠ cs.lengthParity w by contrapose! this simp only [lengthParity_eq_ofAdd_length, this] rcases ht with ⟨w, i, rfl⟩ simp [lengthParity_simple]
Mathlib/GroupTheory/Coxeter/Inversion.lean
102
105
theorem conj (w : W) : cs.IsReflection (w * t * w⁻¹) := by
obtain ⟨u, i, rfl⟩ := ht use w * u, i group
245
import Mathlib.LinearAlgebra.CliffordAlgebra.Basic import Mathlib.Data.ZMod.Basic import Mathlib.RingTheory.GradedAlgebra.Basic #align_import linear_algebra.clifford_algebra.grading from "leanprover-community/mathlib"@"34020e531ebc4e8aac6d449d9eecbcd1508ea8d0" namespace CliffordAlgebra variable {R M : Type*} [CommRing R] [AddCommGroup M] [Module R M] variable {Q : QuadraticForm R M} open scoped DirectSum variable (Q) def evenOdd (i : ZMod 2) : Submodule R (CliffordAlgebra Q) := ⨆ j : { n : ℕ // ↑n = i }, LinearMap.range (ι Q) ^ (j : ℕ) #align clifford_algebra.even_odd CliffordAlgebra.evenOdd
Mathlib/LinearAlgebra/CliffordAlgebra/Grading.lean
35
37
theorem one_le_evenOdd_zero : 1 ≤ evenOdd Q 0 := by
refine le_trans ?_ (le_iSup _ ⟨0, Nat.cast_zero⟩) exact (pow_zero _).ge
246
import Mathlib.LinearAlgebra.CliffordAlgebra.Basic import Mathlib.Data.ZMod.Basic import Mathlib.RingTheory.GradedAlgebra.Basic #align_import linear_algebra.clifford_algebra.grading from "leanprover-community/mathlib"@"34020e531ebc4e8aac6d449d9eecbcd1508ea8d0" namespace CliffordAlgebra variable {R M : Type*} [CommRing R] [AddCommGroup M] [Module R M] variable {Q : QuadraticForm R M} open scoped DirectSum variable (Q) def evenOdd (i : ZMod 2) : Submodule R (CliffordAlgebra Q) := ⨆ j : { n : ℕ // ↑n = i }, LinearMap.range (ι Q) ^ (j : ℕ) #align clifford_algebra.even_odd CliffordAlgebra.evenOdd theorem one_le_evenOdd_zero : 1 ≤ evenOdd Q 0 := by refine le_trans ?_ (le_iSup _ ⟨0, Nat.cast_zero⟩) exact (pow_zero _).ge #align clifford_algebra.one_le_even_odd_zero CliffordAlgebra.one_le_evenOdd_zero
Mathlib/LinearAlgebra/CliffordAlgebra/Grading.lean
40
42
theorem range_ι_le_evenOdd_one : LinearMap.range (ι Q) ≤ evenOdd Q 1 := by
refine le_trans ?_ (le_iSup _ ⟨1, Nat.cast_one⟩) exact (pow_one _).ge
246
import Mathlib.LinearAlgebra.CliffordAlgebra.Basic import Mathlib.Data.ZMod.Basic import Mathlib.RingTheory.GradedAlgebra.Basic #align_import linear_algebra.clifford_algebra.grading from "leanprover-community/mathlib"@"34020e531ebc4e8aac6d449d9eecbcd1508ea8d0" namespace CliffordAlgebra variable {R M : Type*} [CommRing R] [AddCommGroup M] [Module R M] variable {Q : QuadraticForm R M} open scoped DirectSum variable (Q) def evenOdd (i : ZMod 2) : Submodule R (CliffordAlgebra Q) := ⨆ j : { n : ℕ // ↑n = i }, LinearMap.range (ι Q) ^ (j : ℕ) #align clifford_algebra.even_odd CliffordAlgebra.evenOdd theorem one_le_evenOdd_zero : 1 ≤ evenOdd Q 0 := by refine le_trans ?_ (le_iSup _ ⟨0, Nat.cast_zero⟩) exact (pow_zero _).ge #align clifford_algebra.one_le_even_odd_zero CliffordAlgebra.one_le_evenOdd_zero theorem range_ι_le_evenOdd_one : LinearMap.range (ι Q) ≤ evenOdd Q 1 := by refine le_trans ?_ (le_iSup _ ⟨1, Nat.cast_one⟩) exact (pow_one _).ge #align clifford_algebra.range_ι_le_even_odd_one CliffordAlgebra.range_ι_le_evenOdd_one theorem ι_mem_evenOdd_one (m : M) : ι Q m ∈ evenOdd Q 1 := range_ι_le_evenOdd_one Q <| LinearMap.mem_range_self _ m #align clifford_algebra.ι_mem_even_odd_one CliffordAlgebra.ι_mem_evenOdd_one theorem ι_mul_ι_mem_evenOdd_zero (m₁ m₂ : M) : ι Q m₁ * ι Q m₂ ∈ evenOdd Q 0 := Submodule.mem_iSup_of_mem ⟨2, rfl⟩ (by rw [Subtype.coe_mk, pow_two] exact Submodule.mul_mem_mul (LinearMap.mem_range_self (ι Q) m₁) (LinearMap.mem_range_self (ι Q) m₂)) #align clifford_algebra.ι_mul_ι_mem_even_odd_zero CliffordAlgebra.ι_mul_ι_mem_evenOdd_zero
Mathlib/LinearAlgebra/CliffordAlgebra/Grading.lean
58
65
theorem evenOdd_mul_le (i j : ZMod 2) : evenOdd Q i * evenOdd Q j ≤ evenOdd Q (i + j) := by
simp_rw [evenOdd, Submodule.iSup_eq_span, Submodule.span_mul_span] apply Submodule.span_mono simp_rw [Set.iUnion_mul, Set.mul_iUnion, Set.iUnion_subset_iff, Set.mul_subset_iff] rintro ⟨xi, rfl⟩ ⟨yi, rfl⟩ x hx y hy refine Set.mem_iUnion.mpr ⟨⟨xi + yi, Nat.cast_add _ _⟩, ?_⟩ simp only [Subtype.coe_mk, Nat.cast_add, pow_add] exact Submodule.mul_mem_mul hx hy
246
import Mathlib.LinearAlgebra.CliffordAlgebra.Basic import Mathlib.Data.ZMod.Basic import Mathlib.RingTheory.GradedAlgebra.Basic #align_import linear_algebra.clifford_algebra.grading from "leanprover-community/mathlib"@"34020e531ebc4e8aac6d449d9eecbcd1508ea8d0" namespace CliffordAlgebra variable {R M : Type*} [CommRing R] [AddCommGroup M] [Module R M] variable {Q : QuadraticForm R M} open scoped DirectSum variable (Q) def evenOdd (i : ZMod 2) : Submodule R (CliffordAlgebra Q) := ⨆ j : { n : ℕ // ↑n = i }, LinearMap.range (ι Q) ^ (j : ℕ) #align clifford_algebra.even_odd CliffordAlgebra.evenOdd theorem one_le_evenOdd_zero : 1 ≤ evenOdd Q 0 := by refine le_trans ?_ (le_iSup _ ⟨0, Nat.cast_zero⟩) exact (pow_zero _).ge #align clifford_algebra.one_le_even_odd_zero CliffordAlgebra.one_le_evenOdd_zero theorem range_ι_le_evenOdd_one : LinearMap.range (ι Q) ≤ evenOdd Q 1 := by refine le_trans ?_ (le_iSup _ ⟨1, Nat.cast_one⟩) exact (pow_one _).ge #align clifford_algebra.range_ι_le_even_odd_one CliffordAlgebra.range_ι_le_evenOdd_one theorem ι_mem_evenOdd_one (m : M) : ι Q m ∈ evenOdd Q 1 := range_ι_le_evenOdd_one Q <| LinearMap.mem_range_self _ m #align clifford_algebra.ι_mem_even_odd_one CliffordAlgebra.ι_mem_evenOdd_one theorem ι_mul_ι_mem_evenOdd_zero (m₁ m₂ : M) : ι Q m₁ * ι Q m₂ ∈ evenOdd Q 0 := Submodule.mem_iSup_of_mem ⟨2, rfl⟩ (by rw [Subtype.coe_mk, pow_two] exact Submodule.mul_mem_mul (LinearMap.mem_range_self (ι Q) m₁) (LinearMap.mem_range_self (ι Q) m₂)) #align clifford_algebra.ι_mul_ι_mem_even_odd_zero CliffordAlgebra.ι_mul_ι_mem_evenOdd_zero theorem evenOdd_mul_le (i j : ZMod 2) : evenOdd Q i * evenOdd Q j ≤ evenOdd Q (i + j) := by simp_rw [evenOdd, Submodule.iSup_eq_span, Submodule.span_mul_span] apply Submodule.span_mono simp_rw [Set.iUnion_mul, Set.mul_iUnion, Set.iUnion_subset_iff, Set.mul_subset_iff] rintro ⟨xi, rfl⟩ ⟨yi, rfl⟩ x hx y hy refine Set.mem_iUnion.mpr ⟨⟨xi + yi, Nat.cast_add _ _⟩, ?_⟩ simp only [Subtype.coe_mk, Nat.cast_add, pow_add] exact Submodule.mul_mem_mul hx hy #align clifford_algebra.even_odd_mul_le CliffordAlgebra.evenOdd_mul_le instance evenOdd.gradedMonoid : SetLike.GradedMonoid (evenOdd Q) where one_mem := Submodule.one_le.mp (one_le_evenOdd_zero Q) mul_mem _i _j _p _q hp hq := Submodule.mul_le.mp (evenOdd_mul_le Q _ _) _ hp _ hq #align clifford_algebra.even_odd.graded_monoid CliffordAlgebra.evenOdd.gradedMonoid -- Porting note: added `protected` protected def GradedAlgebra.ι : M →ₗ[R] ⨁ i : ZMod 2, evenOdd Q i := DirectSum.lof R (ZMod 2) (fun i => ↥(evenOdd Q i)) 1 ∘ₗ (ι Q).codRestrict _ (ι_mem_evenOdd_one Q) #align clifford_algebra.graded_algebra.ι CliffordAlgebra.GradedAlgebra.ι theorem GradedAlgebra.ι_apply (m : M) : GradedAlgebra.ι Q m = DirectSum.of (fun i => ↥(evenOdd Q i)) 1 ⟨ι Q m, ι_mem_evenOdd_one Q m⟩ := rfl #align clifford_algebra.graded_algebra.ι_apply CliffordAlgebra.GradedAlgebra.ι_apply nonrec theorem GradedAlgebra.ι_sq_scalar (m : M) : GradedAlgebra.ι Q m * GradedAlgebra.ι Q m = algebraMap R _ (Q m) := by rw [GradedAlgebra.ι_apply Q, DirectSum.of_mul_of, DirectSum.algebraMap_apply] exact DirectSum.of_eq_of_gradedMonoid_eq (Sigma.subtype_ext rfl <| ι_sq_scalar _ _) #align clifford_algebra.graded_algebra.ι_sq_scalar CliffordAlgebra.GradedAlgebra.ι_sq_scalar
Mathlib/LinearAlgebra/CliffordAlgebra/Grading.lean
91
122
theorem GradedAlgebra.lift_ι_eq (i' : ZMod 2) (x' : evenOdd Q i') : -- Porting note: added a second `by apply` lift Q ⟨by apply GradedAlgebra.ι Q, by apply GradedAlgebra.ι_sq_scalar Q⟩ x' = DirectSum.of (fun i => evenOdd Q i) i' x' := by
cases' x' with x' hx' dsimp only [Subtype.coe_mk, DirectSum.lof_eq_of] induction hx' using Submodule.iSup_induction' with | mem i x hx => obtain ⟨i, rfl⟩ := i -- Porting note: `dsimp only [Subtype.coe_mk] at hx` doesn't work, use `change` instead change x ∈ LinearMap.range (ι Q) ^ i at hx induction hx using Submodule.pow_induction_on_left' with | algebraMap r => rw [AlgHom.commutes, DirectSum.algebraMap_apply]; rfl | add x y i hx hy ihx ihy => -- Note: in #8386 `map_add` had to be specialized to avoid a timeout -- (the definition was already very slow) rw [AlgHom.map_add, ihx, ihy, ← AddMonoidHom.map_add] rfl | mem_mul m hm i x hx ih => obtain ⟨_, rfl⟩ := hm rw [AlgHom.map_mul, ih, lift_ι_apply, GradedAlgebra.ι_apply Q, DirectSum.of_mul_of] refine DirectSum.of_eq_of_gradedMonoid_eq (Sigma.subtype_ext ?_ ?_) <;> dsimp only [GradedMonoid.mk, Subtype.coe_mk] · rw [Nat.succ_eq_add_one, add_comm, Nat.cast_add, Nat.cast_one] rfl | zero => rw [AlgHom.map_zero] apply Eq.symm apply DFinsupp.single_eq_zero.mpr; rfl | add x y hx hy ihx ihy => rw [AlgHom.map_add, ihx, ihy, ← AddMonoidHom.map_add]; rfl
246
import Mathlib.LinearAlgebra.CliffordAlgebra.Grading import Mathlib.Algebra.Module.Opposites #align_import linear_algebra.clifford_algebra.conjugation from "leanprover-community/mathlib"@"34020e531ebc4e8aac6d449d9eecbcd1508ea8d0" variable {R : Type*} [CommRing R] variable {M : Type*} [AddCommGroup M] [Module R M] variable {Q : QuadraticForm R M} namespace CliffordAlgebra section Involute def involute : CliffordAlgebra Q →ₐ[R] CliffordAlgebra Q := CliffordAlgebra.lift Q ⟨-ι Q, fun m => by simp⟩ #align clifford_algebra.involute CliffordAlgebra.involute @[simp] theorem involute_ι (m : M) : involute (ι Q m) = -ι Q m := lift_ι_apply _ _ m #align clifford_algebra.involute_ι CliffordAlgebra.involute_ι @[simp]
Mathlib/LinearAlgebra/CliffordAlgebra/Conjugation.lean
55
56
theorem involute_comp_involute : involute.comp involute = AlgHom.id R (CliffordAlgebra Q) := by
ext; simp
247
import Mathlib.LinearAlgebra.CliffordAlgebra.Grading import Mathlib.Algebra.Module.Opposites #align_import linear_algebra.clifford_algebra.conjugation from "leanprover-community/mathlib"@"34020e531ebc4e8aac6d449d9eecbcd1508ea8d0" variable {R : Type*} [CommRing R] variable {M : Type*} [AddCommGroup M] [Module R M] variable {Q : QuadraticForm R M} namespace CliffordAlgebra section Reverse open MulOpposite def reverseOp : CliffordAlgebra Q →ₐ[R] (CliffordAlgebra Q)ᵐᵒᵖ := CliffordAlgebra.lift Q ⟨(MulOpposite.opLinearEquiv R).toLinearMap ∘ₗ ι Q, fun m => unop_injective <| by simp⟩ @[simp] theorem reverseOp_ι (m : M) : reverseOp (ι Q m) = op (ι Q m) := lift_ι_apply _ _ _ @[simps! apply] def reverseOpEquiv : CliffordAlgebra Q ≃ₐ[R] (CliffordAlgebra Q)ᵐᵒᵖ := AlgEquiv.ofAlgHom reverseOp (AlgHom.opComm reverseOp) (AlgHom.unop.injective <| hom_ext <| LinearMap.ext fun _ => by simp) (hom_ext <| LinearMap.ext fun _ => by simp) @[simp] theorem reverseOpEquiv_opComm : AlgEquiv.opComm (reverseOpEquiv (Q := Q)) = reverseOpEquiv.symm := rfl def reverse : CliffordAlgebra Q →ₗ[R] CliffordAlgebra Q := (opLinearEquiv R).symm.toLinearMap.comp reverseOp.toLinearMap #align clifford_algebra.reverse CliffordAlgebra.reverse @[simp] theorem unop_reverseOp (x : CliffordAlgebra Q) : (reverseOp x).unop = reverse x := rfl @[simp] theorem op_reverse (x : CliffordAlgebra Q) : op (reverse x) = reverseOp x := rfl @[simp]
Mathlib/LinearAlgebra/CliffordAlgebra/Conjugation.lean
111
111
theorem reverse_ι (m : M) : reverse (ι Q m) = ι Q m := by
simp [reverse]
247
import Mathlib.LinearAlgebra.CliffordAlgebra.Conjugation #align_import linear_algebra.clifford_algebra.fold from "leanprover-community/mathlib"@"446eb51ce0a90f8385f260d2b52e760e2004246b" universe u1 u2 u3 variable {R M N : Type*} variable [CommRing R] [AddCommGroup M] [AddCommGroup N] variable [Module R M] [Module R N] variable (Q : QuadraticForm R M) namespace CliffordAlgebra section Foldr def foldr (f : M →ₗ[R] N →ₗ[R] N) (hf : ∀ m x, f m (f m x) = Q m • x) : N →ₗ[R] CliffordAlgebra Q →ₗ[R] N := (CliffordAlgebra.lift Q ⟨f, fun v => LinearMap.ext <| hf v⟩).toLinearMap.flip #align clifford_algebra.foldr CliffordAlgebra.foldr @[simp] theorem foldr_ι (f : M →ₗ[R] N →ₗ[R] N) (hf) (n : N) (m : M) : foldr Q f hf n (ι Q m) = f m n := LinearMap.congr_fun (lift_ι_apply _ _ _) n #align clifford_algebra.foldr_ι CliffordAlgebra.foldr_ι @[simp] theorem foldr_algebraMap (f : M →ₗ[R] N →ₗ[R] N) (hf) (n : N) (r : R) : foldr Q f hf n (algebraMap R _ r) = r • n := LinearMap.congr_fun (AlgHom.commutes _ r) n #align clifford_algebra.foldr_algebra_map CliffordAlgebra.foldr_algebraMap @[simp] theorem foldr_one (f : M →ₗ[R] N →ₗ[R] N) (hf) (n : N) : foldr Q f hf n 1 = n := LinearMap.congr_fun (AlgHom.map_one _) n #align clifford_algebra.foldr_one CliffordAlgebra.foldr_one @[simp] theorem foldr_mul (f : M →ₗ[R] N →ₗ[R] N) (hf) (n : N) (a b : CliffordAlgebra Q) : foldr Q f hf n (a * b) = foldr Q f hf (foldr Q f hf n b) a := LinearMap.congr_fun (AlgHom.map_mul _ _ _) n #align clifford_algebra.foldr_mul CliffordAlgebra.foldr_mul
Mathlib/LinearAlgebra/CliffordAlgebra/Fold.lean
77
81
theorem foldr_prod_map_ι (l : List M) (f : M →ₗ[R] N →ₗ[R] N) (hf) (n : N) : foldr Q f hf n (l.map <| ι Q).prod = List.foldr (fun m n => f m n) n l := by
induction' l with hd tl ih · rw [List.map_nil, List.prod_nil, List.foldr_nil, foldr_one] · rw [List.map_cons, List.prod_cons, List.foldr_cons, foldr_mul, foldr_ι, ih]
248
import Mathlib.LinearAlgebra.CliffordAlgebra.Conjugation #align_import linear_algebra.clifford_algebra.fold from "leanprover-community/mathlib"@"446eb51ce0a90f8385f260d2b52e760e2004246b" universe u1 u2 u3 variable {R M N : Type*} variable [CommRing R] [AddCommGroup M] [AddCommGroup N] variable [Module R M] [Module R N] variable (Q : QuadraticForm R M) namespace CliffordAlgebra @[elab_as_elim]
Mathlib/LinearAlgebra/CliffordAlgebra/Fold.lean
140
157
theorem right_induction {P : CliffordAlgebra Q → Prop} (algebraMap : ∀ r : R, P (algebraMap _ _ r)) (add : ∀ x y, P x → P y → P (x + y)) (mul_ι : ∀ m x, P x → P (x * ι Q m)) : ∀ x, P x := by
/- It would be neat if we could prove this via `foldr` like how we prove `CliffordAlgebra.induction`, but going via the grading seems easier. -/ intro x have : x ∈ ⊤ := Submodule.mem_top (R := R) rw [← iSup_ι_range_eq_top] at this induction this using Submodule.iSup_induction' with | mem i x hx => induction hx using Submodule.pow_induction_on_right' with | algebraMap r => exact algebraMap r | add _x _y _i _ _ ihx ihy => exact add _ _ ihx ihy | mul_mem _i x _hx px m hm => obtain ⟨m, rfl⟩ := hm exact mul_ι _ _ px | zero => simpa only [map_zero] using algebraMap 0 | add _x _y _ _ ihx ihy => exact add _ _ ihx ihy
248
import Mathlib.LinearAlgebra.CliffordAlgebra.Conjugation #align_import linear_algebra.clifford_algebra.fold from "leanprover-community/mathlib"@"446eb51ce0a90f8385f260d2b52e760e2004246b" universe u1 u2 u3 variable {R M N : Type*} variable [CommRing R] [AddCommGroup M] [AddCommGroup N] variable [Module R M] [Module R N] variable (Q : QuadraticForm R M) namespace CliffordAlgebra @[elab_as_elim] theorem right_induction {P : CliffordAlgebra Q → Prop} (algebraMap : ∀ r : R, P (algebraMap _ _ r)) (add : ∀ x y, P x → P y → P (x + y)) (mul_ι : ∀ m x, P x → P (x * ι Q m)) : ∀ x, P x := by intro x have : x ∈ ⊤ := Submodule.mem_top (R := R) rw [← iSup_ι_range_eq_top] at this induction this using Submodule.iSup_induction' with | mem i x hx => induction hx using Submodule.pow_induction_on_right' with | algebraMap r => exact algebraMap r | add _x _y _i _ _ ihx ihy => exact add _ _ ihx ihy | mul_mem _i x _hx px m hm => obtain ⟨m, rfl⟩ := hm exact mul_ι _ _ px | zero => simpa only [map_zero] using algebraMap 0 | add _x _y _ _ ihx ihy => exact add _ _ ihx ihy #align clifford_algebra.right_induction CliffordAlgebra.right_induction @[elab_as_elim]
Mathlib/LinearAlgebra/CliffordAlgebra/Fold.lean
161
168
theorem left_induction {P : CliffordAlgebra Q → Prop} (algebraMap : ∀ r : R, P (algebraMap _ _ r)) (add : ∀ x y, P x → P y → P (x + y)) (ι_mul : ∀ x m, P x → P (ι Q m * x)) : ∀ x, P x := by
refine reverse_involutive.surjective.forall.2 ?_ intro x induction' x using CliffordAlgebra.right_induction with r x y hx hy m x hx · simpa only [reverse.commutes] using algebraMap r · simpa only [map_add] using add _ _ hx hy · simpa only [reverse.map_mul, reverse_ι] using ι_mul _ _ hx
248
import Mathlib.LinearAlgebra.CliffordAlgebra.Conjugation #align_import linear_algebra.clifford_algebra.fold from "leanprover-community/mathlib"@"446eb51ce0a90f8385f260d2b52e760e2004246b" universe u1 u2 u3 variable {R M N : Type*} variable [CommRing R] [AddCommGroup M] [AddCommGroup N] variable [Module R M] [Module R N] variable (Q : QuadraticForm R M) namespace CliffordAlgebra @[elab_as_elim] theorem right_induction {P : CliffordAlgebra Q → Prop} (algebraMap : ∀ r : R, P (algebraMap _ _ r)) (add : ∀ x y, P x → P y → P (x + y)) (mul_ι : ∀ m x, P x → P (x * ι Q m)) : ∀ x, P x := by intro x have : x ∈ ⊤ := Submodule.mem_top (R := R) rw [← iSup_ι_range_eq_top] at this induction this using Submodule.iSup_induction' with | mem i x hx => induction hx using Submodule.pow_induction_on_right' with | algebraMap r => exact algebraMap r | add _x _y _i _ _ ihx ihy => exact add _ _ ihx ihy | mul_mem _i x _hx px m hm => obtain ⟨m, rfl⟩ := hm exact mul_ι _ _ px | zero => simpa only [map_zero] using algebraMap 0 | add _x _y _ _ ihx ihy => exact add _ _ ihx ihy #align clifford_algebra.right_induction CliffordAlgebra.right_induction @[elab_as_elim] theorem left_induction {P : CliffordAlgebra Q → Prop} (algebraMap : ∀ r : R, P (algebraMap _ _ r)) (add : ∀ x y, P x → P y → P (x + y)) (ι_mul : ∀ x m, P x → P (ι Q m * x)) : ∀ x, P x := by refine reverse_involutive.surjective.forall.2 ?_ intro x induction' x using CliffordAlgebra.right_induction with r x y hx hy m x hx · simpa only [reverse.commutes] using algebraMap r · simpa only [map_add] using add _ _ hx hy · simpa only [reverse.map_mul, reverse_ι] using ι_mul _ _ hx #align clifford_algebra.left_induction CliffordAlgebra.left_induction def foldr'Aux (f : M →ₗ[R] CliffordAlgebra Q × N →ₗ[R] N) : M →ₗ[R] Module.End R (CliffordAlgebra Q × N) := by have v_mul := (Algebra.lmul R (CliffordAlgebra Q)).toLinearMap ∘ₗ ι Q have l := v_mul.compl₂ (LinearMap.fst _ _ N) exact { toFun := fun m => (l m).prod (f m) map_add' := fun v₂ v₂ => LinearMap.ext fun x => Prod.ext (LinearMap.congr_fun (l.map_add _ _) x) (LinearMap.congr_fun (f.map_add _ _) x) map_smul' := fun c v => LinearMap.ext fun x => Prod.ext (LinearMap.congr_fun (l.map_smul _ _) x) (LinearMap.congr_fun (f.map_smul _ _) x) } #align clifford_algebra.foldr'_aux CliffordAlgebra.foldr'Aux theorem foldr'Aux_apply_apply (f : M →ₗ[R] CliffordAlgebra Q × N →ₗ[R] N) (m : M) (x_fx) : foldr'Aux Q f m x_fx = (ι Q m * x_fx.1, f m x_fx) := rfl #align clifford_algebra.foldr'_aux_apply_apply CliffordAlgebra.foldr'Aux_apply_apply
Mathlib/LinearAlgebra/CliffordAlgebra/Fold.lean
195
200
theorem foldr'Aux_foldr'Aux (f : M →ₗ[R] CliffordAlgebra Q × N →ₗ[R] N) (hf : ∀ m x fx, f m (ι Q m * x, f m (x, fx)) = Q m • fx) (v : M) (x_fx) : foldr'Aux Q f v (foldr'Aux Q f v x_fx) = Q v • x_fx := by
cases' x_fx with x fx simp only [foldr'Aux_apply_apply] rw [← mul_assoc, ι_sq_scalar, ← Algebra.smul_def, hf, Prod.smul_mk]
248
import Mathlib.LinearAlgebra.CliffordAlgebra.Fold import Mathlib.LinearAlgebra.ExteriorAlgebra.Basic #align_import linear_algebra.exterior_algebra.of_alternating from "leanprover-community/mathlib"@"ce11c3c2a285bbe6937e26d9792fda4e51f3fe1a" variable {R M N N' : Type*} variable [CommRing R] [AddCommGroup M] [AddCommGroup N] [AddCommGroup N'] variable [Module R M] [Module R N] [Module R N'] -- This instance can't be found where it's needed if we don't remind lean that it exists. instance AlternatingMap.instModuleAddCommGroup {ι : Type*} : Module R (M [⋀^ι]→ₗ[R] N) := by infer_instance #align alternating_map.module_add_comm_group AlternatingMap.instModuleAddCommGroup namespace ExteriorAlgebra open CliffordAlgebra hiding ι def liftAlternating : (∀ i, M [⋀^Fin i]→ₗ[R] N) →ₗ[R] ExteriorAlgebra R M →ₗ[R] N := by suffices (∀ i, M [⋀^Fin i]→ₗ[R] N) →ₗ[R] ExteriorAlgebra R M →ₗ[R] ∀ i, M [⋀^Fin i]→ₗ[R] N by refine LinearMap.compr₂ this ?_ refine (LinearEquiv.toLinearMap ?_).comp (LinearMap.proj 0) exact AlternatingMap.constLinearEquivOfIsEmpty.symm refine CliffordAlgebra.foldl _ ?_ ?_ · refine LinearMap.mk₂ R (fun m f i => (f i.succ).curryLeft m) (fun m₁ m₂ f => ?_) (fun c m f => ?_) (fun m f₁ f₂ => ?_) fun c m f => ?_ all_goals ext i : 1 simp only [map_smul, map_add, Pi.add_apply, Pi.smul_apply, AlternatingMap.curryLeft_add, AlternatingMap.curryLeft_smul, map_add, map_smul, LinearMap.add_apply, LinearMap.smul_apply] · -- when applied twice with the same `m`, this recursive step produces 0 intro m x dsimp only [LinearMap.mk₂_apply, QuadraticForm.coeFn_zero, Pi.zero_apply] simp_rw [zero_smul] ext i : 1 exact AlternatingMap.curryLeft_same _ _ #align exterior_algebra.lift_alternating ExteriorAlgebra.liftAlternating @[simp]
Mathlib/LinearAlgebra/ExteriorAlgebra/OfAlternating.lean
68
76
theorem liftAlternating_ι (f : ∀ i, M [⋀^Fin i]→ₗ[R] N) (m : M) : liftAlternating (R := R) (M := M) (N := N) f (ι R m) = f 1 ![m] := by
dsimp [liftAlternating] rw [foldl_ι, LinearMap.mk₂_apply, AlternatingMap.curryLeft_apply_apply] congr -- Porting note: In Lean 3, `congr` could use the `[Subsingleton (Fin 0 → M)]` instance to finish -- the proof. Here, the instance can be synthesized but `congr` does not use it so the following -- line is provided. rw [Matrix.zero_empty]
249
import Mathlib.LinearAlgebra.CliffordAlgebra.Fold import Mathlib.LinearAlgebra.ExteriorAlgebra.Basic #align_import linear_algebra.exterior_algebra.of_alternating from "leanprover-community/mathlib"@"ce11c3c2a285bbe6937e26d9792fda4e51f3fe1a" variable {R M N N' : Type*} variable [CommRing R] [AddCommGroup M] [AddCommGroup N] [AddCommGroup N'] variable [Module R M] [Module R N] [Module R N'] -- This instance can't be found where it's needed if we don't remind lean that it exists. instance AlternatingMap.instModuleAddCommGroup {ι : Type*} : Module R (M [⋀^ι]→ₗ[R] N) := by infer_instance #align alternating_map.module_add_comm_group AlternatingMap.instModuleAddCommGroup namespace ExteriorAlgebra open CliffordAlgebra hiding ι def liftAlternating : (∀ i, M [⋀^Fin i]→ₗ[R] N) →ₗ[R] ExteriorAlgebra R M →ₗ[R] N := by suffices (∀ i, M [⋀^Fin i]→ₗ[R] N) →ₗ[R] ExteriorAlgebra R M →ₗ[R] ∀ i, M [⋀^Fin i]→ₗ[R] N by refine LinearMap.compr₂ this ?_ refine (LinearEquiv.toLinearMap ?_).comp (LinearMap.proj 0) exact AlternatingMap.constLinearEquivOfIsEmpty.symm refine CliffordAlgebra.foldl _ ?_ ?_ · refine LinearMap.mk₂ R (fun m f i => (f i.succ).curryLeft m) (fun m₁ m₂ f => ?_) (fun c m f => ?_) (fun m f₁ f₂ => ?_) fun c m f => ?_ all_goals ext i : 1 simp only [map_smul, map_add, Pi.add_apply, Pi.smul_apply, AlternatingMap.curryLeft_add, AlternatingMap.curryLeft_smul, map_add, map_smul, LinearMap.add_apply, LinearMap.smul_apply] · -- when applied twice with the same `m`, this recursive step produces 0 intro m x dsimp only [LinearMap.mk₂_apply, QuadraticForm.coeFn_zero, Pi.zero_apply] simp_rw [zero_smul] ext i : 1 exact AlternatingMap.curryLeft_same _ _ #align exterior_algebra.lift_alternating ExteriorAlgebra.liftAlternating @[simp] theorem liftAlternating_ι (f : ∀ i, M [⋀^Fin i]→ₗ[R] N) (m : M) : liftAlternating (R := R) (M := M) (N := N) f (ι R m) = f 1 ![m] := by dsimp [liftAlternating] rw [foldl_ι, LinearMap.mk₂_apply, AlternatingMap.curryLeft_apply_apply] congr -- Porting note: In Lean 3, `congr` could use the `[Subsingleton (Fin 0 → M)]` instance to finish -- the proof. Here, the instance can be synthesized but `congr` does not use it so the following -- line is provided. rw [Matrix.zero_empty] #align exterior_algebra.lift_alternating_ι ExteriorAlgebra.liftAlternating_ι
Mathlib/LinearAlgebra/ExteriorAlgebra/OfAlternating.lean
79
85
theorem liftAlternating_ι_mul (f : ∀ i, M [⋀^Fin i]→ₗ[R] N) (m : M) (x : ExteriorAlgebra R M) : liftAlternating (R := R) (M := M) (N := N) f (ι R m * x) = liftAlternating (R := R) (M := M) (N := N) (fun i => (f i.succ).curryLeft m) x := by
dsimp [liftAlternating] rw [foldl_mul, foldl_ι] rfl
249
import Mathlib.LinearAlgebra.CliffordAlgebra.Fold import Mathlib.LinearAlgebra.ExteriorAlgebra.Basic #align_import linear_algebra.exterior_algebra.of_alternating from "leanprover-community/mathlib"@"ce11c3c2a285bbe6937e26d9792fda4e51f3fe1a" variable {R M N N' : Type*} variable [CommRing R] [AddCommGroup M] [AddCommGroup N] [AddCommGroup N'] variable [Module R M] [Module R N] [Module R N'] -- This instance can't be found where it's needed if we don't remind lean that it exists. instance AlternatingMap.instModuleAddCommGroup {ι : Type*} : Module R (M [⋀^ι]→ₗ[R] N) := by infer_instance #align alternating_map.module_add_comm_group AlternatingMap.instModuleAddCommGroup namespace ExteriorAlgebra open CliffordAlgebra hiding ι def liftAlternating : (∀ i, M [⋀^Fin i]→ₗ[R] N) →ₗ[R] ExteriorAlgebra R M →ₗ[R] N := by suffices (∀ i, M [⋀^Fin i]→ₗ[R] N) →ₗ[R] ExteriorAlgebra R M →ₗ[R] ∀ i, M [⋀^Fin i]→ₗ[R] N by refine LinearMap.compr₂ this ?_ refine (LinearEquiv.toLinearMap ?_).comp (LinearMap.proj 0) exact AlternatingMap.constLinearEquivOfIsEmpty.symm refine CliffordAlgebra.foldl _ ?_ ?_ · refine LinearMap.mk₂ R (fun m f i => (f i.succ).curryLeft m) (fun m₁ m₂ f => ?_) (fun c m f => ?_) (fun m f₁ f₂ => ?_) fun c m f => ?_ all_goals ext i : 1 simp only [map_smul, map_add, Pi.add_apply, Pi.smul_apply, AlternatingMap.curryLeft_add, AlternatingMap.curryLeft_smul, map_add, map_smul, LinearMap.add_apply, LinearMap.smul_apply] · -- when applied twice with the same `m`, this recursive step produces 0 intro m x dsimp only [LinearMap.mk₂_apply, QuadraticForm.coeFn_zero, Pi.zero_apply] simp_rw [zero_smul] ext i : 1 exact AlternatingMap.curryLeft_same _ _ #align exterior_algebra.lift_alternating ExteriorAlgebra.liftAlternating @[simp] theorem liftAlternating_ι (f : ∀ i, M [⋀^Fin i]→ₗ[R] N) (m : M) : liftAlternating (R := R) (M := M) (N := N) f (ι R m) = f 1 ![m] := by dsimp [liftAlternating] rw [foldl_ι, LinearMap.mk₂_apply, AlternatingMap.curryLeft_apply_apply] congr -- Porting note: In Lean 3, `congr` could use the `[Subsingleton (Fin 0 → M)]` instance to finish -- the proof. Here, the instance can be synthesized but `congr` does not use it so the following -- line is provided. rw [Matrix.zero_empty] #align exterior_algebra.lift_alternating_ι ExteriorAlgebra.liftAlternating_ι theorem liftAlternating_ι_mul (f : ∀ i, M [⋀^Fin i]→ₗ[R] N) (m : M) (x : ExteriorAlgebra R M) : liftAlternating (R := R) (M := M) (N := N) f (ι R m * x) = liftAlternating (R := R) (M := M) (N := N) (fun i => (f i.succ).curryLeft m) x := by dsimp [liftAlternating] rw [foldl_mul, foldl_ι] rfl #align exterior_algebra.lift_alternating_ι_mul ExteriorAlgebra.liftAlternating_ι_mul @[simp]
Mathlib/LinearAlgebra/ExteriorAlgebra/OfAlternating.lean
89
92
theorem liftAlternating_one (f : ∀ i, M [⋀^Fin i]→ₗ[R] N) : liftAlternating (R := R) (M := M) (N := N) f (1 : ExteriorAlgebra R M) = f 0 0 := by
dsimp [liftAlternating] rw [foldl_one]
249
import Mathlib.LinearAlgebra.CliffordAlgebra.Fold import Mathlib.LinearAlgebra.ExteriorAlgebra.Basic #align_import linear_algebra.exterior_algebra.of_alternating from "leanprover-community/mathlib"@"ce11c3c2a285bbe6937e26d9792fda4e51f3fe1a" variable {R M N N' : Type*} variable [CommRing R] [AddCommGroup M] [AddCommGroup N] [AddCommGroup N'] variable [Module R M] [Module R N] [Module R N'] -- This instance can't be found where it's needed if we don't remind lean that it exists. instance AlternatingMap.instModuleAddCommGroup {ι : Type*} : Module R (M [⋀^ι]→ₗ[R] N) := by infer_instance #align alternating_map.module_add_comm_group AlternatingMap.instModuleAddCommGroup namespace ExteriorAlgebra open CliffordAlgebra hiding ι def liftAlternating : (∀ i, M [⋀^Fin i]→ₗ[R] N) →ₗ[R] ExteriorAlgebra R M →ₗ[R] N := by suffices (∀ i, M [⋀^Fin i]→ₗ[R] N) →ₗ[R] ExteriorAlgebra R M →ₗ[R] ∀ i, M [⋀^Fin i]→ₗ[R] N by refine LinearMap.compr₂ this ?_ refine (LinearEquiv.toLinearMap ?_).comp (LinearMap.proj 0) exact AlternatingMap.constLinearEquivOfIsEmpty.symm refine CliffordAlgebra.foldl _ ?_ ?_ · refine LinearMap.mk₂ R (fun m f i => (f i.succ).curryLeft m) (fun m₁ m₂ f => ?_) (fun c m f => ?_) (fun m f₁ f₂ => ?_) fun c m f => ?_ all_goals ext i : 1 simp only [map_smul, map_add, Pi.add_apply, Pi.smul_apply, AlternatingMap.curryLeft_add, AlternatingMap.curryLeft_smul, map_add, map_smul, LinearMap.add_apply, LinearMap.smul_apply] · -- when applied twice with the same `m`, this recursive step produces 0 intro m x dsimp only [LinearMap.mk₂_apply, QuadraticForm.coeFn_zero, Pi.zero_apply] simp_rw [zero_smul] ext i : 1 exact AlternatingMap.curryLeft_same _ _ #align exterior_algebra.lift_alternating ExteriorAlgebra.liftAlternating @[simp] theorem liftAlternating_ι (f : ∀ i, M [⋀^Fin i]→ₗ[R] N) (m : M) : liftAlternating (R := R) (M := M) (N := N) f (ι R m) = f 1 ![m] := by dsimp [liftAlternating] rw [foldl_ι, LinearMap.mk₂_apply, AlternatingMap.curryLeft_apply_apply] congr -- Porting note: In Lean 3, `congr` could use the `[Subsingleton (Fin 0 → M)]` instance to finish -- the proof. Here, the instance can be synthesized but `congr` does not use it so the following -- line is provided. rw [Matrix.zero_empty] #align exterior_algebra.lift_alternating_ι ExteriorAlgebra.liftAlternating_ι theorem liftAlternating_ι_mul (f : ∀ i, M [⋀^Fin i]→ₗ[R] N) (m : M) (x : ExteriorAlgebra R M) : liftAlternating (R := R) (M := M) (N := N) f (ι R m * x) = liftAlternating (R := R) (M := M) (N := N) (fun i => (f i.succ).curryLeft m) x := by dsimp [liftAlternating] rw [foldl_mul, foldl_ι] rfl #align exterior_algebra.lift_alternating_ι_mul ExteriorAlgebra.liftAlternating_ι_mul @[simp] theorem liftAlternating_one (f : ∀ i, M [⋀^Fin i]→ₗ[R] N) : liftAlternating (R := R) (M := M) (N := N) f (1 : ExteriorAlgebra R M) = f 0 0 := by dsimp [liftAlternating] rw [foldl_one] #align exterior_algebra.lift_alternating_one ExteriorAlgebra.liftAlternating_one @[simp]
Mathlib/LinearAlgebra/ExteriorAlgebra/OfAlternating.lean
96
99
theorem liftAlternating_algebraMap (f : ∀ i, M [⋀^Fin i]→ₗ[R] N) (r : R) : liftAlternating (R := R) (M := M) (N := N) f (algebraMap _ (ExteriorAlgebra R M) r) = r • f 0 0 := by
rw [Algebra.algebraMap_eq_smul_one, map_smul, liftAlternating_one]
249
import Mathlib.LinearAlgebra.CliffordAlgebra.Fold import Mathlib.LinearAlgebra.ExteriorAlgebra.Basic #align_import linear_algebra.exterior_algebra.of_alternating from "leanprover-community/mathlib"@"ce11c3c2a285bbe6937e26d9792fda4e51f3fe1a" variable {R M N N' : Type*} variable [CommRing R] [AddCommGroup M] [AddCommGroup N] [AddCommGroup N'] variable [Module R M] [Module R N] [Module R N'] -- This instance can't be found where it's needed if we don't remind lean that it exists. instance AlternatingMap.instModuleAddCommGroup {ι : Type*} : Module R (M [⋀^ι]→ₗ[R] N) := by infer_instance #align alternating_map.module_add_comm_group AlternatingMap.instModuleAddCommGroup namespace ExteriorAlgebra open CliffordAlgebra hiding ι def liftAlternating : (∀ i, M [⋀^Fin i]→ₗ[R] N) →ₗ[R] ExteriorAlgebra R M →ₗ[R] N := by suffices (∀ i, M [⋀^Fin i]→ₗ[R] N) →ₗ[R] ExteriorAlgebra R M →ₗ[R] ∀ i, M [⋀^Fin i]→ₗ[R] N by refine LinearMap.compr₂ this ?_ refine (LinearEquiv.toLinearMap ?_).comp (LinearMap.proj 0) exact AlternatingMap.constLinearEquivOfIsEmpty.symm refine CliffordAlgebra.foldl _ ?_ ?_ · refine LinearMap.mk₂ R (fun m f i => (f i.succ).curryLeft m) (fun m₁ m₂ f => ?_) (fun c m f => ?_) (fun m f₁ f₂ => ?_) fun c m f => ?_ all_goals ext i : 1 simp only [map_smul, map_add, Pi.add_apply, Pi.smul_apply, AlternatingMap.curryLeft_add, AlternatingMap.curryLeft_smul, map_add, map_smul, LinearMap.add_apply, LinearMap.smul_apply] · -- when applied twice with the same `m`, this recursive step produces 0 intro m x dsimp only [LinearMap.mk₂_apply, QuadraticForm.coeFn_zero, Pi.zero_apply] simp_rw [zero_smul] ext i : 1 exact AlternatingMap.curryLeft_same _ _ #align exterior_algebra.lift_alternating ExteriorAlgebra.liftAlternating @[simp] theorem liftAlternating_ι (f : ∀ i, M [⋀^Fin i]→ₗ[R] N) (m : M) : liftAlternating (R := R) (M := M) (N := N) f (ι R m) = f 1 ![m] := by dsimp [liftAlternating] rw [foldl_ι, LinearMap.mk₂_apply, AlternatingMap.curryLeft_apply_apply] congr -- Porting note: In Lean 3, `congr` could use the `[Subsingleton (Fin 0 → M)]` instance to finish -- the proof. Here, the instance can be synthesized but `congr` does not use it so the following -- line is provided. rw [Matrix.zero_empty] #align exterior_algebra.lift_alternating_ι ExteriorAlgebra.liftAlternating_ι theorem liftAlternating_ι_mul (f : ∀ i, M [⋀^Fin i]→ₗ[R] N) (m : M) (x : ExteriorAlgebra R M) : liftAlternating (R := R) (M := M) (N := N) f (ι R m * x) = liftAlternating (R := R) (M := M) (N := N) (fun i => (f i.succ).curryLeft m) x := by dsimp [liftAlternating] rw [foldl_mul, foldl_ι] rfl #align exterior_algebra.lift_alternating_ι_mul ExteriorAlgebra.liftAlternating_ι_mul @[simp] theorem liftAlternating_one (f : ∀ i, M [⋀^Fin i]→ₗ[R] N) : liftAlternating (R := R) (M := M) (N := N) f (1 : ExteriorAlgebra R M) = f 0 0 := by dsimp [liftAlternating] rw [foldl_one] #align exterior_algebra.lift_alternating_one ExteriorAlgebra.liftAlternating_one @[simp] theorem liftAlternating_algebraMap (f : ∀ i, M [⋀^Fin i]→ₗ[R] N) (r : R) : liftAlternating (R := R) (M := M) (N := N) f (algebraMap _ (ExteriorAlgebra R M) r) = r • f 0 0 := by rw [Algebra.algebraMap_eq_smul_one, map_smul, liftAlternating_one] #align exterior_algebra.lift_alternating_algebra_map ExteriorAlgebra.liftAlternating_algebraMap @[simp]
Mathlib/LinearAlgebra/ExteriorAlgebra/OfAlternating.lean
103
115
theorem liftAlternating_apply_ιMulti {n : ℕ} (f : ∀ i, M [⋀^Fin i]→ₗ[R] N) (v : Fin n → M) : liftAlternating (R := R) (M := M) (N := N) f (ιMulti R n v) = f n v := by
rw [ιMulti_apply] -- Porting note: `v` is generalized automatically so it was removed from the next line induction' n with n ih generalizing f · -- Porting note: Lean does not automatically synthesize the instance -- `[Subsingleton (Fin 0 → M)]` which is needed for `Subsingleton.elim 0 v` on line 114. letI : Subsingleton (Fin 0 → M) := by infer_instance rw [List.ofFn_zero, List.prod_nil, liftAlternating_one, Subsingleton.elim 0 v] · rw [List.ofFn_succ, List.prod_cons, liftAlternating_ι_mul, ih, AlternatingMap.curryLeft_apply_apply] congr exact Matrix.cons_head_tail _
249
import Mathlib.LinearAlgebra.CliffordAlgebra.Fold import Mathlib.LinearAlgebra.ExteriorAlgebra.Basic #align_import linear_algebra.exterior_algebra.of_alternating from "leanprover-community/mathlib"@"ce11c3c2a285bbe6937e26d9792fda4e51f3fe1a" variable {R M N N' : Type*} variable [CommRing R] [AddCommGroup M] [AddCommGroup N] [AddCommGroup N'] variable [Module R M] [Module R N] [Module R N'] -- This instance can't be found where it's needed if we don't remind lean that it exists. instance AlternatingMap.instModuleAddCommGroup {ι : Type*} : Module R (M [⋀^ι]→ₗ[R] N) := by infer_instance #align alternating_map.module_add_comm_group AlternatingMap.instModuleAddCommGroup namespace ExteriorAlgebra open CliffordAlgebra hiding ι def liftAlternating : (∀ i, M [⋀^Fin i]→ₗ[R] N) →ₗ[R] ExteriorAlgebra R M →ₗ[R] N := by suffices (∀ i, M [⋀^Fin i]→ₗ[R] N) →ₗ[R] ExteriorAlgebra R M →ₗ[R] ∀ i, M [⋀^Fin i]→ₗ[R] N by refine LinearMap.compr₂ this ?_ refine (LinearEquiv.toLinearMap ?_).comp (LinearMap.proj 0) exact AlternatingMap.constLinearEquivOfIsEmpty.symm refine CliffordAlgebra.foldl _ ?_ ?_ · refine LinearMap.mk₂ R (fun m f i => (f i.succ).curryLeft m) (fun m₁ m₂ f => ?_) (fun c m f => ?_) (fun m f₁ f₂ => ?_) fun c m f => ?_ all_goals ext i : 1 simp only [map_smul, map_add, Pi.add_apply, Pi.smul_apply, AlternatingMap.curryLeft_add, AlternatingMap.curryLeft_smul, map_add, map_smul, LinearMap.add_apply, LinearMap.smul_apply] · -- when applied twice with the same `m`, this recursive step produces 0 intro m x dsimp only [LinearMap.mk₂_apply, QuadraticForm.coeFn_zero, Pi.zero_apply] simp_rw [zero_smul] ext i : 1 exact AlternatingMap.curryLeft_same _ _ #align exterior_algebra.lift_alternating ExteriorAlgebra.liftAlternating @[simp] theorem liftAlternating_ι (f : ∀ i, M [⋀^Fin i]→ₗ[R] N) (m : M) : liftAlternating (R := R) (M := M) (N := N) f (ι R m) = f 1 ![m] := by dsimp [liftAlternating] rw [foldl_ι, LinearMap.mk₂_apply, AlternatingMap.curryLeft_apply_apply] congr -- Porting note: In Lean 3, `congr` could use the `[Subsingleton (Fin 0 → M)]` instance to finish -- the proof. Here, the instance can be synthesized but `congr` does not use it so the following -- line is provided. rw [Matrix.zero_empty] #align exterior_algebra.lift_alternating_ι ExteriorAlgebra.liftAlternating_ι theorem liftAlternating_ι_mul (f : ∀ i, M [⋀^Fin i]→ₗ[R] N) (m : M) (x : ExteriorAlgebra R M) : liftAlternating (R := R) (M := M) (N := N) f (ι R m * x) = liftAlternating (R := R) (M := M) (N := N) (fun i => (f i.succ).curryLeft m) x := by dsimp [liftAlternating] rw [foldl_mul, foldl_ι] rfl #align exterior_algebra.lift_alternating_ι_mul ExteriorAlgebra.liftAlternating_ι_mul @[simp] theorem liftAlternating_one (f : ∀ i, M [⋀^Fin i]→ₗ[R] N) : liftAlternating (R := R) (M := M) (N := N) f (1 : ExteriorAlgebra R M) = f 0 0 := by dsimp [liftAlternating] rw [foldl_one] #align exterior_algebra.lift_alternating_one ExteriorAlgebra.liftAlternating_one @[simp] theorem liftAlternating_algebraMap (f : ∀ i, M [⋀^Fin i]→ₗ[R] N) (r : R) : liftAlternating (R := R) (M := M) (N := N) f (algebraMap _ (ExteriorAlgebra R M) r) = r • f 0 0 := by rw [Algebra.algebraMap_eq_smul_one, map_smul, liftAlternating_one] #align exterior_algebra.lift_alternating_algebra_map ExteriorAlgebra.liftAlternating_algebraMap @[simp] theorem liftAlternating_apply_ιMulti {n : ℕ} (f : ∀ i, M [⋀^Fin i]→ₗ[R] N) (v : Fin n → M) : liftAlternating (R := R) (M := M) (N := N) f (ιMulti R n v) = f n v := by rw [ιMulti_apply] -- Porting note: `v` is generalized automatically so it was removed from the next line induction' n with n ih generalizing f · -- Porting note: Lean does not automatically synthesize the instance -- `[Subsingleton (Fin 0 → M)]` which is needed for `Subsingleton.elim 0 v` on line 114. letI : Subsingleton (Fin 0 → M) := by infer_instance rw [List.ofFn_zero, List.prod_nil, liftAlternating_one, Subsingleton.elim 0 v] · rw [List.ofFn_succ, List.prod_cons, liftAlternating_ι_mul, ih, AlternatingMap.curryLeft_apply_apply] congr exact Matrix.cons_head_tail _ #align exterior_algebra.lift_alternating_apply_ι_multi ExteriorAlgebra.liftAlternating_apply_ιMulti @[simp] theorem liftAlternating_comp_ιMulti {n : ℕ} (f : ∀ i, M [⋀^Fin i]→ₗ[R] N) : (liftAlternating (R := R) (M := M) (N := N) f).compAlternatingMap (ιMulti R n) = f n := AlternatingMap.ext <| liftAlternating_apply_ιMulti f #align exterior_algebra.lift_alternating_comp_ι_multi ExteriorAlgebra.liftAlternating_comp_ιMulti @[simp]
Mathlib/LinearAlgebra/ExteriorAlgebra/OfAlternating.lean
125
135
theorem liftAlternating_comp (g : N →ₗ[R] N') (f : ∀ i, M [⋀^Fin i]→ₗ[R] N) : (liftAlternating (R := R) (M := M) (N := N') fun i => g.compAlternatingMap (f i)) = g ∘ₗ liftAlternating (R := R) (M := M) (N := N) f := by
ext v rw [LinearMap.comp_apply] induction' v using CliffordAlgebra.left_induction with r x y hx hy x m hx generalizing f · rw [liftAlternating_algebraMap, liftAlternating_algebraMap, map_smul, LinearMap.compAlternatingMap_apply] · rw [map_add, map_add, map_add, hx, hy] · rw [liftAlternating_ι_mul, liftAlternating_ι_mul, ← hx] simp_rw [AlternatingMap.curryLeft_compAlternatingMap]
249
import Mathlib.LinearAlgebra.CliffordAlgebra.Conjugation #align_import linear_algebra.clifford_algebra.star from "leanprover-community/mathlib"@"4d66277cfec381260ba05c68f9ae6ce2a118031d" variable {R : Type*} [CommRing R] variable {M : Type*} [AddCommGroup M] [Module R M] variable {Q : QuadraticForm R M} namespace CliffordAlgebra instance instStarRing : StarRing (CliffordAlgebra Q) where star x := reverse (involute x) star_involutive x := by simp only [reverse_involute_commute.eq, reverse_reverse, involute_involute] star_mul x y := by simp only [map_mul, reverse.map_mul] star_add x y := by simp only [map_add] theorem star_def (x : CliffordAlgebra Q) : star x = reverse (involute x) := rfl #align clifford_algebra.star_def CliffordAlgebra.star_def theorem star_def' (x : CliffordAlgebra Q) : star x = involute (reverse x) := reverse_involute _ #align clifford_algebra.star_def' CliffordAlgebra.star_def' @[simp]
Mathlib/LinearAlgebra/CliffordAlgebra/Star.lean
50
50
theorem star_ι (m : M) : star (ι Q m) = -ι Q m := by
rw [star_def, involute_ι, map_neg, reverse_ι]
250
import Mathlib.LinearAlgebra.CliffordAlgebra.Conjugation #align_import linear_algebra.clifford_algebra.star from "leanprover-community/mathlib"@"4d66277cfec381260ba05c68f9ae6ce2a118031d" variable {R : Type*} [CommRing R] variable {M : Type*} [AddCommGroup M] [Module R M] variable {Q : QuadraticForm R M} namespace CliffordAlgebra instance instStarRing : StarRing (CliffordAlgebra Q) where star x := reverse (involute x) star_involutive x := by simp only [reverse_involute_commute.eq, reverse_reverse, involute_involute] star_mul x y := by simp only [map_mul, reverse.map_mul] star_add x y := by simp only [map_add] theorem star_def (x : CliffordAlgebra Q) : star x = reverse (involute x) := rfl #align clifford_algebra.star_def CliffordAlgebra.star_def theorem star_def' (x : CliffordAlgebra Q) : star x = involute (reverse x) := reverse_involute _ #align clifford_algebra.star_def' CliffordAlgebra.star_def' @[simp] theorem star_ι (m : M) : star (ι Q m) = -ι Q m := by rw [star_def, involute_ι, map_neg, reverse_ι] #align clifford_algebra.star_ι CliffordAlgebra.star_ι @[simp]
Mathlib/LinearAlgebra/CliffordAlgebra/Star.lean
57
58
theorem star_smul (r : R) (x : CliffordAlgebra Q) : star (r • x) = r • star x := by
rw [star_def, star_def, map_smul, map_smul]
250
import Mathlib.LinearAlgebra.CliffordAlgebra.Conjugation #align_import linear_algebra.clifford_algebra.star from "leanprover-community/mathlib"@"4d66277cfec381260ba05c68f9ae6ce2a118031d" variable {R : Type*} [CommRing R] variable {M : Type*} [AddCommGroup M] [Module R M] variable {Q : QuadraticForm R M} namespace CliffordAlgebra instance instStarRing : StarRing (CliffordAlgebra Q) where star x := reverse (involute x) star_involutive x := by simp only [reverse_involute_commute.eq, reverse_reverse, involute_involute] star_mul x y := by simp only [map_mul, reverse.map_mul] star_add x y := by simp only [map_add] theorem star_def (x : CliffordAlgebra Q) : star x = reverse (involute x) := rfl #align clifford_algebra.star_def CliffordAlgebra.star_def theorem star_def' (x : CliffordAlgebra Q) : star x = involute (reverse x) := reverse_involute _ #align clifford_algebra.star_def' CliffordAlgebra.star_def' @[simp] theorem star_ι (m : M) : star (ι Q m) = -ι Q m := by rw [star_def, involute_ι, map_neg, reverse_ι] #align clifford_algebra.star_ι CliffordAlgebra.star_ι @[simp] theorem star_smul (r : R) (x : CliffordAlgebra Q) : star (r • x) = r • star x := by rw [star_def, star_def, map_smul, map_smul] #align clifford_algebra.star_smul CliffordAlgebra.star_smul @[simp]
Mathlib/LinearAlgebra/CliffordAlgebra/Star.lean
62
64
theorem star_algebraMap (r : R) : star (algebraMap R (CliffordAlgebra Q) r) = algebraMap R (CliffordAlgebra Q) r := by
rw [star_def, involute.commutes, reverse.commutes]
250
import Mathlib.LinearAlgebra.CliffordAlgebra.Fold import Mathlib.LinearAlgebra.CliffordAlgebra.Grading #align_import linear_algebra.clifford_algebra.even from "leanprover-community/mathlib"@"9264b15ee696b7ca83f13c8ad67c83d6eb70b730" namespace CliffordAlgebra -- Porting note: explicit universes universe uR uM uA uB variable {R : Type uR} {M : Type uM} [CommRing R] [AddCommGroup M] [Module R M] variable {Q : QuadraticForm R M} -- put this after `Q` since we want to talk about morphisms from `CliffordAlgebra Q` to `A` and -- that order is more natural variable {A : Type uA} {B : Type uB} [Ring A] [Ring B] [Algebra R A] [Algebra R B] open scoped DirectSum variable (Q) def even : Subalgebra R (CliffordAlgebra Q) := (evenOdd Q 0).toSubalgebra (SetLike.one_mem_graded _) fun _x _y hx hy => add_zero (0 : ZMod 2) ▸ SetLike.mul_mem_graded hx hy #align clifford_algebra.even CliffordAlgebra.even -- Porting note: added, otherwise Lean can't find this when it needs it instance : AddCommMonoid (even Q) := AddSubmonoidClass.toAddCommMonoid _ @[simp] theorem even_toSubmodule : Subalgebra.toSubmodule (even Q) = evenOdd Q 0 := rfl #align clifford_algebra.even_to_submodule CliffordAlgebra.even_toSubmodule variable (A) @[ext] structure EvenHom : Type max uA uM where bilin : M →ₗ[R] M →ₗ[R] A contract (m : M) : bilin m m = algebraMap R A (Q m) contract_mid (m₁ m₂ m₃ : M) : bilin m₁ m₂ * bilin m₂ m₃ = Q m₂ • bilin m₁ m₃ #align clifford_algebra.even_hom CliffordAlgebra.EvenHom variable {A Q} @[simps] def EvenHom.compr₂ (g : EvenHom Q A) (f : A →ₐ[R] B) : EvenHom Q B where bilin := g.bilin.compr₂ f.toLinearMap contract _m := (f.congr_arg <| g.contract _).trans <| f.commutes _ contract_mid _m₁ _m₂ _m₃ := (f.map_mul _ _).symm.trans <| (f.congr_arg <| g.contract_mid _ _ _).trans <| f.map_smul _ _ #align clifford_algebra.even_hom.compr₂ CliffordAlgebra.EvenHom.compr₂ variable (Q) nonrec def even.ι : EvenHom Q (even Q) where bilin := LinearMap.mk₂ R (fun m₁ m₂ => ⟨ι Q m₁ * ι Q m₂, ι_mul_ι_mem_evenOdd_zero Q _ _⟩) (fun _ _ _ => by simp only [LinearMap.map_add, add_mul]; rfl) (fun _ _ _ => by simp only [LinearMap.map_smul, smul_mul_assoc]; rfl) (fun _ _ _ => by simp only [LinearMap.map_add, mul_add]; rfl) fun _ _ _ => by simp only [LinearMap.map_smul, mul_smul_comm]; rfl contract m := Subtype.ext <| ι_sq_scalar Q m contract_mid m₁ m₂ m₃ := Subtype.ext <| calc ι Q m₁ * ι Q m₂ * (ι Q m₂ * ι Q m₃) = ι Q m₁ * (ι Q m₂ * ι Q m₂ * ι Q m₃) := by simp only [mul_assoc] _ = Q m₂ • (ι Q m₁ * ι Q m₃) := by rw [Algebra.smul_def, ι_sq_scalar, Algebra.left_comm] #align clifford_algebra.even.ι CliffordAlgebra.even.ι instance : Inhabited (EvenHom Q (even Q)) := ⟨even.ι Q⟩ variable (f : EvenHom Q A) @[ext high]
Mathlib/LinearAlgebra/CliffordAlgebra/Even.lean
116
128
theorem even.algHom_ext ⦃f g : even Q →ₐ[R] A⦄ (h : (even.ι Q).compr₂ f = (even.ι Q).compr₂ g) : f = g := by
rw [EvenHom.ext_iff] at h ext ⟨x, hx⟩ induction x, hx using even_induction with | algebraMap r => exact (f.commutes r).trans (g.commutes r).symm | add x y hx hy ihx ihy => have := congr_arg₂ (· + ·) ihx ihy exact (f.map_add _ _).trans (this.trans <| (g.map_add _ _).symm) | ι_mul_ι_mul m₁ m₂ x hx ih => have := congr_arg₂ (· * ·) (LinearMap.congr_fun (LinearMap.congr_fun h m₁) m₂) ih exact (f.map_mul _ _).trans (this.trans <| (g.map_mul _ _).symm)
251
import Mathlib.LinearAlgebra.CliffordAlgebra.Conjugation import Mathlib.LinearAlgebra.CliffordAlgebra.Even import Mathlib.LinearAlgebra.QuadraticForm.Prod import Mathlib.Tactic.LiftLets #align_import linear_algebra.clifford_algebra.even_equiv from "leanprover-community/mathlib"@"2196ab363eb097c008d4497125e0dde23fb36db2" namespace CliffordAlgebra variable {R M : Type*} [CommRing R] [AddCommGroup M] [Module R M] variable (Q : QuadraticForm R M) namespace EquivEven abbrev Q' : QuadraticForm R (M × R) := Q.prod <| -@QuadraticForm.sq R _ set_option linter.uppercaseLean3 false in #align clifford_algebra.equiv_even.Q' CliffordAlgebra.EquivEven.Q' theorem Q'_apply (m : M × R) : Q' Q m = Q m.1 - m.2 * m.2 := (sub_eq_add_neg _ _).symm set_option linter.uppercaseLean3 false in #align clifford_algebra.equiv_even.Q'_apply CliffordAlgebra.EquivEven.Q'_apply def e0 : CliffordAlgebra (Q' Q) := ι (Q' Q) (0, 1) #align clifford_algebra.equiv_even.e0 CliffordAlgebra.EquivEven.e0 def v : M →ₗ[R] CliffordAlgebra (Q' Q) := ι (Q' Q) ∘ₗ LinearMap.inl _ _ _ #align clifford_algebra.equiv_even.v CliffordAlgebra.EquivEven.v
Mathlib/LinearAlgebra/CliffordAlgebra/EvenEquiv.lean
69
71
theorem ι_eq_v_add_smul_e0 (m : M) (r : R) : ι (Q' Q) (m, r) = v Q m + r • e0 Q := by
rw [e0, v, LinearMap.comp_apply, LinearMap.inl_apply, ← LinearMap.map_smul, Prod.smul_mk, smul_zero, smul_eq_mul, mul_one, ← LinearMap.map_add, Prod.mk_add_mk, zero_add, add_zero]
252