-
Notifications
You must be signed in to change notification settings - Fork 444
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: fine-grained equational lemmas for non-recursive functions #4154
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
nomeata
force-pushed
the
joachim/nonrec-eqns2
branch
from
May 13, 2024 17:08
142e1a2
to
5b1e503
Compare
github-actions
bot
added
the
toolchain-available
A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN
label
May 13, 2024
leanprover-community-mathlib4-bot
added a commit
to leanprover-community/batteries
that referenced
this pull request
May 13, 2024
leanprover-community-mathlib4-bot
added a commit
to leanprover-community/mathlib4
that referenced
this pull request
May 13, 2024
leanprover-community-mathlib4-bot
added
the
breaks-mathlib
This is not necessarily a blocker for merging: but there needs to be a plan
label
May 13, 2024
Mathlib CI status (docs):
|
leanprover-community-mathlib4-bot
added a commit
to leanprover-community/batteries
that referenced
this pull request
May 13, 2024
leanprover-community-mathlib4-bot
added a commit
to leanprover-community/mathlib4
that referenced
this pull request
May 13, 2024
…to joachim/nonrec-eqns2
leanprover-community-mathlib4-bot
added a commit
to leanprover-community/batteries
that referenced
this pull request
Jun 3, 2024
leanprover-community-mathlib4-bot
added a commit
to leanprover-community/mathlib4
that referenced
this pull request
Jun 3, 2024
leanprover-community-mathlib4-bot
added
the
release-ci
Enable all CI checks for a PR, like is done for releases
label
Jun 3, 2024
nomeata
added a commit
to nomeata/leansat
that referenced
this pull request
Jun 3, 2024
…to joachim/nonrec-eqns2
nomeata
removed
the
release-ci
Enable all CI checks for a PR, like is done for releases
label
Aug 15, 2024
leanprover-community-mathlib4-bot
added a commit
to leanprover-community/batteries
that referenced
this pull request
Aug 15, 2024
leanprover-community-mathlib4-bot
added a commit
to leanprover-community/mathlib4
that referenced
this pull request
Aug 15, 2024
to avoid `id` checkpoints in the proof, which would make the lemma ineligible for dsmip
leanprover-community-mathlib4-bot
added
the
release-ci
Enable all CI checks for a PR, like is done for releases
label
Aug 15, 2024
nomeata
removed
the
release-ci
Enable all CI checks for a PR, like is done for releases
label
Aug 15, 2024
nomeata
added a commit
that referenced
this pull request
Aug 22, 2024
This is part of #3983. After #4154 introduced equational lemmas for non-recursive functions and #5055 unififed the lemmas for structural and wf recursive funcitons, this now disables the special handling of recursive functions in `findMatchToSplit?`, so that the equational lemmas should be the same no matter how the function was defined. The new option `eqns.deepRecursiveSplit` can be disabled to get the old behavior. This can break existing code, as there now can be extra equational lemmas: * Explicit uses of `f.eq_2` might have to be adjusted if the numbering changed. * Uses of `rw [f]` or `simp [f]` may no longer apply if they previously matched (and introduced a `match` statement), when the equational lemmas got more fine-grained. In this case either case analysis on the parameters before rewriting helps, or setting the option `opt.deepRecursiveSplit false` while defining the function
leanprover-community-mathlib4-bot
added a commit
to leanprover-community/batteries
that referenced
this pull request
Aug 22, 2024
leanprover-community-mathlib4-bot
added a commit
to leanprover-community/mathlib4
that referenced
this pull request
Aug 22, 2024
leanprover-community-mathlib4-bot
added
breaks-mathlib
This is not necessarily a blocker for merging: but there needs to be a plan
and removed
builds-mathlib
CI has verified that Mathlib builds against this PR
labels
Aug 22, 2024
nomeata
changed the title
feat: fine-grained equational lemmas for non-recursive equations
feat: fine-grained equational lemmas for non-recursive functions
Aug 22, 2024
leanprover-community-mathlib4-bot
added
builds-mathlib
CI has verified that Mathlib builds against this PR
and removed
breaks-mathlib
This is not necessarily a blocker for merging: but there needs to be a plan
labels
Aug 22, 2024
nomeata
added a commit
to leanprover-community/mathlib4
that referenced
this pull request
Aug 23, 2024
commit 6d957dc Author: Joachim Breitner <[email protected]> Date: Thu Aug 22 15:10:57 2024 +0200 Fix proof commit 5b95381 Merge: 48bea5e bc78dd4 Author: leanprover-community-mathlib4-bot <[email protected]> Date: Thu Aug 22 11:24:01 2024 +0000 Trigger CI for leanprover/lean4#4154 commit 48bea5e Author: Joachim Breitner <[email protected]> Date: Wed Aug 21 18:35:50 2024 +0200 Switch to Mathlib.Init commit 4d38bbd Author: leanprover-community-mathlib4-bot <[email protected]> Date: Wed Aug 21 18:25:08 2024 +0000 Trigger CI for leanprover/lean4#4154 commit f84b84d Author: leanprover-community-mathlib4-bot <[email protected]> Date: Wed Aug 21 09:58:00 2024 +0000 Trigger CI for leanprover/lean4#4154 commit f958309 Author: leanprover-community-mathlib4-bot <[email protected]> Date: Wed Aug 21 09:39:13 2024 +0000 Trigger CI for leanprover/lean4#4154 commit 4b976ec Author: Joachim Breitner <[email protected]> Date: Wed Aug 21 10:54:32 2024 +0200 Try to remove some nolints commit 0cbb129 Author: Joachim Breitner <[email protected]> Date: Wed Aug 21 10:53:14 2024 +0200 Reduce diff commit a485ac8 Author: leanprover-community-mathlib4-bot <[email protected]> Date: Tue Aug 20 08:02:41 2024 +0000 Trigger CI for leanprover/lean4#4154 commit b5cb54a Author: leanprover-community-mathlib4-bot <[email protected]> Date: Mon Aug 19 13:09:14 2024 +0000 Trigger CI for leanprover/lean4#4154 commit 8b1ce21 Author: Joachim Breitner <[email protected]> Date: Mon Aug 19 12:56:07 2024 +0200 Like this? commit e6ce4b5 Author: Joachim Breitner <[email protected]> Date: Mon Aug 19 11:38:06 2024 +0200 nolint attributes commit e24f1c6 Author: Joachim Breitner <[email protected]> Date: Mon Aug 19 11:15:52 2024 +0200 Another simp only gone commit a9d54a8 Author: Joachim Breitner <[email protected]> Date: Mon Aug 19 11:11:30 2024 +0200 aesop_cat broke :-( commit b4edcec Author: Joachim Breitner <[email protected]> Date: Mon Aug 19 11:03:43 2024 +0200 Use dsimp only commit 8e66ddd Author: Joachim Breitner <[email protected]> Date: Mon Aug 19 10:28:04 2024 +0200 Fixes in ComposableArrows commit 471b000 Author: Joachim Breitner <[email protected]> Date: Mon Aug 19 10:18:56 2024 +0200 Use cond_false commit 8120390 Author: Joachim Breitner <[email protected]> Date: Mon Aug 19 10:14:41 2024 +0200 No rfl after simp needed anymore commit 0544693 Author: Joachim Breitner <[email protected]> Date: Mon Aug 19 10:13:00 2024 +0200 Less dsimp only commit 5cffe6e Author: Joachim Breitner <[email protected]> Date: Mon Aug 19 10:10:21 2024 +0200 More autoParam commit 8e019f8 Author: Joachim Breitner <[email protected]> Date: Fri Aug 16 17:16:43 2024 +0200 More fixes commit 7b6f094 Author: Joachim Breitner <[email protected]> Date: Fri Aug 16 17:13:46 2024 +0200 More fixes commit 3151f57 Author: Joachim Breitner <[email protected]> Date: Fri Aug 16 17:10:35 2024 +0200 More [autoParam] commit 54a6616 Author: Joachim Breitner <[email protected]> Date: Fri Aug 16 17:07:19 2024 +0200 Some fixes commit 9c41f64 Author: Joachim Breitner <[email protected]> Date: Fri Aug 16 12:15:03 2024 +0200 Check for cold cache commit 66ff376 Author: Joachim Breitner <[email protected]> Date: Fri Aug 16 14:54:25 2024 +0200 No longer needed dsimps? commit 2298410 Author: leanprover-community-mathlib4-bot <[email protected]> Date: Fri Aug 16 12:24:02 2024 +0000 Trigger CI for leanprover/lean4#4154 commit 8bca337 Author: Joachim Breitner <[email protected]> Date: Fri Aug 16 12:17:43 2024 +0200 Some reasonable fixes commit 14247a2 Author: Joachim Breitner <[email protected]> Date: Fri Aug 16 12:16:08 2024 +0200 Revert "work-around dsimp Function.eval" This reverts commit 8c36154. commit 0c86721 Author: leanprover-community-mathlib4-bot <[email protected]> Date: Fri Aug 16 10:35:28 2024 +0000 Trigger CI for leanprover/lean4#4154 commit 4b2124e Author: leanprover-community-mathlib4-bot <[email protected]> Date: Fri Aug 16 09:45:57 2024 +0000 Trigger CI for leanprover/lean4#4154 commit 125f713 Author: leanprover-community-mathlib4-bot <[email protected]> Date: Fri Aug 16 08:51:57 2024 +0000 Trigger CI for leanprover/lean4#4154 commit af7ab6c Author: Joachim Breitner <[email protected]> Date: Fri Aug 16 08:16:31 2024 +0200 Style exception commit f11401e Author: Joachim Breitner <[email protected]> Date: Fri Aug 16 08:08:49 2024 +0200 toAdditive: transport MatcherInfo commit 8c36154 Author: Joachim Breitner <[email protected]> Date: Thu Aug 15 18:27:00 2024 +0200 work-around dsimp Function.eval commit 5fcef86 Author: leanprover-community-mathlib4-bot <[email protected]> Date: Thu Aug 15 14:24:51 2024 +0000 Trigger CI for leanprover/lean4#4154 commit d4e2758 Author: leanprover-community-mathlib4-bot <[email protected]> Date: Thu Aug 15 13:59:06 2024 +0000 Trigger CI for leanprover/lean4#4154 commit af1456c Author: Joachim Breitner <[email protected]> Date: Thu Aug 15 15:49:23 2024 +0200 Fix call to getEqnsFor? commit c62ab2f Author: leanprover-community-mathlib4-bot <[email protected]> Date: Thu Aug 15 12:30:12 2024 +0000 Trigger CI for leanprover/lean4#4154 commit d9bc3e9 Author: leanprover-community-mathlib4-bot <[email protected]> Date: Thu Aug 15 11:47:22 2024 +0000 Trigger CI for leanprover/lean4#4154 commit 40bc4fe Author: Joachim Breitner <[email protected]> Date: Thu Aug 15 10:50:26 2024 +0000 chore: do not set release-ci label upon failed PR test (#15775) with leanprover/lean4#5022 the need for this should have disappeared commit 2ff3b31 Merge: 33a583e b8ad879 Author: leanprover-community-mathlib4-bot <[email protected]> Date: Thu Aug 15 10:32:05 2024 +0000 Trigger CI for leanprover/lean4#4154 commit 33a583e Merge: 1c951db 85647f2 Author: leanprover-community-mathlib4-bot <[email protected]> Date: Mon Jun 3 15:24:02 2024 +0000 Trigger CI for leanprover/lean4#4154 commit 1c951db Author: leanprover-community-mathlib4-bot <[email protected]> Date: Mon May 13 18:13:38 2024 +0000 Trigger CI for leanprover/lean4#4154 commit f05d463 Author: leanprover-community-mathlib4-bot <[email protected]> Date: Mon May 13 17:26:47 2024 +0000 Update lean-toolchain for testing leanprover/lean4#4154
github-merge-queue bot
pushed a commit
that referenced
this pull request
Aug 25, 2024
#5129) This is part of #3983. After #4154 introduced equational lemmas for non-recursive functions and #5055 unififed the lemmas for structural and wf recursive funcitons, this now disables the special handling of recursive functions in `findMatchToSplit?`, so that the equational lemmas should be the same no matter how the function was defined. The new option `eqns.deepRecursiveSplit` can be disabled to get the old behavior. ### Breaking change This can break existing code, as there now can be extra equational lemmas: * Explicit uses of `f.eq_2` might have to be adjusted if the numbering changed. * Uses of `rw [f]` or `simp [f]` may no longer apply if they previously matched (and introduced a `match` statement), when the equational lemmas got more fine-grained. In this case either case analysis on the parameters before rewriting helps, or setting the option `opt.deepRecursiveSplit false` while defining the function
tobiasgrosser
pushed a commit
to opencompl/lean4
that referenced
this pull request
Aug 26, 2024
leanprover#5129) This is part of leanprover#3983. After leanprover#4154 introduced equational lemmas for non-recursive functions and leanprover#5055 unififed the lemmas for structural and wf recursive funcitons, this now disables the special handling of recursive functions in `findMatchToSplit?`, so that the equational lemmas should be the same no matter how the function was defined. The new option `eqns.deepRecursiveSplit` can be disabled to get the old behavior. ### Breaking change This can break existing code, as there now can be extra equational lemmas: * Explicit uses of `f.eq_2` might have to be adjusted if the numbering changed. * Uses of `rw [f]` or `simp [f]` may no longer apply if they previously matched (and introduced a `match` statement), when the equational lemmas got more fine-grained. In this case either case analysis on the parameters before rewriting helps, or setting the option `opt.deepRecursiveSplit false` while defining the function
nomeata
added a commit
that referenced
this pull request
Aug 29, 2024
in #4154 and #5129 the rules for equational lemmas have changed, and new options were introduced that can be used to revert to the pre-4.12 behavior. Hopefully nobody really needs these options besides for backwards compatibility, therefore we put these options in the `backward` option name space. So the previous behavior can be achieved by setting ```lean set_option backward.eqns.nonrecursive false set_option backward.eqns.deepRecursiveSplit false ```
github-merge-queue bot
pushed a commit
that referenced
this pull request
Aug 29, 2024
in #4154 and #5129 the rules for equational lemmas have changed, and new options were introduced that can be used to revert to the pre-4.12 behavior. Hopefully nobody really needs these options besides for backwards compatibility, therefore we put these options in the `backward` option name space. So the previous behavior can be achieved by setting ```lean set_option backward.eqns.nonrecursive false set_option backward.eqns.deepRecursiveSplit false ```
bjoernkjoshanssen
pushed a commit
to leanprover-community/mathlib4
that referenced
this pull request
Sep 9, 2024
and with leanprover/lean4#4154 it actually complains, so let's remove them now.
bjoernkjoshanssen
pushed a commit
to leanprover-community/mathlib4
that referenced
this pull request
Sep 9, 2024
and with leanprover/lean4#4154 it actually complains, so let's remove them now.
bjoernkjoshanssen
pushed a commit
to leanprover-community/mathlib4
that referenced
this pull request
Sep 12, 2024
and with leanprover/lean4#4154 it actually complains, so let's remove them now.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
builds-mathlib
CI has verified that Mathlib builds against this PR
release-ci
Enable all CI checks for a PR, like is done for releases
toolchain-available
A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN
will-merge-soon
…unless someone speaks up
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is part of #3983.
Fine-grained equational lemmas are useful even for non-recursive functions, so this adds them.
The new option
eqns.nonrecursive
can be set tofalse
to have the old behavior.Breaking channge
This is a breaking change: Previously,
rw [Option.map]
would rewriteOption.map f o
tomatch o with …
. Now this rewrite will fail because the equational lemmas require constructors here (like they do for, say,List.map
).Remedies:
o
before rewriting.rw [Option.map.eq_def]
, which rewrites any (saturated) application ofOption.map
set_option eqns.nonrecursive false
when defining the function in question.Interaction with simp
The
simp
tactic so far had a special provision for non-recursive functions so thatsimp [f]
will try to use the equational lemmas, but will also unfoldf
else, so less breakage here (but maybe performance improvements with functions with many cases when applied to a constructor, as the simplifier will no longer unfold to a largematch
-statement and then collapse it right away).For projection functions and functions marked
[reducible]
,simp [f]
won’t use the equational theorems, and will only use its internal unfolding machinery.Implementation notes
It uses the same
mkEqnTypes
function as for recursive functions, so we are close to a consistency here. There is still the wrinkle that for recursive functions we don't split matches without an interesting recursive call inside. Unifying that is future work.