Documentation

Batteries.Lean.Meta.Basic

def Lean.Meta.sortFVarsByContextOrder {m : TypeType} [Monad m] [MonadLCtx m] (hyps : Array FVarId) :
m (Array FVarId)

Sort the given FVarIds by the order in which they appear in the current local context. If any of the FVarIds do not appear in the current local context, the result is unspecified.

Equations
Instances For
    @[implicit_reducible]
    Equations
    def Lean.MetavarContext.getExprMVarDecl {m : TypeType} [Monad m] [MonadError m] (mctx : MetavarContext) (mvarId : MVarId) :
    m MetavarDecl

    Get the MetavarDecl of mvarId. If mvarId is not a declared metavariable in the given MetavarContext, throw an error.

    Equations
    • One or more equations did not get rendered due to their size.
    Instances For
      def Lean.MetavarContext.declareExprMVar (mctx : MetavarContext) (mvarId : MVarId) (mdecl : MetavarDecl) :
      MetavarContext

      Declare a metavariable. You must make sure that the metavariable is not already declared.

      Equations
      • One or more equations did not get rendered due to their size.
      Instances For
        def Lean.MetavarContext.isExprMVarAssignedOrDelayedAssigned (mctx : MetavarContext) (mvarId : MVarId) :
        Bool

        Check whether a metavariable is assigned or delayed-assigned. A delayed-assigned metavariable is already 'solved' but the solution cannot be substituted yet because we have to wait for some other metavariables to be assigned first. So in most situations you want to treat a delayed-assigned metavariable as assigned.

        Equations
        Instances For
          def Lean.MetavarContext.isExprMVarDeclared (mctx : MetavarContext) (mvarId : MVarId) :
          Bool

          Check whether a metavariable is declared in the given MetavarContext.

          Equations
          Instances For
            def Lean.MetavarContext.eraseExprMVarAssignment (mctx : MetavarContext) (mvarId : MVarId) :
            MetavarContext

            Erase any assignment or delayed assignment of the given metavariable.

            Equations
            • One or more equations did not get rendered due to their size.
            Instances For
              def Lean.MetavarContext.unassignedExprMVars (mctx : MetavarContext) (includeDelayed : Bool := false) :
              Array MVarId

              Obtain all unassigned metavariables from the given MetavarContext. If includeDelayed is true, delayed-assigned metavariables are considered unassigned.

              Equations
              • One or more equations did not get rendered due to their size.
              Instances For
                def Lean.MVarId.isDeclared {m : TypeType} [Monad m] [MonadMCtx m] (mvarId : MVarId) :
                m Bool

                Check whether a metavariable is declared.

                Equations
                Instances For
                  def Lean.MVarId.eraseAssignment {m : TypeType} [MonadMCtx m] (mvarId : MVarId) :
                  m Unit

                  Erase any assignment or delayed assignment of the given metavariable.

                  Equations
                  Instances For
                    def Lean.MVarId.synthInstance (g : MVarId) :
                    MetaM Unit

                    Solve a goal by synthesizing an instance.

                    Equations
                    • g.synthInstance = do let __do_liftg.getType let __do_liftLean.Meta.synthInstance __do_lift g.assign __do_lift
                    Instances For
                      def Lean.MVarId.getTypeCleanup (mvarId : MVarId) :
                      MetaM Expr

                      Get the type the given metavariable after instantiating metavariables and cleaning up annotations.

                      Equations
                      • mvarId.getTypeCleanup = do let __do_liftmvarId.getType let __do_liftLean.instantiateMVars __do_lift pure __do_lift.cleanupAnnotations
                      Instances For
                        def Lean.Meta.getUnassignedExprMVars {m : TypeType} [Monad m] [MonadMCtx m] (includeDelayed : Bool := false) :
                        m (Array MVarId)

                        Obtain all unassigned metavariables. If includeDelayed is true, delayed-assigned metavariables are considered unassigned.

                        Equations
                        Instances For
                          def Lean.Meta.unhygienic {m : TypeType} {α : Type} [MonadWithOptions m] (x : m α) :
                          m α

                          Run a computation with hygiene turned off.

                          Equations
                          • Lean.Meta.unhygienic x = Lean.withOptions (fun (x : Lean.Options) => Lean.Option.set x Lean.Meta.tactic.hygienic false) x
                          Instances For
                            def Lean.Meta.mkFreshIdWithPrefix {m : TypeType} [Monad m] [MonadNameGenerator m] («prefix» : Name) :
                            m Name

                            A variant of mkFreshId which generates names with a particular prefix. The generated names are unique and have the form <prefix>.<N> where N is a natural number. They are not suitable as user-facing names.

                            Equations
                            • Lean.Meta.mkFreshIdWithPrefix «prefix» = do let ngenLean.getNGen have r : Lean.Name := { namePrefix := «prefix», idx := ngen.idx }.curr Lean.setNGen ngen.next pure r
                            Instances For
                              def Lean.Meta.saturate1 {m : TypeType} [Monad m] [MonadError m] [MonadRecDepth m] [MonadLiftT (ST IO.RealWorld) m] (goal : MVarId) (tac : MVarIdm (Option (Array MVarId))) :
                              m (Option (Array MVarId))

                              saturate1 goal tac runs tac on goal, then on the resulting goals, etc., until tac does not apply to any goal any more (i.e. it returns none). The order of applications is depth-first, so if tac generates goals [g₁, g₂, ⋯], we apply tac to g₁ and recursively to all its subgoals before visiting g₂. If tac does not apply to goal, saturate1 returns none. Otherwise it returns the generated subgoals to which tac did not apply. saturate1 respects the MonadRecDepth recursion limit.

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