leanprover / leanprover/lean4

Running `simp?` output produces different goal than `simp`

Open
#4,615 4 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug P-medium
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
 /-- info: "4.10.0-rc1" -/
#guard_msgs in
#eval Lean.versionString

/--
info: Try this: simp only [exists_prop, exists_and_left, exists_eq_right_right]
---
warning: declaration uses 'sorry'
---
info: [Meta.Tactic.simp.rewrite] exists_prop:1000, ∃ x_1, a = x ==> 1 < a ∧ a = x
[Meta.Tactic.simp.rewrite] exists_and_left:1000, ∃ x_1, 1 < a ∧ a = x ==> 1 < a ∧ ∃ x_1, a = x
[Meta.Tactic.simp.rewrite] exists_prop:1000, ∃ x_1, a = x ==> 0 < a ∧ a = x
[Meta.Tactic.simp.rewrite] exists_eq_right_right:1000, ∃ a, 1 < a ∧ 0 < a ∧ a = x ==> 1 < x ∧ 0 < x
-/
#guard_msgs in
set_option trace.Meta.Tactic.simp.rewrite true in
example (x : Nat) : ∃ (a : Nat) (_ : 0 < a) (_ : 1 < a), a = x := by
  simp?
  show 1 < x ∧ 0 < x
  sorry

example (x : Nat) : ∃ (a : Nat) (_ : 0 < a) (_ : 1 < a), a = x := by
  simp only [exists_prop, exists_and_left, exists_eq_right_right]
  show 0 < x ∧ 1 < x
  sorry
Context

Originally reported on Zulip.

Steps to Reproduce

Paste the above code into a Lean editor.

Expected behavior: The goal is the same.

Actual behavior: The goal is different.

Versions

This particular repro works on 4.7.0+ (where the simp lemmas were introduced), but there may be a simpler reproduction that uses pre-4.7.0 simp lemmas.

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 reproduction from the issue in a Lean nightly environment and compare the goals after simp? and the explicit simp only invocation. Investigate the simp? tactic output and the simplifier rewrite trace; done means both forms produce the same goal for this example and the reproduced test passes.

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
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.