1-- Natural powers in a bundled ring, written x ^ n: the recursion laws,2-- additivity and multiplicativity of exponents, powers of one, and closure3-- of the carrier 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.Ring.Pow10import Basic11import Group.Power1213-- The n-th power of x in R, the monoid power under the multiplication and14-- one of R; written x ^ n wherever a hypothesis supplies the ring. The15-- ring tactics read a power with a literal exponent as the product it16-- abbreviates, so (x + y) ^ 2 = x ^ 2 + R[2] * x * y + y ^ 2 is closed by17-- ring without unfolding.18def Ring.pow (R x : Set, n : Nat) : Set:=19 monoidPow(Ring.mul(R), Ring.one(R), x, n)2021notationinfixr80"^"=> Ring.pow(R, _, _) viahypothesis Ring(R) for R.carrier22notationinfixr80"^"=> Ring.pow(R, _, _) viahypothesis CommRing(R) for R.carrier23notationinfixr80"^"=> Ring.pow(R, _, _) viahypothesis Field(R) for R.carrier24notationinfixr80"^"=> Ring.pow(R, _, _) viahypothesis OrderedField(R, lt) for R.carrier2526theorem Ring.pow.value (R x : Set, n : Nat)27shows Ring.pow(R, x, n) = monoidPow(R.mul, R.one, x, n)28proof29simp [Ring.pow]3031section PowerLaws32variable (R : Set)33hypothesisring : Ring(R)3435theorem Ring.pow_zero (x : R)36shows x ^ 0= R[1]37proof38simp [Ring.pow, monoidPow.zero]3940theorem Ring.pow_succ_left (x : R) (n : Nat)41shows x ^ (n +1) = x * x ^ n42proof43have monoid := IsRing.multiplicative with (Ring.parts withring)44have step := monoidPow.succ_left at R.carrier, R.mul, R.one, x, n45with monoid, *46simp [Ring.pow, step]4748theorem Ring.pow_succ (x : R) (n : Nat)49shows x ^ (n +1) = x ^ n * x50proof51have monoid := IsRing.multiplicative with (Ring.parts withring)52have step := monoidPow.succ_right at R.carrier, R.mul, R.one, x, n53with monoid, *54simp [Ring.pow, step]5556theorem Ring.pow_one (x : R)57shows x ^ 1= x58proof59have monoid := IsRing.multiplicative with (Ring.parts withring)60have one := monoidPow.one with monoid, *61simp [Ring.pow, one]6263instance Ring.pow_mem (x : R) (n : Nat)64shows x ^ n ∈ R65proof66have monoid := IsRing.multiplicative with (Ring.parts withring)67have closed := monoidPow.closed at R.carrier, R.mul, R.one, x, n68with monoid, *69simp [Ring.pow, closed]7071theorem Ring.pow_add (x : R) (m n : Nat)72shows x ^ (m + n) = x ^ m * x ^ n73proof74have monoid := IsRing.multiplicative with (Ring.parts withring)75havesplit:= monoidPow.add at R.carrier, R.mul, R.one, x, m, n with monoid, *76simp [Ring.pow, split]7778theorem Ring.pow_mul (x : R) (m n : Nat)79shows x ^ (m * n) = (x ^ m) ^ n80proof81have monoid := IsRing.multiplicative with (Ring.parts withring)82havesplit:= monoidPow.mul at R.carrier, R.mul, R.one, x, m, n with monoid, *83simp [Ring.pow, split]8485theorem Ring.one_pow (n : Nat)86shows R[1] ^ n = R[1]87proof88have monoid := IsRing.multiplicative with (Ring.parts withring)89have power := monoidPow.unit at R.carrier, R.mul, R.one, n with monoid90simp [Ring.pow, power]9192end PowerLaws93