Zulip Chat Archive

Stream: mathlib4

Topic: Real Closed Fields Project


Artie Khovanov (Jun 26 2025 at 01:16):

I'm formalising some real algebra in Mathlib :slight_smile:
https://artie2000.github.io/real_closed_field/
I've got a blueprint, which should make it relatively easy to contribute if you are interested!
I've already formalised some material on orderings of rings and fields.
I think a good target is the characterisation of real closed fields (Theorem 40 / RCF_tfae).
I have some material beyond this (Sturm's theorem, real closures, Artin-Schreier theorem) but I haven't fully worked out a path to formalising it.
Eventually I want to prove the Tarski-Seidenberg principle, but that's quite far away and I'm not really sure how equipped Lean is to handle the computational aspects of the theory.
I'm doing this in my spare time, so progress will be slow, but any contributions are very welcome! The ultimate goal is to upstream everything to Mathlib.

Kenny Lau (Jun 26 2025 at 02:09):

wow that's quite quick!

Violeta Hernández (Aug 21 2025 at 22:27):

Hi! I'm interested in this. I kind of need this in order to show surreals are real closed.

Artie Khovanov (Aug 22 2025 at 00:07):

@Violeta Hernández what results do you need? See the blueprint for what I have planned

Violeta Hernández (Aug 22 2025 at 00:08):

I need the result that for RR a real-closed field and Γ\Gamma a divisible group, the field of Hahn series R[[XΓ]]R[[X^\Gamma]] is also real-closed

Violeta Hernández (Aug 22 2025 at 00:15):

I'm not really sure if this is more of a Hahn series result or a real-closed field result

Violeta Hernández (Aug 22 2025 at 00:15):

Found this on ncatlab
image.png

Artie Khovanov (Aug 22 2025 at 00:18):

Yep OK so the only bit of real closed field theory you need there is that index 2 in algebraic closure implies real closed (so, Theorem 50 in the current version of my blueprint)

Artie Khovanov (Aug 22 2025 at 00:19):

The rest is Hahn series stuff eg k[t^G][i]=k[i][t^G]

Artie Khovanov (Aug 22 2025 at 00:22):

At the moment that result (Theorem 50) is a while away, at least the way I want to prove it, due to missing API around quadratic extensions (see Lemma 3)
But any contributions in this direction would of course be very welcome :)

Violeta Hernández (Aug 22 2025 at 00:23):

How do you even write down K[i] in Mathlib?

Artie Khovanov (Aug 22 2025 at 00:24):

AdjoinRoot K (X^2 + 1)

Artie Khovanov (Aug 22 2025 at 00:25):

And, if you already have your field, use IsAdjoinRoot

Violeta Hernández (Aug 22 2025 at 00:28):

Thanks!

Violeta Hernández (Aug 22 2025 at 00:28):

I'll read about this. Hope I'm not jumping into something far beyond my depth...

Artie Khovanov (Aug 22 2025 at 00:31):

Nothing in the blueprint is really beyond the level of a first course in number fields, if you take the ordering stuff as given
And much of the proofs is just polynomial manipulation
I'm still getting to grips with this part of the library though; it feels like there's definitely missing API

Violeta Hernández (Aug 22 2025 at 00:32):

Polynomials in Mathlib my beloathed

Artie Khovanov (Aug 22 2025 at 00:32):

There isn't even a normal form for them

Weiyi Wang (Aug 31 2025 at 01:01):

