un_algebra
Simple Rust implementations of selected abstract algebraic structures.
Synopsis
Mathematical abstract algebra is built on a rich collection of algebraic structures. Learning about these structures can give non-mathematicians insights into the mathematical entities they need to work with--for example, real numbers, complex numbers, vectors, matrices, and permutations. By definition, these structures must comply with sets of axioms and properties, which are in turn a rich source of properties for generative testing.
un_algebra
(_un_derstanding _algebra_) is a simple
implementation of selected algebraic structures in Rust. I hope it
is useful for developers learning abstract algebra concepts for the
first time. Currently this crate provides magma, semigroup,
quasigroup, monoid, group, ring and field implementations.
Documentation
See https://docs.rs/un_algebra
Contributions
Please refer to the contributing guide.
Installation
Add un_algebra
to your Cargo.toml dependencies:
[]
= "0.3.0"
Production use
un_algebra
is intended to support self-study of abstract algebraic
structures--it is not optimized for use in a production environment.
For production environments I recommend using a more sophisticated
library like alga.
Compatibility
un_algebra
uses 2018 edition features but unfortunately requires
Rust nightly as it uses the (experimental) external documentation
feature.
Errors
I'm not a mathematician so my implementation of the various
structures and their respective axioms in un_algebra
may not be
strictly correct. Please let me know of any errors.
Examples
un_algebra
implements the relevant structure traits for all the
Rust standard library integer and floating point types, for example,
an additive group for integer types i8
, i16
, i32
, etc.
The Rust standard library has no support for complex numbers (ℂ) or rational numbers (ℚ) so I've used the complex and rational types from the [num] crate and implemented examples using both these numeric types.
In addition, the crate examples directory contains abstract structure implementations of selected concepts, for example, finite fields.
Example
Rust's i128
type forms several un_algebra
algebraic structures,
starting with additive and multiplicative magmas (with "wrapping"
or modular arithmetic):
use *;
i128
also forms additive and multiplicative semigroups:
And additive and multiplicative monoids with one and zero as the monoid identities:
i128
also forms an additive group and additive commutative
group (with "wrapping" or modular negation), but not a
multiplicative group, as the integers have no closed division
operation:
And a ring and commutative ring:
References
Please refer to the reading document for more background on each structure and its associated axioms and properties.
To-Do
-
Some structures have up to five trait variants: abstract, additive, multiplicative and their numeric counterparts. Research techniques for reducing the number of these traits with some kind of trait "context" that can be abstract, additive, or multiplicative.
-
Should the numeric equality traits be factored out to a separate crate used by
un_algebra
?
License
This project is licensed under the MIT license (see LICENSE.txt or https://opensource.org/licenses/MIT).