-
Notifications
You must be signed in to change notification settings - Fork 988
feat(FieldTheory): real closed field #33697
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
artie2000
commented
Jan 7, 2026
- Define real closed fields
- Prove some very basic properties
PR summary 8520ad2c07Import changes for modified filesNo significant changes to the import graph Import changes for all files
|
| open Polynomial | ||
|
|
||
| /-- A field `R` is real closed if | ||
| 1. `R` is real |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't you mean?
| 1. `R` is real | |
| 1. `R` is semireal |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"(Formally) real" and "semireal" are equivalent for a field, and so nobody ever distinguishes them. I've used IsSemireal as the preferred spelling because it's the usual definition of a "real field."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have a definition for real fields in Mathlib, though? I'd rather keep the wording clear.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's coming very soon!
You're allowed to lie a little about the implementation if it makes it clearer what you mean mathematically
And here it's not even lying imo
| -/ | ||
| class IsRealClosed (R : Type*) [Field R] : Prop extends IsSemireal R where | ||
| isSquare_or_isSquare_neg (x : R) : IsSquare x ∨ IsSquare (-x) | ||
| exists_isRoot_of_odd_natDegree {f : R[X]} (hf : Odd f.natDegree) : ∃ x, f.IsRoot x |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think this might save us some tedium in the future?
| exists_isRoot_of_odd_natDegree {f : R[X]} (hf : Odd f.natDegree) : ∃ x, f.IsRoot x | |
| exists_isRoot_of_odd_natDegree' {f : R[X]} (hf : Odd f.natDegree) (hf' : 1 < f.degree) : ∃ x, f.IsRoot x |
You can then prove the version without the extra hypothesis as a theorem (every linear polynomial has a root).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I fear I have already done the tedious work you mention haha
I like this idea (and you can do a similar thing where you turn the first condition into an implication), but I'm not sure it should be the definition? I can make it an alternate constructor?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you don't need this hypothesis, it's as easy as putting a single underscore in your proof. Having a new constructor would also mean we couldn't use where notation on it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The where notation thing is true
But idk, feels weird to me to change the definition like this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah OK just checked my project and this is a three line tactic proof making use of a utility lemma that isn't in Mathlib yet. The polynomial library sucks enough that I don't want to add something like this. I can add the alternate constructor in a future PR though?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe an alternate solution is to just add the lemma "every polynomial of degree 1 has a root" to Mathlib?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My bad, we have it already: Polynomial.exists_root_of_degree_eq_one. Polynomial library doesn't suck!
But I thought about it and adding this condition wouldn't actually help? Like, any proof that works for degree > 1 is going to work for degree = 1. In fact it's usually going to be by induction, and degree = 1 is the base case so you can't avoid it.
What I do want to add is the theorem that, if all nonlinear odd-degree polynomials are reducible, then they all have roots (Polynomial.has_root_of_odd_natDegree_imp_not_irreducible in my repo). That's the real way to kill the base case imo.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright then! No need to bother with this, then.
|
|
||
| variable {R : Type u} [Field R] | ||
|
|
||
| theorem of_orderedField [LinearOrder R] [IsStrictOrderedRing R] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| theorem of_orderedField [LinearOrder R] [IsStrictOrderedRing R] | |
| theorem of_orderedField [LinearOrder R] [IsOrderedRing R] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And maybe this could be of_isOrderedRing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed on Zulip, [Field F] [LinearOrder F] [IsStrictOrderedRing F] is the preferred spelling of "ordered field" for performance reasons.
And I like the idea of using LinearOrderedField as an abbreviation in names for [Field F] [LinearOrder F] [IsStrictOrderedRing F]. It's used throughout the library as a result of renames not happening when unbundling occured. Maybe it should be documented somewhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(I should change to of_linearOrderedField though, thanks for pointing out)
Co-authored-by: Violeta Hernández Palacios <vi.hdz.p@gmail.com>
Co-authored-by: Violeta Hernández Palacios <vi.hdz.p@gmail.com>
| variable [IsRealClosed R] | ||
|
|
||
| @[aesop 50%] | ||
| theorem _root_.IsSquare.of_not_isSquare_neg {x : R} (hx : ¬ IsSquare (-x)) : IsSquare x := by aesop |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an iff for x ≠ 0, might that be worth adding too? And perhaps we could have ¬ IsSquare x → IsSquare (-x) as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The iff needs semireal implies formally real (or similar) so I'll defer it until I've upstreamed formally real rings
Co-authored-by: Violeta Hernández Palacios <vi.hdz.p@gmail.com>