{-# OPTIONS --cubical --safe #-}
module CantorNormalForm.Exponentiation where
open import CantorNormalForm.Base
open import CantorNormalForm.Addition
open import CantorNormalForm.Subtraction
open import CantorNormalForm.Multiplication
infixl 37 _^_
_^_ : Cnf โ Cnf โ Cnf
a ^ ๐ = ๐
๐ ^ (ฯ^ b + d [ _ ]) = ๐
(ฯ^ ๐ + ๐ [ _ ]) ^ (ฯ^ b + d [ _ ]) = ๐
a ^ (ฯ^ ๐ + d [ _ ]) = a ยท a ^ d
a@(ฯ^ ๐ + _ [ _ ]) ^ (ฯ^ (ฯ^ ๐ + ๐ [ _ ]) + d [ _ ]) = ฯ^โจ ๐ โฉ ยท a ^ d
a@(ฯ^ ๐ + _ [ _ ]) ^ (ฯ^ b + d [ _ ]) = ฯ^โจ b - ๐ โฉ ยท a ^ d
a@(ฯ^ u + _ [ _ ]) ^ (ฯ^ b + d [ _ ]) = ฯ^โจ u ยท ฯ^โจ b โฉ โฉ ยท a ^ d