leanprover-community / leanprover-community/mathlib4
`apply_rules` with discharger
Open
Nobody has claimed this yet.
- Dominant language
- Lean
- Stars
- 4.2k
- Forks
- 1.7k
- PR merge metrics
- No merged PRs in 30d
Description
Using apply_rules with a discharger is a cheap way to write a nontrivial tactic. This worked before #3480 but now seems to be broken:
import Mathlib.Tactic.Positivity
import Mathlib.Tactic.SolveByElim
open Lean Mathlib
def PositivityDischarge (g : MVarId) : MetaM (Option (List MVarId)) :=
do Meta.Positivity.positivity g; pure (some []) <|> pure none
-- works
example (x : ℤ) : 0 ≤ x ^ 2 := by
solve_by_elim (config := { discharge := PositivityDischarge })
-- fails
example (x : ℤ) : 0 ≤ x ^ 2 := by
solve_by_elim (config := { discharge := PositivityDischarge, backtracking := false })
-- fails
example (x : ℤ) : 0 ≤ x ^ 2 := by
apply_rules (config := { discharge := PositivityDischarge })
See Zulip
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the three examples using the Mathlib.Tactic.Positivity and Mathlib.Tactic.SolveByElim imports, comparing apply_rules with solve_by_elim and backtracking enabled or disabled. Trace the apply_rules and solve_by_elim entry points and their discharge handling; done means the discharger succeeds in the apply_rules example and in the non-backtracking solve_by_elim case.
Written by the indexing model from the issue text.
Assessment
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100