-
Notifications
You must be signed in to change notification settings - Fork 438
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: GuessLex: print inferred termination argument #3012
Conversation
With set_option showInferredTerminationBy true this prints a message like Inferred termination argument: termination_by ackermann n m => (sizeOf n, sizeOf m) it tries hard to use names that * match the names that the user used, if present * have no daggers (so that it can be copied) * do not shadow each other * do not shadow anything from the environment (just to be nice) it does so by appending sufficient `'` to the name. Some of the emitted `sizeOf` calls unnecessary, but they are needed sometimes with dependent parameters. A follow-up PR will not emit them for non-dependent arguments, so that in most cases the output is pretty. Somewhen down the road we also want a code action, maybe triggered by `termination_by?`. This should come after #2921, as that simplifies that feature (no need to merge termination arguments from different cliques for example.)
83769bf
to
e902a82
Compare
This seems to work, but there may be room for refinements:
|
Ok, figued out the last question myself :-) |
|
I built mathlib with the option set to
Only 19 definitions in all of mathlib need the decreasing argument to be guessed (all others are either structural, have an explicit None of these use more than one argument, which is expected, as until very recently, a definition that needed a lexicographic argument would not be accepted. There are 33
Some of them say
– was lean3 able to guess lexicographic orders? |
Actually this is a source of confusion for me: What is the default termination metric if not lexicographic? In lean 3 this was what you get out of the box, and I haven't looked at this in detail but I don't see what else one could even do here. I don't see why "guessing" is necessary and this choice of terminology suggests that I don't understand what you are trying to do. |
If you have a function with two arguments,
If you don't specify a This is not about inferring the well-founded relation, given a termination argument; that is done by type class resolution, and I did not touch that part. And there, yes, there the default is to use lexicographic orders for |
lean 3 would always do |
Thanks, that explains the porting comments.
This already happens at least for the “fixed prefixes”. So if |
…to joachim/guesslex-show-measure
…sslex-show-measure
With
this prints a message like
it tries hard to use names that
it does so by appending sufficient
'
to the name.Some of the emitted
sizeOf
calls are unnecessary, but they are neededsometimes with dependent parameters. A follow-up PR will not emit them
for non-dependent arguments, so that in most cases the output is pretty.
Somewhen down the road we also want a code action, maybe triggered by
termination_by?
. This should come after #2921, as that simplifies thatfeature (no need to merge termination arguments from different cliques
for example.)