Skip to content

Commit 60034e9

Browse files
yury-harmonicFormulaRabbit81
authored andcommitted
feat(OrderOfElement): add lemmas like orderOf 0 = 0 (leanprover-community#28886)
Co-authored-by: Yury Kudryashov <162619279+yury-harmonic@users.noreply.github.com>
1 parent aa9e284 commit 60034e9

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

Mathlib/GroupTheory/OrderOfElement.lean

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,12 @@ theorem orderOf_eq_zero_iff' : orderOf x = 0 ↔ ∀ n : ℕ, 0 < n → x ^ n
199199
@[to_additive]
200200
lemma orderOf_ne_zero_iff : orderOf x ≠ 0 ↔ IsOfFinOrder x := orderOf_eq_zero_iff.not_left
201201

202+
/-- In a nontrivial monoid with zero, the order of the zero element is zero. -/
203+
@[simp]
204+
lemma orderOf_zero (M₀ : Type*) [MonoidWithZero M₀] [Nontrivial M₀] : orderOf (0 : M₀) = 0 := by
205+
rw [orderOf_eq_zero_iff, isOfFinOrder_iff_pow_eq_one]
206+
simp +contextual [ne_of_gt]
207+
202208
@[to_additive]
203209
theorem orderOf_eq_iff {n} (h : 0 < n) :
204210
orderOf x = n ↔ x ^ n = 1 ∧ ∀ m, m < n → 0 < m → x ^ m ≠ 1 := by
@@ -344,10 +350,14 @@ theorem Function.Injective.isOfFinOrder_iff [Monoid H] {f : G →* H} (hf : Inje
344350
theorem orderOf_submonoid {H : Submonoid G} (y : H) : orderOf (y : G) = orderOf y :=
345351
orderOf_injective H.subtype Subtype.coe_injective y
346352

347-
@[to_additive]
353+
@[to_additive (attr := norm_cast)]
348354
theorem orderOf_units {y : Gˣ} : orderOf (y : G) = orderOf y :=
349355
orderOf_injective (Units.coeHom G) Units.val_injective y
350356

357+
@[to_additive (attr := norm_cast)]
358+
theorem Units.isOfFinOrder_val {u : Gˣ} : IsOfFinOrder (u : G) ↔ IsOfFinOrder u :=
359+
Units.coeHom_injective.isOfFinOrder_iff
360+
351361
/-- If the order of `x` is finite, then `x` is a unit with inverse `x ^ (orderOf x - 1)`. -/
352362
@[to_additive (attr := simps) /-- If the additive order of `x` is finite, then `x` is an additive
353363
unit with inverse `(addOrderOf x - 1) • x`. -/]
@@ -834,6 +844,21 @@ lemma orderOf_eq_card_powers : orderOf x = Fintype.card (powers x : Submonoid G)
834844

835845
end FiniteCancelMonoid
836846

847+
lemma isOfFinOrder_iff_isUnit [Monoid G] [Finite Gˣ] {x : G} : IsOfFinOrder x ↔ IsUnit x := by
848+
use IsOfFinOrder.isUnit
849+
rintro ⟨u, rfl⟩
850+
rw [Units.isOfFinOrder_val]
851+
apply isOfFinOrder_of_finite
852+
853+
alias ⟨_, IsUnit.isOfFinOrder⟩ := isOfFinOrder_iff_isUnit
854+
855+
lemma orderOf_eq_zero_iff_eq_zero {G₀ : Type*} [GroupWithZero G₀] [Finite G₀] {a : G₀} :
856+
orderOf a = 0 ↔ a = 0 := by
857+
-- Prove an instance inline to avoid extra imports.
858+
-- TODO: move this instance elsewhere?
859+
have : Finite G₀ˣ := .of_injective _ Units.val_injective
860+
simp [isOfFinOrder_iff_isUnit]
861+
837862
section FiniteGroup
838863
variable [Group G] {x y : G}
839864

0 commit comments

Comments
 (0)