Skip to content

Conversation

@artie2000
Copy link
Collaborator

  • Define real closed fields
  • Prove some very basic properties

Open in Gitpod

@github-actions
Copy link

github-actions bot commented Jan 7, 2026

PR summary 8520ad2c07

Import changes for modified files

No significant changes to the import graph

Import changes for all files
Files Import difference
Mathlib.FieldTheory.IsRealClosed.Basic (new file) 786

Declarations diff

+ IsRealClosed
+ _root_.IsSquare.of_not_isSquare_neg
+ exists_eq_pow_of_isSquare
+ exists_eq_pow_of_nonneg
+ exists_eq_pow_of_odd
+ exists_eq_zpow_of_isSquare
+ exists_eq_zpow_of_nonneg
+ exists_eq_zpow_of_odd
+ isSquare_neg_of_not_isSquare
+ nonneg_iff_isSquare
+ of_linearOrderedField

You can run this locally as follows
## summary with just the declaration names:
./scripts/declarations_diff.sh <optional_commit>

## more verbose report:
./scripts/declarations_diff.sh long <optional_commit>

The doc-module for script/declarations_diff.sh contains some details about this script.


No changes to technical debt.

You can run this locally as

./scripts/technical-debt-metrics.sh pr_summary
  • The relative value is the weighted sum of the differences with weight given by the inverse of the current value of the statistic.
  • The absolute value is the relative value divided by the total sum of the inverses of the current values (i.e. the weighted average of the differences).

@github-actions github-actions bot added the t-algebra Algebra (groups, rings, fields, etc) label Jan 7, 2026
@artie2000 artie2000 changed the title feat(FieldTheory): Real Closed Field feat(FieldTheory): real closed field Jan 7, 2026
open Polynomial

/-- A field `R` is real closed if
1. `R` is real
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't you mean?

Suggested change
1. `R` is real
1. `R` is semireal

Copy link
Collaborator Author

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."

Copy link
Collaborator

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.

Copy link
Collaborator Author

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
Copy link
Collaborator

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?

Suggested change
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).

Copy link
Collaborator Author

@artie2000 artie2000 Jan 7, 2026

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?

Copy link
Collaborator

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.

Copy link
Collaborator Author

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

Copy link
Collaborator Author

@artie2000 artie2000 Jan 7, 2026

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?

Copy link
Collaborator

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?

Copy link
Collaborator Author

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.

Copy link
Collaborator

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]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
theorem of_orderedField [LinearOrder R] [IsStrictOrderedRing R]
theorem of_orderedField [LinearOrder R] [IsOrderedRing R]

Copy link
Collaborator

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?

Copy link
Collaborator Author

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?

Copy link
Collaborator Author

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>
@artie2000 artie2000 added the awaiting-author A reviewer has asked the author a question or requested changes. label Jan 7, 2026
variable [IsRealClosed R]

@[aesop 50%]
theorem _root_.IsSquare.of_not_isSquare_neg {x : R} (hx : ¬ IsSquare (-x)) : IsSquare x := by aesop
Copy link
Collaborator

@vihdzp vihdzp Jan 7, 2026

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?

Copy link
Collaborator Author

@artie2000 artie2000 Jan 8, 2026

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

@artie2000 artie2000 removed the awaiting-author A reviewer has asked the author a question or requested changes. label Jan 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

t-algebra Algebra (groups, rings, fields, etc)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants