Skip to main content

deep_causality_algebra/algebra/
group_add.rs

1/*
2 * SPDX-License-Identifier: MIT
3 * Copyright (c) 2023 - 2026. The DeepCausality Authors and Contributors. All Rights Reserved.
4 */
5use crate::Zero;
6use core::ops::{Add, Sub};
7
8/// Represents an **Additive Group**.
9///
10/// An additive group is a `Group` where the binary operation is addition (`+`).
11///
12/// # Mathematical Definition
13///
14/// A set `G` is a group under addition if it satisfies:
15/// 1.  **Closure:** `a + b` is in `G`. (Implicit in Rust).
16/// 2.  **Associativity:** `(a + b) + c = a + (b + c)`. (Implied by `Add` trait).
17/// 3.  **Identity Element:** There is an element `0` such that `a + 0 = a`.
18///     (Provided by the `Zero` trait).
19/// 4.  **Inverse Element:** For each `a`, there is an inverse `-a` such that
20///     `a + (-a) = 0`. (Provided by the `Sub` trait, which defines `a - a`).
21///
22/// The `Clone` bound is included for practical purposes within the Rust type system.
23pub trait AddGroup: Add<Output = Self> + Sub<Output = Self> + Zero + Clone {}
24
25// Blanket Implementation for all types that impl Add, Sub, and have zero
26impl<T> AddGroup for T where T: Add<Output = T> + Sub<Output = T> + Zero + Clone {}