leanprover / leanprover/lean4

Regression in v4.33.0-rc1: `simp` creates type-incorrect goals at `.implicit` transparency

Open
#14,466 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Prerequisites
Description

When updating DyLean to v4.33.0-rc1, I noticed the following regression:
the tactic simp can transform a type-correct goal (at .implicit transparency) into a type-incorrect goal at .implicit transparency)

def f {a: Type} {p: a → Prop} [DecidablePred p] (x: a) : Option (Subtype p) :=
  if h: p x then
    some ⟨x, h⟩
  else
    none

def g {a: Type} {p: a → Prop} (x: Subtype p) : a :=
  x.val

set_option linter.tacticCheckInstances true

/--
warning: produced tactic goal is not type-correct at `.implicit` transparency; consider using propositional rewriting or marking some of the following as `@[implicit_reducible]`:
  g
Full error:
  Application type mismatch: The argument
    inst✝ (g ⟨a, b⟩)
  has type
    Decidable (p (g ⟨a, b⟩))
  but is expected to have type
    Decidable (p a)
  in the application
    @dite (Option (Subtype p)) (p a) (inst✝ (g ⟨a, b⟩))

Note: This linter can be disabled with `set_option linter.tacticCheckInstances false`
-/
#guard_msgs in
public
example (a: Type) (p: a → Prop) [DecidablePred p]
  : ∀ x: Subtype p, f (g x) = some x
:= by
  simp [f, g]
  grind
Context

Likely stemming from #13895: adding the option set_option backward.isDefEq.respectTransparency.types false fixes the issue.

Steps to Reproduce

Expected behavior: simp closes the goal, and the linter does not trigger

Actual behavior: simp does not close the goal, and the linter does trigger after a call to simp

Versions
  • "4.33.0-rc1"
  • "4.34.0, commit 323137b022369d56a044ae5af01d1efd55872361" (on 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

Run the self-contained reproducer against v4.33.0-rc1 and the current nightly, focusing on simp at .implicit transparency and the linter.tacticCheckInstances warning. Investigate the interaction with backward.isDefEq.respectTransparency.types, using #13895 as context; done means simp closes the goal without producing a type-incorrect goal or triggering the linter.

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
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.