Documentation

Aesop.Util.Basic

@[inline]
def Aesop.time {m : TypeType u_1} {α : Type} [Monad m] [MonadLiftT BaseIO m] (x : m α) :
m (α × Nanos)
Equations
  • Aesop.time x = do let startliftM IO.monoNanosNow let ax let stopliftM IO.monoNanosNow pure (a, { nanos := stop - start })
Instances For
    @[inline]
    def Aesop.time' {m : TypeType u_1} [Monad m] [MonadLiftT BaseIO m] (x : m Unit) :
    Equations
    • Aesop.time' x = do let startliftM IO.monoNanosNow x let stopliftM IO.monoNanosNow pure { nanos := stop - start }
    Instances For
      @[inline]
      def Aesop.PersistentHashSet.toList {α : Type u_1} [BEq α] [Hashable α] (s : Lean.PersistentHashSet α) :
      List α
      Equations
      Instances For
        @[inline]
        def Aesop.PersistentHashSet.toArray {α : Type u_1} [BEq α] [Hashable α] (s : Lean.PersistentHashSet α) :
        Array α
        Equations
        Instances For
          def Aesop.PersistentHashSet.toHashSet {α : Type u_1} [BEq α] [Hashable α] (s : Lean.PHashSet α) :
          Std.HashSet α
          Equations
          Instances For
            def Aesop.PersistentHashSet.filter {α : Type u_1} [BEq α] [Hashable α] (p : αBool) (s : Lean.PHashSet α) :
            Lean.PHashSet α
            Equations
            • Aesop.PersistentHashSet.filter p s = Lean.PersistentHashSet.fold (fun (s : Lean.PHashSet α) (a : α) => if p a = true then s else Lean.PersistentHashSet.erase s a) s s
            Instances For
              def Aesop.getConclusionDiscrTreeKeys (type : Lean.Expr) :
              Lean.MetaM (Array Lean.Meta.DiscrTree.Key)
              Equations
              • One or more equations did not get rendered due to their size.
              Instances For
                def Aesop.isEmptyTrie {α : Type} :
                Lean.Meta.DiscrTree.Trie αBool
                Equations
                • Aesop.isEmptyTrie (Lean.Meta.DiscrTree.Trie.node vs children) = (vs.isEmpty && children.isEmpty)
                Instances For
                  @[specialize #[]]
                  def Aesop.filterDiscrTreeM {m : Type u_1 → Type u_2} {σ : Type u_1} {α : Type} [Monad m] [Inhabited σ] (p : αm (ULift Bool)) (f : σαm σ) (init : σ) (t : Lean.Meta.DiscrTree α) :
                  m (Lean.Meta.DiscrTree α × σ)

                  Remove elements for which p returns false from the given DiscrTree. The removed elements are monadically folded over using f and init, so f is called once for each removed element and the final state of type σ is returned.

                  Equations
                  • One or more equations did not get rendered due to their size.
                  Instances For
                    def Aesop.filterDiscrTree {σ : Type u_1} {α : Type} [Inhabited σ] (p : αBool) (f : σασ) (init : σ) (t : Lean.Meta.DiscrTree α) :
                    Lean.Meta.DiscrTree α × σ

                    Remove elements for which p returns false from the given DiscrTree. The removed elements are folded over using f and init, so f is called once for each removed element and the final state of type σ is returned.

                    Equations
                    Instances For
                      def Aesop.SimpTheorems.addSimpEntry (s : Lean.Meta.SimpTheorems) :
                      Lean.Meta.SimpEntryLean.Meta.SimpTheorems
                      Equations
                      • One or more equations did not get rendered due to their size.
                      • Aesop.SimpTheorems.addSimpEntry s (Lean.Meta.SimpEntry.toUnfoldThms n thms) = s.registerDeclToUnfoldThms n thms
                      Instances For
                        def Aesop.SimpTheorems.foldSimpEntriesM {m : Type u_1 → Type u_2} {σ : Type u_1} [Monad m] (f : σLean.Meta.SimpEntrym σ) (init : σ) (thms : Lean.Meta.SimpTheorems) :
                        m σ
                        Equations
                        • One or more equations did not get rendered due to their size.
                        Instances For
                          def Aesop.SimpTheorems.foldSimpEntries {σ : Type u_1} (f : σLean.Meta.SimpEntryσ) (init : σ) (thms : Lean.Meta.SimpTheorems) :
                          σ
                          Equations
                          Instances For
                            def Aesop.SimpTheorems.simpEntries (thms : Lean.Meta.SimpTheorems) :
                            Array Lean.Meta.SimpEntry
                            Equations
                            Instances For
                              def Aesop.SimpTheorems.containsDecl (thms : Lean.Meta.SimpTheorems) (decl : Lean.Name) :
                              Bool
                              Equations
                              • Aesop.SimpTheorems.containsDecl thms decl = (thms.isLemma (Lean.Meta.Origin.decl decl) || thms.isDeclToUnfold decl || Lean.PersistentHashMap.contains thms.toUnfoldThms decl)
                              Instances For
                                def Aesop.forEachExprInLDeclCore {ω : Type} {m : TypeType} [STWorld ω m] [MonadLiftT (ST ω) m] [Monad m] (ldecl : Lean.LocalDecl) (g : Lean.Exprm Bool) :
                                Lean.MonadCacheT Lean.Expr Unit m Unit
                                Equations
                                • One or more equations did not get rendered due to their size.
                                Instances For
                                  @[always_inline]
                                  def Aesop.forEachExprInLDecl' {ω : Type} {m : TypeType} [STWorld ω m] [MonadLiftT (ST ω) m] [Monad m] (ldecl : Lean.LocalDecl) (g : Lean.Exprm Bool) :
                                  m Unit
                                  Equations
                                  Instances For
                                    @[always_inline]
                                    def Aesop.forEachExprInLDecl {ω : Type} {m : TypeType} [STWorld ω m] [MonadLiftT (ST ω) m] [Monad m] (ldecl : Lean.LocalDecl) (g : Lean.Exprm Unit) :
                                    m Unit
                                    Equations
                                    Instances For
                                      @[always_inline]
                                      def Aesop.forEachExprInLCtxCore {ω : Type} {m : TypeType} [STWorld ω m] [MonadLiftT (ST ω) m] [Monad m] (lctx : Lean.LocalContext) (g : Lean.Exprm Bool) :
                                      Lean.MonadCacheT Lean.Expr Unit m Unit
                                      Equations
                                      • One or more equations did not get rendered due to their size.
                                      Instances For
                                        @[always_inline]
                                        def Aesop.forEachExprInLCtx' {ω : Type} {m : TypeType} [STWorld ω m] [MonadLiftT (ST ω) m] [Monad m] [MonadControlT Lean.MetaM m] [MonadLiftT Lean.MetaM m] (mvarId : Lean.MVarId) (g : Lean.Exprm Bool) :
                                        m Unit
                                        Equations
                                        Instances For
                                          @[always_inline]
                                          def Aesop.forEachExprInLCtx {ω : Type} {m : TypeType} [STWorld ω m] [MonadLiftT (ST ω) m] [Monad m] [MonadControlT Lean.MetaM m] [MonadLiftT Lean.MetaM m] (mvarId : Lean.MVarId) (g : Lean.Exprm Unit) :
                                          m Unit
                                          Equations
                                          Instances For
                                            @[always_inline]
                                            def Aesop.forEachExprInGoalCore {ω : Type} {m : TypeType} [STWorld ω m] [MonadLiftT (ST ω) m] [Monad m] [MonadControlT Lean.MetaM m] [MonadLiftT Lean.MetaM m] (mvarId : Lean.MVarId) (g : Lean.Exprm Bool) :
                                            Lean.MonadCacheT Lean.Expr Unit m Unit
                                            Equations
                                            • One or more equations did not get rendered due to their size.
                                            Instances For
                                              @[always_inline]
                                              def Aesop.forEachExprInGoal' {ω : Type} {m : TypeType} [STWorld ω m] [MonadLiftT (ST ω) m] [Monad m] [MonadControlT Lean.MetaM m] [MonadLiftT Lean.MetaM m] (mvarId : Lean.MVarId) (g : Lean.Exprm Bool) :
                                              m Unit
                                              Equations
                                              Instances For
                                                @[always_inline]
                                                def Aesop.forEachExprInGoal {ω : Type} {m : TypeType} [STWorld ω m] [MonadLiftT (ST ω) m] [Monad m] [MonadControlT Lean.MetaM m] [MonadLiftT Lean.MetaM m] (mvarId : Lean.MVarId) (g : Lean.Exprm Unit) :
                                                m Unit
                                                Equations
                                                Instances For
                                                  @[inline]
                                                  def Aesop.setThe (σ : Type u_1) {m : Type u_1 → Type u_2} [MonadStateOf σ m] (s : σ) :
                                                  m PUnit
                                                  Equations
                                                  Instances For
                                                    @[inline]
                                                    def Aesop.runMetaMAsCoreM {α : Type} (x : Lean.MetaM α) :
                                                    Lean.CoreM α
                                                    Equations
                                                    Instances For
                                                      @[inline]
                                                      def Aesop.runTermElabMAsCoreM {α : Type} (x : Lean.Elab.TermElabM α) :
                                                      Lean.CoreM α
                                                      Equations
                                                      Instances For
                                                        def Aesop.runTacticMAsMetaM {α : Type} (x : Lean.Elab.Tactic.TacticM α) (goals : List Lean.MVarId) :
                                                        Lean.MetaM (α × List Lean.MVarId)
                                                        Equations
                                                        • Aesop.runTacticMAsMetaM x goals = do let __discr((ReaderT.run x { elaborator := Lean.Name.anonymous }).run { goals := goals }).run' match __discr with | (a, s) => pure (a, s.goals)
                                                        Instances For
                                                          def Aesop.runTacticSyntaxAsMetaM (stx : Lean.Syntax) (goals : List Lean.MVarId) :
                                                          Lean.MetaM (List Lean.MVarId)
                                                          Equations
                                                          Instances For
                                                            def Aesop.updateSimpEntryPriority (priority : Nat) (e : Lean.Meta.SimpEntry) :
                                                            Lean.Meta.SimpEntry
                                                            Equations
                                                            Instances For
                                                              def Aesop.hasSorry {m : TypeType} [Monad m] [Lean.MonadMCtx m] (e : Lean.Expr) :
                                                              m Bool
                                                              Equations
                                                              Instances For
                                                                def Aesop.isAppOfUpToDefeq (f e : Lean.Expr) :
                                                                Lean.MetaM Bool
                                                                Equations
                                                                • One or more equations did not get rendered due to their size.
                                                                Instances For
                                                                  def Aesop.getAppUpToDefeq (e : Lean.Expr) :
                                                                  Lean.MetaM (Lean.Expr × Array Lean.Expr)

                                                                  If the input expression e reduces to f x₁ ... xₙ via repeated whnf, this function returns f and [x₁, ⋯, xₙ]. Otherwise it returns e (unchanged, not in WHNF!) and [].

                                                                  Equations
                                                                  Instances For
                                                                    def Aesop.partitionGoalsAndMVars {α : Type} (mvarId : αLean.MVarId) (goals : Array α) :
                                                                    Lean.MetaM (Array (α × UnorderedArraySet Lean.MVarId) × UnorderedArraySet Lean.MVarId)

                                                                    Partition an array of structures containing MVarIds into 'goals' and 'proper mvars'. An MVarId from the input array goals is classified as a proper mvar if any of the MVarIds depend on it, and as a goal otherwise. Additionally, for each goal, we report the set of mvars that the goal depends on.

                                                                    Equations
                                                                    • One or more equations did not get rendered due to their size.
                                                                    Instances For
                                                                      def Aesop.runTacticMCapturingPostState (t : Lean.Elab.Tactic.TacticM Unit) (preState : Lean.Meta.SavedState) (preGoals : List Lean.MVarId) :
                                                                      Lean.MetaM (Lean.Meta.SavedState × List Lean.MVarId)
                                                                      Equations
                                                                      • One or more equations did not get rendered due to their size.
                                                                      Instances For
                                                                        def Aesop.runTacticCapturingPostState (t : Lean.Syntax.Tactic) (preState : Lean.Meta.SavedState) (preGoals : List Lean.MVarId) :
                                                                        Lean.MetaM (Lean.Meta.SavedState × List Lean.MVarId)
                                                                        Equations
                                                                        Instances For
                                                                          def Aesop.runTacticSeqCapturingPostState (t : Lean.TSyntax `Lean.Parser.Tactic.tacticSeq) (preState : Lean.Meta.SavedState) (preGoals : List Lean.MVarId) :
                                                                          Lean.MetaM (Lean.Meta.SavedState × List Lean.MVarId)
                                                                          Equations
                                                                          Instances For
                                                                            def Aesop.runTacticsCapturingPostState (ts : Array Lean.Syntax.Tactic) (preState : Lean.Meta.SavedState) (preGoals : List Lean.MVarId) :
                                                                            Lean.MetaM (Lean.Meta.SavedState × List Lean.MVarId)
                                                                            Equations
                                                                            • One or more equations did not get rendered due to their size.
                                                                            Instances For
                                                                              def Aesop.withAllTransparencySeqSyntax (md : Lean.Meta.TransparencyMode) (k : Lean.TSyntax `Lean.Parser.Tactic.tacticSeq) :
                                                                              Lean.TSyntax `Lean.Parser.Tactic.tacticSeq
                                                                              Equations
                                                                              Instances For
                                                                                def Aesop.withAllTransparencySyntax (md : Lean.Meta.TransparencyMode) (k : Lean.TSyntax `tactic) :
                                                                                Lean.TSyntax `tactic
                                                                                Equations
                                                                                Instances For
                                                                                  def Aesop.addTryThisTacticSeqSuggestion (ref : Lean.Syntax) (suggestion : Lean.TSyntax `Lean.Parser.Tactic.tacticSeq) (origSpan? : Option Lean.Syntax := none) :
                                                                                  Lean.MetaM Unit

                                                                                  Register a "Try this" suggestion for a tactic sequence.

                                                                                  It works when the tactic to replace appears on its own line:

                                                                                  by
                                                                                    aesop?
                                                                                  

                                                                                  It doesn't work (i.e., the suggestion will appear but in the wrong place) when the tactic to replace is preceded by other text on the same line:

                                                                                  have x := by aesop?
                                                                                  

                                                                                  The Try this: suggestion in the infoview is not correctly formatted, but there's nothing we can do about this at the moment.

                                                                                  Equations
                                                                                  • One or more equations did not get rendered due to their size.
                                                                                  Instances For
                                                                                    def Aesop.elabPattern (stx : Lean.Syntax) :
                                                                                    Lean.Elab.TermElabM Lean.Expr
                                                                                    Equations
                                                                                    Instances For
                                                                                      def Aesop.tacticsToMessageData (ts : Array Lean.Syntax.Tactic) :
                                                                                      Lean.MessageData
                                                                                      Equations
                                                                                      • Aesop.tacticsToMessageData ts = Lean.MessageData.joinSep (Array.map Lean.toMessageData ts).toList ((Lean.MessageData.ofFormat Std.format) "\n")
                                                                                      Instances For
                                                                                        def Aesop.getUnusedNames (lctx : Lean.LocalContext) (suggestions : Array Lean.Name) :
                                                                                        Array Lean.Name × Lean.LocalContext

                                                                                        Note: the returned local context contains invalid LocalDecls.

                                                                                        Equations
                                                                                        Instances For
                                                                                          def Aesop.Name.ofComponents (cs : List Lean.Name) :
                                                                                          Lean.Name
                                                                                          Equations
                                                                                          • One or more equations did not get rendered due to their size.
                                                                                          Instances For
                                                                                            @[macro_inline]
                                                                                            def Aesop.withExceptionTransform {m : TypeType} {α : Type} [Monad m] [Lean.MonadError m] (f : Lean.MessageDataLean.MessageData) (x : m α) :
                                                                                            m α
                                                                                            Equations
                                                                                            • One or more equations did not get rendered due to their size.
                                                                                            Instances For
                                                                                              @[macro_inline]
                                                                                              def Aesop.withExceptionPrefix {m : TypeType} {α : Type} [Monad m] [Lean.MonadError m] (pre : Lean.MessageData) :
                                                                                              m αm α
                                                                                              Equations
                                                                                              Instances For
                                                                                                def Aesop.withPPAnalyze {m : TypeType} {α : Type} [Monad m] [Lean.MonadWithOptions m] (x : m α) :
                                                                                                m α
                                                                                                Equations
                                                                                                • Aesop.withPPAnalyze x = Lean.withOptions (fun (x : Lean.Options) => (x.setBool `pp.analyze true).setBool `pp.proofs true) x
                                                                                                Instances For
                                                                                                  @[implicit_reducible]
                                                                                                  def Aesop.instMonadCacheStateRefT'_aesop {α β : Type} {m : TypeType} {ω σ : Type} [Lean.MonadCache α β m] :
                                                                                                  Lean.MonadCache α β (StateRefT' ω σ m)
                                                                                                  Equations
                                                                                                  • Aesop.instMonadCacheStateRefT'_aesop = { findCached? := fun (a : α) => liftM (Lean.MonadCache.findCached? a), cache := fun (a : α) (b : β) => liftM (Lean.MonadCache.cache a b) }
                                                                                                  Instances For
                                                                                                    def Aesop.runInMetaState {m : TypeType u_1} {α : Type} [Monad m] [MonadLiftT Lean.MetaM m] [MonadFinally m] (s : Lean.Meta.SavedState) (x : m α) :
                                                                                                    m α

                                                                                                    A generalized variant of Meta.SavedState.runMetaM

                                                                                                    Equations
                                                                                                    • Aesop.runInMetaState s x = do let initialStatehave this := Lean.saveState; liftM this tryFinally (do liftM s.restore x) (liftM initialState.restore)
                                                                                                    Instances For
                                                                                                      def Aesop.lBoolOr (x y : Lean.LBool) :
                                                                                                      Lean.LBool
                                                                                                      Equations
                                                                                                      Instances For
                                                                                                        def Aesop.compareArrayLex {α : Type u_1} (cmp : ααOrdering) (xs ys : Array α) :
                                                                                                        Ordering
                                                                                                        Equations
                                                                                                        • One or more equations did not get rendered due to their size.
                                                                                                        Instances For
                                                                                                          def Aesop.compareArraySizeThenLex {α : Type u_1} (cmp : ααOrdering) (xs ys : Array α) :
                                                                                                          Ordering
                                                                                                          Equations
                                                                                                          Instances For
                                                                                                            @[implicit_reducible]
                                                                                                            def Aesop.instMonadParentDeclReaderT_aesop {m : TypeType} {ρ : Type} [Lean.Elab.MonadParentDecl m] :
                                                                                                            Lean.Elab.MonadParentDecl (ReaderT ρ m)
                                                                                                            Equations
                                                                                                            Instances For
                                                                                                              @[implicit_reducible]
                                                                                                              def Aesop.instMonadParentDeclStateRefT'_aesop {m : TypeType} {ω σ : Type} [Lean.Elab.MonadParentDecl m] :
                                                                                                              Lean.Elab.MonadParentDecl (StateRefT' ω σ m)
                                                                                                              Equations
                                                                                                              Instances For
                                                                                                                def Aesop.isDefEqReducibleRigid (s t : Lean.Expr) :
                                                                                                                Lean.MetaM Bool
                                                                                                                Equations
                                                                                                                • One or more equations did not get rendered due to their size.
                                                                                                                Instances For
                                                                                                                  def Aesop.isHypRedundantReducibleRigid (type : Lean.Expr) :
                                                                                                                  Lean.MetaM Bool
                                                                                                                  Equations
                                                                                                                  • One or more equations did not get rendered due to their size.
                                                                                                                  Instances For