leanprover / leanprover/lean4

Type universes and mutual definitions not working together

Open
#5,576 0 comments 0 reactions 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

Please put an X between the brackets as you perform the following steps:

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 sig is changed from Type u to Type
  • the type of ArityZero is changed from Type to Type 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

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 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.