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.
Generate a trie node from values and an array of children.
Equations
Instances For
Inspect a trie node as an array of values and an array of children.
Equations
Instances For
Returns the values stored at the current trie node.
Equivalent to t.asNode.1.
Equations
- t.nodeValues = match t.force with | ⟨Lean.Meta.DiscrTree.Trie.chain key child, property⟩ => #[] | ⟨Lean.Meta.DiscrTree.Trie.node vs children, property⟩ => vs
Instances For
Returns the child nodes of the current trie node.
Equivalent to t.asNode.2.
Equations
- t.nodeChildren = match t.force with | ⟨Lean.Meta.DiscrTree.Trie.chain k v, property⟩ => #[(k, v)] | ⟨Lean.Meta.DiscrTree.Trie.node vs cs, property⟩ => cs
Instances For
Whether the current trie node has children.
Equations
- t.hasChildren = match t.force with | ⟨Lean.Meta.DiscrTree.Trie.chain key child, property⟩ => true | ⟨Lean.Meta.DiscrTree.Trie.node vs cs, property⟩ => !cs.isEmpty
Instances For
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
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
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.
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
- t.isEmptyNode = match t.force with | ⟨Lean.Meta.DiscrTree.Trie.chain key child, property⟩ => false | ⟨Lean.Meta.DiscrTree.Trie.node vs children, property⟩ => vs.isEmpty && children.isEmpty
Instances For
Fold the keys and values stored in a Trie.
Equations
- Lean.Meta.DiscrTree.Trie.fold initialKeys f init t = (Lean.Meta.DiscrTree.Trie.foldM initialKeys (fun (s : σ) (k : Array Lean.Meta.DiscrTree.Key) (a : α) => pure (f s k a)) init t).run
Instances For
Fold the values stored in a Trie.
Equations
- Lean.Meta.DiscrTree.Trie.foldValues f init t = (Lean.Meta.DiscrTree.Trie.foldValuesM (fun (x1 : σ) (x2 : α) => pure (f x1 x2)) init t).run
Instances For
The number of values stored in a Trie.
Monadically fold over the keys and values stored in a DiscrTree.
Equations
- Lean.Meta.DiscrTree.foldM f init t = t.root.foldlM (fun (s : σ) (k : Lean.Meta.DiscrTree.Key) (t : Lean.Meta.DiscrTree.Trie α) => Lean.Meta.DiscrTree.Trie.foldM #[k] f s t) init
Instances For
Fold over the keys and values stored in a DiscrTree
Equations
- Lean.Meta.DiscrTree.fold f init t = (Lean.Meta.DiscrTree.foldM (fun (s : σ) (keys : Array Lean.Meta.DiscrTree.Key) (a : α) => pure (f s keys a)) init t).run
Instances For
Fold over the values stored in a DiscrTree.
Equations
- Lean.Meta.DiscrTree.foldValues f init t = (Lean.Meta.DiscrTree.foldValuesM (fun (x1 : σ) (x2 : α) => pure (f x1 x2)) init t).run
Instances For
Check for the presence of a value satisfying a predicate.
Equations
- t.containsValueP f = Lean.Meta.DiscrTree.foldValues (fun (r : Bool) (a : α) => r || f a) false t
Instances For
Extract the keys and values stored in a DiscrTree.
Equations
- t.toArray = Lean.Meta.DiscrTree.fold (fun (as : Array (Array Lean.Meta.DiscrTree.Key × α)) (keys : Array Lean.Meta.DiscrTree.Key) (a : α) => as.push (keys, a)) #[] t
Instances For
Get the number of values stored in a DiscrTree. O(n) in the size of the tree.
Equations
- t.size = t.root.foldl (fun (n : Nat) (x : Lean.Meta.DiscrTree.Key) (t : Lean.Meta.DiscrTree.Trie α) => n + t.size) 0
Instances For
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.