Expand description
Fundamental algebraic structures.
|(• ◡•)|ノ〵(❍ᴥ❍⋃) - "ALGEBRAIC!!!"
For most applications requiring an abstraction over the reals, FieldApprox
should be sufficient.
§Fundamental algebraic structures
Most of these traits also come in an approximate flavor for types that do not satisfy the required properties exactly, but would still benefit from abstractions over the structure in question.
§Algebraic properties
The goal of algebraic structures is to allow elements of sets to be combined together using one
or several operators. The number and properties of those operators characterize the algebraic
structure. Abstract operators are usually noted ∘
, +
, or ×
. The last two are preferred
when their behavior conform with the usual meaning of addition and multiplication of reals.
Let Self
be a set. Here is a list of the most common properties those operator may fulfill:
(Closure) a, b ∈ Self ⇒ a ∘ b ∈ Self,
(Divisibility) ∀ a, b ∈ Self, ∃! r, l ∈ Self such that l ∘ a = b and a ∘ r = b
(Invertibility) ∃ e ∈ Self, ∀ a ∈ Self, ∃ r, l ∈ Self such that l ∘ a = a ∘ r = e
If the right and left inverse are equal they are usually noted r = l = a⁻¹.
(Associativity) ∀ a, b, c ∈ Self, (a ∘ b) ∘ c = a ∘ (b ∘ c)
(Neutral Elt.) ∃ e ∈ Self, ∀ a ∈ Self, e ∘ a = a ∘ e = a
(Commutativity) ∀ a, b ∈ Self, a ∘ b = b ∘ a
When one works with inexact arithmetic, e.g. using floating point numbers, those properties cannot possibly be satisfied due to the discrete nature of our computing tools. Thus a looser, approximate, version is available. Note that fulfilling a property listed above implies that its approximate version is fulfilled as well.
(Approx. Closure) a, b ∈ Self ⇒ ∃ c ≈ a ∘ b such that c ∈ Self,
(Approx. Div.) ∀ a, b ∈ Self, ∃ r, l ∈ Self such that l ∘ a ≈ b and a ∘ r ≈ b
(Approx. Inv.) ∃ e ∈ Self, ∀ a ∈ Self, ∃ r, l ∈ Self such that l ∘ a ≈ e and a ∘ r ≈ e
(Approx. Assoc.) ∀ a, b, c ∈ Self, (a ∘ b) ∘ c ≈ a ∘ (b ∘ c)
(Approx. Neutr.) ∃ e ∈ Self, ∀ a ∈ Self, e ∘ a ≈ a and a ∘ e ≈ a
(Approx. Commut.) ∀ a, b ∈ Self, a ∘ b ≈ b ∘ a
§Identity elements
Two traits are provided that allow the definition of the additive and multiplicative identity elements:
IdentityAdditive
IdentityMultiplicative
§Group-like structures
These structures are provided for both the addition and multiplication.
Magma
|
_______/ \______
/ \
divisibility associativity
| |
V V
Quasigroup Semigroup
| |
identity identity
| |
V V
Loop Monoid
| |
associativity invertibility
\______ _______/
\ /
|
V
Group
|
commutativity
|
V
AbelianGroup
The following traits are provided:
-
`Closure`(`Additive`|`Multiplicative`)(`Approx`)?
-
`Magma`(`Additive`|`Multiplicative`)(`Approx`)?
Quasigroup
(Additive
|Multiplicative
)(Approx
)?-
`Loop`(`Additive`|`Multiplicative`)(`Approx`)?
Semigroup
(Additive
|Multiplicative
)(Approx
)?-
`Monoid`(`Additive`|`Multiplicative`)(`Approx`)?
-
`Group`(`Additive`|`Multiplicative`)(`Approx`)?
AbelianGroup
(Additive
|Multiplicative
)(Approx
)?
§Ring-like structures
GroupAdditiveAbelian MonoidMultiplicative
\________ ________/
\ /
|
V
Ring
|
commutativity_of_mul
|
V
RingCommutative GroupMultiplicativeAbelian
\_______ ___________/
\ /
|
V
Field
The following traits are provided:
-
`Ring`(`Approx`)?
RingCommutative
(Approx
)?-
`Field`(`Approx`)?
§Module-like structures
GroupAdditiveAbelian RingCommutative
\______ _____/
\ /
| |
V V
Module<Scalar> Field
\______ _____/
\ /
| |
V V
VectorSpace<Scalar>
The following traits are provided:
Module
(Approx
)?VectorSpace
(Approx
)?
§Quickcheck properties
Functions are provided to test that algebraic properties like assciociativity and commutativity hold for a given set of arguments.
For example:
#[quickcheck]
fn prop_mul_is_associative_approx(args: (i32, i32, i32)) -> bool {
SemigroupMultiplicativeApprox::prop_mul_is_associative_approx(args)
}
Traits§
- Field
- A field is a commutative ring, and an abelian group under the multiplication operator.
- Field
Approx - An approximate field is an approx. commutative ring, and an approx. abelian group under the multiplication operator.
- Group
- A group is a loop and a monoid at the same time.
- Group
Abelian - A commutative group.
- Group
Abelian Approx - An approximately commutative group.
- Group
Approx - An approximate group is an approx. loop and an approx. monoid simultaneously.
- Loop
- A quasigroup with an unique identity element.
- Loop
Approx - An approximate quasigroup with an unique identity element.
- Magma
- Types that are closed under a given operator.
- Magma
Approx - Types that are approximately closed under a given operator.
- Module
- A module combines two sets: one with an additive abelian group structure and another with a commutative ring structure.
- Module
Approx - A module with approximate operators.
- Monoid
- A semigroup equipped with an identity element.
- Monoid
Approx - An approximate semigroup equipped with an identity element.
- Quasigroup
- A magma with the divisibility property.
- Quasigroup
Approx - A magma with the approximate divisibility property.
- Ring
- A ring is the combination of an abelian group and a multiplicative monoid structure.
- Ring
Approx - An approximate ring is given the approximate version of the ring’s properties.
- Ring
Commutative - An ring with a commutative multiplication.
- Ring
Commutative Approx - An approximative ring with an approximately commutative multiplication.
- Semigroup
- An associative magma.
- Semigroup
Approx - An approximately associative magma.
- Vector
Space - A vector space has a module structure over a field instead of a ring.
- Vector
Space Approx - A approximate vector space has an approx. module structure over an approx. field.