-- Natural powers in a bundled ring, written x ^ n: the recursion laws, -- additivity and multiplicativity of exponents, powers of one, and closure -- of the carrier under powers -- Part of Cumulus, the Grace17 mathematics library. -- Copyright (c) 2026 Grant Passmore. -- Released under the Apache License 2.0. See LICENSE in the repository root. -- Authors: Grant Passmore module Grace.Cumulus.Algebra.Ring.Pow import Basic import Group.Power -- The n-th power of x in R, the monoid power under the multiplication and -- one of R; written x ^ n wherever a hypothesis supplies the ring. The -- ring tactics read a power with a literal exponent as the product it -- abbreviates, so (x + y) ^ 2 = x ^ 2 + R[2] * x * y + y ^ 2 is closed by -- ring without unfolding. def Ring.pow (R x : Set, n : Nat) : Set := monoidPow(Ring.mul(R), Ring.one(R), x, n) notation infixr 80 "^" => Ring.pow(R, _, _) via hypothesis Ring(R) for R.carrier notation infixr 80 "^" => Ring.pow(R, _, _) via hypothesis CommRing(R) for R.carrier notation infixr 80 "^" => Ring.pow(R, _, _) via hypothesis Field(R) for R.carrier notation infixr 80 "^" => Ring.pow(R, _, _) via hypothesis OrderedField(R, lt) for R.carrier theorem Ring.pow.value (R x : Set, n : Nat) shows Ring.pow(R, x, n) = monoidPow(R.mul, R.one, x, n) proof simp [Ring.pow] section PowerLaws variable (R : Set) hypothesis ring : Ring(R) theorem Ring.pow_zero (x : R) shows x ^ 0 = R[1] proof simp [Ring.pow, monoidPow.zero] theorem Ring.pow_succ_left (x : R) (n : Nat) shows x ^ (n + 1) = x * x ^ n proof have monoid := IsRing.multiplicative with (Ring.parts with ring) have step := monoidPow.succ_left at R.carrier, R.mul, R.one, x, n with monoid, * simp [Ring.pow, step] theorem Ring.pow_succ (x : R) (n : Nat) shows x ^ (n + 1) = x ^ n * x proof have monoid := IsRing.multiplicative with (Ring.parts with ring) have step := monoidPow.succ_right at R.carrier, R.mul, R.one, x, n with monoid, * simp [Ring.pow, step] theorem Ring.pow_one (x : R) shows x ^ 1 = x proof have monoid := IsRing.multiplicative with (Ring.parts with ring) have one := monoidPow.one with monoid, * simp [Ring.pow, one] instance Ring.pow_mem (x : R) (n : Nat) shows x ^ n ∈ R proof have monoid := IsRing.multiplicative with (Ring.parts with ring) have closed := monoidPow.closed at R.carrier, R.mul, R.one, x, n with monoid, * simp [Ring.pow, closed] theorem Ring.pow_add (x : R) (m n : Nat) shows x ^ (m + n) = x ^ m * x ^ n proof have monoid := IsRing.multiplicative with (Ring.parts with ring) have split := monoidPow.add at R.carrier, R.mul, R.one, x, m, n with monoid, * simp [Ring.pow, split] theorem Ring.pow_mul (x : R) (m n : Nat) shows x ^ (m * n) = (x ^ m) ^ n proof have monoid := IsRing.multiplicative with (Ring.parts with ring) have split := monoidPow.mul at R.carrier, R.mul, R.one, x, m, n with monoid, * simp [Ring.pow, split] theorem Ring.one_pow (n : Nat) shows R[1] ^ n = R[1] proof have monoid := IsRing.multiplicative with (Ring.parts with ring) have power := monoidPow.unit at R.carrier, R.mul, R.one, n with monoid simp [Ring.pow, power] end PowerLaws