Skip to content
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

fix: occurence check in mkInjectiveTheoremTypeCore? #3398

Merged
merged 2 commits into from
May 6, 2024

Conversation

arthur-adjedj
Copy link
Contributor

@arthur-adjedj arthur-adjedj commented Feb 19, 2024

Closes #3386

Currently, when generating the signature of an injectivity lemma for a certain constructor c : forall xs, Foo a_1 ... a_n, mkInjectiveTheoremTypeCore? will differentiate between variables which are bound to stay the same between the two equal values (i.e inductive indices), and non-fixed ones. To do that, the function currently checks whether a variable x ∈ xs appears in the final co-domain Foo a_1 ... a_n of the constructor. This condition isn't enough however. As shown in the linked issue, the codomain may also depend on variables which appears in the type of free vars contained in Foo a_1 ... a_n, but not in the term itself. This PR fixes the issue by also checking the types of any free variable occuring in the final codomain, so as to ensure injectivity lemmas are well-typed.

@github-actions github-actions bot added the toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN label Feb 19, 2024
leanprover-community-mathlib4-bot added a commit to leanprover-community/batteries that referenced this pull request Feb 19, 2024
leanprover-community-mathlib4-bot added a commit to leanprover-community/mathlib4 that referenced this pull request Feb 19, 2024
@leanprover-community-mathlib4-bot leanprover-community-mathlib4-bot added the builds-mathlib CI has verified that Mathlib builds against this PR label Feb 19, 2024
@leanprover-community-mathlib4-bot
Copy link
Collaborator

leanprover-community-mathlib4-bot commented Feb 19, 2024

Mathlib CI status (docs):

  • ✅ Mathlib branch lean-pr-testing-3398 has successfully built against this PR. (2024-02-19 14:56:16) View Log
  • ✅ Mathlib branch lean-pr-testing-3398 has successfully built against this PR. (2024-02-19 15:38:43) View Log
  • ❗ Std/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase 605cecdde33e2ae84dec5653af4d8f9bc2649b17 --onto 62cdb51ed5b9d8487877d5a4adbcd4659d81fc6a. (2024-04-24 20:33:27)

leanprover-community-mathlib4-bot added a commit to leanprover-community/batteries that referenced this pull request Feb 19, 2024
leanprover-community-mathlib4-bot added a commit to leanprover-community/mathlib4 that referenced this pull request Feb 19, 2024
@arthur-adjedj arthur-adjedj marked this pull request as ready for review March 6, 2024 23:18
@arthur-adjedj
Copy link
Contributor Author

awaiting-review

@github-actions github-actions bot added the awaiting-review Waiting for someone to review the PR label Mar 6, 2024
arthur-adjedj added a commit to arthur-adjedj/lean4 that referenced this pull request Mar 13, 2024
There remains 2 issues:
- the check for existing mutual equivalents of the nested appearance is not right. This will need more work
- (not certain) instead of simply collecting necessary local variables from `loose_bvars`, we should also collect them in the type of the lvars associated, in a chain, similarly to `occursOrInType` in PR leanprover#3398

The generation of `SizeOf` is failing on a simple example, and more complex ones lead to a segfault, but this is a good step forward.
arthur-adjedj added a commit to arthur-adjedj/lean4 that referenced this pull request Mar 15, 2024
There remains 2 issues:
- the check for existing mutual equivalents of the nested appearance is not right. This will need more work
- (not certain) instead of simply collecting necessary local variables from `loose_bvars`, we should also collect them in the type of the lvars associated, in a chain, similarly to `occursOrInType` in PR leanprover#3398

The generation of `SizeOf` is failing on a simple example, and more complex ones lead to a segfault, but this is a good step forward.
arthur-adjedj added a commit to arthur-adjedj/lean4 that referenced this pull request Mar 31, 2024
There remains 2 issues:
- the check for existing mutual equivalents of the nested appearance is not right. This will need more work
- (not certain) instead of simply collecting necessary local variables from `loose_bvars`, we should also collect them in the type of the lvars associated, in a chain, similarly to `occursOrInType` in PR leanprover#3398

The generation of `SizeOf` is failing on a simple example, and more complex ones lead to a segfault, but this is a good step forward.
github-merge-queue bot pushed a commit that referenced this pull request Apr 24, 2024
Not certain this is a good idea. Motivated by code duplication
introduced in #3398.
@semorrison
Copy link
Collaborator

!bench

@leanprover-bot
Copy link
Collaborator

Here are the benchmark results for commit 70a0ce4.
There were no significant changes against commit 605cecd.

@semorrison semorrison added this pull request to the merge queue May 6, 2024
Merged via the queue into leanprover:master with commit e0c1afd May 6, 2024
11 checks passed
@semorrison semorrison removed the awaiting-review Waiting for someone to review the PR label May 9, 2024
github-merge-queue bot pushed a commit that referenced this pull request May 10, 2024
This reverts commit 706a4cf introduced
in #3970

As explained in #4124, `findM?` can become a footgun if used in monads
which induce side-effects such as caching. This PR removes that
function, and fixes the code introduced by #3398 for which the function
was first added.

cc @semorrison.
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 toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN
Projects
None yet
Development

Successfully merging this pull request may close these issues.

genInjectivity failure
4 participants