doc-next-gen

Mathlib.Algebra.Ring.Basic

Module docstring

{"# Semirings and rings

This file gives lemmas about semirings, rings and domains. This is analogous to Algebra.Group.Basic, the difference being that the former is about + and * separately, while the present file is about their interaction.

For the definitions of semirings and rings see Algebra.Ring.Defs. "}

AddHom.mulLeft definition
[Distrib R] (r : R) : AddHom R R
Full source
/-- Left multiplication by an element of a type with distributive multiplication is an `AddHom`. -/
@[simps -fullyApplied]
def mulLeft [Distrib R] (r : R) : AddHom R R where
  toFun := (r * ·)
  map_add' := mul_add r
Left multiplication as an additive homomorphism
Informal description
For any type \( R \) with distributive multiplication and an element \( r \in R \), the function \( x \mapsto r \cdot x \) is an additive homomorphism from \( R \) to itself. That is, it satisfies \( r \cdot (x + y) = r \cdot x + r \cdot y \) for all \( x, y \in R \).
AddHom.mulRight definition
[Distrib R] (r : R) : AddHom R R
Full source
/-- Left multiplication by an element of a type with distributive multiplication is an `AddHom`. -/
@[simps -fullyApplied]
def mulRight [Distrib R] (r : R) : AddHom R R where
  toFun a := a * r
  map_add' _ _ := add_mul _ _ r
Right multiplication as an additive homomorphism
Informal description
For any type \( R \) with distributive multiplication and an element \( r \in R \), the function \( x \mapsto x \cdot r \) is an additive homomorphism from \( R \) to itself. That is, it satisfies \( (x + y) \cdot r = x \cdot r + y \cdot r \) for all \( x, y \in R \).
AddMonoidHom.mulLeft definition
[NonUnitalNonAssocSemiring R] (r : R) : R →+ R
Full source
/-- Left multiplication by an element of a (semi)ring is an `AddMonoidHom` -/
def mulLeft [NonUnitalNonAssocSemiring R] (r : R) : R →+ R where
  toFun := (r * ·)
  map_zero' := mul_zero r
  map_add' := mul_add r
Left multiplication as an additive monoid homomorphism
Informal description
For any element \( r \) in a non-unital non-associative semiring \( R \), the function mapping \( x \mapsto r \cdot x \) is an additive monoid homomorphism from \( R \) to itself. This means it satisfies: 1. \( r \cdot 0 = 0 \) (preservation of zero) 2. \( r \cdot (x + y) = r \cdot x + r \cdot y \) for all \( x, y \in R \) (preservation of addition)
AddMonoidHom.coe_mulLeft theorem
[NonUnitalNonAssocSemiring R] (r : R) : (mulLeft r : R → R) = HMul.hMul r
Full source
@[simp]
theorem coe_mulLeft [NonUnitalNonAssocSemiring R] (r : R) :
    (mulLeft r : R → R) = HMul.hMul r :=
  rfl
Underlying Function of Left Multiplication Homomorphism
Informal description
For any element $r$ in a non-unital non-associative semiring $R$, the underlying function of the additive monoid homomorphism $\text{mulLeft}_r$ is equal to the left multiplication by $r$, i.e., $x \mapsto r \cdot x$.
AddMonoidHom.mulRight definition
[NonUnitalNonAssocSemiring R] (r : R) : R →+ R
Full source
/-- Right multiplication by an element of a (semi)ring is an `AddMonoidHom` -/
def mulRight [NonUnitalNonAssocSemiring R] (r : R) : R →+ R where
  toFun a := a * r
  map_zero' := zero_mul r
  map_add' _ _ := add_mul _ _ r
Right multiplication as an additive monoid homomorphism
Informal description
For any element $r$ in a non-unital non-associative semiring $R$, the function mapping $a \mapsto a * r$ is an additive monoid homomorphism from $R$ to itself. This means it satisfies: 1. $0 * r = 0$ (preservation of zero) 2. $(a + b) * r = a * r + b * r$ for all $a, b \in R$ (preservation of addition)
AddMonoidHom.coe_mulRight theorem
[NonUnitalNonAssocSemiring R] (r : R) : (mulRight r) = (· * r)
Full source
@[simp]
theorem coe_mulRight [NonUnitalNonAssocSemiring R] (r : R) :
    (mulRight r) = (· * r) :=
  rfl
Right multiplication homomorphism equals right multiplication function
Informal description
For any element $r$ in a non-unital non-associative semiring $R$, the right multiplication map $\lambda a. a * r$ (as an additive monoid homomorphism) is equal to the function $\cdot * r$.
AddMonoidHom.mulRight_apply theorem
[NonUnitalNonAssocSemiring R] (a r : R) : mulRight r a = a * r
Full source
theorem mulRight_apply [NonUnitalNonAssocSemiring R] (a r : R) :
    mulRight r a = a * r :=
  rfl
Right Multiplication Homomorphism Evaluation: $\text{mulRight}(r)(a) = a * r$
Informal description
For any elements $a$ and $r$ in a non-unital non-associative semiring $R$, the right multiplication homomorphism evaluated at $a$ satisfies $\text{mulRight}(r)(a) = a * r$.
MulOpposite.instHasDistribNeg instance
: HasDistribNeg αᵐᵒᵖ
Full source
instance MulOpposite.instHasDistribNeg : HasDistribNeg αᵐᵒᵖ where
  neg_mul _ _ := unop_injective <| mul_neg _ _
  mul_neg _ _ := unop_injective <| neg_mul _ _
Distributive Negation on the Multiplicative Opposite
Informal description
For any type $\alpha$ with a multiplication operation and an involutive negation that distributes over multiplication, the multiplicative opposite $\alpha^\text{op}$ also inherits a distributive negation operation. Specifically, for any $x, y \in \alpha$, the negation operation on $\alpha^\text{op}$ satisfies $-(\text{op}(x) \cdot \text{op}(y)) = -\text{op}(x) \cdot \text{op}(y) = \text{op}(x) \cdot -\text{op}(y)$, where $\text{op} : \alpha \to \alpha^\text{op}$ is the canonical embedding.
vieta_formula_quadratic theorem
{b c x : α} (h : x * x - b * x + c = 0) : ∃ y : α, y * y - b * y + c = 0 ∧ x + y = b ∧ x * y = c
Full source
/-- Vieta's formula for a quadratic equation, relating the coefficients of the polynomial with
  its roots. This particular version states that if we have a root `x` of a monic quadratic
  polynomial, then there is another root `y` such that `x + y` is negative the `a_1` coefficient
  and `x * y` is the `a_0` coefficient. -/
theorem vieta_formula_quadratic {b c x : α} (h : x * x - b * x + c = 0) :
    ∃ y : α, y * y - b * y + c = 0 ∧ x + y = b ∧ x * y = c := by
  have : c = x * (b - x) := (eq_neg_of_add_eq_zero_right h).trans (by simp [mul_sub, mul_comm])
  refine ⟨b - x, ?_, by simp, by rw [this]⟩
  rw [this, sub_add, ← sub_mul, sub_self]
Vieta's Formula for Quadratic Polynomials
Informal description
Let $\alpha$ be a type with a commutative multiplication operation. For any elements $b, c, x \in \alpha$ such that $x$ is a root of the monic quadratic polynomial $X^2 - bX + c$ (i.e., $x^2 - b x + c = 0$), there exists another root $y \in \alpha$ such that: 1. $y$ is also a root of the polynomial: $y^2 - b y + c = 0$, 2. The sum of the roots equals the linear coefficient: $x + y = b$, 3. The product of the roots equals the constant term: $x \cdot y = c$.
succ_ne_self theorem
{α : Type*} [NonAssocRing α] [Nontrivial α] (a : α) : a + 1 ≠ a
Full source
theorem succ_ne_self {α : Type*} [NonAssocRing α] [Nontrivial α] (a : α) : a + 1 ≠ a := fun h =>
  one_ne_zero ((add_right_inj a).mp (by simp [h]))
Non-triviality of successor in non-associative rings
Informal description
For any element $a$ in a nontrivial non-associative ring $\alpha$, we have $a + 1 \neq a$.
IsLeftCancelMulZero.to_noZeroDivisors theorem
[MulZeroClass α] [IsLeftCancelMulZero α] : NoZeroDivisors α
Full source
lemma IsLeftCancelMulZero.to_noZeroDivisors [MulZeroClass α]
    [IsLeftCancelMulZero α] : NoZeroDivisors α where
  eq_zero_or_eq_zero_of_mul_eq_zero {x _} h :=
    or_iff_not_imp_left.mpr fun ne ↦ mul_left_cancel₀ ne ((mul_zero x).symm ▸ h)
Left cancellation property implies no zero divisors
Informal description
Let $\alpha$ be a type equipped with a multiplication operation and a zero element, forming a `MulZeroClass`. If $\alpha$ satisfies the left cancellation property for multiplication by nonzero elements (i.e., for any $a, b, c \in \alpha$, if $a \neq 0$ and $a \cdot b = a \cdot c$, then $b = c$), then $\alpha$ has no zero divisors (i.e., for any $a, b \in \alpha$, if $a \cdot b = 0$, then $a = 0$ or $b = 0$).
IsRightCancelMulZero.to_noZeroDivisors theorem
[MulZeroClass α] [IsRightCancelMulZero α] : NoZeroDivisors α
Full source
lemma IsRightCancelMulZero.to_noZeroDivisors [MulZeroClass α]
    [IsRightCancelMulZero α] : NoZeroDivisors α where
  eq_zero_or_eq_zero_of_mul_eq_zero {_ y} h :=
    or_iff_not_imp_right.mpr fun ne ↦ mul_right_cancel₀ ne ((zero_mul y).symm ▸ h)
Right cancellation property implies no zero divisors
Informal description
Let $\alpha$ be a type equipped with a multiplication operation and a zero element, forming a `MulZeroClass`. If $\alpha$ satisfies the right cancellation property for multiplication by nonzero elements (i.e., for any $a, b, c \in \alpha$, if $b \neq 0$ and $a \cdot b = c \cdot b$, then $a = c$), then $\alpha$ has no zero divisors (i.e., for any $a, b \in \alpha$, if $a \cdot b = 0$, then $a = 0$ or $b = 0$).
NoZeroDivisors.to_isCancelMulZero instance
[NonUnitalNonAssocRing α] [NoZeroDivisors α] : IsCancelMulZero α
Full source
instance (priority := 100) NoZeroDivisors.to_isCancelMulZero
    [NonUnitalNonAssocRing α] [NoZeroDivisors α] :
    IsCancelMulZero α where
  mul_left_cancel_of_ne_zero ha h := by
    rw [← sub_eq_zero, ← mul_sub] at h
    exact sub_eq_zero.1 ((eq_zero_or_eq_zero_of_mul_eq_zero h).resolve_left ha)
  mul_right_cancel_of_ne_zero hb h := by
    rw [← sub_eq_zero, ← sub_mul] at h
    exact sub_eq_zero.1 ((eq_zero_or_eq_zero_of_mul_eq_zero h).resolve_right hb)
No Zero Divisors Implies Cancellative Multiplication in Non-Unital Non-Associative Rings
Informal description
For any non-unital non-associative ring $\alpha$ with no zero divisors, multiplication by any nonzero element is cancellative.
isCancelMulZero_iff_noZeroDivisors theorem
[NonUnitalNonAssocRing α] : IsCancelMulZero α ↔ NoZeroDivisors α
Full source
/-- In a ring, `IsCancelMulZero` and `NoZeroDivisors` are equivalent. -/
lemma isCancelMulZero_iff_noZeroDivisors [NonUnitalNonAssocRing α] :
    IsCancelMulZeroIsCancelMulZero α ↔ NoZeroDivisors α :=
  ⟨fun _ => IsRightCancelMulZero.to_noZeroDivisors _, fun _ => inferInstance⟩
Equivalence of Cancellative Multiplication and No Zero Divisors in Non-Unital Non-Associative Rings
Informal description
For any non-unital non-associative ring $\alpha$, the following are equivalent: 1. Multiplication by any nonzero element is cancellative (i.e., for all $a, b, c \in \alpha$, if $b \neq 0$ and either $a \cdot b = c \cdot b$ or $b \cdot a = b \cdot c$, then $a = c$). 2. The ring has no zero divisors (i.e., for all $a, b \in \alpha$, if $a \cdot b = 0$, then $a = 0$ or $b = 0$).
NoZeroDivisors.to_isDomain theorem
[Ring α] [h : Nontrivial α] [NoZeroDivisors α] : IsDomain α
Full source
lemma NoZeroDivisors.to_isDomain [Ring α] [h : Nontrivial α] [NoZeroDivisors α] :
    IsDomain α :=
  { NoZeroDivisors.to_isCancelMulZero α, h with .. }
No Zero Divisors Implies Domain in Nontrivial Rings
Informal description
For any ring $\alpha$ that is nontrivial (i.e., $0 \neq 1$) and has no zero divisors, $\alpha$ is a domain. That is, multiplication by any nonzero element is cancellative on both sides.
IsDomain.to_noZeroDivisors instance
[Semiring α] [IsDomain α] : NoZeroDivisors α
Full source
instance (priority := 100) IsDomain.to_noZeroDivisors [Semiring α] [IsDomain α] :
    NoZeroDivisors α :=
  IsRightCancelMulZero.to_noZeroDivisors α
Domains Have No Zero Divisors
Informal description
For any domain $\alpha$ (a nontrivial semiring where multiplication by nonzero elements is cancellative), $\alpha$ has no zero divisors. That is, for any $a, b \in \alpha$, if $a \cdot b = 0$, then $a = 0$ or $b = 0$.
Subsingleton.to_isCancelMulZero instance
[Mul α] [Zero α] [Subsingleton α] : IsCancelMulZero α
Full source
instance Subsingleton.to_isCancelMulZero [Mul α] [Zero α] [Subsingleton α] : IsCancelMulZero α where
  mul_right_cancel_of_ne_zero hb := (hb <| Subsingleton.eq_zero _).elim
  mul_left_cancel_of_ne_zero hb := (hb <| Subsingleton.eq_zero _).elim
Subsingleton Types are Cancellative for Multiplication by Nonzero Elements
Informal description
Every subsingleton type with multiplication and a zero element is cancellative for multiplication by nonzero elements.
Subsingleton.to_noZeroDivisors instance
[Mul α] [Zero α] [Subsingleton α] : NoZeroDivisors α
Full source
instance Subsingleton.to_noZeroDivisors [Mul α] [Zero α] [Subsingleton α] : NoZeroDivisors α where
  eq_zero_or_eq_zero_of_mul_eq_zero _ := .inl (Subsingleton.eq_zero _)
Subsingleton Types Have No Zero Divisors
Informal description
Every subsingleton type with multiplication and a zero element has no zero divisors.
isDomain_iff_cancelMulZero_and_nontrivial theorem
[Semiring α] : IsDomain α ↔ IsCancelMulZero α ∧ Nontrivial α
Full source
lemma isDomain_iff_cancelMulZero_and_nontrivial [Semiring α] :
    IsDomainIsDomain α ↔ IsCancelMulZero α ∧ Nontrivial α :=
  ⟨fun _ => ⟨inferInstance, inferInstance⟩, fun ⟨_, _⟩ => {}⟩
Characterization of Domains in Semirings: Cancellative Multiplication and Nontriviality
Informal description
A semiring $\alpha$ is a domain if and only if it satisfies the following two conditions: 1. Multiplication by any nonzero element is cancellative (both left and right cancellation). 2. The semiring is nontrivial (i.e., contains at least two distinct elements).
isCancelMulZero_iff_isDomain_or_subsingleton theorem
[Semiring α] : IsCancelMulZero α ↔ IsDomain α ∨ Subsingleton α
Full source
lemma isCancelMulZero_iff_isDomain_or_subsingleton [Semiring α] :
    IsCancelMulZeroIsCancelMulZero α ↔ IsDomain α ∨ Subsingleton α := by
  refine ⟨fun t ↦ ?_, fun h ↦ h.elim (fun _ ↦ inferInstance) (fun _ ↦ inferInstance)⟩
  rw [or_iff_not_imp_right, not_subsingleton_iff_nontrivial]
  exact fun _ ↦ {}
Characterization of Cancellative Semirings: $\text{IsCancelMulZero}\,\alpha \leftrightarrow \text{IsDomain}\,\alpha \lor \text{Subsingleton}\,\alpha$
Informal description
For a semiring $\alpha$, the property of being cancellative for multiplication by nonzero elements (`IsCancelMulZero`) holds if and only if $\alpha$ is either a domain (i.e., a nontrivial cancellative semiring) or a subsingleton (i.e., has at most one element).
isDomain_iff_noZeroDivisors_and_nontrivial theorem
[Ring α] : IsDomain α ↔ NoZeroDivisors α ∧ Nontrivial α
Full source
lemma isDomain_iff_noZeroDivisors_and_nontrivial [Ring α] :
    IsDomainIsDomain α ↔ NoZeroDivisors α ∧ Nontrivial α := by
  rw [← isCancelMulZero_iff_noZeroDivisors, isDomain_iff_cancelMulZero_and_nontrivial]
Characterization of Domains in Rings: No Zero Divisors and Nontriviality
Informal description
For any ring $\alpha$, the following are equivalent: 1. $\alpha$ is a domain (i.e., a nontrivial ring where multiplication by any nonzero element is cancellative). 2. $\alpha$ has no zero divisors and is nontrivial (i.e., contains at least two distinct elements).
noZeroDivisors_iff_isDomain_or_subsingleton theorem
[Ring α] : NoZeroDivisors α ↔ IsDomain α ∨ Subsingleton α
Full source
lemma noZeroDivisors_iff_isDomain_or_subsingleton [Ring α] :
    NoZeroDivisorsNoZeroDivisors α ↔ IsDomain α ∨ Subsingleton α := by
  rw [← isCancelMulZero_iff_noZeroDivisors, isCancelMulZero_iff_isDomain_or_subsingleton]
Characterization of No Zero Divisors: $\text{NoZeroDivisors}\,\alpha \leftrightarrow \text{IsDomain}\,\alpha \lor \text{Subsingleton}\,\alpha$
Informal description
For a ring $\alpha$, the following are equivalent: 1. $\alpha$ has no zero divisors (i.e., for all $a, b \in \alpha$, $a \cdot b = 0$ implies $a = 0$ or $b = 0$). 2. $\alpha$ is either a domain (a nontrivial ring with cancellative multiplication) or a subsingleton (a ring with at most one element).
one_div_neg_one_eq_neg_one theorem
: (1 : R) / -1 = -1
Full source
lemma one_div_neg_one_eq_neg_one : (1 : R) / -1 = -1 :=
  have : -1 * -1 = (1 : R) := by rw [neg_mul_neg, one_mul]
  Eq.symm (eq_one_div_of_mul_eq_one_right this)
Division Identity: $1 / (-1) = -1$
Informal description
For any element $1$ in a ring $R$ with a multiplicative inverse and distributive negation, the division of $1$ by $-1$ equals $-1$, i.e., $1 / (-1) = -1$.
one_div_neg_eq_neg_one_div theorem
(a : R) : 1 / -a = -(1 / a)
Full source
lemma one_div_neg_eq_neg_one_div (a : R) : 1 / -a = -(1 / a) :=
  calc
    1 / -a = 1 / (-1 * a) := by rw [neg_eq_neg_one_mul]
    _ = 1 / a * (1 / -1) := by rw [one_div_mul_one_div_rev]
    _ = 1 / a * -1 := by rw [one_div_neg_one_eq_neg_one]
    _ = -(1 / a) := by rw [mul_neg, mul_one]
Reciprocal of Negative Element: $\frac{1}{-a} = -\frac{1}{a}$
Informal description
For any element $a$ in a ring $R$ with division and distributive negation, the reciprocal of $-a$ equals the negative of the reciprocal of $a$, i.e., $\frac{1}{-a} = -\frac{1}{a}$.
div_neg_eq_neg_div theorem
(a b : R) : b / -a = -(b / a)
Full source
lemma div_neg_eq_neg_div (a b : R) : b / -a = -(b / a) :=
  calc
    b / -a = b * (1 / -a) := by rw [← inv_eq_one_div, division_def]
    _ = b * -(1 / a) := by rw [one_div_neg_eq_neg_one_div]
    _ = -(b * (1 / a)) := by rw [neg_mul_eq_mul_neg]
    _ = -(b / a) := by rw [mul_one_div]
Division by Negative Element: $\frac{b}{-a} = -\frac{b}{a}$
Informal description
For any elements $a$ and $b$ in a ring $R$ with division and distributive negation, the division of $b$ by $-a$ equals the negation of the division of $b$ by $a$, i.e., $\frac{b}{-a} = -\frac{b}{a}$.
neg_div theorem
(a b : R) : -b / a = -(b / a)
Full source
lemma neg_div (a b : R) : -b / a = -(b / a) := by
  rw [neg_eq_neg_one_mul, mul_div_assoc, ← neg_eq_neg_one_mul]
Negation and Division Identity: $-b / a = -(b / a)$
Informal description
For any elements $a$ and $b$ in a ring $R$ with distributive negation, the quotient of $-b$ by $a$ equals the negation of the quotient of $b$ by $a$, i.e., $-b / a = -(b / a)$.
neg_div' theorem
(a b : R) : -(b / a) = -b / a
Full source
@[field_simps]
lemma neg_div' (a b : R) : -(b / a) = -b / a := by simp [neg_div]
Negation of Quotient Equals Quotient of Negation: $-(b / a) = -b / a$
Informal description
For any elements $a$ and $b$ in a ring $R$ with distributive negation, the negation of the quotient $b / a$ is equal to the quotient of $-b$ by $a$, i.e., $-(b / a) = -b / a$.
neg_div_neg_eq theorem
(a b : R) : -a / -b = a / b
Full source
@[simp]
lemma neg_div_neg_eq (a b : R) : -a / -b = a / b := by rw [div_neg_eq_neg_div, neg_div, neg_neg]
Double Negation Cancellation in Division: $\frac{-a}{-b} = \frac{a}{b}$
Informal description
For any elements $a$ and $b$ in a ring $R$ with distributive negation, the quotient of $-a$ by $-b$ equals the quotient of $a$ by $b$, i.e., $\frac{-a}{-b} = \frac{a}{b}$.
neg_inv theorem
: -a⁻¹ = (-a)⁻¹
Full source
lemma neg_inv : -a⁻¹ = (-a)⁻¹ := by rw [inv_eq_one_div, inv_eq_one_div, div_neg_eq_neg_div]
Negation and Inverse Commute: $-a^{-1} = (-a)^{-1}$
Informal description
For any element $a$ in a division monoid, the negation of the inverse of $a$ is equal to the inverse of the negation of $a$, i.e., $-a^{-1} = (-a)^{-1}$.
div_neg theorem
(a : R) : a / -b = -(a / b)
Full source
lemma div_neg (a : R) : a / -b = -(a / b) := by rw [← div_neg_eq_neg_div]
Division by Negative Denominator: $\frac{a}{-b} = -\frac{a}{b}$
Informal description
For any element $a$ in a ring $R$ with division and distributive negation, the division of $a$ by $-b$ equals the negation of the division of $a$ by $b$, i.e., $\frac{a}{-b} = -\frac{a}{b}$.
inv_neg theorem
: (-a)⁻¹ = -a⁻¹
Full source
@[simp]
lemma inv_neg : (-a)⁻¹ = -a⁻¹ := by rw [neg_inv]
Inverse of Negation Equals Negation of Inverse: $(-a)^{-1} = -a^{-1}$
Informal description
For any element $a$ in a division monoid, the inverse of the negation of $a$ is equal to the negation of the inverse of $a$, i.e., $(-a)^{-1} = -a^{-1}$.
inv_neg_one theorem
: (-1 : R)⁻¹ = -1
Full source
lemma inv_neg_one : (-1 : R)⁻¹ = -1 := by rw [← neg_inv, inv_one]
Inverse of Negative One: $(-1)^{-1} = -1$
Informal description
In any ring $R$ with a multiplicative inverse operation, the inverse of $-1$ is $-1$, i.e., $(-1)^{-1} = -1$.