I reminded myself about this project as I stumbled upon some theory mentioning real-closeness. Specifically this lemma: a Gamma-valued, real-closed or algebraically closed field F has a section (a group homomorphism Gamma->F that's right inverse of the valuation. I wonder if it is in the scope of the project, or when the definition of real closed field will be ready in mathlib to express this.

Aaron Liu (Aug 31 2025 at 01:02):

for any Gamma?

Aaron Liu (Aug 31 2025 at 01:03):

or does the valuation have to be surjective

Aaron Liu (Aug 31 2025 at 01:04):

wait what do you mean the field has a section, and where did the valuation come from

Weiyi Wang (Aug 31 2025 at 01:08):

For any valuation. Gamma just refers to the value group (so surjectivity implied). "Section" is just name given to the homomorphism in the article I am reading

Artie Khovanov (Aug 31 2025 at 01:11):

I have "real closed field" stated but I haven't proved much about them yet
the API around finite extensions of fields needs work

Weiyi Wang (Aug 31 2025 at 01:23):

:smile: Would be nice to see it in mathlib even with just simple definition and lemmas. I think the actual lemma I need is "you can take n-th root in real closed fields"

Artie Khovanov (Aug 31 2025 at 01:25):

Well, you can't take nth roots, necessarily. You can take them when n is odd, or when n is even and your element is non-negative. Stuff about real closed fields is generally proved from the algebraically closed field version using the characterisation of real closed fields as non-algebraically-closed fields whose extension by 1\sqrt{-1} is algebraically closed.

Weiyi Wang (Aug 31 2025 at 01:28):

sorry I should clarify I meant taking n-th root of a positive number

Artie Khovanov (Aug 31 2025 at 01:29):

Here is the definition I have right now:

/- An ordered field is real closed if every nonegative element is a square and
   every odd-degree polynomial has a root. -/
class IsRealClosed (R : Type*) [Field R] [LinearOrder R] : Prop extends IsStrictOrderedRing R where
  isSquare_of_nonneg {x : R} (hx : 0  x) : IsSquare x
  exists_isRoot_of_odd_natDegree {f : R[X]} (hf : Odd f.natDegree) :  x, f.IsRoot x

I don't have much else (you can check out the project blueprint to see current scope and progress)

Violeta Hernández (Aug 31 2025 at 06:08):

I'd love to see the definition in Mathlib too. That way I can add the relevant proof_wanted for my project!

Filippo A. E. Nuccio (Aug 31 2025 at 11:07):

I think @Florent Schaffhauser had somethink on this.

Artie Khovanov (Aug 31 2025 at 13:13):

Yes, this project comes as a result of his work on real algebra.

Artie Khovanov (Dec 28 2025 at 02:26):

@Violeta Hernández just proved the result you wanted - it's very_weak_Artin_Schreier in my project

Artie Khovanov (Dec 28 2025 at 02:27):

unfortunately it's built on top of some custom field extension API but yeah working on it

Violeta Hernández (Dec 28 2025 at 02:28):

Thank you very much! This is really nice.

Aaron Liu (Dec 28 2025 at 02:29):

is this the result we wanted?

Violeta Hernández (Dec 28 2025 at 02:31):

Hmm... I think what we really want eventually is the converse? So as to show that the surcomplex numbers are algebraically closed.

Aaron Liu (Dec 28 2025 at 02:31):

I feel like that shouldn't be too hard

Artie Khovanov (Dec 28 2025 at 02:32):

Converse is also proved in that file (and yes is much easier, was proved months ago)

Aaron Liu (Dec 28 2025 at 02:32):

since every polynomial factors into degree-at-most-two irreducibles which then factor over the field extension by the quadratic formula

Artie Khovanov (Dec 28 2025 at 02:33):

Artie Khovanov said:

Converse is also proved in that file (and yes is much easier, was proved months ago)

Wait no I got confused
Your converse I just proved last night and is the harder direction lmao

Violeta Hernández (Dec 28 2025 at 02:35):

It feels a bit weird to write any theorem as ∃! _ : LinearOrder, _. Would it make sense to make a type-valued RealClosed structure which bundles the ring ordering and uses it to define a LinearOrder instance? Or am I saying nonsense?

Artie Khovanov (Dec 28 2025 at 02:35):

I am very close to having the whole thing (RealClosedField.TFAE) finished, and then I can work on making it closer to Mathlib. Just got one implication (IVT) to go.

Aaron Liu (Dec 28 2025 at 02:35):

the ordering is unique anyways

Artie Khovanov (Dec 28 2025 at 02:37):

Violeta Hernández said:

It feels a bit weird to write any theorem as ∃! _ : LinearOrder, _. Would it make sense to make a type-valued RealClosed structure which bundles the ring ordering and uses it to define a LinearOrder instance? Or am I saying nonsense?

Normally we say an ordered field is real closed if...

I suppose you could say a field is real closed if... which works as Aaron says by uniqueness, but that would be quite strange

Really what's best to do is to use the 3 or 4 theorems that that result uses. So, show it's real, then create the order on it, then show it's real closed.

Violeta Hernández (Dec 28 2025 at 02:38):

Aaron Liu said:

the ordering is unique anyways

Yes, but I believe we like it when we're able to specify data, even if said data is uniquely characterized.

Violeta Hernández (Dec 28 2025 at 02:59):

Wait, any field with a finite dimensional algebraically closed extension is real closed??? I had no idea

Aaron Liu (Dec 28 2025 at 03:06):

artin schrICANTSPELL

Violeta Hernández (Dec 28 2025 at 03:07):

TIL

Aaron Liu (Dec 28 2025 at 03:09):

any finite extension where the upper field is algebraically closed, the lower field is either algebraically closed or real closed

Aaron Liu (Dec 28 2025 at 03:10):

it kind of intuitively makes sense maybe

Violeta Hernández (Dec 28 2025 at 03:10):

your intuition is clearly more calibrated than mine

Aaron Liu (Dec 28 2025 at 03:23):

everything is intuitive of you've played with it too much

Violeta Hernández (Dec 28 2025 at 03:24):

I imagine the idea is if some other polynomial is missing a root then you can start constructing an infinite set of other polynomials that are also missing roots?

Aaron Liu (Dec 28 2025 at 03:47):

like consider the finite fields

Aaron Liu (Dec 28 2025 at 03:48):

a finite extension Fp/K\overline{\mathbb{F}_p}/K corresponds to a finite closed subgroup of Z^\widehat{\mathbb{Z}}

Aaron Liu (Dec 28 2025 at 03:48):

but Z^\widehat{\mathbb{Z}} is Z\mathbb{Z}-torsion free so every element has infinite order

Violeta Hernández (Dec 28 2025 at 03:49):

That makes sense

Florent Schaffhauser (Dec 28 2025 at 06:45):

Artie Khovanov said:

Violeta Hernández said:

It feels a bit weird to write any theorem as ∃! _ : LinearOrder, _. Would it make sense to make a type-valued RealClosed structure which bundles the ring ordering and uses it to define a LinearOrder instance? Or am I saying nonsense?

Normally we say an ordered field is real closed if...

I suppose you could say a field is real closed if... which works as Aaron says by uniqueness, but that would be quite strange

Not really, no :blush:

Define a real-closed field to be a real field with no non-trivial real extension. Then such a field indeed has a canonical linear ordering. Note that, in this approach, a real field does not come with an ordering.

Conversely, given a real field, there is an ordering, but it is not canonical in general. The upshot of starting with an ordered field is that you get a canonical real closure.

@Artie Khovanov I remember we discussed it after your talk in Heidelberg :blush:

Violeta Hernández (Dec 28 2025 at 08:45):

Perhaps these could be separate things? We could have IsRealClosed for a field with non-trivial real extensions, and something else like IsOrderedRealClosed for a real closed field with a compatible linear order.

Florent Schaffhauser (Dec 28 2025 at 09:30):

Yes, I guess it depends what the end goal is :slight_smile: The important thing is: if the real field is real-closed, then the ordering is unique.

In principle, you have a theory of real fields and a theory of ordered fields. Ordered fields are real and real fields admit an ordering, which is not unique in general but is unique when the real field is real-closed.

Moreover, the following characterisation of real-closed fields holds, which makes no reference to an ordering.

Let KK be a field. Then the following conditions are equivalent.

  1. KK is a real-closed field.
  2. KK is a real field and, for all aKa \in K, either aa or a-a is a square in KK, and, moreover, every polynomial of odd degree with coefficients in KK has a root in KK.
  3. The KK-algebra K[T]/(T2+1)K[T]/(T^2 + 1) is an algebraically closed field.

Artie Khovanov (Dec 28 2025 at 13:21):

Violeta Hernández said:

Wait, any field with a finite dimensional algebraically closed extension is real closed??? I had no idea

Yeah it's a really cool result. Needs a bunch more algebra though, which is where I'm hoping my new concrete field extension API will really start to pay off.

Artie Khovanov (Dec 28 2025 at 15:00):

Florent Schaffhauser said:

Yes, I guess it depends what the end goal is :slight_smile: The important thing is: if the real field is real-closed, then the ordering is unique.

In principle, you have a theory of real fields and a theory of ordered fields. Ordered fields are real and real fields admit an ordering, which is not unique in general but is unique when the real field is real-closed.

Moreover, the following characterisation of real-closed fields holds, which makes no reference to an ordering.

Let KK be a field. Then the following conditions are equivalent.

  1. KK is a real-closed field.
  2. KK is a real field and, for all aKa \in K, either aa or a-a is a square in KK, and, moreover, every polynomial of odd degree with coefficients in KK has a root in KK.
  3. The KK-algebra K[T]/(T2+1)K[T]/(T^2 + 1) is an algebraically closed field.

Just proved IsSemireal.TFAE_RCF in the same file :tada:

Violeta Hernández (Dec 28 2025 at 18:32):

Florent Schaffhauser said:

Yes, I guess it depends what the end goal is :slight_smile: The important thing is: if the real field is real-closed, then the ordering is unique.

The fact that you can state meaningful results about real-closed fields without reference to orderings suggest to me that this intermediate notion is useful. We could then have as a theorem that there's a unique ordering which makes them into an ordered real closed field.

Violeta Hernández (Dec 28 2025 at 18:35):

Basically, I think we should be able to ask is a field is real closed without having to awkwardly ask "does there exist a linear ordering which makes it real closed".

Artie Khovanov (Dec 28 2025 at 18:37):

The "right" definition of that notion is imv a real field FF such that, for all xx in FF, either xx or x-x is a square, and moreover all odd-degree polynomials over FF have a root - ie Florent's condition 2. And yeah it's a general fact that real fields have a unique ordering iff for all xx in FF, either xx or x-x is a square (or if you like you can even drop real and say for all nonzero xx in FF, exactly one of xx and x-x is a square).

Violeta Hernández (Dec 28 2025 at 18:42):

Actually, is the condition that a linear order be a ring ordering equivalent to docs#IsOrderedRing ? Or are these separate things?

Artie Khovanov (Dec 28 2025 at 18:44):

We usually want IsStrictOrderedRing, which is equivalent over domains to IsOrderedRing, but the instance isn't in Mathlib, so we spell "(totally) ordered field" as [Field F] [LinearOrder F] [IsStrictOrderedRing F] .

Artie Khovanov (Dec 28 2025 at 18:45):

But, to answer your question, depending on the source you read, an "order compatible with ring operations" means, usually, IsOrderedRing and, more rarely, IsStrictOrderedRing.

Violeta Hernández (Dec 28 2025 at 18:46):

I believe we recently did make this into an instance: docs#IsOrderedRing.toIsStrictOrderedRing

Artie Khovanov (Dec 28 2025 at 18:46):

huh
my PR got turned down iirc :sob:

Violeta Hernández (Dec 28 2025 at 18:47):

Second time's the charm?

Artie Khovanov (Dec 28 2025 at 18:48):

Oh I am silly, just checked the blame
That was my PR!
What got turned down was me weakening the typeclasses everywhere!
Because it added about 1% to Mathlib's compile time, spread out over pretty much all the algebra/order files.

Artie Khovanov (Dec 28 2025 at 18:48):

So the instance is there but you shouldn't use it unless you really need to.

Violeta Hernández (Dec 28 2025 at 18:49):

Artie Khovanov said:

But, to answer your question, depending on the source you read, an "order compatible with ring operations" means, usually, IsOrderedRing and, more rarely, IsStrictOrderedRing.

Hmm, so what so you think about this? Having the IsRealClosedinstance not depend on orders, and proving theorems about real closed fields with their canonical ordering using the typeclasses IsRealClosed + LinearOrder + IsStrictOrderedRing

Artie Khovanov (Dec 28 2025 at 18:50):

That could work yeah! (But IsStrictOrderedRing because of what I said)

Artie Khovanov (Dec 28 2025 at 18:51):

Like the first thing you prove is that x ≥ 0 ↔ IsSquare x, and then you proceed as normal

Artie Khovanov (Dec 28 2025 at 19:05):

I'm very happy to announce that the main theorem of the project, the characterisation of real closed fields, has been proved (sorry-free). It's IsRealClosed.TFAE in this file. The project blueprint is at https://artie2000.github.io/real_closed_field.

Let RR be an ordered field. TFAE:

  1. RR is a real closed field; that is, all non-negative elements of RR have a square root and all odd-degree polynomials over RR have a root.
  2. RˉRR[X]/(X2+1)=R(i)\bar{R}\cong_{R}R[X]/(X^2+1)=R(i).
  3. RR has no nontrivial ordered algebraic extensions.
  4. RR has no nontrivial algebraic extensions by ordered fields.
  5. Polynomials over RR satisfy the intermediate value (Darboux) property.

Ruben Van de Velde (Dec 28 2025 at 19:08):

Planning to pr it to mathlib?

Artie Khovanov (Dec 28 2025 at 19:08):

(deleted)

Artie Khovanov (Dec 28 2025 at 19:09):

Ruben Van de Velde said:

Planning to pr it to mathlib?

Yes. I am in the process of PRing some preliminaries, but I could do with more eyes on the process, which is proceeding very slowly right now (tbf also because I've been slow to respond). Please help out at #PR reviews > #27282 Real algebra

Artie Khovanov (Dec 28 2025 at 19:13):

A lot of my work is technically independent of these real algbera preliminaries, so I'll start upstreaming in parallel when I get a chance.

Artie Khovanov (Dec 28 2025 at 23:59):

Weiyi Wang said:

:smile: Would be nice to see it in mathlib even with just simple definition and lemmas. I think the actual lemma I need is "you can take n-th root in real closed fields"

Now proved in the same place as IsRealClosed.exists_eq_pow_of_nonneg. This one should get into Mathlib sooner rather than later, modulo the definitional questions above.

Artie Khovanov (Dec 29 2025 at 02:28):

Violeta Hernández said:

I imagine the idea is if some other polynomial is missing a root then you can start constructing an infinite set of other polynomials that are also missing roots?

Yeah, the vibe is like, if you can do the Artin-Schreier (positive char) and Kummer (char 0) constructions once, you can iterate them over and over. And Galois theory says we always have prime-index subextensions, so that gets us started. This note by Keith Conrad has an elementary proof that I can understand, although it's probably not the one to write up in Mathlib (instead we should develop Artin-Schreier and Kummer theory more fully).

Violeta Hernández (Dec 29 2025 at 07:29):

Kummer and Artin-Schrier extensions? It's actually uncanny just how related your projects are to our combinatorial games project haha

Florent Schaffhauser (Dec 29 2025 at 10:37):

Artie Khovanov said:

I'm very happy to announce that the main theorem of the project, the characterisation of real closed fields, has been proved (sorry-free). It's IsRealClosed.TFAE in this file. The project blueprint is at https://artie2000.github.io/real_closed_field.

Let RR be an ordered field. TFAE:

  1. RR is a real closed field; that is, all non-negative elements of RR have a square root and all odd-degree polynomials over RR have a root.
  2. RˉRR[X]/(X2+1)=R(i)\bar{R}\cong_{R}R[X]/(X^2+1)=R(i).
  3. RR has no nontrivial ordered algebraic extensions.
  4. RR has no nontrivial algebraic extensions by ordered fields.
  5. Polynomials over RR satisfy the intermediate value (Darboux) property.

Congratulations! How about the following, slightly modified statement, though?

Let RR be a field. TFAE:

  1. RR is a real closed field; that is, all non-negative elements of RR have a square root and all odd-degree polynomials over RR have a root.
  2. RˉRR[X]/(X2+1)=R(i)\bar{R}\cong_{R}R[X]/(X^2+1)=R(i).
  3. RR admits an ordering and has no nontrivial ordered algebraic extensions.
  4. RR admits an ordering and has no nontrivial algebraic extensions by ordered fields.
  5. RR admits an ordering and polynomials over RR satisfy the intermediate value (Darboux) property.

The point is that it is not necessary to fix an ordering on RR at the outset.

Artie Khovanov (Dec 29 2025 at 11:45):

Florent Schaffhauser said:

Congratulations! How about the following, slightly modified statement, though?

...

The point is that it is not necessary to fix an ordering on RR at the outset.

As I said, I already have a version of this statement. But yeah I am planning to change the definition to not require an order as per your and Violeta's suggestion.

I don't think I will state it the way you have, though. Rather, I plan to have one TFAE for real fields and one for ordered fields. There isn't a nice way to state conditions (3) and (5) if you don't assume an order.

Artie Khovanov (Dec 29 2025 at 11:54):

So:

Let RR be a real field. TFAE:

  1. RR is real closed.
  2. RˉRR(i)\bar{R}\cong_R R(i).
  3. RR has no nontrivial real extensions.

Let RR be an ordered field. TFAE:

  1. RR is real closed.
  2. RR has no nontrivial ordered extensions.
  3. Polynomials over RR satisfy the IVP.

Artie Khovanov (Dec 29 2025 at 11:55):

(Note: since typeclass search finds ordered -> real, we don't need to repeat conditions (2) and (3)).

Artie Khovanov (Dec 29 2025 at 12:14):

Violeta Hernández said:

Kummer and Artin-Schrier extensions? It's actually uncanny just how related your projects are to our combinatorial games project haha

Please support my IsAdjoinRoot refactor when it comes through upstreaming so it's easier to work with concrete algebraic extensions! :slight_smile:

Artie Khovanov (Dec 30 2025 at 15:35):

image.png
RR is a RCF. Anyone know an order-free argument for this bit? I removed the order from everything else. Not mathematically necessary of course, but would be nice.

Aaron Liu (Dec 30 2025 at 15:36):

everything has a square root and every cubic+ polynomial has a root

Aaron Liu (Dec 30 2025 at 15:36):

so by repeatedly taking out roots every polynomial factors into degree-at-most-two factors over RR

Aaron Liu (Dec 30 2025 at 15:37):

then the quadratic factors split over R[i]R[i] by the quadratic formula

Artie Khovanov (Dec 30 2025 at 15:37):

It's clear (a2+b2)-(a^2+b^2) isn't a square because it's the negation of a sum of squares. But why can't (a+a2+b2)-(a+\sqrt{a^2+b^2}) be a square?

Aaron Liu (Dec 30 2025 at 15:38):

wait what

Aaron Liu (Dec 30 2025 at 15:38):

every element of R[i]R[i] has a square root

Aaron Liu (Dec 30 2025 at 15:39):

oh wait that's what you were proving

Artie Khovanov (Dec 30 2025 at 15:40):

@Aaron Liu see the blueprint for the proof I am using. I am not doing the symmetric polynomials proof.
It is not true that everything has a square root, nor that every cubic+ polynomial has a root. Rather, exactly one of xx or x-x has a square root for every x0x\neq 0, and every odd-degree polynomial has a root. These two facts together do imply that R(i)R(i) is the only nontrivial finite extension of RR, and this lemma is one step in the Galois-theoretic proof of this fact.

Aaron Liu (Dec 30 2025 at 15:40):

yeah I have a proof

Aaron Liu (Dec 30 2025 at 15:42):

for the lemma you showed

Aaron Liu (Dec 30 2025 at 15:42):

I think I have a proof

Aaron Liu (Dec 30 2025 at 15:42):

just gotta think about it a bit more make sure my proof isn't bogus

Artie Khovanov (Dec 30 2025 at 15:42):

ah OK
I misunderstood what you were saying slightly but we're on the same page now!

Aaron Liu (Dec 30 2025 at 15:43):

so everything or its negative is a square

Aaron Liu (Dec 30 2025 at 15:43):

do I get that a sum of squares is a square or is that difficult

Artie Khovanov (Dec 30 2025 at 15:45):

That's the same difficulty as this lemma
You do get that negation of sum of squares isn't a square (ie no nontrivial sums of squares to 0)

Aaron Liu (Dec 30 2025 at 15:46):

well if the negation of a sum of squares isn't a square

Aaron Liu (Dec 30 2025 at 15:46):

then either the sum of squares is a square or the negation of the sum of squares is a square

Aaron Liu (Dec 30 2025 at 15:46):

therefore the sum of squares is a square

Artie Khovanov (Dec 30 2025 at 15:47):

oh yeah good point!

Artie Khovanov (Dec 30 2025 at 15:48):

lol that's what I said above, I'm so silly
but yeah is there a trick for the a+a2+b2a+\sqrt{a^2+b^2} when a<0a<0 (or a different approach entirely)

Aaron Liu (Dec 30 2025 at 15:48):

I'm quite confident now that my proof isn't bogus

Aaron Liu (Dec 30 2025 at 15:48):

alright so we want to prove that a+bia+bi isn't a square

Aaron Liu (Dec 30 2025 at 15:49):

the norm of a+bia+bi is (a+bi)(abi)=a2+b2(a+bi)(a-bi) = a^2 + b^2

Aaron Liu (Dec 30 2025 at 15:49):

this is a square

Aaron Liu (Dec 30 2025 at 15:49):

dividing by a2+b2\sqrt{a^2+b^2} we obtain an element of norm one

Aaron Liu (Dec 30 2025 at 15:50):

by hilbert 90 this is of the form a+bia2+b2=(c+di)/(cdi)\frac{a+bi}{\sqrt{a^2+b^2}} = (c+di)/(c-di) for some c,dRc, d \in R

Aaron Liu (Dec 30 2025 at 15:51):

then (c+di)a2+b2c2+d2(c+di)\sqrt{\frac{a^2+b^2}{c^2+d^2}} is a square root of a+bia+bi

Artie Khovanov (Dec 30 2025 at 15:52):

nice!
Hilbert 90 seems a bit overkill
I think I can find something completely elementary here

Aaron Liu (Dec 30 2025 at 15:53):

well you use the tools available

Artie Khovanov (Dec 30 2025 at 15:54):

yeah I mean
such as the axioms of an ordered ring!

Artie Khovanov (Dec 30 2025 at 15:59):

right so unpacking the axioms it comes down to, if a2b2a^2-b^2 is a square, then so are a+ba+b and aba-b, which is the heart of your proof

Aaron Liu (Dec 30 2025 at 16:00):

this feels false?

Aaron Liu (Dec 30 2025 at 16:09):

surely if I put a=1a = -1 and b=1b = -1 then we get a2b2=0=02a^2-b^2=0=0^2 but a+b=2a+b=-2 isn't a square

Artie Khovanov (Dec 30 2025 at 16:10):

sorry uh
here aa is a square and bb is not

Artie Khovanov (Dec 30 2025 at 16:11):

yeah OK this is too complicated without the notion of "order"

Aaron Liu (Dec 30 2025 at 16:12):

order is just whether or not it's a square

Aaron Liu (Dec 30 2025 at 16:14):

so I was looking at your lemma 16

Artie Khovanov (Dec 30 2025 at 16:14):

yes but I mean, how does the proof of a2b2    aba^2\geq b^2\implies a\geq|b| go in this formalism?

Aaron Liu (Dec 30 2025 at 16:14):

Artie Khovanov said:

image.png

the proof you had in an image

Aaron Liu (Dec 30 2025 at 16:15):

can't you just avoid showing positivity at all

Artie Khovanov (Dec 30 2025 at 16:15):

I need cc and dd to be in RR, not in R(i)R(i).
This is like, the dumbest possible proof: write out a general square, compare coefficients, rearrange.

Aaron Liu (Dec 30 2025 at 16:16):

why do you need them to be in RR

Aaron Liu (Dec 30 2025 at 16:16):

what goes wrong if they're in R(i)R(i)

Artie Khovanov (Dec 30 2025 at 16:16):

(removed)

Artie Khovanov (Dec 30 2025 at 16:25):

Aaron Liu said:

what goes wrong if they're in R(i)R(i)

we are trying to prove that everything in R(i)R(i) has a square root
so we can't just be taking square roots in R(i)R(i)
I've thoroughly confused myself at this point lol

Aaron Liu (Dec 30 2025 at 16:26):

but you proved every element of RR has a square root in R(i)R(i)

Aaron Liu (Dec 30 2025 at 16:26):

a+a2+b22R\frac{a+\sqrt{a^2+b^2}}{2} \in R so it has a square root in R(i)R(i)

Artie Khovanov (Dec 30 2025 at 16:29):

oh right yep (I just came to this conclusion too lol)
yeah that's how you do it, just case split
in which case the formula isn't nearly as monstrous, either

Artie Khovanov (Dec 30 2025 at 16:33):

thanks for figuring it out, I'm really being silly today

Violeta Hernández (Dec 30 2025 at 21:26):

Artie Khovanov said:

image.png
RR is a RCF. Anyone know an order-free argument for this bit? I removed the order from everything else. Not mathematically necessary of course, but would be nice.

Not an answer to your question, but I think we should have some mechanism for declaring an ordering within a proof, so that statements don't need the order assumption, but proofs can freely use it.

Artie Khovanov (Dec 30 2025 at 21:28):

Yes, I have this already. In my project it's letI := IsSemireal.toLinearOrder K.

Artie Khovanov (Dec 30 2025 at 22:08):

@Aaron Liu I checked the standard textbooks and it looks like you can't really avoid this nasty computation (unless you start with a different definition ofc).

Aaron Liu (Dec 30 2025 at 22:09):

wait what does that mean

Artie Khovanov (Dec 30 2025 at 22:10):

like, there's not an obvious approach that's simpler than what you / we came up with

Aaron Liu (Dec 30 2025 at 22:10):

is hilbert 90 really that nasty

Violeta Hernández (Dec 30 2025 at 22:10):

We could just wrap it in an auxiliary lemma

Artie Khovanov (Dec 30 2025 at 22:10):

the proof doesn't use Hilbert 90?

Violeta Hernández (Dec 30 2025 at 22:10):

If x^2 = a^2 + b^2 then x^2 + a is a square

Artie Khovanov (Dec 30 2025 at 22:11):

I just mean you looking at my arument and observing that we don't need a+sqrt{a^2+b^2} to be a square

Ruben Van de Velde (Dec 30 2025 at 22:12):

Is this the same Hilbert 90 proved in regular flt?

Aaron Liu (Dec 30 2025 at 22:12):

Aaron Liu said:

I'm quite confident now that my proof isn't bogus

see my proof above

Violeta Hernández (Dec 30 2025 at 22:13):

I don't even need to know what Hilbert 90 is to know this is overkill

Aaron Liu (Dec 30 2025 at 22:13):

I think something similar was mentioned on the wikipedia page

Aaron Liu (Dec 30 2025 at 22:13):

the page for hilbert 90

Aaron Liu (Dec 30 2025 at 22:13):

you can classify pythagorean triples or something

Artie Khovanov (Dec 30 2025 at 22:14):

apparently the argument in my blueprint is actually Gauss' original argument
he just, solved the equations lol

Aaron Liu (Dec 30 2025 at 22:14):

algebra used to be the art of solving equations

Violeta Hernández (Dec 30 2025 at 22:16):

people had weird tastes back then

Artie Khovanov (Dec 30 2025 at 22:21):

image.png
OK the revised blueprint is ready. Will rewrite the file at some point.

Artie Khovanov (Dec 30 2025 at 22:22):

image.png
The new definition @Florent Schaffhauser. I thought it would be better to not assume realness either.

Artie Khovanov (Dec 30 2025 at 22:24):

I know this is all pretty "trivial" but computation in Lean is pain. Someday if I have time I'll write a tactic for computations in finite extensions...

Aaron Liu (Dec 30 2025 at 22:25):

this feels grindable

Artie Khovanov (Dec 30 2025 at 22:26):

The proofs are available on my repo; feel free to try golfing them!

Artie Khovanov (Dec 30 2025 at 22:26):

Well, the old order-based proofs are, but the new proofs are very similar.

Aaron Liu (Dec 30 2025 at 22:26):

I'll see what I can do

Artie Khovanov (Dec 31 2025 at 17:19):

Artie Khovanov said:

image.png
The new definition Florent Schaffhauser. I thought it would be better to not assume realness either.

Oops this definition was wrong (consider Fp\mathbb{F}_p). Sticking to the standard definition!

Aaron Liu (Dec 31 2025 at 17:20):

what happens in oh I get it

Aaron Liu (Dec 31 2025 at 17:20):

actually no I don't get it

Aaron Liu (Dec 31 2025 at 17:21):

what's up with Fp\mathbb{F}_p

Aaron Liu (Dec 31 2025 at 17:27):

yeah this definition seems fine

Aaron Liu (Dec 31 2025 at 17:46):

ah yeah I think I get it now

Artie Khovanov (Dec 31 2025 at 17:46):

quadratic residues

Artie Khovanov (Dec 31 2025 at 17:47):

indeed I think "sums of squares in F are squares in F" is equivalent to "all elements of F(i) are squares"

Artie Khovanov (Dec 31 2025 at 17:56):

@Aaron Liu
The map xx2x\to x^2 on Fp×\mathbb{F}_p^\times has kernel {±1}\{\pm1\}, so exactly half of the nonzero residues modulo pp are squares (these are called quadratic residues in number theory). Moreover, since Fp×\mathbb{F}_p^\times is cyclic and 1-1 has order 2, 1-1 is not a square. Therefore exactly one of aa and a-a is a square for every aFp×=Fp{0}a\in\mathbb{F}_p^\times=\mathbb{F}_p\setminus\{0\}. However, Fp\mathbb{F}_p is not even real, let alone real closed, since 1=1++1-1=1+\cdots+1 is a sum of squares.

Aaron Liu (Dec 31 2025 at 17:59):

Artie Khovanov said:

Moreover, since Fp×\mathbb{F}_p^\times is cyclic and 1-1 has order 2, 1-1 is not a square.

no I'm pretty sure that only happens if p3(mod4)p \equiv 3 \pmod{4}

Aaron Liu (Dec 31 2025 at 18:00):

and what happened to the part where all odd degree polynomials have a root

Artie Khovanov (Dec 31 2025 at 18:01):

Oh damn I'm so bad at this :skull:
And sorry I thought you were saying you didn't know what residues were!

Aaron Liu (Dec 31 2025 at 18:01):

oh sorry I know what residues are

Artie Khovanov (Dec 31 2025 at 18:02):

Aaron Liu said:

and what happened to the part where all odd degree polynomials have a root

yeah ik it's not strictly a counterexample but it shows the argument can't work
just need to think of a field F with no odd-degree extensions such that F(i) has a quadratic extension
probably the limit of odd-degree finite extensions of Q\mathbb{Q} works

Aaron Liu (Dec 31 2025 at 18:04):

Artie Khovanov said:

probably the limit of odd-degree finite extensions of Q\mathbb{Q} works

I don't think you get that everything or its minus is a square

Aaron Liu (Dec 31 2025 at 18:05):

I think the limit colimit of the odd-degree finite extensions of Fp\mathbb{F}_p works when p3(mod4)p \equiv 3 \pmod{4}

Artie Khovanov (Dec 31 2025 at 18:16):

Yep that works I think
Nice
Thanks!

Florent Schaffhauser (Jan 01 2026 at 08:53):

Artie Khovanov said:

[...]
However, Fp\mathbb{F}_p is not even real, let alone real closed, since 1=1++1-1=1+\cdots+1 is a sum of squares.

If not yet included in your development, you could add that real fields necessarily have characteristic zero.

Artie Khovanov (Jan 01 2026 at 13:42):

Florent Schaffhauser said:

Artie Khovanov said:

[...]
However, Fp\mathbb{F}_p is not even real, let alone real closed, since 1=1++1-1=1+\cdots+1 is a sum of squares.

If not yet included in your development, you could add that real fields necessarily have characteristic zero.

Yeah I will do. Changing the definition has forced me to add a bunch of facts about real fields.

Artie Khovanov (Jan 01 2026 at 13:42):

Was just giving an elementary proof ^^

Artie Khovanov (Jan 02 2026 at 23:36):

Artie Khovanov said:

OK the revised blueprint is ready. Will rewrite the file at some point.

Rewrite done! The definition of RCF no longer requires an ordered field:

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

Artie Khovanov (Jan 07 2026 at 02:09):

Now tracking upstreaming PRs at this topic - please help out with reviews if you can!

Elliot Glazer (Jan 24 2026 at 04:02):

Artie Khovanov said:

Eventually I want to prove the Tarski-Seidenberg principle, but that's quite far away and I'm not really sure how equipped Lean is to handle the computational aspects of the theory.

I believe Lean can prove termination of all primitive recursive functions, so it should be able to directly implement the CAD algorithm for deciding the theory of a real-closed field. This should even be able to decide propositions about e.g. (R,+,,<,0,1,π)(\mathbb{R}, +, \cdot, <, 0, 1, \pi) thanks to the effective bounds on transcendentality of π\pi provided by Baker's Theorem.

Of course, proving this algorithm correctly resolves propositions about these fields would be much more involved than merely implementing it.

Artie Khovanov (Jan 24 2026 at 11:57):

Yeah I mean in practice rather than in principle


Last updated: Feb 28 2026 at 14:05 UTC