A monolithic commutative ring typeclass for internal use in grind
. #
The Lean.Grind.CommRing
class will be used to convert expressions into the internal representation via polynomials,
with coefficients expressed via OfNat
and Neg
.
The IsCharP α p
typeclass expresses that the ring has characteristic p
,
i.e. that a coefficient OfNat.ofNat x : α
is zero if and only if x % p = 0
(in Nat
).
See
theorem ofNat_ext_iff {x y : Nat} : OfNat.ofNat (α := α) x = OfNat.ofNat (α := α) y ↔ x % p = y % p
theorem ofNat_emod (x : Nat) : OfNat.ofNat (α := α) (x % p) = OfNat.ofNat x
theorem ofNat_eq_iff_of_lt {x y : Nat} (h₁ : x < p) (h₂ : y < p) :
OfNat.ofNat (α := α) x = OfNat.ofNat (α := α) y ↔ x = y
A semiring, i.e. a type equipped with addition, multiplication, and a map from the natural numbers, satisfying appropriate compatibilities.
Use Ring
instead if the type also has negation,
CommSemiring
if the multiplication is commutative,
or CommRing
if the type has negation and multiplication is commutative.
- add : α → α → α
- mul : α → α → α
- natCast : NatCast α
In every semiring there is a canonical map from the natural numbers to the semiring, providing the values of
0
and1
. Note that this function need not be injective. Natural number numerals in the semiring. The field
ofNat_eq_natCast
ensures that these are (propositionally) equal to the values ofnatCast
.Addition is associative.
Addition is commutative.
Zero is the right identity for addition.
Multiplication is associative.
One is the right identity for multiplication.
One is the left identity for multiplication.
Left distributivity of multiplication over addition.
Right distributivity of multiplication over addition.
Zero is right absorbing for multiplication.
Zero is left absorbing for multiplication.
The zeroth power of any element is one.
The successor power law for exponentiation.
Numerals are consistently defined with respect to addition.
Numerals are consistently defined with respect to the canonical map from natural numbers.
Instances
A ring, i.e. a type equipped with addition, negation, multiplication, and a map from the integers, satisfying appropriate compatibilities.
Use CommRing
if the multiplication is commutative.
- add : α → α → α
- mul : α → α → α
- neg : α → α
- sub : α → α → α
- intCast : IntCast α
In every ring there is a canonical map from the integers to the ring.
Negation is the left inverse of addition.
Subtraction is addition of the negative.
The canonical map from the integers is consistent with the canonical map from the natural numbers.
The canonical map from the integers is consistent with negation.
Instances
A commutative semiring, i.e. a semiring with commutative multiplication.
Use CommRing
if the type has negation.
Instances
A commutative ring, i.e. a ring with commutative multiplication.
Instances
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.
A ring α
has characteristic p
if OfNat.ofNat x = 0
iff x % p = 0
.
Note that for p = 0
, we have x % p = x
, so this says that OfNat.ofNat
is injective from Nat
to α
.
In the case of a semiring, we take the stronger condition that
OfNat.ofNat x = OfNat.ofNat y
iff x % p = y % p
.
Two numerals in a semiring are equal iff they are congruent module
p
in the natural numbers.