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

Incorrect promotion from index to paramater #3458

Closed
1 task done
arthur-adjedj opened this issue Feb 22, 2024 · 0 comments · Fixed by #3591
Closed
1 task done

Incorrect promotion from index to paramater #3458

arthur-adjedj opened this issue Feb 22, 2024 · 0 comments · Fixed by #3591
Labels
bug Something isn't working

Comments

@arthur-adjedj
Copy link
Contributor

arthur-adjedj commented Feb 22, 2024

Prerequisites

  • Put an X between the brackets on this line if you have done all of the following:
    • Check that your issue is not already filed.
    • Reduce the issue to a minimal, self-contained, reproducible test case. Avoid dependencies to mathlib4 or std4.

Description

Some inductive types with indices get their indices promoted to parameters in cases where it shouldn't, leading to kernel-level errors afterwards

Context

The issue was first discovered here

Steps to Reproduce

MWE:

inductive All {I : Type u} (P : I → Type v) : List I → Type (max u v) where
  | cons : P x → All P xs → All P (x :: xs)

inductive  {I : Type u}  : I → Type (max u v) where
  | mk : (i : I)  → All Iμ [] → Iμ i

Expected behavior: No error

Actual behavior: The index of gets promoted to a parameter during elaboration, leading to the following error:

arg #6 of '_nested.All_1.cons' contains a non valid occurrence

Versions

nightly-2024-02-21
Ubuntu

Additional Information

While there are some workarounds to avoid the promotion of indices to parameters, Lean would benefit from having an option to turn that feature off altogether.

Impact

Add 👍 to issues you consider important. If others are impacted by this issue, please ask them to add 👍 to it.

@arthur-adjedj arthur-adjedj added the bug Something isn't working label Feb 22, 2024
arthur-adjedj added a commit to arthur-adjedj/lean4 that referenced this issue Feb 22, 2024
arthur-adjedj added a commit to arthur-adjedj/lean4 that referenced this issue Mar 4, 2024
arthur-adjedj added a commit to arthur-adjedj/lean4 that referenced this issue Mar 4, 2024
arthur-adjedj added a commit to arthur-adjedj/lean4 that referenced this issue Mar 4, 2024
arthur-adjedj added a commit to arthur-adjedj/lean4 that referenced this issue Mar 4, 2024
arthur-adjedj added a commit to arthur-adjedj/lean4 that referenced this issue Mar 4, 2024
arthur-adjedj added a commit to arthur-adjedj/lean4 that referenced this issue Mar 4, 2024
arthur-adjedj added a commit to arthur-adjedj/lean4 that referenced this issue Mar 4, 2024
arthur-adjedj added a commit to arthur-adjedj/lean4 that referenced this issue Mar 4, 2024
arthur-adjedj added a commit to arthur-adjedj/lean4 that referenced this issue Mar 7, 2024
github-merge-queue bot pushed a commit that referenced this issue Apr 22, 2024
This PR partly addresses #3458, by adding an option `autoPromoteIndices`
to turn off the promotion of fixed indices to parameters. The actual fix
for the issue is in a separate PR #3591.

Because nested inductive datatypes parameters cannot contain local
variables, it is often desirable for a fixed index to not be promoted,
as to allow free variables in that place. See example in `3458_1.lean`
arthur-adjedj added a commit to arthur-adjedj/lean4 that referenced this issue Apr 24, 2024
github-merge-queue bot pushed a commit that referenced this issue May 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant