leanprover / leanprover/lean4

`rw` and `simp` do not invoke tactics specified in auto-params

Open
#3,475 2 comments 9 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

Here is mwe provide by Jireh Loreaux.

theorem foo (m : Nat) (h : m.succ = 1 := by assumption) : m.succ = 1 := h

theorem foo' (m : Nat) (h : m.succ = 1) : m.succ = 1 := h

example (m : Nat) (h : m.succ = 1) : m.succ = 1 := by
  rw [foo'] -- succeeds, leaving the goal `⊢ m.succ = n`
  exact h

example (m : Nat) (h : m.succ = 1) : m.succ = 1 := by
  rw [foo _] -- succeeds, the autoParam fills the proof obligation

example (m : Nat) (h : m.succ = 1) : m.succ = 1 := by
  rw [foo]
  /-
  tactic 'assumption' failed

  m✝: Nat
  h: Nat.succ m✝ = 1
  m: Nat
  ⊢ Nat.succ m = 1
  -/

example (m : Nat) (h : m.succ = 1) : m.succ = 1 := by
  simp [foo _] -- succeeds, the autoParam fills the proof obligation

example (m : Nat) (h : m.succ = 1) : 1 + m.succ = 2 := by
  simp [foo] -- simp made no progress

The main obstacle is that to execute tactics we need to be in TacticM, but simp and rw implemented using MetaM. We had to address a similar issue for implementing custom discharge tactics for simp: https://github.com/leanprover/lean4/blob/master/src/Lean/Elab/Tactic/Simp.lean#L37

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 custom simp discharge-tactic implementation cited in src/Lean/Elab/Tactic/Simp.lean around line 37, then trace how rw and simp handle auto-params. The examples in the issue should execute the tactic supplied by the auto-param, and the final simp example should make progress.

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.