-
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: drop support for termination_by' #3033
Conversation
until around 7fe6881 the way to define well-founded recursions was to specify a `WellFoundedRelation` on the argument explicitly. This was rather low-level, for example one had to predict the packing of multiple arguments into `PProd`s, the packing of mutual functions into `PSum`s, and the cliques that were calculated. Then the current `termination_by` syntax was introduced, where you sepecify the termination argument at a higher level (one clause per functions, unpacked arguments), and the `WellFoundedRelation` is found using type class resolution. The old syntax was kept around as `termination_by'`. But at the time of writing, this is not used anywhere in the lean, std, mathlib or the theroem-proving-in-lean repositories. Also, should be possible to express anything that the old syntax supported also with the new one, possibly requiring a helper type with a suitable instance, or a very generic wrapper like ``` inductive WithWFRel {a : Type _} {rel : a → a → Prop} (h : WellFounded rel) where | mk : a -> WithWFRel h instance : WellFoundedRelation (WithWFRel h) := invImage (fun x => match x with | .mk x => x) ⟨_, h⟩ ``` Since the old syntax is unused, has an unhelpful name and relies on internals, this removes the support. Now is a good time before the refactoring that's planned in #2921. The test suite was updated without particular surprises. The parametric `terminationHint` parser is gone, which means we can match on syntax more easily now, in `expandDecreasingBy?`.
Silly commit convention, removal of a feature is strange |
I think this should not be done without a clear deprecation and migration strategy, including the |
Yeah, that is something I wonder as well: How fast can we still move? Do you have evidence that this is used anywhere? And moreover that any of these theses are not better served by You are probably not on board with “Renaming the old syntax as Also, would you argue we need a migration strategy for #2921 as well? |
|
No, there has never been any indication that this was on its way out. Primes in lean generally don't indicate deprecation, they indicate a less common variation on the operation for which we couldn't think of a better name.
I do not doubt that uses are better served by And yes, I do have a current use of
Yes, of course. Any change which breaks proofs needs to have a migration strategy, even if it is only expressed in prose in the release notes. |
That’s what I thought :-) I’ll escalate this to @leodemoura. Personally I hope we are still in a phase of lean development where we can still clean up things, even if it breaks hypothetical code, and where we can use std and mathlib (and soon more stuff on reservior) to distinguish actual breakage from hypothetical breakage. |
I think you misunderstand. Having a deprecation period doesn't mean you can't clean up, and even if you don't do a deprecation period a migration guide for breakage is essential to keep users happy. Lean is moving fast and breaking my code all the time, and this is off-putting to many users we want to attract. |
Oh, that I am absolutely on board with; this change should be well documented in the release notes. |
I stand corrected, my |
I didn't say document the change, I said a migration guide. That means to explain not just that X was removed but what to replace it with. A trivial syntactic change would be best for this, followed by an explanation of how to make the more involved change to the new syntax (and potentially new proof goals). To be clear, I'm not opposed to this change. But removals especially need to come with assistance for users on how to fix their stuff. |
I agree! |
I’d like to remove support for the `termination_by'` annotation. Until leanprover-community#371 it wasn't used anywhere in lean, std, mathlib, so this PR removes the single use of it. It does so using the pattern that can be used to replace uses of `termination_by'`, should there be more: Using the helper type `WellFounded.Wrap` one can indicate an explicit `WellFounded` relation to use. So this PR uses that pattern to avoid the use of `termination_by'` here, and at the same time provides the necessary definitions for others, so when Lean drops support for `termination_by'` (leanprover/lean4#3033), we can tell users how migrate.
leanprover-community/batteries#420 adds the necessary definitions to If the release note point out how to use that idiom when this change lands, would that be satisfactory? |
There are a few separate concerns here:
For (1) I'll do my best with whatever we end up with, but my quick take is that there is no simple replacement currently, because of the aforementioned packing process. For (2) I think your suggestion is sufficient. For (3) I think it might be worth considering a syntax similar to |
Thanks for taking care of (1)! For me, the big question is: does (3) even exist? If I had seen more than the one use of Using sourcegraph I can indeed find three more occurrences of
After this research I am not entirely sure that (3) doesn’t exist. With the current facts I’d say removal is still the better option. But nothing stops us from adding |
af3d4e0
to
f6f6edd
Compare
One thing which I don't like about the current system which seems vaguely (3)-like is that you have to declare an instance in order to make the definition, even though it may just be something private to the definition. This pollutes the namespace with additional declarations (sometimes with long names), and unlike most cases you can't use a local |
Right, but you can work around that using So a work-around exists, the question is whether the work-around is ok enough, or bad enough to warrant supporting (and documenting, explaining, including the internals of bundling paramters etc.) a separate |
True, I think under the circumstances it's better not to pursue |
This removes support for the `termination_by'` annotation. Until #371 it wasn't used anywhere in lean, std, mathlib, so this PR removes the single use of it. It does so using the pattern that can be used to replace uses of `termination_by'`, should there be more: Using the helper type `WellFounded.Wrap` one can indicate an explicit `WellFounded` relation to use. So this PR uses that pattern to avoid the use of `termination_by'` here, and at the same time provides the necessary definitions for others, so when Lean drops support for `termination_by'` (leanprover/lean4#3033), we can tell users how migrate. * Use wfRel instead
Added a (short) migration guide to the release notes. Will probably merge next week, maybe around monday afternoon my time. |
Right. I guess you’d end up with something like “ |
I plan to remove support for `termination_by' (leanprover/lean4#3033), and investigated uses in the wild. Your case case be replaced with `termination_by` rather easily.
until around 7fe6881 the way to define well-founded recursions was to
specify a
WellFoundedRelation
on the argument explicitly. This wasrather low-level, for example one had to predict the packing of multiple
arguments into
PProd
s, the packing of mutual functions intoPSum
s,and the cliques that were calculated.
Then the current
termination_by
syntax was introduced, where youspecify the termination argument at a higher level (one clause per
functions, unpacked arguments), and the
WellFoundedRelation
is foundusing type class resolution.
The old syntax was kept around as
termination_by'
. This is not usedanywhere in the lean, std, mathlib or the theorem-proving-in-lean repositories,
and three occurrences I found in the wild can do without
In particular, it should be possible to express anything that the old syntax
supported also with the new one, possibly requiring a helper type with a
suitable instance, or the following generic wrapper that now lives in std
Since the old syntax is unused, has an unhelpful name and relies on
internals, this removes the support. Now is a good time before the
refactoring that's planned in #2921.
The test suite was updated without particular surprises.
The parametric
terminationHint
parser is gone, which means we canmatch on syntax more easily now, in
expandDecreasingBy?
.