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: bug at typeOccursCheck #6104

Closed
wants to merge 1 commit into from
Closed

Conversation

leodemoura
Copy link
Member

This PR fixes bug at typeOccursCheck that allowed cycles in the metavariable assignments.

closes #6013

@leodemoura leodemoura added the changelog-language Language features, tactics, and metaprograms label Nov 16, 2024
@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 Nov 17, 2024
leanprover-community-mathlib4-bot added a commit to leanprover-community/batteries that referenced this pull request Nov 17, 2024
leanprover-community-mathlib4-bot added a commit to leanprover-community/mathlib4 that referenced this pull request Nov 17, 2024
@leanprover-community-bot leanprover-community-bot added the breaks-mathlib This is not necessarily a blocker for merging: but there needs to be a plan label Nov 17, 2024
@leanprover-community-bot
Copy link
Collaborator

leanprover-community-bot commented Nov 17, 2024

Mathlib CI status (docs):

visitMVar (mvarId' : MVarId) (numArgs : Nat := 0) : Bool :=
if let some mvarDecl := mctx.findDecl? mvarId' then
occursCheck (skipAtMostNumBinders mvarDecl.type numArgs)
if let some b := skipAtMostNumBinders? mvarDecl.type numArgs then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it make more sense to get rid of skipAtMostNumBinders? altogether? Its only purpose now is to avoid doing the occurs check in some forall binder types. But not doing the type occurs check is exactly the bug we're trying to fix.

This PR fixes bug at `typeOccursCheck` that allowed cycles in the
metavariable assignments.

closes #6013
@kim-em kim-em force-pushed the typeOccursCheckIssue branch from 840b98e to fd193fe Compare November 19, 2024 05:38
@kim-em
Copy link
Collaborator

kim-em commented Nov 19, 2024

This needed one extra type ascription in Plausible, but otherwise Mathlib was unharmed.

@kim-em
Copy link
Collaborator

kim-em commented Nov 19, 2024

Oh! The change required in Plausible is exactly what is now failing in the test typeOccursCheckIssue.lean.

leanprover-community-mathlib4-bot added a commit to leanprover-community/batteries that referenced this pull request Nov 19, 2024
leanprover-community-mathlib4-bot added a commit to leanprover-community/mathlib4 that referenced this pull request Nov 19, 2024
@leanprover-community-bot leanprover-community-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 Nov 19, 2024
@JovanGerb
Copy link
Contributor

At #6128, I made a change to not create unused let binders in metavariable types when eliminating dependencies. This, together with a proper type occurs check, closes #6013 and causes no breakages.

@leodemoura leodemoura closed this Nov 21, 2024
github-merge-queue bot pushed a commit that referenced this pull request Nov 21, 2024
This PR does the same fix as #6104, but such that it doesn't break the
test/the file in `Plausible`. This is done by not creating unused let
binders in metavariable types that are made by `elimMVar`. (This is also
a positive thing for users looking at metavariable types, for example in
error messages)

We get rid of `skipAtMostNumBinders`. This function was originally
defined for the purpose of making this test work, but it is a hack
because it allows cycles in the metavariable context.

It would make sense to split these changes into 2 PRs, but I combined
them here to show that the combination of them closes #6013 without
breaking anything

Closes #6013
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 changelog-language Language features, tactics, and metaprograms 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.

stack overflow during elaboration
4 participants