1-- Natural powers in a bundled group, written x ^ n: the recursion laws,2-- additivity and multiplicativity of exponents, powers of the unit and of3-- inverses, and closure of subgroups under powers4-- Part of Cumulus, the Grace17 mathematics library.5-- Copyright (c) 2026 Grant Passmore.6-- Released under the Apache License 2.0. See LICENSE in the repository root.7-- Authors: Grant Passmore89module Grace.Cumulus.Algebra.Group.Pow10import Subgroup11import Power1213-- The n-th power of x in G, the monoid power under the operation and unit14-- of G; written x ^ n wherever a hypothesis supplies the group.15def groupPow (G x : Set, n : Nat) : Set:= monoidPow(G.mul, G.one, x, n)1617notationinfixr80"^"=> groupPow(G, _, _) viahypothesis Group(G) for G.carrier18notationinfixr80"^"=> groupPow(G, _, _) viahypothesis AbelianGroup(G) for G.carrier19notationinfixr80"^"=> groupPow(G, _, _) viahypothesis Subgroup(H, G) for H2021theorem groupPow.value (G x : Set, n : Nat)22shows groupPow(G, x, n) = monoidPow(G.mul, G.one, x, n)23proof24simp [groupPow]2526section PowerLaws27variable (G : Set)28hypothesis group : Group(G)2930theorem pow_zero (x : G)31shows x ^ 0= G.one32proof33simp [groupPow, monoidPow.zero]3435theorem pow_succ_left (x : G) (n : Nat)36shows x ^ (n +1) = x * x ^ n37proof38have monoid := IsGroup.monoid with (Group.parts with group)39have step := monoidPow.succ_left at G.carrier, G.mul, G.one, x, n with monoid, *40simp [groupPow, step]4142theorem pow_succ (x : G) (n : Nat)43shows x ^ (n +1) = x ^ n * x44proof45have monoid := IsGroup.monoid with (Group.parts with group)46have step := monoidPow.succ_right at G.carrier, G.mul, G.one, x, n with monoid, *47simp [groupPow, step]4849theorem pow_one (x : G)50shows x ^ 1= x51proof52have monoid := IsGroup.monoid with (Group.parts with group)53have one := monoidPow.one with monoid, *54simp [groupPow, one]5556instance Group.pow_mem (x : G) (n : Nat)57shows x ^ n ∈ G58proof59have monoid := IsGroup.monoid with (Group.parts with group)60have closed := monoidPow.closed at G.carrier, G.mul, G.one, x, n with monoid, *61simp [groupPow, closed]6263theorem pow_add (x : G) (m n : Nat)64shows x ^ (m + n) = x ^ m * x ^ n65proof66have monoid := IsGroup.monoid with (Group.parts with group)67havesplit:= monoidPow.add at G.carrier, G.mul, G.one, x, m, n with monoid, *68simp [groupPow, split]6970theorem pow_mul (x : G) (m n : Nat)71shows x ^ (m * n) = (x ^ m) ^ n72proof73have monoid := IsGroup.monoid with (Group.parts with group)74havesplit:= monoidPow.mul at G.carrier, G.mul, G.one, x, m, n with monoid, *75simp [groupPow, split]7677theorem one_pow (n : Nat)78shows G.one ^ n = G.one79proof80have monoid := IsGroup.monoid with (Group.parts with group)81have power := monoidPow.unit at G.carrier, G.mul, G.one, n with monoid82simp [groupPow, power]8384theorem pow_mul_comm (x : G) (m n : Nat)85shows x ^ m * x ^ n = x ^ n * x ^ m86proof87have monoid := IsGroup.monoid with (Group.parts with group)88have swap := monoidPow.add_commute at G.carrier, G.mul, G.one, x, m, n with monoid, *89simp [groupPow, swap]9091theorem pow_mul_self_comm (x : G) (n : Nat)92shows x * x ^ n = x ^ n * x93proof94have monoid := IsGroup.monoid with (Group.parts with group)95have swap := monoidPow.commute at G.carrier, G.mul, G.one, x, n with monoid, *96simp [groupPow, swap]9798theorem inv_pow (x : G) (n : Nat)99shows x⁻¹ ^ n = (x ^ n)⁻¹100proof101induction n102| zero =>103rw [pow_zero, pow_zero, inv_one]104rfl105| succ(k) using ih =>106have step : x⁻¹ ^ (k +1) = x⁻¹ ^ k * x⁻¹ := pow_succ with*107have stepX : x ^ (k +1) = x * x ^ k := pow_succ_left with*108rw [← add.right_one, step, stepX, ih, mul_inv_rev]109rfl110111-- The power that completes a vanishing product is the inverse power.112theorem pow_eq_inv_pow_of_pow_add (x : G) (m n : Nat)113requires vanishes : x ^ (m + n) = G.one114shows x ^ n = (x ^ m)⁻¹115proof116havesplit : x ^ (m + n) = x ^ m * x ^ n := pow_add with*117have product : x ^ m * x ^ n = G.one bycc118exact eq_inv_of_mul_eq_one_right with*119120end PowerLaws121122section SubgroupPowers123variable (G H : Set)124hypothesis subgroup : Subgroup(H, G)125126instance Subgroup.pow_mem (h : H) (n : Nat)127shows h ^ n ∈ H128proof129have group := Subgroup.group with subgroup130induction n131| zero =>132have zero : h ^ 0= G.one := pow_zero with*133rw zero134exact Subgroup.one_mem with*135| succ(k) using ih =>136have step : h ^ (k +1) = h ^ k * h := pow_succ with*137rw [← add.right_one, step]138exact Subgroup.mul_mem with*139140end SubgroupPowers141