Zulip Chat Archive
Stream: general
Topic: Poll: partial order on complex numbers in mathlib
Bryan Gin-ge Chen (Feb 11 2021 at 06:17):
/poll
Bryan Gin-ge Chen (Feb 11 2021 at 06:18):
Oh, would it be better to put the poll in #general?
Notification Bot (Feb 11 2021 at 06:20):
This topic was moved here from #PR reviews > #4684 by Bryan Gin-ge Chen
Bryan Gin-ge Chen (Feb 11 2021 at 06:21):
Quoting from #4684:
/--
We put a partial order on ℂ so that `z ≤ w` exactly if `w - z` is real and nonnegative.
Complex numbers with different imaginary parts are incomparable.
-/
instance : partial_order ℂ :=
{ le := λ z w, ∃ x : ℝ, 0 ≤ x ∧ w = z + x,
...
Johan Commelin (Feb 11 2021 at 06:49):
Are there any other candidates for which we might want to use results from the order library?
Damiano Testa (Feb 11 2021 at 06:58):
I am not sure whether this is relevant or not, but there are partial orderings on ℂ, different than the one above that appear in the literature. For instance, when talking about Bridgeland stability conditions, (partially) ordering complex numbers by a choice of argument appears often. One example, is on page 2 of the paper below, with even an explanatory picture:
https://www.maths.ed.ac.uk/~abayer/dc-lecture-notes.pdf
Mario Carneiro (Feb 11 2021 at 07:15):
Well it's not just a matter of whether there is any better order to put on the complexes. Not putting an order on the complexes should also be an option. Sometimes I think that we're undermining the benefits of type theory when we make everything apply to everything like this; I'm reminded of the incident where nat
had a has_coe_fn
to nat -> nat
Mario Carneiro (Feb 11 2021 at 07:16):
My rationale is that if you ask a mathematician "are the complexes ordered" the answer you will get is "no"
Scott Morrison (Feb 11 2021 at 07:18):
I guess my ancient functional analysis origins are showing. I would have said "yes". :-)
Mario Carneiro (Feb 11 2021 at 07:18):
I have seen this particular order before, I think in coq or mizar, but it seems more like a formalization trick than anything else
Scott Morrison (Feb 11 2021 at 07:18):
It's the standard ordering on any Banach *
-algebra or C*-algebra, specialised to the smallest example of such.
Mario Carneiro (Feb 11 2021 at 07:19):
is there a wiki link for this?
Damiano Testa (Feb 11 2021 at 07:20):
Just to clarify: what I meant by my comment is that I personally would not consider the complex numbers to be ordered, but I am happy with someone saying "for this section, I am going to order the complex numbers as follows: [...]". Whether they use the "lexicographic-like" stuff with the reals, arguments, norms, or whatever else is less relevant (to me!).
So, from this point of view, I believe that my position is close to Mario's.
Scott Morrison (Feb 11 2021 at 07:20):
wikipedia does indeed say the ordering is only on the self-adjoint elements
Scott Morrison (Feb 11 2021 at 07:22):
https://en.wikipedia.org/wiki/C*-algebra#Structure_of_C*-algebras
Scott Morrison (Feb 11 2021 at 07:23):
Okay, I'll agree that extending the partial order, rather than just the self-adjoint elements, is not particularly important or useful.
Scott Morrison (Feb 11 2021 at 07:23):
It's useful for the sake of formalisation, because you don't need to carry around witnesses of self-adjointness when talking about the ordering of self-adjoint elements.
Mario Carneiro (Feb 11 2021 at 07:26):
well that should be some kind of subspace. Of course this is pretty explicit for real
Mario Carneiro (Feb 11 2021 at 07:30):
That said I'm sympathetic to the formalization argument and I won't fight too hard on this. I just want to double check that this isn't another division by zero kind of thing that will require us to defend the choice to aghast mainstream mathematicians all the time
Mario Carneiro (Feb 11 2021 at 07:31):
or maybe nat subtraction is a better parallel
Scott Morrison (Feb 11 2021 at 08:09):
I'm pretty sure this is no where near as aghasting as monus.
Kevin Buzzard (Feb 11 2021 at 08:32):
Are we talking about making this a global instance? I think most mathematicians expect C not to have an order
Scott Morrison (Feb 11 2021 at 08:49):
Ok! How should I hide it away?
Mario Carneiro (Feb 11 2021 at 08:51):
Like Bryan said, another option is to have this be an instance in a locale. That means you would say open_locale complex_order
or something like that and it would add local attribute [instance] complex.partial_order
and so on
Scott Morrison (Feb 11 2021 at 09:57):
Done!
Scott Morrison (Feb 24 2021 at 06:25):
Reviving this question briefly: someone pointed out to me recently that it is completely standard to write 0 ≤ z
in informal mathematics, when z
is a complex number to mean "z is real and non-negative".
When the partial_order ℂ
discussed above is available, it is possible to do exactly this in Lean too.
Johan Commelin (Feb 24 2021 at 06:37):
@Scott Morrison do you have particular reasons against using a locale
?
Johan Commelin (Feb 24 2021 at 06:37):
Doesn't that give us the best of both worlds?
Mario Carneiro (Feb 24 2021 at 06:52):
It's also possible to write I <= z
with that partial order, and I'm not sure what this actually means would be in the top 3 guesses if you showed this to a random mathematician
Mario Carneiro (Feb 24 2021 at 06:54):
(that said, we are of course no strangers to definitions that make sense in a limited range and give pseudo-sensible results out of range)
Johan Commelin (Feb 24 2021 at 06:56):
Right, we should just define I <= z
to mean z = 37
whenever z
is non-real :stuck_out_tongue_wink: /s
Scott Morrison (Feb 24 2021 at 07:41):
It's even pretty sensible: I <= z means z-I is a positive complex number, ie a positive real.
Scott Morrison (Feb 24 2021 at 07:42):
I don't have my heart set on making this instance global. I just wanted to say that I'd realised people use it naturally.
Johan Commelin (Feb 24 2021 at 07:52):
ooh, ok :thumbs_up:
Gabriel Ebner (Feb 24 2021 at 08:24):
Ah great, then we can finally write x ≤ 0 ∨ 0 ≤ x
instead of im x = 0
.
Gabriel Ebner (Feb 24 2021 at 08:26):
I would advise against making local(ized) instances for notation classes. This might get confusing because the pretty-printer will always print it as x ≤ 0
, but Lean can't parse x ≤ 0
unless the locale is opened.
Gabriel Ebner (Feb 24 2021 at 08:26):
In a similar vein, I think it would be just as confusing if we had multiple instances for has_le ℂ
.
Gabriel Ebner (Feb 24 2021 at 08:28):
I am not convinced that this type class is a good idea. But if we have it, I think it should be global.
Gabriel Ebner (Feb 24 2021 at 08:30):
In Scott's example you could just say (z : ℝ) (h : 0 ≤ z)
or even (z : ℝ≥0)
instead of (z : ℂ) (h : 0 ≤ z)
and then use coercions. And the coercion allows simp lemmas to trigger, while the hypothesis doesn't (as easily).
Damiano Testa (Feb 24 2021 at 08:36):
Following up on Gabriel's comment, the Riemann hypothesis becomes a statement about zeros of the ζ-function lying on the line
{ s : ℂ | I * s ≤ I * 1 / 2 ∨ I * 1 / 2 ≤ I * s }
i.e.
ζ (s) = 0 → I * s ≤ I * 1 / 2 ∨ I * 1 / 2 ≤ I * s
Gabriel Ebner (Feb 24 2021 at 08:42):
(deleted)
Damiano Testa (Feb 24 2021 at 08:42):
I could be wrong: I had to change it a few times to get my head around the right condition... ahahah
Gabriel Ebner (Feb 24 2021 at 08:43):
Second try (this ≤ is really hard to interpret): is this a very convoluted way of saying re s = 1/2
?
Damiano Testa (Feb 24 2021 at 08:44):
I was trying to exploit
x ≤ s ∨ s ≤ x ↔ im x = im s
Damiano Testa (Feb 24 2021 at 08:44):
Gabriel, indeed, that is what I was trying to achieve! Ahaha
Damiano Testa (Feb 24 2021 at 08:46):
I view this partial order as uncountably many incomparable orders, one for each imaginary part. On a given line with a fixed imaginary part, you simply compare the real parts. This is what it is, right?
Mario Carneiro (Feb 24 2021 at 08:46):
yes
Damiano Testa (Feb 24 2021 at 08:47):
To be honest, I am not thrilled about this order, but I am also unlikely to actually ever seriously use an order on ℂ, so I am happy to go with whatever makes formalizing simpler.
Mario Carneiro (Feb 24 2021 at 08:48):
There is another order on the complexes that I have used before, namely lexicographic order of (re z, im z)
Mario Carneiro (Feb 24 2021 at 08:48):
which has the advantage of being total
Damiano Testa (Feb 24 2021 at 08:49):
The one in question is closer to lex on (im z, re z)
, except that the order on im
is inexistent: you can only compare something with itself.
Mario Carneiro (Feb 24 2021 at 08:50):
It coincides with both
Mario Carneiro (Feb 24 2021 at 08:50):
The given partial order is a subset of both total orders (re z, im z)
and (im z, re z)
Damiano Testa (Feb 24 2021 at 08:51):
Yes, you are right: this is so confusing for me! :upside_down:
Mario Carneiro (Feb 24 2021 at 08:52):
Personally it makes more sense to me to sort the numbers -1, -I, 0, I, 1
in that order
Mario Carneiro (Feb 24 2021 at 08:53):
like if I had a whole random collection of complex numbers and wanted to arrange them lex order seems the easiest to follow
Damiano Testa (Feb 24 2021 at 08:54):
My tutees just taught me the "jungle river metric" on ℝ^2
, which has similar features (although it does allow you to change the x coordinate, but at a cost).
(You should view the x-axis as a river and you can only travel vertically or along the river, so to go from (a,b) to (c,d) you first go vertically to the x-axis, then you slide on the river and finally you move vertically again)
Jireh Loreaux (Jul 28 2023 at 15:58):
(Note: what follows was merged from another thread)
With #6210 (see also this thread), the IsROrC
class will now extend PartialOrder
, so that we can have a StarOrderedRing
instance for IsROrC
. However, this would entail making the existing scoped PartialOrder ℂ
instance a global instance (x ≤ y ↔ x.re ≤ y.re ∧ x.im = y.im
). The question is: is that okay?
Jireh Loreaux (Jul 28 2023 at 15:58):
/poll Can we make the PartialOrder ℂ
instance global?
yes
no
Kalle Kytölä (Jul 28 2023 at 16:26):
What would be the arguments against making this instance global?
Of course, one shouldn't use on too much in the first place... But when it is used in math, I think it is almost always in exactly the sense (x ≤ y ↔ x.re ≤ y.re ∧ x.im = y.im
) that Jireh describes.
Trying to force myself to think of some other mathematically reasonable meaning and use of on , I could only come up with "two-dimensional cumulative distribution functions determining a Borel (probability) measure on ", in which case the reasonable choice of partial order would be (x ≤ y ↔ x.re ≤ y.re ∧ x.im ≤ y.im
). But I doubt this other partial order should be a global instance. (For that purpose we have Fin 2 → ℝ
, I guess.)
Jireh Loreaux (Jul 28 2023 at 16:36):
Kalle, turning your comments into an argument against it would go something like this:
"there are other partial orders we may want to consider on ℂ
from time to time; e.g., two-dimensional cumulative distribution functions determining a Borel (probability) measure on ℂ
result in the pointwise order (x.re ≤ y.re ∧ x.im ≤ y.im
). If the instance suggested by the poll is made global, then to use this alternative partial order we would have to disable it locally."
I'm not saying I support that argument, but you asked for an argument against it.
Eric Wieser (Jul 28 2023 at 16:36):
What would be the arguments against making this instance global?
That the order is surprising for people who aren't paying attention, I guess. Perhaps you wrote z < w
but meant to write norm z < norm w
or z.re < w.re
.
If you think the complex partial order is stupid, then you will be annoyed that this silently did the wrong thing instead of giving you an error.
Jireh Loreaux (Jul 28 2023 at 16:41):
Eric, I think what you're suggesting is probably (IMHO) the best argument against it. Although I think where it might be most confusing is if you wanted norm z < norm w
(or something related), but for some reason they were coerced to ℂ
; then Lean doesn't complain, but you didn't get what you expected and it is sometimes easy to miss a ↑
in the goal.
Eric Wieser (Jul 28 2023 at 16:41):
A good example of another family of scoped instances is the one that sets {1} + {2, 3} = {3, 4}
; that's disabled behind the Pointwise
locale, even though its the "obvious" instance
Kevin Buzzard (Jul 28 2023 at 16:44):
I totally agree that the partial order is completely stupid, and indeed am savage with undergraduates when they write for complex numbers, but what I am unclear about is whether this instinct is a reasonable basis for arguing against not making the instance global. 6 years ago I would have also argued that is also completely stupid and I have now made my peace with this idea having better understood the nature of Lean's type theory.
Jireh Loreaux (Jul 28 2023 at 16:46):
Kevin, do you think a partial order instance on H →L[ℂ] H
with H
a Hilbert space is also stupid? (the order is propositionally the same as f₁ ≤ f₂
iff f₂ - f₁
is positive semidefinite.)
Kevin Buzzard (Jul 28 2023 at 16:50):
A more mathematical comment: a few months ago when thinking about this order I wanted to dismiss it out of hand because everyone knows that (a) there's a standard proof which shows that there's no sensible order on the complexes ("squares are nonnegative and -1 is negative") and hence (b) the complexes are a field and a ring, and this order will not make them an ordered field or an ordered ring, and thus it's a terrible idea. However the argument for (a) shows that there is no total order on the complexes which is compatible with the ring structure (squares are nonnegative because you check the two cases x>=0 and x<0, so the argument doesn't apply to which is neither > 0 nor < 0) and (b) when I actually started to think about it, the axioms you come up with are satisfied anyway; for example and doesn't imply , but this isn't true for the reals either; you have to demand and to make this work, and this is true for the complexes with the proposed order. So even though my gut feeling is that this is horrible, I cannot mathematically justify this and so I might just be wrong.
Kevin Buzzard (Jul 28 2023 at 16:52):
Jireh I have never seen that ordering in my life but perhaps my answer is: if it is a partial order which satisfies , and if and implies , and if it also satisfies under the additional assumptions and then I cannot really find a mathematical objection to it.
Jireh Loreaux (Jul 28 2023 at 16:54):
Kevin, it's the standard order on selfadjoint elements, but extended to be defined on all elements by requiring that the imaginary parts are equal. It definitely doesn't satisfy a * c ≤ b * d
if 0 ≤ a
and 0 ≤ c
because it lacks commutativity (this is partly why a StarOrderedRing
is in general not an OrderedRing
).
Kevin Buzzard (Jul 28 2023 at 16:56):
?
Jireh Loreaux (Jul 28 2023 at 16:57):
both of those inequalities fail
Kevin Buzzard (Jul 28 2023 at 16:58):
Oh interesting. Just to be clear we're assuming here, which implies that the imaginary part of is zero. This doesn't help? This is what saves us in the complexes.
Jireh Loreaux (Jul 28 2023 at 16:58):
Right, but ℂ
is commutative. The product of positive operators is positive if and only if they commute. (Essentially because that's what's needed to make the product selfadjoint)
Kalle Kytölä (Jul 28 2023 at 17:03):
Thanks everyone for much better arguments than I had in mind!
After these, I do like Eric's balanced vote for both yes and no :rofl:, but I think the self-adjoint use case is so dear to me that I vote for whatever makes it the most convenient (which I believe is Jireh's proposed instance).
Eric Wieser (Jul 28 2023 at 17:04):
Note that this has been discussed (at least once) before:
Johan Commelin said:
I think it was/is controversial to make that order an instance on
ℂ
, because it is pretty non-canonical.
Eric Wieser (Jul 28 2023 at 17:06):
In fact, we even had a poll! (in a different thread again)
Jireh Loreaux (Jul 28 2023 at 17:07):
Kevin the inequality that holds in a StarOrderedRing
is docs#conjugate_le_conjugate a ≤ b → star c * a * c ≤ star c * b * c
. (with our definition, this holds for all a b c
, but mathematically you should think of a b
as being self-adjoint and c
as being anything). When your ring is commutative and positive elements (things of the form star c * c
) have positive square roots, then you can get 0 ≤ c → a ≤ b → c * a ≤ c * b
because sqrt c
exists (and is positive, hence selfadjoint too) and c * a = sqrt c * a * sqrt c ≤ sqrt c * b * sqrt b = c * b
.
Anatole Dedecker (Jul 28 2023 at 17:08):
As I said in another thread, the thing that really sold this order to me is the fact that it’s the natural order coming from the star algebra structure.
Kalle Kytölä (Jul 28 2023 at 17:09):
I see I even upvoted Kevin's message against the instance in that thread, but I think that message gave the impression of using a ≤ b
as an obscure form of hypothesis, which I don't think it would be in clear enough operator-theory context.
(But I'm slightly torn: the "readable to any mathematician not familiar with mathlib" is a strong argument, and Eric's position seems ever more tempting. :balance: )
Anatole Dedecker (Jul 28 2023 at 17:11):
By the way, maybe I’ve been influenced by Lean too early, but I don’t remember ever seeing the order on operators being restricted to self adjoint elements 🤔
Jireh Loreaux (Jul 28 2023 at 17:28):
As far as readability is concerned, I'm skeptical that this will really be a problem, even in the context of Kevin's message. For example, I think it's totally natural for a mathematician to say that z : ℂ
is positive (they mean z ∈ Set.range ((↑) : ℝ≥0 → ℂ)
), which is just phrased as 0 ≤ z
with this partial order instance. Likewise, to say z : ℂ
is not positive just means z ∉ Set.range ((↑) : ℝ≥0 → ℂ)
(or ¬ (0 ≤ z)
.
The only small footgun I see in that regard is that ¬ (0 ≤ z)
is not equivalent to z < 0
, but of course that's to be expected since ℂ
isn't a linear order.
Eric Wieser (Jul 28 2023 at 17:34):
Eric Wieser said:
In fact, we even had a poll! (in a different thread again)
should we merge these threads? They ask exactly the same question.
Jireh Loreaux (Jul 28 2023 at 17:35):
@Kevin Buzzard in case it affects your decision, we do already have the StrictOrderedCommRing ℂ
instance in the scope in which PartialOrder ℂ
is declared.
Notification Bot (Jul 28 2023 at 17:38):
26 messages were moved here from #general > global PartialOrder ℂ instance by Eric Wieser.
Kevin Buzzard (Jul 28 2023 at 17:48):
I don't really use the complexes so I was not going to vote.
Kevin Buzzard (Jul 28 2023 at 17:49):
I mean, I know I made the PR which introduced them to mathlib in 2017 ;-) :older_man: but I've moved on since then :-)
Kalle Kytölä (Jul 28 2023 at 17:51):
The readability argument is very good against results stated directly about using . But I think the intention is to only put results in the library about generic star-ordered rings (or similar), in which case I don't think we would be actively misleading the mathematician not familiar with mathlib.
(Or maybe the form where would still be acceptable as a hypothesis, but I think this is still non-misleading.)
Jireh Loreaux (Jul 28 2023 at 17:54):
Kalle, I'm not sure I agree that we would only have results in the library about generic star ordered rings. I could certainly imagine stating inequalities about continuous functions taking values in ℂ
, because these would be relevant to the continuous functional calculus.
Eric Wieser (Jul 28 2023 at 17:56):
Maybe @Yaël Dillies can give an opinion on whether open scoped Pointwise
causes any trouble in combinatorics
Kalle Kytölä (Jul 28 2023 at 17:56):
Ok, thanks for the warning, Jireh! I think I'm still mildly in favor...
(I think if this weren't a global instance, the files containing those -specific of -valued-function-specific results would still make it an instance, and it's not that much of a readability improvement. Ultimately one just has to know the definitions...)
Eric Wieser (Jul 28 2023 at 17:57):
Ultimately I think the only things to worry about here are:
- People who are confused when they get this partial order and would prefer not to get one
- People who are confused when they expected this order but don't get it (because they forgot to write
open scoped ComplexOrder
) - Problems with using
open scoped
for instances in general
Damiano Testa (Jul 28 2023 at 18:54):
Would it be possible to pretty-print the order with a subscript as in ? My biggest concern is the "surprise" effect of having an order on .
Yury G. Kudryashov (Jul 29 2023 at 01:42):
Damiano Testa said:
Would it be possible to pretty-print the order with a subscript as in ? My biggest concern is the "surprise" effect of having an order on .
I hope, someone can write an unexpander for this.
Yury G. Kudryashov (Jul 29 2023 at 01:44):
Kalle Kytölä said:
The readability argument is very good against results stated directly about using . But I think the intention is to only put results in the library about generic star-ordered rings (or similar), in which case I don't think we would be actively misleading the mathematician not familiar with mathlib.
(Or maybe the form where would still be acceptable as a hypothesis, but I think this is still non-misleading.)
IMHO, at least comparison with zero should be allowed. Then theorems like docs#Complex.continuousAt_arg can be formulated in a more natural way h : ¬z ≤ 0
Yaël Dillies (Jul 30 2023 at 07:00):
Eric Wieser said:
Maybe Yaël Dillies can give an opinion on whether
open scoped Pointwise
causes any trouble in combinatorics
Absolutely not. pointwise
is in fact my most frequently opened locale.
Eric Wieser (Jul 31 2023 at 10:00):
@Sebastien Gouezel, @Oliver Nash, @Anne Baanen, @Floris van Doorn: has your opinion changed in the two years between the polls?
Anne Baanen (Jul 31 2023 at 10:04):
If I understand the message history here correctly: the plan is to make docs#StarOrderedRing a superclass of docs#IsROrC, which would make the currently scoped order on ℂ
a global instance?
Anne Baanen (Jul 31 2023 at 10:08):
My hesitation to make the order global is that it wasn't obviously the right one and we might want other orders instead. StarOrderedRing sounds appropriately general so in that case I'm happy with the change.
Eric Wieser (Jul 31 2023 at 10:08):
That's not really what this poll is about though: we can make the superclass without making it global, so we don't need to mix the votes here
Eric Wieser (Jul 31 2023 at 10:09):
Unless your comment is "oh, this is obviously the right order after all!"
Anne Baanen (Jul 31 2023 at 10:10):
I see, then I suppose I have one more question: did anyone need to put another order on ℂ in the meantime?
Eric Wieser (Jul 31 2023 at 10:11):
I think the answer to that is probably no.
Anne Baanen (Jul 31 2023 at 10:12):
Alright, thanks for catching me up! Then my vote is now weak support for scoped
.
Oliver Nash (Jul 31 2023 at 10:21):
Eric Wieser said:
Oliver Nash: has your opinion changed in the two years between the polls?
No, but I haven't thought carefully about this so I decided not to vote in the new poll.
Oliver Nash (Jul 31 2023 at 10:22):
Eric Wieser said:
we can make the superclass without making it global, so we don't need to mix the votes here
Looking quickly now I cannot easily reconcile this claim witht he claim in new poll saying that we would have to make the partial order instance global to create the star-ordered ring instance.
Oliver Nash (Jul 31 2023 at 10:23):
To be totally honest, I think there are already enough oars in this boat so I'm reluctant to spend time on it.
Yury G. Kudryashov (Jul 31 2023 at 18:40):
We can add le
and lt
fields to IsROrC
instead of adding PartialOrder K
to extends
.
Yury G. Kudryashov (Jul 31 2023 at 18:41):
But I would prefer to have a global StarOrderedRing
instance.
Floris van Doorn (Aug 01 2023 at 12:54):
Given that we now have a StarOrderedRing
class for which the complexes are an instance, I don't feel strongly anymore about my position to keep the order on ℂ
scoped. I think we can still keep it scoped (it seems to work fine for the pointwise operations on sets - so I see no reason it would be annoying here), but it's also ok with me if we make it global.
Last updated: Dec 20 2023 at 11:08 UTC