[][src]Module alga::general

Fundamental algebraic structures.

For most applications requiring an abstraction over the reals, Real should be sufficient.

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

Identity elements

Two traits are provided that allow the definition of the additive and multiplicative identity elements:

AbstractGroup-like structures

These structures are provided for both the addition and multiplication.

These can be derived automatically by alga_traits attribute from alga_derive crate.

           AbstractMagma
                |
        _______/ \______
       /                \
 divisibility       associativity
      |                  |
      V                  V
AbstractQuasigroup AbstractSemigroup
      |                  |
  identity            identity
      |                  |
      V                  V
 AbstractLoop       AbstractMonoid
      |                  |
 associativity     invertibility
       \______   _______/
              \ /
               |
               V
         AbstractGroup
               |
         commutativity
               |
               V
     AbstractGroupAbelian

The following traits are provided:

Ring-like structures

These can be derived automatically by alga_traits attribute from alga_derive crate.

     GroupAbelian           Monoid
          \________   ________/
                   \ /
                    |
                    V
                   Ring
                    |
           commutativity_of_mul
                    |
                    V
             RingCommutative           GroupAbelian
                     \_______   ___________/
                             \ /
                              |
                              V
                            Field

The following traits are provided:

Module-like structures

    GroupAbelian         RingCommutative
          \______         _____/
                 \       /
                  |     |
                  V     V
               Module<Scalar>          Field
                   \______         _____/
                          \       /
                           |     |
                           V     V
                     VectorSpace<Scalar>

The following traits are provided:

Quickcheck properties

Functions are provided to test that algebraic properties like associativity and commutativity hold for a given set of arguments.

These tests can be automatically derived by alga_quickcheck attribute from alga_derive crate.

For example:

This example is not tested
use algebra::general::SemigroupMultiplicative;

quickcheck! {
    fn prop_mul_is_associative(args: (i32, i32, i32)) -> bool {
        SemigroupMultiplicative::prop_mul_is_associative(args)
    }
}

Structs

Additive

The addition operator, commonly symbolized by +.

Id

The universal identity element wrt. a given operator, usually noted Id with a context-dependent subscript.

Multiplicative

The multiplication operator, commonly symbolized by ×.

Traits

AbstractField

A field is a commutative ring, and an abelian group under both operators.

AbstractGroup

A group is a loop and a monoid at the same time.

AbstractGroupAbelian

An commutative group.

AbstractLoop

A quasigroup with an unique identity element.

AbstractMagma

Types that are closed under a given operator.

AbstractModule

A module combines two sets: one with an abelian group structure and another with a commutative ring structure.

AbstractMonoid

A semigroup equipped with an identity element.

AbstractQuasigroup

A magma with the divisibility property.

AbstractRing

A ring is the combination of an abelian group and a multiplicative monoid structure.

AbstractRingCommutative

A ring with a commutative multiplication.

AbstractSemigroup

An associative magma.

AdditiveGroup

[Alias] Algebraic structure specialized for one kind of operation.

AdditiveGroupAbelian

[Alias] Algebraic structure specialized for one kind of operation.

AdditiveLoop

[Alias] Algebraic structure specialized for one kind of operation.

AdditiveMagma

[Alias] Algebraic structure specialized for one kind of operation.

AdditiveMonoid

[Alias] Algebraic structure specialized for one kind of operation.

AdditiveQuasigroup

[Alias] Algebraic structure specialized for one kind of operation.

AdditiveSemigroup

[Alias] Algebraic structure specialized for one kind of operation.

ClosedAdd

[Alias] Trait alias for Add and AddAsign with result of type Self.

ClosedDiv

[Alias] Trait alias for Div and DivAsign with result of type Self.

ClosedMul

[Alias] Trait alias for Mul and MulAsign with result of type Self.

ClosedNeg

[Alias] Trait alias for Neg with result of type Self.

ClosedSub

[Alias] Trait alias for Sub and SubAsign with result of type Self.

Field

[Alias] Algebraic structure specialized for one kind of operation.

Identity

A type that is equipped with identity.

Inverse

Trait used to define the inverse element relative to the given operator.

JoinSemilattice

A set where every two elements have a suppremum (i.e. smallest upper bound).

Lattice

Partially orderable sets where every two elements have a suppremum and infimum.

MeetSemilattice

A set where every two elements have an infimum (i.e. greatest lower bound).

Module

A module which overloads the * and + operators.

MultiplicativeGroup

[Alias] Algebraic structure specialized for one kind of operation.

MultiplicativeGroupAbelian

[Alias] Algebraic structure specialized for one kind of operation.

MultiplicativeLoop

[Alias] Algebraic structure specialized for one kind of operation.

MultiplicativeMagma

[Alias] Algebraic structure specialized for one kind of operation.

MultiplicativeMonoid

[Alias] Algebraic structure specialized for one kind of operation.

MultiplicativeQuasigroup

[Alias] Algebraic structure specialized for one kind of operation.

MultiplicativeSemigroup

[Alias] Algebraic structure specialized for one kind of operation.

Operator

Trait implemented by types representing abstract operators.

Real

Trait shared by all reals.

Ring

[Alias] Algebraic structure specialized for one kind of operation.

RingCommutative

[Alias] Algebraic structure specialized for one kind of operation.

SubsetOf

Nested sets and conversions between them (using an injective mapping). Useful to work with substructures. In generic code, it is preferable to use SupersetOf as trait bound whenever possible instead of SubsetOf (because SupersetOf is automatically implemented whenever SubsetOf is).

SupersetOf

Nested sets and conversions between them. Useful to work with substructures. It is preferable to implement the SupersetOf trait instead of SubsetOf whenever possible (because SupersetOf is automatically implemented whenever SubsetOf is.