# Ring
## Metadata
**Status**:: #x
**Zettel**:: #zettel/fleeting
**Created**:: [[2024-03-30]]
**Topic**:: [[♯ Math]]
## Synopsis
A ring is a set with two binary operators ⨁ and ⨂。
- The set under the operation ⨁ form an [[Abelian Group]].
- The set under the operation ⨂ form a [[Monoid (Math)|Monoid]].
- The operator ⨂ distributes over ⨁:
$
(a \oplus b) \otimes c = (a \otimes c) \oplus (b \otimes c)
$
## Analogy for Programmer
A field can be thought of as a type with two defined operators. The operators determine the operations can be performed on the type.
```rust
pub trait Ring {
// identity of ⨁
const ZERO: Self;
// ⨁ is closed
fn add(self, rhs: Self) -> Self;
// ⨁ inverse
fn negate(self) -> Self;
// identity of ⨂
const ONE: Self;
// ⨂ is closed
fn multiply(self, rhs: Self) -> Self;
}
```
There are constraints cannot be defined through the programming interface, see [[Group#Analogy for Programmer]] for reference.
## References
- [[RareSkills Authors - Rings and Fields A Programmer's Perspective (Highlights)]]