Sums of squares #
We introduce sums of squares in a type R
endowed with an [Add R]
, [Zero R]
and [Mul R]
instances. Sums of squares in R
are defined by an inductive predicate isSumSq : R → Prop
:
0 : R
is a sum of squares and if S
is a sum of squares, then for all a : R
, a * a + S
is a
sum of squares in R
.
Main declaration #
- The predicate
isSumSq : R → Prop
, defining the property of being a sum of squares inR
.
Auxiliary declarations #
- The type
SumSqIn R
: in an additive monoid with multiplicationR
, we introduce the typeSumSqIn R
as the submonoid ofR
whose carrier is the subset{S : R | isSumSq S}
.
Theorems #
isSumSq.add
: ifS1
andS2
are sums of squares inR
, then so isS1 + S2
.SumSq.nonneg
: in a linearly ordered semiringR
with an[ExistsAddOfLE R]
instance, sums of squares are non-negative.SquaresInSumSq
: a square is a sum of squares.SquaresAddClosure
: the submonoid ofR
generated by the squares inR
is the set of sums of squares inR
.
In a type R
with an addition, a zero element and a multiplication, the property of being a sum of
squares is defined by an inductive predicate: 0 : R
is a sum of squares and if S
is a sum of
squares, then for all a : R
, a * a + S
is a sum of squares in R
.
- zero: ∀ {R : Type u_1} [inst : Mul R] [inst_1 : Add R] [inst_2 : Zero R], isSumSq 0
- sq_add: ∀ {R : Type u_1} [inst : Mul R] [inst_1 : Add R] [inst_2 : Zero R] (a S : R), isSumSq S → isSumSq (a * a + S)
Instances For
In an additive monoid with multiplication, every square is a sum of squares. By definition, a square
in R
is a term x : R
such that x = y * y
for some y : R
and in Mathlib this is known as
IsSquare R
(see Mathlib.Algebra.Group.Even).
In an additive monoid with multiplication R
, the submonoid generated by the squares is the set of
sums of squares.
Let R
be a linearly ordered semiring in which the property a ≤ b → ∃ c, a + c = b
holds
(e.g. R = ℕ
). If S : R
is a sum of squares in R
, then 0 ≤ S
. This is used in
Mathlib.Algebra.Ring.Semireal.Defs
to show that linearly ordered fields are semireal.