leanprover / leanprover/lean4

Nested inductives cannot have indices

Open
#1,964 3 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

P-low
Dominant language
Lean
Stars
9.2k
Forks
990
Avg merge
1d 17h
Merged PRs (30d)
175

Description

Prerequisites
  • Put an X between the brackets on this line if you have done all of the following:
    • Checked that your issue isn't already filed.
    • Reduced the issue to a self-contained, reproducible test case.
Description

The definition of Foo1 below succeeds, but Foo2 fails with the error (kernel) invalid nested inductive datatype 'Prod', nested inductive datatypes parameters cannot contain local variables.

inductive Foo1 : Nat -> Nat -> Type where 
| bar1 : ∀ (a b: Nat), (Foo1 a b × Foo1 a b) -> Foo1 a b

inductive Foo2 : Nat -> Nat -> Type where 
| bar2 : ∀ (a b c: Nat), (Foo2 a c × Foo2 b c) -> Foo2 a c

Expected behavior: The definition of both Foo1 and Foo2 to succeed.

Actual behavior: Foo2 fails with the error (kernel) invalid nested inductive datatype 'Prod', nested inductive datatypes parameters cannot contain local variables.

Reproduces how often: 100%

Versions

Checked on:

  • Lean (version 4.0.0-nightly-2022-12-16, commit f6cd6c069587, Release) MacOS
  • Lean (version 4.0.0-nightly-2022-10-22, commit 1e00eff3e7e8, Release) MacOS
Additional Information

For this trivial example expanding Prod works, i.e.

inductive Foo2 : Nat -> Nat -> Type where 
| bar2 : ∀ (a b c: Nat), Foo2 a c -> Foo2 b c -> Foo2 a c

but my use case is more complex.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the self-contained Foo1 and Foo2 definitions in the issue, comparing the failing nested Prod case with the expanded constructor form. Done means the original Foo2 definition is accepted without the invalid nested inductive datatype error, while preserving the reported behavior.

Written by the indexing model from the issue text.

Assessment

Domain
compilers
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.