Expand description
§use-algebra
Small finite algebra law helpers for `RustUse`.
Explicit group-like and ring-like law checks over caller-supplied finite sample sets.
Surface · When to use it · Installation · Examples · Scope
use-algebra provides a deliberately small finite-law surface. The first concrete slice focuses on explicit checks over a caller-supplied sample set and caller-supplied operations: closure, associativity, commutativity, identity discovery, inverse checks, and combined predicates for monoids, groups, abelian groups, distributive laws, and rings.
Binary-law predicatesis_closed_under, is_associative, and is_commutative keep algebraic-law checks explicit over finite sample sets.
|
Identity and inverse helpersidentity_element and has_inverses cover the common building blocks for monoids and groups.
|
Structure checksis_monoid, is_group, is_abelian_group, is_distributive_over, and is_ring provide compact finite checks for common algebraic structures.
|
§What this crate provides
| Area | Root exports | Best fit |
|---|---|---|
| Basic law checks | is_closed_under, is_associative, is_commutative | Finite structure checks over explicit sample sets and operations |
| Identity and inverse checks | identity_element, has_inverses | Building monoid and group checks without a trait hierarchy |
| Combined structure predicates | is_monoid, is_group, is_abelian_group, is_distributive_over, is_ring | Small algebra experiments, education, and validation helpers |
| If you need to… | Start here |
|---|---|
| Check whether a binary operation stays inside a sample set | is_closed_under(...) |
| Discover a two-sided identity element inside a sample set | identity_element(...) |
| Check whether every value has a two-sided inverse | has_inverses(...) |
| Validate a finite abelian group or ring model | is_abelian_group(...) or is_ring(...) |
§When to use it directly
Choose use-algebra directly when finite algebra-law checks are the only surface you need and you want to keep that concern narrower than the umbrella facade.
| Scenario | Use use-algebra directly? | Why |
|---|---|---|
| You want explicit law checks over a finite sample set | Yes | The crate stays small and does not force a trait hierarchy |
| You are teaching or validating modular arithmetic structures | Yes | The helpers work directly with caller-supplied operations |
| You need symbolic algebra or generic numeric towers | No | Those are intentionally out of scope for this first slice |
| You need matrix-specific or geometry-specific abstractions | Usually no | Those belong in adjacent focused crates |
§Installation
[dependencies]
use-algebra = "0.0.1"§Quick examples
§Check a finite abelian group
use use_algebra::{identity_element, is_abelian_group};
let residues = [0_u8, 1, 2];
let add_mod_3 = |left, right| (left + right) % 3;
assert_eq!(identity_element(&residues, add_mod_3), Some(0));
assert!(is_abelian_group(&residues, add_mod_3));§Check a finite ring
use use_algebra::{is_distributive_over, is_ring};
let residues = [0_u8, 1, 2];
let add_mod_3 = |left, right| (left + right) % 3;
let mul_mod_3 = |left, right| (left * right) % 3;
assert!(is_distributive_over(&residues, mul_mod_3, add_mod_3));
assert!(is_ring(&residues, add_mod_3, mul_mod_3));[!IMPORTANT] These helpers check the laws over the exact finite sample set and exact operations you provide. They do not prove a law for values outside that set.
§Scope
- The current surface is intentionally small and concrete.
- The first slice focuses on finite sample-set checks over caller-supplied binary operations.
- These helpers are law predicates, not symbolic algebra or theorem-proving tools.
- Linear algebra and calculus-specific abstractions belong in adjacent focused crates.
§Status
use-algebra is a concrete pre-1.0 crate in the RustUse docs surface. The API remains intentionally small while adjacent numeric and linear crates continue to grow around it.
Algebraic-structure utilities for RustUse.
Re-exports§
pub use laws::has_inverses;pub use laws::identity_element;pub use laws::is_abelian_group;pub use laws::is_associative;pub use laws::is_closed_under;pub use laws::is_commutative;pub use laws::is_distributive_over;pub use laws::is_group;pub use laws::is_monoid;pub use laws::is_ring;