1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/*
* SPDX-License-Identifier: MIT
* Copyright (c) 2023 - 2026. The DeepCausality Authors and Contributors. All Rights Reserved.
*/
use crateAssociative;
use ;
/// Represents an **Additive Semigroup**.
///
/// A semigroup is an algebraic structure with a single associative binary
/// operation. Unlike a monoid, a semigroup does NOT require an identity element.
///
/// # Mathematical Definition
///
/// A set `S` with a binary operation `+` is an additive semigroup if:
/// 1. **Closure:** `a + b` is in `S` for all `a, b` in `S`. (Implicit in Rust).
/// 2. **Associativity:** `(a + b) + c = a + (b + c)` for all `a, b, c` in `S`.
///
/// # Examples
/// - Positive integers under addition (no zero identity).
/// - Non-empty strings under concatenation.
// Blanket implementation
/// Represents a **Multiplicative Semigroup**.
///
/// A semigroup is an algebraic structure with a single associative binary
/// operation. Unlike a monoid, a semigroup does NOT require an identity element.
///
/// # Mathematical Definition
///
/// A set `S` with a binary operation `*` is a multiplicative semigroup if:
/// 1. **Closure:** `a * b` is in `S` for all `a, b` in `S`. (Implicit in Rust).
/// 2. **Associativity:** `(a * b) * c = a * (b * c)` for all `a, b, c` in `S`.
///
/// # Hierarchy
/// ```text
/// Magma (closure only)
/// ↓
/// Semigroup (+ associativity)
/// ↓
/// Monoid (+ identity)
/// ```
// Blanket implementation