Documentation

Lean.Meta.Tactic.Grind.Action

Action #

Action is the control interface for grind’s search steps. It is defined in Continuation-Passing Style (CPS):

abbrev Action :=
  Goal → (kna : Goal → GrindM ActionResult) → (kp : Goal → GrindM ActionResult) → GrindM ActionResult

An Action receives: the current Goal, a continuation kna to run when the action is not applicable, and a continuation kp to run when it makes progress.

It returns an ActionResult:

Why CPS? #

Two core requirements motivated CPS:

Contract (what every Action must guarantee) #

Why Action is not a Monad #

Although it looks like “a computation that can call a continuation”, Action is a control operator, not a lawful monad:

@[reducible, inline]
Instances For

    If the goal is already inconsistent, returns .closed []. Otherwise, executes then not applicable continuation.

    Instances For

      x >> y, executes x and then y

      • If x is not applicable, then x >> y is not applicable.
      • If y is not applicable, it behaves like a skip.
      Instances For

        Choice: tries x, if not applicable, tries y.

        Instances For
          @[implicit_reducible]

          Repeats x up to n times while it remains applicable.

          Instances For

            loop reference implementation without tryCatchRuntimeEx for proving sanity checking lemmas.

            Instances For

              Runs action a on the given goal.

              Instances For

                Executes x, but behaves like a skip if it is not applicable.

                Instances For

                  TSyntax `grind => TSyntax `Lean.Parser.Tactic.Grind.grindStep

                  Instances For
                    def Lean.Meta.Grind.Action.mkGrindSeq (s : List TGrind) :
                    TSyntax `Lean.Parser.Tactic.Grind.grindSeq
                    Instances For

                      Given [t₁, ..., tₙ], returns

                      · t₁
                        ...
                        tₙ
                      

                      If the list is empty, it returns · done.

                      Instances For

                        If tracing is enabled and continuation produced .closed [t₁, ..., tₙ], returns the singleton sequence [t] where t is

                        · t₁
                          ...
                          tₙ
                        
                        Instances For

                          If tracing is enabled and continuation produced .closed [(next => t₁; ...; tₙ)] or its variant using · returns .close [t₁, ... tₙ]

                          Instances For

                            Appends a new tactic syntax to a successful result. Used by leaf actions to record the tactic that produced progress. If (← getConfig).trace is false, it just returns r.

                            Instances For

                              Returns .closed [← mk] if tracing is enabled, and .closed [] otherwise.

                              Instances For

                                A terminal action which closes the goal or not. This kind of action may make progress, but we only include mkTac into the resulting tactic sequence if it closed the goal.

                                Instances For

                                  Returns true if the tactic sequence seq closes goal starting at saved state s?. If s? is none just returns true.

                                  Instances For

                                    Helper action that checks whether the resulting tactic script produced by its continuation can close the original goal. If warnOnly = true, just generates a warning message instead of an error

                                    Instances For

                                      Helper action for satellite solvers that use CheckResult.

                                      Instances For

                                        Some sanity check properties.