Zulip Chat Archive

Stream: Is there code for X?

Topic: Well-ordering of the integers


Heather Macbeth (Sep 29 2020 at 17:23):

Does mathlib have the max of a nonempty bounded-above subset of Z\mathbb{Z}?

example (s : set ) (h₁ : nonempty s) (h₂ : bdd_above s) :  k, is_greatest s k

Yury G. Kudryashov (Sep 29 2020 at 17:57):

docs#int.exists_greatest_of_bdd

Yury G. Kudryashov (Sep 29 2020 at 18:00):

Found by git grep bdd src/data/int

Heather Macbeth (Sep 29 2020 at 18:01):

Great, thank you!

Caleb Schultz Kisby (Jun 28 2023 at 03:39):

I hope it's okay for me to piggyback off of this much older thread.
Is there code for more generic applications of the Well-ordering principle? i.e. if I have my own (finite or lower-bounded) type with a custom ordering on that type, is there existing code that will let me grab the least element?

Mario Carneiro (Jun 28 2023 at 03:41):

WellFounded.min?

Siddhartha Gadgil (Jun 28 2023 at 06:59):

A related question: for the minimum of a non-empty set of natural numbers, I found an expression for example:
Nat.lt_wfRel.wf.min {n: ℕ | n % 2 = 0} (by use 2; simp)

Is there something nicer than Nat.lt_wfRel.wf.min to use here?

Mario Carneiro (Jun 28 2023 at 07:04):

Nat.find

Siddhartha Gadgil (Jun 28 2023 at 10:18):

Mario Carneiro said:

Nat.find

Thanks a lot. That is computable too.

Caleb Schultz Kisby (Jun 28 2023 at 16:17):

Thanks @Mario Carneiro, that's what I was looking for! Now I just need to figure out how to use it in my specific case :)

Caleb Schultz Kisby (Jun 28 2023 at 16:19):

Actually, Nat.find is even better, I just need to change the less-than relation!


Last updated: Dec 20 2023 at 11:08 UTC