leanprover-community / leanprover-community/lean

Kernel failed to type-check due to name collision involving `include`

Open
#751 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
C++
Stars
433
Forks
79
PR merge metrics
No merged PRs in 30d

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

Under the following conditions, we get an error in the kernel:

  • two variables, one depending on another
  • the dependent one is included, transitively includeing its dependency
  • there is a local variable with the same name as the dependency
  • the included variables are not used in the declaration
Steps to Reproduce

The following code errors:

variables (a : ℕ)
variables (ha : a = a)

include ha

theorem ex (a : ℕ) : a = a := rfl

/-
error:
kernel failed to type check declaration 'ex' this is usually due to a buggy tactic or a bug in the builtin elaborator
elaborated type:
  a = a → ℕ → ∀ (a : ℕ), a = a
elaborated value:
  λ (ha : a = a) (a a : ℕ), rfl
nested exception message:
failed to add declaration to environment, it contains local constants
-/

Expected behavior: No errors in the kernel, like when there's no name clash.

Actual behavior: An error:

error:
kernel failed to type check declaration 'ex' this is usually due to a buggy tactic or a bug in the builtin elaborator
elaborated type:
  a = a → ℕ → ∀ (a : ℕ), a = a
elaborated value:
  λ (ha : a = a) (a a : ℕ), rfl
nested exception message:
failed to add declaration to environment, it contains local constants

Reproduces how often: always

Versions

Lean (version 3.45.0, commit 22b09be35ef6, Release)

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 Lean reproducer under Lean 3.45.0, focusing on the interaction between dependent variables, transitive include, and the local name collision. Done means the declaration type-checks without the kernel reporting local constants in the environment, while the no-name-clash case continues to work.

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
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.