Zulip Chat Archive
Stream: mathlib4
Topic: deprecate Mathlib.Data.Nat.PartENat?
Kim Morrison (Sep 01 2025 at 03:59):
This is a leaf file, since 2018. I don't really see what it would be useful for, and I just ran into it during a (tedious, long, painful) refactor that unfortunately needs doing.
Could we get it out of the way so no one needs to run into it next time?
If there are projects using it I'm happy to hear that, but otherwise, let's clean up!
Violeta Hernández (Sep 01 2025 at 05:08):
I'd like to see the entirety of Part go. I understand there's computational nuances that make it different from Option but I don't think said nuances are relevant to Mathlib at all. Just my two cents.
Aaron Liu (Sep 01 2025 at 12:46):
Part is useful computationally, but usually I find it's too general (arbitrary proof is needed), whereas Option is too restrictive (failure must be decidable)
Kim Morrison (Sep 02 2025 at 03:01):
chore: deprecate PartENat #29231
Jovan Gerbscheid (Sep 06 2025 at 14:13):
Am I right to understand that the only purpose of Part instead of Option is to avoid using classical logic?
Aaron Liu (Sep 06 2025 at 14:20):
the purpose of Part is to make certain things computable
Jovan Gerbscheid (Sep 06 2025 at 14:22):
Do you have an example where #eval isn't otherwise possible?
Aaron Liu (Sep 06 2025 at 14:31):
Jovan Gerbscheid said:
Do you have an example where
#evalisn't otherwise possible?
when you have a function (x : α) → P x → β where P : α → Prop is a predicate which is not recursively enumerable, you can make this into a α → Part β but you can't make this into a function α → Option β using partial_fixpoint
Aaron Liu (Sep 06 2025 at 14:33):
if the predicate is RE then you can make a computable α → Option β with partial_fixpoint, but it will never return none (it will run forever instead)
Aaron Liu (Sep 06 2025 at 14:33):
if the predicate is decidable then you can make this into a total function α → Option β which is computable and always terminates
Aaron Liu (Sep 06 2025 at 14:35):
I don't have any non-RE predicates on me now, so no concrete example
Jovan Gerbscheid (Sep 06 2025 at 14:35):
Sure, but can you #eval a Part? If not, I feel like this is a "no" to my question
Aaron Liu (Sep 06 2025 at 14:36):
you can docs#Part.get a Part
Aaron Liu (Sep 06 2025 at 14:37):
if you don't feel like providing a proof then you can docs#Part.unwrap it (but this is unsound)
Aaron Liu (Sep 06 2025 at 14:37):
and these are all computable
Jovan Gerbscheid (Sep 06 2025 at 14:40):
But surely such a thing belongs in Batteries?
Aaron Liu (Sep 06 2025 at 14:41):
maybe
Jovan Gerbscheid (Sep 06 2025 at 14:47):
So from what I understand, if we make e.g. Array.find?' that returns a Part, then using that is equivalent (in the runtime) to using Array.find, but it delays the moment at which a proof needs to be given, because Array.find requires the proof upfront.
Aaron Liu (Sep 06 2025 at 14:48):
yeah that sounds right, modulo the fact that I can't find Array.find anywhere
Jovan Gerbscheid (Sep 06 2025 at 14:50):
I'm sure lean will get around to making that API at some point. Or they will make Array.find return a Part :laughing:
Aaron Liu (Sep 06 2025 at 14:50):
unfortunately the important operation Part.ωSup is noncomputable, and there's no way to make it computable since Part is too general
Jovan Gerbscheid (Sep 06 2025 at 14:51):
Wait, there is Part API for things that aren't computable when the whole point was computability?
Aaron Liu (Sep 06 2025 at 14:52):
yeah it's a bit weird
Aaron Liu (Sep 06 2025 at 14:54):
right now the behavior of getting a none is "undefined behavior", if that were weakened to "infinite loop" then Part.ωSup could be computable
Jovan Gerbscheid (Sep 06 2025 at 14:55):
Huh, but you prove in get that you can't get a none?
Aaron Liu (Sep 06 2025 at 14:56):
yes
Aaron Liu (Sep 06 2025 at 15:04):
here I have a thread
Last updated: Dec 20 2025 at 21:32 UTC