@@ -199,6 +199,12 @@ theorem orderOf_eq_zero_iff' : orderOf x = 0 ↔ ∀ n : ℕ, 0 < n → x ^ n
199199@[to_additive]
200200lemma 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]
203209theorem 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
344350theorem 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) ]
348354theorem 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
353363unit with inverse `(addOrderOf x - 1) • x`. -/ ]
@@ -834,6 +844,21 @@ lemma orderOf_eq_card_powers : orderOf x = Fintype.card (powers x : Submonoid G)
834844
835845end 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+
837862section FiniteGroup
838863variable [Group G] {x y : G}
839864
0 commit comments