Type universes and mutual definitions not working together
Nobody has claimed this yet.
- Dominant language
- Lean
- Stars
- 9.2k
- Forks
- 990
- Avg merge
- 1d 17h
- Merged PRs (30d)
- 175
Description
Prerequisites
Please put an X between the brackets as you perform the following steps:
- Check that your issue is not already filed:
https://github.com/leanprover/lean4/issues - Reduce the issue to a minimal, self-contained, reproducible test case.
Avoid dependencies to Mathlib or Batteries. - Test your test case against the latest nightly release, for example on
https://live.lean-lang.org/#project=lean-nightly
(You can also use the settings there to switch to “Lean nightly”)
Description
The following code
inductive ArityZero
inductive Expr (sig: Type u)
def IsStrongCause (expr: Expr sig) := expr = expr
mutual
def bar (a: IsStrongCause expr): True := trivial
def foo (expr: Expr ArityZero) :=
let isc: IsStrongCause expr := rfl
bar isc
end
procuces the following error
application type mismatch
bar isc
argument
isc
has type
IsStrongCause expr : Prop
but is expected to have type
IsStrongCause ?m.141 : Prop
Using @bar ArityZero expr isc instead gives
application type mismatch
@bar ArityZero
argument
ArityZero
has type
Type : Type 1
but is expected to have type
Type u_1 : Type (u_1 + 1)
The issue does not manifest if either:
- the type of
sigis changed fromType utoType - the type of
ArityZerois changed fromTypetoType u, or - the definitions are made not mutual (which is OK since they aren't recursive)
Expected behavior: The code produces no errors, as in the case of the above changes.
Versions
Lean: 4.12.0-nightly-2024-10-01
OS/Platform: live.lean-lang.org
Impact
Add 👍 to issues you consider important. If others are impacted by this issue, please ask them to add 👍 to it.
Contributor 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.
Research direction
Start by running the self-contained reproducer from the issue against the specified Lean nightly version, then compare it with the listed non-mutual and universe-annotation variants. Done means the original mutual definitions using Type universes elaborate without errors; no repository file or test is named.
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
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 42/100