Skip to main content

alice/core/
ops.rs

1// Algebraic hierachy from Magma -> AlbeianGroup
2
3
4pub trait Magma: Clone + Eq + Sized {
5    fn op(&self, other: &Self) -> Self;
6}
7
8pub trait Semigroup: Magma {
9
10}
11
12pub trait Monoid: Magma {
13    fn identity() -> Self;
14}
15
16pub trait Group: Monoid {
17    fn inverse(&self) -> Self;
18}
19
20pub trait AbelianGroup: Group {
21   fn add(&self, other: &Self) -> Self{
22       self.op(other)
23   }
24
25   fn zero() -> Self {
26       Self::identity()
27   }
28
29   fn neg(&self) -> Self {
30       self.inverse()
31   }
32   
33   fn sub(&self, other: &Self) -> Self {
34       self.add(&other.neg())
35   }
36}
37
38pub trait TopologicalGroup: Group {}
39
40pub trait FiniteGroup: Group {
41    fn order() -> usize;
42    fn elements() -> alloc::vec::Vec<Self>;
43}
44
45pub trait SimpleGroup: FiniteGroup {}