leanprover / leanprover/lean4

Strict positivity constraints for inductive behave differently on a type alias

Open
#13,465 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Prerequisites
Description
abbrev Alias (α : Type) := Option α

inductive I1 : Type where
| mk : Option I1 → I1

/-- error: (kernel) arg #1 of I2.mk' contains a non valid occurrence of the datatypes being declared -/
#guard_msgs in
inductive I2 : Type where
| mk : Alias I2 → I2

in this example Alias and Option should have identical effect when being used in inductive definition. But the second one failed.

The alias appears to omit the fact that X in Option X is in a positive position, and I haven't find a mechanism to make that property propagating to alias or other declarations

Context

N/A, example is self-contained

Steps to Reproduce
  1. compile the code example without comment

Expected behavior: should compile cleanly

Actual behavior: (kernel) arg #1 of I2.mk' contains a non valid occurrence of the datatypes being declared

Versions

4.29.1

Additional Information

N/A

Impact

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 Alias, I1, and I2 reproduction in the issue and compile it against Lean nightly. Investigate how strict positivity is checked for inductive declarations through type aliases; done means the I2 declaration compiles with the same behavior as the direct Option case.

Written by the indexing model from the issue text.

Assessment

Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.