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]
Equations
Instances For
    Equations
    Instances For

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

      Equations
      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.
        Equations
        Instances For

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

          Equations
          Instances For

            Repeats x up to n times while it remains applicable.

            Equations
            Instances For

              Runs action a on the given goal.

              Equations
              • One or more equations did not get rendered due to their size.
              Instances For

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

                Equations
                Instances For

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

                  Equations
                  Instances For
                    Equations
                    • One or more equations did not get rendered due to their size.
                    Instances For
                      def Lean.Meta.Grind.Action.mkGrindSeq (s : List TGrind) :
                      TSyntax `Lean.Parser.Tactic.Grind.grindSeq
                      Equations
                      • One or more equations did not get rendered due to their size.
                      Instances For

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

                        next =>
                          t₁
                          ...
                          tₙ
                        

                        If the list is empty, it returns next => done.

                        Equations
                        • One or more equations did not get rendered due to their size.
                        Instances For

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

                          next =>
                            t₁
                            ...
                            tₙ
                          
                          Equations
                          • One or more equations did not get rendered due to their size.
                          Instances For

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

                            Equations
                            • One or more equations did not get rendered due to their size.
                            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.

                              Equations
                              Instances For

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

                                Equations
                                • One or more equations did not get rendered due to their size.
                                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.

                                  Equations
                                  • One or more equations did not get rendered due to their size.
                                  Instances For

                                    Helper action for satellite solvers that use CheckResult.

                                    Equations
                                    • One or more equations did not get rendered due to their size.
                                    Instances For
                                      Equations
                                      • One or more equations did not get rendered due to their size.
                                      Instances For

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

                                        Equations
                                        Instances For

                                          Helper action that checks whether the resulting tactic script produced by its continuation can close the original goal.

                                          Equations
                                          • One or more equations did not get rendered due to their size.
                                          Instances For

                                            Some sanity check properties.