deep_causality_algebra/algebra/ring_commutative.rs
1/*
2 * SPDX-License-Identifier: MIT
3 * Copyright (c) 2023 - 2026. The DeepCausality Authors and Contributors. All Rights Reserved.
4 */
5use crate::Ring;
6use crate::algebra::commutative::Commutative;
7
8/// A marker trait for a **Commutative Ring**.
9///
10/// A commutative ring is a `Ring` where the multiplication operation is
11/// commutative. This means the order of operands in multiplication does not
12/// affect the result.
13///
14/// # Mathematical Definition
15///
16/// A ring `(R, +, *)` is commutative if it satisfies the following additional law:
17///
18/// 1. **Commutativity of Multiplication:** `a * b = b * a` for all `a, b` in `R`.
19///
20/// ## Note on Implementation
21///
22/// This is a **marker trait** and has no methods. Its purpose is to signal at the
23/// type level that the commutativity law holds. The compiler cannot verify this
24/// law, so implementing this trait is a promise by the developer that the
25/// underlying type's multiplication is commutative.
26///
27/// This property is particularly important for constructs like matrix algebra,
28/// where certain properties (e.g., of the determinant) depend on the underlying
29/// ring being commutative.
30pub trait CommutativeRing: Ring + Commutative {}
31
32// Blanket implementation
33impl<T> CommutativeRing for T where T: Ring + Commutative {}