@@ -3,7 +3,6 @@ Copyright (c) 2024 Florent Schaffhauser. All rights reserved.
3
3
Released under Apache 2.0 license as described in the file LICENSE.
4
4
Authors: Florent Schaffhauser
5
5
-/
6
-
7
6
import Mathlib.Algebra.Ring.Defs
8
7
import Mathlib.Algebra.Group.Submonoid.Basic
9
8
import Mathlib.Algebra.Group.Even
@@ -13,27 +12,27 @@ import Mathlib.Algebra.Order.Ring.Defs
13
12
# Sums of squares
14
13
15
14
We introduce sums of squares in a type `R` endowed with an `[Add R]`, `[Zero R]` and `[Mul R]`
16
- instances. Sums of squares in `R` are defined by an inductive predicate `isSumSq : R → Prop`:
15
+ instances. Sums of squares in `R` are defined by an inductive predicate `IsSumSq : R → Prop`:
17
16
`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
18
17
sum of squares in `R`.
19
18
20
19
## Main declaration
21
20
22
- - The predicate `isSumSq : R → Prop`, defining the property of being a sum of squares in `R`.
21
+ - The predicate `IsSumSq : R → Prop`, defining the property of being a sum of squares in `R`.
23
22
24
23
## Auxiliary declarations
25
24
26
- - The type `SumSqIn R` : in an additive monoid with multiplication `R`, we introduce the type
27
- `SumSqIn R` as the submonoid of `R` whose carrier is the subset `{S : R | isSumSq S}`.
25
+ - The type `sumSqIn R` : in an additive monoid with multiplication `R`, we introduce the type
26
+ `sumSqIn R` as the submonoid of `R` whose carrier is the subset `{S : R | IsSumSq S}`.
28
27
29
28
## Theorems
30
29
31
- - `isSumSq .add`: if `S1` and `S2` are sums of squares in `R`, then so is `S1 + S2`.
32
- - `SumSq .nonneg`: in a linearly ordered semiring `R` with an `[ExistsAddOfLE R]` instance, sums of
30
+ - `IsSumSq .add`: if `S1` and `S2` are sums of squares in `R`, then so is `S1 + S2`.
31
+ - `IsSumSq .nonneg`: in a linearly ordered semiring `R` with an `[ExistsAddOfLE R]` instance, sums of
33
32
squares are non-negative.
34
- - `SquaresInSumSq `: a square is a sum of squares.
35
- - `SquaresAddClosure `: the submonoid of `R` generated by the squares in `R` is the set of sums of
36
- squares in `R`.
33
+ - `mem_sumSqIn_of_isSquare `: a square is a sum of squares.
34
+ - `AddSubmonoid.closure_isSquare `: the submonoid of `R` generated by the squares in `R` is the set
35
+ of sums of squares in `R`.
37
36
38
37
-/
39
38
@@ -45,57 +44,68 @@ squares is defined by an inductive predicate: `0 : R` is a sum of squares and if
45
44
squares, then for all `a : R`, `a * a + S` is a sum of squares in `R`.
46
45
-/
47
46
@[mk_iff]
48
- inductive isSumSq [Add R] [Zero R] : R → Prop
49
- | zero : isSumSq 0
50
- | sq_add (a S : R) (pS : isSumSq S) : isSumSq (a * a + S)
47
+ inductive IsSumSq [Add R] [Zero R] : R → Prop
48
+ | zero : IsSumSq 0
49
+ | sq_add (a S : R) (pS : IsSumSq S) : IsSumSq (a * a + S)
50
+
51
+ @[deprecated (since := "2024-08-09")] alias isSumSq := IsSumSq
51
52
52
53
/--
53
54
If `S1` and `S2` are sums of squares in a semiring `R`, then `S1 + S2` is a sum of squares in `R`.
54
55
-/
55
- theorem isSumSq .add [AddMonoid R] {S1 S2 : R} (p1 : isSumSq S1)
56
- (p2 : isSumSq S2) : isSumSq (S1 + S2) := by
56
+ theorem IsSumSq .add [AddMonoid R] {S1 S2 : R} (p1 : IsSumSq S1)
57
+ (p2 : IsSumSq S2) : IsSumSq (S1 + S2) := by
57
58
induction p1 with
58
59
| zero => rw [zero_add]; exact p2
59
- | sq_add a S pS ih => rw [add_assoc]; exact isSumSq.sq_add a (S + S2) ih
60
+ | sq_add a S pS ih => rw [add_assoc]; exact IsSumSq.sq_add a (S + S2) ih
61
+
62
+ @[deprecated (since := "2024-08-09")] alias isSumSq.add := IsSumSq.add
60
63
61
64
variable (R) in
62
65
/--
63
- In an additive monoid with multiplication `R`, the type `SumSqIn R` is the submonoid of sums of
66
+ In an additive monoid with multiplication `R`, the type `sumSqIn R` is the submonoid of sums of
64
67
squares in `R`.
65
68
-/
66
- def SumSqIn [AddMonoid R] : AddSubmonoid R where
67
- carrier := {S : R | isSumSq S}
68
- zero_mem' := isSumSq.zero
69
- add_mem' := isSumSq.add
69
+ def sumSqIn [AddMonoid R] : AddSubmonoid R where
70
+ carrier := {S : R | IsSumSq S}
71
+ zero_mem' := IsSumSq.zero
72
+ add_mem' := IsSumSq.add
73
+
74
+ @[deprecated (since := "2024-08-09")] alias SumSqIn := sumSqIn
70
75
71
76
/--
72
77
In an additive monoid with multiplication, every square is a sum of squares. By definition, a square
73
78
in `R` is a term `x : R` such that `x = y * y` for some `y : R` and in Mathlib this is known as
74
79
`IsSquare R` (see Mathlib.Algebra.Group.Even).
75
80
-/
76
- theorem SquaresInSumSq [AddMonoid R] {x : R} (px : IsSquare x) : x ∈ SumSqIn R := by
81
+ theorem mem_sumSqIn_of_isSquare [AddMonoid R] {x : R} (px : IsSquare x) : x ∈ sumSqIn R := by
77
82
rcases px with ⟨y, py⟩
78
83
rw [py, ← AddMonoid.add_zero (y * y)]
79
- exact isSumSq.sq_add _ _ isSumSq.zero
84
+ exact IsSumSq.sq_add _ _ IsSumSq.zero
85
+
86
+ @[deprecated (since := "2024-08-09")] alias SquaresInSumSq := mem_sumSqIn_of_isSquare
80
87
81
- open AddSubmonoid in
82
88
/--
83
89
In an additive monoid with multiplication `R`, the submonoid generated by the squares is the set of
84
90
sums of squares.
85
91
-/
86
- theorem SquaresAddClosure [AddMonoid R] : closure IsSquare = SumSqIn R := by
87
- refine le_antisymm (closure_le.2 (fun x hx ↦ SquaresInSumSq hx)) (fun x hx ↦ ?_)
92
+ theorem AddSubmonoid.closure_isSquare [AddMonoid R] : closure {x : R | IsSquare x} = sumSqIn R := by
93
+ refine le_antisymm (closure_le.2 (fun x hx ↦ mem_sumSqIn_of_isSquare hx)) (fun x hx ↦ ?_)
88
94
induction hx with
89
95
| zero => exact zero_mem _
90
96
| sq_add a S _ ih => exact AddSubmonoid.add_mem _ (subset_closure ⟨a, rfl⟩) ih
91
97
98
+ @[deprecated (since := "2024-08-09")] alias SquaresAddClosure := AddSubmonoid.closure_isSquare
99
+
92
100
/--
93
101
Let `R` be a linearly ordered semiring in which the property `a ≤ b → ∃ c, a + c = b` holds
94
102
(e.g. `R = ℕ`). If `S : R` is a sum of squares in `R`, then `0 ≤ S`. This is used in
95
103
`Mathlib.Algebra.Ring.Semireal.Defs` to show that linearly ordered fields are semireal.
96
104
-/
97
- theorem isSumSq .nonneg {R : Type *} [LinearOrderedSemiring R] [ExistsAddOfLE R] {S : R}
98
- (pS : isSumSq S) : 0 ≤ S := by
105
+ theorem IsSumSq .nonneg {R : Type *} [LinearOrderedSemiring R] [ExistsAddOfLE R] {S : R}
106
+ (pS : IsSumSq S) : 0 ≤ S := by
99
107
induction pS with
100
108
| zero => simp only [le_refl]
101
109
| sq_add x S _ ih => apply add_nonneg ?_ ih; simp only [← pow_two x, sq_nonneg]
110
+
111
+ @[deprecated (since := "2024-08-09")] alias isSumSq.nonneg := IsSumSq.nonneg
0 commit comments