use-algebra 0.0.4

Utility-first finite algebra law helpers for RustUse
Documentation

use-algebra

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.

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.