Incomplete requirements for nested inductive types
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 48/100
- Issue type
- Documentation
- Clarity
- Clearly specified
- Activity status
- Stale
- Domain
- compilers, documentation
Research direction
Start with the Nested Inductive Types section linked in the issue and review the existing list of requirements alongside the examples provided. Check lean4#6371 for the additional parameter-position constraint. Done means the documentation covers the two missing restrictions and the broader strict-positivity condition, with the exact accepted criteria made explicit where possible.
Written by the indexing model from the issue text.
Description
The section on Nested Inductive Types, and in particular, the list of requirements nested recursive occurrences must satisfy, is incomplete.
Nested recursive occurrences must satisfy the following requirements:
- They must be nested directly under an inductive type's type constructor. Terms that reduce to such nested occurrences are not accepted.
- Local variables such as the constructor's parameters may not occur in the arguments to the nested occurrence.
- The nested occurrences must occur strictly positively.
In what way is the content incorrect?
The list of requirements misses on two known requirements that must be satisfied in order for a nested inductive type to be correctly translated.
- A nested occurrence may not be used inside the rest of the constructor in a way that would have it rely explicitly on the type it's nested in, as that could lead to the construction of an inductive-recursive type. e.g
def Option.IsNone : Option α → Type := Option.rec Unit (fun _ => Empty)
inductive Foo where
| foo : (l : Option Foo) → l.IsNone → Foo
Would need to be translated as the following inductive-recursive type to be well-formed:
mutual
inductive Foo where
| foo : OptionFoo → Foo
inductive OptionFoo where
| none
| some : Foo → Option Foo
def OptionFoo.IsNone : OptionFoo → Type
| none => Unit
| some _ => Empty
end
Instead, lean tries the naive mutual translation, and errors out when checking the translated constructors.
- A nested recursive occurrence may not appear in a parameter position that an index of the inductive type it's nested in may depend on. This one is further documented at lean4#6371, and also fails during translation instead of giving a good early error.
Furthermore, it should probably be noted that, in order for the translation to give rise to a strictly positive type, it is not only necessary that the nested recursive occurrence appear strictly positively inside another inductive type's type constructor (as pointed out in the list of requirements), but also that the type constructors the nested occurrences appear in appear themselves in a strictly positive manner. e.g in the following code, the recursive occurrence Foo appears strictly positively in Option Foo, but Option Foo itself does not appear strictly positively in the constructor, and is thus not accepted.
inductive Foo where
| foo : (Option Foo → Nat) → Foo
Lastly, this is more of a suggestion, but Lean, might benefit from making explicit the exact positivity criteria(s) the system allows for, similarly to Rocq's presentation on the matter.
- Dominant language
- Lean
- Stars
- 147
- Forks
- 72
- Avg merge
- 1d 17h
- Merged PRs (30d)
- 23
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from leanprover/reference-manual
-
doc-request
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
leanprover/reference-manual#955 ·
Maintainers usually reply within 1 day
-
doc-request
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
leanprover/reference-manual#937 ·
Maintainers usually reply within 1 day
-
doc-request
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
leanprover/reference-manual#936 ·
Maintainers usually reply within 1 day
-
doc-request
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
leanprover/reference-manual#935 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
leanprover/reference-manual#896 ·
Maintainers usually reply within 1 day
All issues in leanprover/reference-manual
Similar issues
-
area-dart-model gardening
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 87/100
Maintainers usually reply within 1 day
-
`shift(x, y)` with a uint256 shift amount >= 2**255 shifts in the wrong directionPossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 3 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 71/100
facebookexperimental/semcode#195 ·
Maintainers usually reply within 2 days
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
stjude-rust-labs/sprocket#1476 · 3 comments ·
Maintainers usually reply within 1 day