Zulip Chat Archive

Stream: mathlib4

Topic: Improve error message of `tauto`


Jon Eugster (Jul 16 2023 at 21:32):

Currently, if tauto fails, I find the error messages and proof state a bit confusing. It only shows the "unsolved goals" message which appears in various other contexts too, like having an incomplete proof skeleton, etc.

What would people think about adding an error message like "tauto failed" if tauto failed to make this clearer?

Here's a suggestion of what I'd like the behaviour to be:

MWE

Eric Wieser (Jul 16 2023 at 21:57):

Should there be a variant of focus that accepts a string title to describe the focus operation that failed? focus_with "tauto" (tacs)?

Jon Eugster (Jul 17 2023 at 11:47):

@Eric Wieser something like this?

-- `focusAndDone` already exists in core, modify it to take an error message
def focusAndDoneWithError (m : MessageData) (tactic : TacticM α) : TacticM α :=
  focus do
    let a  tactic

    -- modified code of `done` to throw the error message
    let gs  getUnsolvedGoals
    unless gs.isEmpty do
      logError m
      Term.reportUnsolvedGoals gs
      throwAbortTactic

    pure a

MWE

Eric Wieser (Jul 17 2023 at 11:50):

What does it do if something fails within tauto?

Eric Wieser (Jul 17 2023 at 11:51):

(also note that focusAndDone was called solve in lean 3) nevermind, I see you're matching core's docs#Lean.Elab.Tactic.focusAndDone

Jon Eugster (Jul 17 2023 at 11:53):

currently tauto is implemented as

focus do
  [yada yada]
  done

which I think should be exactly equivalent to

focusAndDone do
  [yada yada]

from core :+1:

Jon Eugster (Jul 17 2023 at 11:55):

and all the code above does is adding tauto failed iff unsolved goals is displayed currently.

What would be a case that tauto fails internally?

Eric Wieser (Jul 17 2023 at 11:55):

I'm suggesting something like:

-- `focusAndDone` already exists in core, modify it to take a scope name
def focusAndDoneWithScope (m : MessageData) (tactic : TacticM α) : TacticM α :=
  focus do
    try
       let a  tactic
   catch e =>
       throwError sorry -- combine m and e

    -- modified code of `done` to throw the error message
    let gs  getUnsolvedGoals
    unless gs.isEmpty do
      logError m!"{m} could not solve some goals"
      Term.reportUnsolvedGoals gs
      throwAbortTactic

Eric Wieser (Jul 17 2023 at 11:56):

That is, distinguish the tactic crashing from it failing to close a goal

Eric Wieser (Jul 17 2023 at 11:56):

Maybe docs#Lean.Elab.throwAbortTactic does some of this for you though


Last updated: Dec 20 2023 at 11:08 UTC