An abelian group is a group whose operation is commutative.
A semigroup/monoid/group action of G on P is the combination of compatible
left and right actions, providing:
A boolean algebra is a structure that defines a few basic operations, namely as conjunction (&), disjunction (|), and negation (~).
A boolean algebra is a structure that defines a few basic operations, namely
as conjunction (&), disjunction (|), and negation (~). Both conjunction and
disjunction must be associative, commutative and should distribute over each
other. Also, both have an identity and they obey the absorption law; that
is x & (y | x) == x and x | (x & y) == x.
CMonoid represents a commutative monoid.
CMonoid represents a commutative monoid.
A monoid is commutative if for all x and y, x |+| y === y |+| x.
CRig is a Rig that is commutative under multiplication.
CRing is a Ring that is commutative under multiplication.
CSemigroup represents a commutative semigroup.
CSemigroup represents a commutative semigroup.
A semigroup is commutative if for all x and y, x |+| y === y |+| x.
A type class used to determine equality between 2 instances of the same type.
A type class used to determine equality between 2 instances of the same
type. Any 2 instances x and y are equal if eqv(x, y) is true.
Moreover, eqv should form an equivalence relation.
A FieldAlgebra is a vector space that is also a Ring.
A FieldAlgebra is a vector space that is also a Ring. An example is the
complex numbers.
A group is a monoid where each element has an inverse.
A simple type class for numeric types that are a subset of the reals.
A (left) semigroup/monoid/group action of G on P is simply the implementation of
a method actl(g, p), or g |+|> p, such that:
A (left) semigroup/monoid/group action of G on P is simply the implementation of
a method actl(g, p), or g |+|> p, such that:
1. (g |+| h) |+|> p === g |+|> (h |+|> p) for all g, h in G and p in P.
2. id |+|> p === p for all p in P (if id is defined)
This type class models a metric space V.
This type class models a metric space V. The distance between 2 points in
V is measured in R, which should be real (ie. IsReal[R] exists).
A module generalizes a vector space by requiring its scalar need only form a ring, rather than a field.
A monoid is a semigroup with an identity.
A monoid is a semigroup with an identity. A monoid is a specialization of a
semigroup, so its operation must be associative. Additionally,
op(x, id) == op(id, x) == x. For example, if we have Monoid[String],
with op as string concatenation, then id = "".
This is a type class for types with n-roots.
This is a type class for types with n-roots. The value returned by nroot
and sqrt are only guaranteed to be approximate answers (except in the case
of Real).
Also, generally nroots where n is even are not defined for
negative numbers. The behaviour is undefined if this is attempted. It would
be nice to ensure an exception is raised, but some types may defer
computation and testing if a value is negative may not be ideal. So, do not
count on ArithmeticExceptions to save you from bad arithmetic!
A normed vector space is a vector space equipped with a function
norm: V => F.
A normed vector space is a vector space equipped with a function
norm: V => F. The main constraint is that the norm of a vector must be
scaled linearly when the vector is scaled; that is
norm(k *: v) == k.abs * norm(v). Additionally, a normed vector space is
also a MetricSpace, where distance(v, w) = norm(v - w), and so must
obey the triangle inequality.
An example of a normed vector space is R^n equipped with the euclidean vector length as the norm.
The Order type class is used to define a total ordering on some type A.
The Order type class is used to define a total ordering on some type A.
An order is defined by a relation <=, which obeys the following laws:
- either x <= y or y <= x (totality) - if x <= y and y <= x, then x == y (antisymmetry) - if x <= y and y <= z, then x <= z (transitivity)
The truth table for compare is defined as follows:
x <= y x >= y Int true true = 0 (corresponds to x == y) true false < 0 (corresponds to x < y) false true > 0 (corresponds to x > y)
By the totality law, x <= y and y <= x cannot be both false.
The PartialOrder type class is used to define a partial ordering on some type A.
The PartialOrder type class is used to define a partial ordering on some type A.
A partial order is defined by a relation <=, which obeys the following laws:
- x <= x (reflexivity) - if x <= y and y <= x, then x === y (anti-symmetry) - if x <= y and y <= z, then x <= z (transitivity)
To compute both <= and >= at the same time, we use a Double number to encode the result of the comparisons x <= y and x >= y. The truth table is defined as follows:
x <= y x >= y Double true true = 0.0 (corresponds to x === y) false false = NaN (x and y cannot be compared) true false = -1.0 (corresponds to x < y) false true = 1.0 (corresponds to x > y)
Rig is a ring whose additive structure doesn't have an inverse (ie.
Rig is a ring whose additive structure doesn't have an inverse (ie. it is monoid, not a group). Put another way, a Rig is a Ring without a negative.
A (right) semigroup/monoid/group action of G on P is simply the implementation of
a method actr(p, g), or p <|+| g, such that:
A (right) semigroup/monoid/group action of G on P is simply the implementation of
a method actr(p, g), or p <|+| g, such that:
1. p <|+| (g |+| h) === (p <|+| g) <|+| h for all g, h in G and p in P.
2. p <|+| id === p for all p in P (if id is defined)
Ring represents a set (A) that is a group over addition (+) and a monoid over multiplication (*).
Ring represents a set (A) that is a group over addition (+) and a monoid over multiplication (*). Aside from this, the multiplication must distribute over addition.
Ring implements some methods (for example fromInt) in terms of other more fundamental methods (zero, one and plus). Where possible, these methods should be overridden by more efficient implementations.
A RingAlgebra is a module that is also a Rng.
A RingAlgebra is a module that is also a Rng. An example is the Gaussian
numbers.
Rng is a ring whose multiplicative structure doesn't have an identity (i.e.
Rng is a ring whose multiplicative structure doesn't have an identity (i.e. it is semigroup, not a monoid). Put another way, a Rng is a Ring without an identity.
A semigroup is any set A with an associative operation (op).
Semiring is a ring without identities or an inverse.
Semiring is a ring without identities or an inverse. Thus, it has no negation, zero, or one.
A Semiring with an additive inverse (-) is a Rng. A Semiring with additive and multiplicative identities (0 and 1) is a Rig. A Semiring with all of the above is a Ring.
A simple ADT representing the Sign of an object.
A trait for things that have some notion of sign and the ability to ensure something has a positive sign.
A Torsor[V, R] requires an AbGroup[R] and provides Action[V, R],
plus a diff operator, <-> in additive notation, such that:
A Torsor[V, R] requires an AbGroup[R] and provides Action[V, R],
plus a diff operator, <-> in additive notation, such that:
1. (g <-> g) === scalar.id for all g in G.
2. (g <-> h) +> h === g for all g, h in G.
3. (g <-> h) +> i === (i <-> h) +> g for all g, h in G.
4. (g <-> h) === -(h <-> g) for all g, h in G.
A vector space is a group V that can be multiplied by scalars in F that
lie in a field.
A vector space is a group V that can be multiplied by scalars in F that
lie in a field. Scalar multiplication must distribute over vector addition
(x *: (v + w) === x *: v + x *: w) and scalar addition
((x + y) *: v === x *: v + y *: v). Scalar multiplication by 1 in F
is an identity function (1 *: v === v). Scalar multiplication is
"associative" (x *: y *: v === (x * y) *: v).
Given any Ring[A] we can construct a RingAlgebra[A, Int].
Given any Ring[A] we can construct a RingAlgebra[A, Int]. This is
possible since we can define fromInt on Ring generally.
A semigroup/monoid/group action of
GonPis the combination of compatible left and right actions, providing:actl(g, p), org |+|> p, such that:1.
(g |+| h) |+|> p === g |+|> (h |+|> p)for allg,hinGandpinP.2.
id |+|> p === pfor allpinP(ifidis defined)actr(p, g), orp <|+| g, such that:3.
p <|+| (g |+| h) === (p <|+| g) <|+| hfor allg,hinGandpinP.4.
p <|+| id === pfor allpinP(ifidis defined)In addition, if
Gis a group, left and right actions are compatible:5.
g |+|> p === p <|+| g.inverse.