/-
Copyright (c) 2024 Florent Schaffhauser. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Florent Schaffhauser, Artie Khovanov
-/
module
public import Mathlib.Algebra.Ring.Subsemiring.Support
public import Mathlib.RingTheory.Ideal.Prime
/-!
# Ring orderings
Let `R` be a commutative ring. We define orderings and preorderings on `R`
as predicates on `Subsemiring R`.
## Definitions
* `IsOrdering`: an ordering is a subsemiring `O` such that `O ∪ -O = R` and
the support `O ∩ -O` of `O` forms a prime ideal.
* `IsPreordering`: a preordering is a subsemiring that contains all squares, but not `-1`.
All orderings are preorderings.
## References
- [*An introduction to real algebra*, T.Y. Lam][lam_1984]
-/
@[expose] public section
open scoped Pointwise
namespace Subsemiring
variable {R : Type*} [CommRing R] {S : Subsemiring R}
/--
An ordering `O` on a ring `R` is a subsemiring of `R` such that `O ∪ -O = R` and
the support `O ∩ -O` of `O` forms a prime ideal.
-/
structure IsOrdering (S : Subsemiring R) : Prop where
isSpanning : S.IsSpanning
support_ne_top : S.support ≠ ⊤
mem_support_or_mem_support :
∀ {x y : R}, x * y ∈ S.support →
x ∈ S.support ∨ y ∈ S.support
theorem IsOrdering.isPrime_supportIdeal (hS : S.IsOrdering) :
(S.supportIdeal hS.isSpanning).IsPrime where
ne_top' := by
apply_fun Submodule.toAddSubgroup
simpa using hS.support_ne_top
mem_or_mem' := hS.mem_support_or_mem_support
theorem IsOrdering.of_isPrime_supportIdeal (hS : S.IsSpanning)
(hS₂ : (S.supportIdeal hS).IsPrime) : S.IsOrdering where
isSpanning := hS
support_ne_top := by simpa [← Submodule.toAddSubgroup_inj] using hS₂.ne_top
mem_support_or_mem_support := hS₂.mem_or_mem
/-- A preordering on a ring `R` is a subsemiring of `R` that contains all squares, but not `-1`. -/
structure IsPreordering (S : Subsemiring R) : Prop where
mem_of_isSquare (S) {x} (hx : IsSquare x) : x ∈ S := by membership
neg_one_notMem (S) : -1 ∉ S := by membership
grind_pattern [membership] IsPreordering.mem_of_isSquare => S.IsPreordering, x ∈ S
attribute [membership →] IsPreordering.neg_one_notMem
namespace IsPreordering
@[simp, membership =>]
protected theorem mul_self_mem (hS : IsPreordering S) (x : R) : x * x ∈ S := by
grind [mem_of_isSquare]
@[simp, membership =>]
protected theorem pow_two_mem (hS : IsPreordering S) (x : R) : x ^ 2 ∈ S := by
grind [mem_of_isSquare, Even.isSquare_pow]
theorem sumSq_le (hS : IsPreordering S) : .sumSq R ≤ S := by
rw [← closure_isSquare, closure_le]
exact fun _ ↦ hS.mem_of_isSquare
protected theorem mem_of_isSumSq (hS : IsPreordering S) {x : R} (hx : IsSumSq x) : x ∈ S := by
grind [membership, hS.sumSq_le]
grind_pattern [membership] IsPreordering.mem_of_isSumSq => S.IsPreordering, x ∈ S
theorem of_sumSq_le (hS : .sumSq R ≤ S) (h : -1 ∉ S) : IsPreordering S where
mem_of_isSquare := by grind [membership]
theorem of_isSpanning (hS : S.IsSpanning) (h : S ≠ ⊤) : S.IsPreordering :=
.of_sumSq_le hS.sumSq_le <| by
contrapose h
rw [eq_top_iff]
intro x _
rcases (isSpanning_def.mp hS) x with hx | hx
· simpa using hx
· simpa using mul_mem h hx
end IsPreordering
/-- An ordering is a preordering. -/
theorem IsOrdering.isPreordering (hS : S.IsOrdering) :
S.IsPreordering := .of_isSpanning hS.isSpanning <| fun hc ↦ by
simpa [hc, supportIdeal] using hS.isPrime_supportIdeal.ne_top
end Subsemiring
/- Deprecated -/
variable (R : Type*) [CommRing R]
/-- A preordering on a ring `R` is a subsemiring of `R` containing all squares,
but not containing `-1`. -/
@[deprecated Subsemiring.IsPreordering +typeChanged (since := "2026-10-28"), ext]
structure RingPreordering extends Subsemiring R where
mem_of_isSquare' {x : R} (hx : IsSquare x) : x ∈ carrier := by aesop
neg_one_notMem' : -1 ∉ carrier := by aesop
attribute [deprecated "no replacement" (since := "2026-10-28")] RingPreordering.ext_iff
namespace RingPreordering
attribute [coe] toSubsemiring
@[deprecated "no replacement" (since := "2026-10-28")]
instance : SetLike (RingPreordering R) R where
coe P := P.carrier
coe_injective p q h := by cases p; cases q; congr; exact SetLike.ext' h
@[deprecated "no replacement" (since := "2026-10-28")]
instance : PartialOrder (RingPreordering R) := .ofSetLike (RingPreordering R)
initialize_simps_projections RingPreordering (carrier → coe, as_prefix coe)
@[deprecated "no replacement" (since := "2026-10-28")]
instance : SubsemiringClass (RingPreordering R) R where
zero_mem _ := Subsemiring.zero_mem _
one_mem _ := Subsemiring.one_mem _
add_mem := Subsemiring.add_mem _
mul_mem := Subsemiring.mul_mem _
variable {R}
set_option linter.deprecated false in
@[deprecated Subsemiring.IsPreordering.mem_of_isSquare +typeChanged (since := "2026-10-28"),
aesop unsafe 80% (rule_sets := [SetLike])]
protected theorem mem_of_isSquare (P : RingPreordering R) {x : R} (hx : IsSquare x) : x ∈ P :=
RingPreordering.mem_of_isSquare' _ hx
@[deprecated Subsemiring.IsPreordering.mul_self_mem +typeChanged (since := "2026-10-28"), simp]
protected theorem mul_self_mem (P : RingPreordering R) (x : R) : x * x ∈ P := by aesop
@[deprecated Subsemiring.IsPreordering.pow_two_mem +typeChanged (since := "2026-10-28"), simp]
protected theorem pow_two_mem (P : RingPreordering R) (x : R) : x ^ 2 ∈ P := by aesop
set_option linter.deprecated false in
@[deprecated Subsemiring.IsPreordering.neg_one_notMem +typeChanged (since := "2026-10-28"),
aesop unsafe 20% forward (rule_sets := [SetLike])]
protected theorem neg_one_notMem (P : RingPreordering R) : -1 ∉ P :=
RingPreordering.neg_one_notMem' _
@[deprecated "no replacement" (since := "2026-10-28")]
theorem toSubsemiring_injective :
Function.Injective (toSubsemiring : RingPreordering R → _) := fun A B h => by ext; rw [h]
@[deprecated "no replacement" (since := "2026-10-28"), simp]
theorem toSubsemiring_inj {P₁ P₂ : RingPreordering R} :
P₁.toSubsemiring = P₂.toSubsemiring ↔ P₁ = P₂ := toSubsemiring_injective.eq_iff
@[deprecated "no replacement" (since := "2026-10-28"), simp]
theorem mem_toSubsemiring {P : RingPreordering R} {x : R} : x ∈ P.toSubsemiring ↔ x ∈ P := .rfl
@[deprecated "no replacement" (since := "2026-10-28"), simp, norm_cast]
theorem coe_toSubsemiring (P : RingPreordering R) : (P.toSubsemiring : Set R) = P := rfl
@[deprecated "no replacement" (since := "2026-10-28"), simp]
theorem mem_mk {toSubsemiring : Subsemiring R} (mem_of_isSquare neg_one_notMem) {x : R} :
x ∈ mk toSubsemiring mem_of_isSquare neg_one_notMem ↔ x ∈ toSubsemiring := .rfl
@[deprecated "no replacement" (since := "2026-10-28"), simp]
theorem coe_set_mk (toSubsemiring : Subsemiring R) (mem_of_isSquare neg_one_notMem) :
(mk toSubsemiring mem_of_isSquare neg_one_notMem : Set R) = toSubsemiring := rfl
section copy
/-- Copy of a preordering with a new `carrier` equal to the old one. Useful to fix definitional
equalities. -/
@[deprecated "no replacement" (since := "2026-10-28"), simps]
protected def copy (P : RingPreordering R) (S : Set R) (hS : S = P) : RingPreordering R where
carrier := S
zero_mem' := by aesop
add_mem' ha hb := by aesop
one_mem' := by aesop
mul_mem' ha hb := by aesop
attribute [deprecated "no replacement" (since := "2026-10-28"), norm_cast] coe_copy
@[deprecated "no replacement" (since := "2026-10-28"), simp]
theorem mem_copy (P : RingPreordering R) (S : Set R) (hS : S = P) {x} :
x ∈ P.copy S hS ↔ x ∈ S := .rfl
@[deprecated "no replacement" (since := "2026-10-28")]
theorem copy_eq (P : RingPreordering R) (S : Set R) (hS : S = P) : P.copy S hS = S := rfl
end copy
/-!
#### Support
-/
section supportAddSubgroup
/--
The support of a ring preordering `P` in a commutative ring `R` is
the set of elements `x` in `R` such that both `x` and `-x` lie in `P`.
-/
@[deprecated AddSubmonoid.support +typeChanged (since := "2026-10-28")]
def supportAddSubgroup (P : RingPreordering R) : AddSubgroup R where
carrier := P ∩ -P
zero_mem' := by aesop
add_mem' := by aesop
neg_mem' := by aesop
@[deprecated AddSubmonoid.mem_support +typeChanged (since := "2026-10-28")]
theorem mem_supportAddSubgroup {P : RingPreordering R} {x} :
x ∈ P.supportAddSubgroup ↔ x ∈ P ∧ -x ∈ P := .rfl
@[deprecated AddSubmonoid.coe_support +typeChanged (since := "2026-10-28")]
theorem coe_supportAddSubgroup {P : RingPreordering R} :
P.supportAddSubgroup = (P ∩ -P : Set R) := rfl
end supportAddSubgroup
/-- Typeclass to track whether the support of a preordering forms an ideal. -/
@[deprecated "no replacement" (since := "2026-10-28")]
class HasIdealSupport (P : RingPreordering R) : Prop where
smul_mem_support (P) (x : R) {a : R} (ha : a ∈ P.supportAddSubgroup) :
x * a ∈ P.supportAddSubgroup
export HasIdealSupport (smul_mem_support)
@[deprecated "no replacement" (since := "2026-10-28")]
theorem hasIdealSupport_iff {P : RingPreordering R} :
P.HasIdealSupport ↔ ∀ x a : R, a ∈ P → -a ∈ P → x * a ∈ P ∧ -(x * a) ∈ P where
mp _ := by simpa [mem_supportAddSubgroup] using P.smul_mem_support
mpr _ := ⟨by simpa [mem_supportAddSubgroup]⟩
@[deprecated Subsemiring.supportIdeal +typeChanged (since := "2026-10-28")]
instance {P : RingPreordering R} [HasMemOrNegMem P] : P.HasIdealSupport where
smul_mem_support x a ha :=
match mem_or_neg_mem P x with
| .inl hx => ⟨by simpa using mul_mem hx ha.1, by simpa using mul_mem hx ha.2⟩
| .inr hx => ⟨by simpa using mul_mem hx ha.2, by simpa using mul_mem hx ha.1⟩
section support
variable (P) in
/--
The support of a ring preordering `P` in a commutative ring `R` is
the set of elements `x` in `R` such that both `x` and `-x` lie in `P`.
-/
@[deprecated Subsemiring.supportIdeal +typeChanged (since := "2026-10-28")]
def support (P : RingPreordering R) [P.HasIdealSupport] : Ideal R where
__ := P.supportAddSubgroup
smul_mem' := by simpa using smul_mem_support P
@[deprecated Subsemiring.mem_supportIdeal +typeChanged (since := "2026-10-28")]
theorem mem_support {P : RingPreordering R} [P.HasIdealSupport] {x} :
x ∈ P.support ↔ x ∈ P ∧ -x ∈ P := .rfl
@[deprecated Subsemiring.coe_supportIdeal +typeChanged (since := "2026-10-28")]
theorem coe_support {P : RingPreordering R} [P.HasIdealSupport] :
P.support = (P : Set R) ∩ -(P : Set R) := rfl
@[deprecated Subsemiring.supportIdeal_toAddSubgroup +typeChanged (since := "2026-10-28"), simp]
theorem supportAddSubgroup_eq {P : RingPreordering R} [P.HasIdealSupport] :
P.supportAddSubgroup = P.support.toAddSubgroup := rfl
end support
/--
An ordering `O` on a ring `R` is a preordering such that
1. `O` contains either `x` or `-x` for each `x` in `R` and
2. the support of `O` is a prime ideal.
-/
@[deprecated Subsemiring.IsOrdering +typeChanged (since := "2026-10-28")]
class IsOrdering (P : RingPreordering R) extends HasMemOrNegMem P, P.support.IsPrime
end RingPreordering
¤ Dauer der Verarbeitung: 0.2 Sekunden
(vorverarbeitet am 2026-11-24)
¤
*© Formatika GbR, Deutschland