That works fairly well— But, in general, the left argument can be far simpler. All of the power operations only assume, on the left, the existence of a single binary operator (semigroup, monoid, group,...); they don't require two (semiring, ring, field,...). This means the Haskell types are far too stringent in requiring Num (~= ring) or Fractional (~= field). Mathematically, these operators should have the types (equivalent to):
(^) :: (Monoid m, Semiring s) => m -> s -> m
(^^) :: (Group m, Ring s) => m -> s -> m
Where the natural numbers with addition and multiplication are the most salient commutative semiring, and the integers with addition/subtraction and multiplication are the most salient commutative ring. The presumed Ring and Semiring classes need not be commutative, though commutativity is required to validate the (a^x)^y = (a^y)^x law.
The reason I think it's important to really drive this point home is because the whole idea of powers extends to other monoids besides just multiplication. For instance, consider Presberger arithmetic: the natural numbers with addition only. In PA we get a weak notion of "multiplication", which is specifically the one that arises from addition-powers. The fact that it's an addition-power rather than true multiplication captures much about its weakness. For another example, we often talk about tensor-powers: the notion of powers that arise from the tensor product. For yet another, we often use notation like f^n(x) to mean that we should iterate the function some number of times. Naturally, endomorphisms should use (^) whereas automorphisms can use (^^).
no subject
Date: 2013-07-22 09:43 pm (UTC)From:That works fairly well— But, in general, the left argument can be far simpler. All of the power operations only assume, on the left, the existence of a single binary operator (semigroup, monoid, group,...); they don't require two (semiring, ring, field,...). This means the Haskell types are far too stringent in requiring
Num
(~= ring) orFractional
(~= field). Mathematically, these operators should have the types (equivalent to):Where the natural numbers with addition and multiplication are the most salient commutative semiring, and the integers with addition/subtraction and multiplication are the most salient commutative ring. The presumed
Ring
andSemiring
classes need not be commutative, though commutativity is required to validate the(a^x)^y = (a^y)^x
law.The reason I think it's important to really drive this point home is because the whole idea of powers extends to other monoids besides just multiplication. For instance, consider Presberger arithmetic: the natural numbers with addition only. In PA we get a weak notion of "multiplication", which is specifically the one that arises from addition-powers. The fact that it's an addition-power rather than true multiplication captures much about its weakness. For another example, we often talk about tensor-powers: the notion of powers that arise from the tensor product. For yet another, we often use notation like
f^n(x)
to mean that we should iterate the function some number of times. Naturally, endomorphisms should use(^)
whereas automorphisms can use(^^)
.