leanprover-community / leanprover-community/mathlib4

`apply_rules` with discharger

Open
#3,844 0 comments 0 reactions 0 assignees View on GitHub

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

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

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.