Documentation

Lean.Meta.DiscrTree.Util

Accessors for traversals. They view t through Trie.force, which is free for chain, node and lazy, but allocates when unfolding a suffix; traversals that need to be fast handle suffix separately.

@[inline]
def Lean.Meta.DiscrTree.Trie.mkNode {α : Type} (vs : Array α) (cs : Array (Key × Trie α)) :
Trie α

Generate a trie node from values and an array of children.

Equations
Instances For
    @[inline]

    Inspect a trie node as an array of values and an array of children.

    Equations
    Instances For
      @[inline]

      Returns the values stored at the current trie node. Equivalent to t.asNode.1.

      Equations
      Instances For
        @[inline]

        Returns the child nodes of the current trie node. Equivalent to t.asNode.2.

        Equations
        Instances For
          @[inline]

          Whether the current trie node has children.

          Equations
          Instances For
            @[inline]

            Returns the child of the current trie node for Key.star, the minimal key.

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

              Returns the child of the current trie node for k.

              Equations
              • One or more equations did not get rendered due to their size.
              Instances For
                @[inline]
                def Lean.Meta.DiscrTree.Trie.foldChildrenM {m : Type u_1 → Type u_2} {σ : Type u_1} {α : Type} [Monad m] (f : σ → Key → Trie α → m σ) (init : σ) (t : Trie α) :
                m σ

                Monadically folds over the children of the current trie node.

                Equations
                • One or more equations did not get rendered due to their size.
                Instances For
                  @[irreducible, specialize #[]]
                  def Lean.Meta.DiscrTree.Trie.matchesSuffix {m : Type → Type u_1} {β : Type} [Monad m] (key : Expr → m (Key × β)) (push : Array Expr → β → Array Expr) (todo : Array Expr) (ks : Array Key) (i : Nat) :

                  Whether the subterms todo match the remaining keys ks[i:] of a suffix, as when traversing its chains. key e returns the key of e and data from which push todo pushes the arguments of e.

                  Equations
                  • One or more equations did not get rendered due to their size.
                  Instances For
                    @[specialize #[]]
                    partial def Lean.Meta.DiscrTree.Trie.getMatchLoop {m : Type → Type u_1} {β α : Type} [Monad m] (key : Expr → m (Key × β)) (push : Array Expr → β → Array Expr) (todo : Array Expr) (c : Trie α) (result : Array α) :
                    m (Array α)

                    Appends the values of the patterns below c matching the subterms todo to result. key and push are as for matchesSuffix; a subterm with key Key.star only matches Key.star patterns.

                    @[inline]

                    Checks whether a trie node is empty (no values and no children).

                    This is only a check for actual trie emptiness (t.size = 0) if all operations maintain the invariant that no trie node has an empty child node.

                    Equations
                    Instances For
                      @[specialize #[]]
                      partial def Lean.Meta.DiscrTree.Trie.foldM {m : Type u_1 → Type u_2} {σ : Type u_1} {α : Type} [Monad m] (initialKeys : Array Key) (f : σ → Array Key → α → m σ) (init : σ) (t : Trie α) :
                      m σ

                      Monadically fold the keys and values stored in a Trie.

                      @[inline]
                      def Lean.Meta.DiscrTree.Trie.fold {σ : Type u_1} {α : Type} (initialKeys : Array Key) (f : σ → Array Key → α → σ) (init : σ) (t : Trie α) :
                      σ

                      Fold the keys and values stored in a Trie.

                      Equations
                      Instances For
                        @[specialize #[]]
                        partial def Lean.Meta.DiscrTree.Trie.foldValuesM {m : Type u_1 → Type u_2} {σ : Type u_1} {α : Type} [Monad m] (f : σ → α → m σ) (init : σ) (t : Trie α) :
                        m σ

                        Monadically fold the values stored in a Trie.

                        @[inline]
                        def Lean.Meta.DiscrTree.Trie.foldValues {σ : Type u_1} {α : Type} (f : σ → α → σ) (init : σ) (t : Trie α) :
                        σ

                        Fold the values stored in a Trie.

                        Equations
                        Instances For
                          partial def Lean.Meta.DiscrTree.Trie.size {α : Type} (t : Trie α) :

                          The number of values stored in a Trie.

                          @[inline]
                          def Lean.Meta.DiscrTree.foldM {m : Type u_1 → Type u_2} {σ : Type u_1} {α : Type} [Monad m] (f : σ → Array Key → α → m σ) (init : σ) (t : DiscrTree α) :
                          m σ

                          Monadically fold over the keys and values stored in a DiscrTree.

                          Equations
                          Instances For
                            @[inline]
                            def Lean.Meta.DiscrTree.fold {σ : Type u_1} {α : Type} (f : σ → Array Key → α → σ) (init : σ) (t : DiscrTree α) :
                            σ

                            Fold over the keys and values stored in a DiscrTree

                            Equations
                            Instances For
                              @[inline]
                              def Lean.Meta.DiscrTree.foldValuesM {m : Type u_1 → Type u_2} {σ : Type u_1} {α : Type} [Monad m] (f : σ → α → m σ) (init : σ) (t : DiscrTree α) :
                              m σ

                              Monadically fold over the values stored in a DiscrTree.

                              Equations
                              • One or more equations did not get rendered due to their size.
                              Instances For
                                @[inline]
                                def Lean.Meta.DiscrTree.foldValues {σ : Type u_1} {α : Type} (f : σ → α → σ) (init : σ) (t : DiscrTree α) :
                                σ

                                Fold over the values stored in a DiscrTree.

                                Equations
                                Instances For
                                  @[inline]
                                  def Lean.Meta.DiscrTree.containsValueP {α : Type} (t : DiscrTree α) (f : α → Bool) :

                                  Check for the presence of a value satisfying a predicate.

                                  Equations
                                  Instances For
                                    @[inline]

                                    Extract the values stored in a DiscrTree.

                                    Equations
                                    Instances For
                                      @[inline]

                                      Extract the keys and values stored in a DiscrTree.

                                      Equations
                                      Instances For
                                        @[inline]

                                        Get the number of values stored in a DiscrTree. O(n) in the size of the tree.

                                        Equations
                                        Instances For
                                          @[specialize #[]]
                                          partial def Lean.Meta.DiscrTree.Trie.mapArraysM {m : Type → Type} [Monad m] {α β : Type} (t : Trie α) (f : Array α → m (Array β)) :
                                          m (Trie β)

                                          Apply a monadic function to the array of values at each node in a DiscrTree. Any resulting subtrees containing no values will be pruned.

                                          @[inline]
                                          def Lean.Meta.DiscrTree.mapArraysM {m : Type → Type} [Monad m] {α β : Type} (d : DiscrTree α) (f : Array α → m (Array β)) :
                                          m (DiscrTree β)

                                          Apply a monadic function to the array of values at each node in a DiscrTree.

                                          Equations
                                          • One or more equations did not get rendered due to their size.
                                          Instances For
                                            @[inline]
                                            def Lean.Meta.DiscrTree.mapArrays {α β : Type} (d : DiscrTree α) (f : Array α → Array β) :

                                            Apply a function to the array of values at each node in a DiscrTree.

                                            Equations
                                            Instances For