Documentation

Std.Tactic.LibrarySearch

Library search #

This file defines tactics std_exact? and std_apply?, (formerly known as library_search) and a term elaborator std_exact?% that tries to find a lemma solving the current goal (subgoals are solved using solveByElim).

example : x < x + 1 := std_exact?%
example : Nat := by std_exact?

These functions will likely lose their std_ prefix once we are ready to replace the corresponding implementations in Mathlib.

A "modifier" for a declaration.

  • none indicates the original declaration,
  • mp indicates that (possibly after binders) the declaration is an , and we want to consider the forward direction,
  • mpr similarly, but for the backward direction.
Instances For
    Equations
    • One or more equations did not get rendered due to their size.
    Equations
    • One or more equations did not get rendered due to their size.
    @[reducible]

    LibrarySearch has an extension mechanism for replacing the function used to find candidate lemmas.

    Equations
    Instances For

      Once we reach Mathlib, and have cache available, we may still want to load a precomputed cache for exact? from a .olean file.

      This makes no sense here in Std, where there is no caching mechanism.

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

        Constructs an discriminator tree from the current environment.

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

          Return matches from local constants.

          N.B. The efficiency of this could likely be considerably improved by caching in environment extension.

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

            Candidate finding function that uses strict discrimination tree for resolution.

            Equations
            Instances For

              Candidate finding function that uses strict discrimination tree for resolution.

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

                Create lemma from name and mod.

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

                  A library search candidate using symmetry includes the goal to solve, the metavar context for that goal, and the name and orientation of a rule to try using with goal.

                  Equations
                  Instances For
                    def Std.Tactic.LibrarySearch.interleaveWith {α : Type u_1} {β : Type u_2} {γ : Type u_3} (f : αγ) (x : Array α) (g : βγ) (y : Array β) :

                    Interleave x y interleaves the elements of x and y until one is empty and then returns final elements in other list.

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

                      Run searchFn on both the goal and symm applied to the goal.

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

                        A type synonym for our subgoal ranking algorithm.

                        Equations
                        Instances For

                          Count how many local hypotheses appear in an expression.

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

                            Returns a tuple:

                            • are there no remaining goals?
                            • how many local hypotheses were used?
                            • how many goals remain, negated?

                            Larger values (i.e. no remaining goals, more local hypotheses, fewer remaining goals) are better.

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

                              Called to abort speculative execution in library search.

                              Equations
                              Instances For

                                Returns true if this is an abort speculation exception.

                                Equations
                                Instances For

                                  Sequentially invokes a tactic act on each value in candidates on the current state.

                                  The tactic act should return a list of meta-variables that still need to be resolved. If this list is empty, then no variables remain to be solved, and tryOnEach returns none with the environment set so each goal is resolved.

                                  If the action throws an internal exception with the abortSpeculationId id then further computation is stopped and intermediate results returned. If any other exception is thrown, then it is silently discarded.

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

                                    Return an action that returns true when the remaining heartbeats is less than the currently remaining heartbeats * leavePercent / 100.

                                    Equations
                                    • One or more equations did not get rendered due to their size.
                                    Instances For
                                      def Std.Tactic.LibrarySearch.solveByElim (required : List Lean.Expr) (exfalso : Bool) (goals : List Lean.MVarId) (maxDepth : Nat) :

                                      Shortcut for calling solveByElim.

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

                                        Try to solve the goal either by:

                                        • calling tactic true
                                        • or applying a library lemma then calling tactic false on the resulting goals.

                                        Typically here tactic is solveByElim, with the Bool flag indicating whether it may retry with exfalso.

                                        If it successfully closes the goal, returns none. Otherwise, it returns some a, where a : Array (List MVarId × MetavarContext), with an entry for each library lemma which was successfully applied, containing a list of the subsidiary goals, and the metavariable context after the application.

                                        (Always succeeds, and the metavariable context stored in the monad is reverted, unless the goal was completely solved.)

                                        (Note that if solveByElim solves some but not all subsidiary goals, this is not currently tracked.)

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

                                          Syntax for std_exact?

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

                                            Syntax for std_apply?

                                            Equations
                                            • One or more equations did not get rendered due to their size.
                                            Instances For
                                              def Std.Tactic.LibrarySearch.exact? (tk : Lean.Syntax) (required : Option (Array (Lean.TSyntax `term))) (solver : Option (Lean.TSyntax `Lean.Parser.Tactic.tacticSeq)) (requireClose : Bool) :

                                              Implementation of the exact? tactic.

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

                                                Term elaborator using the exact? tactic.

                                                Equations
                                                Instances For