text stringlengths 128 2.05k |
|---|
[EQUATION] The element [EQUATION] is called the [MATH] -polynomial of [MATH] and [MATH] (corresponding to the common multiple [MATH] ; note that there can be several different small common multiples). |
[MATH] -polynomials, as defined here, include the reductions as a particular case. It turns out to be convenient, but we shall need reductions on their own to deal with Gröbner bases. |
Definition 11 Let [MATH] be an ideal of the free operad. [MATH] is called a Gröbner basis of [MATH] , if for every [MATH] the leading term of [MATH] is divisible by the leading term of some element of [MATH] |
The main fact about Gröbner bases that makes them so useful is that the tree monomials that are not divisible by leading terms of a Gröbner basis form a basis for the quotient of the free operad modulo [MATH] . Thus, knowing a Gröbner basis for defining relations of an operad allows to obtain important information abou... |
Recall the Buchberger’s algorithm for operads . Its input is a set [MATH] of relations between elements of the free shuffle operad [MATH] . It repeatedly applies the following step: |
Step of the Buchberger’s algorithm: Compute all pairwise [MATH] -polynomials of elements of [MATH] . Reduce all these elements modulo [MATH] until they cannot be reduced further. Extend [MATH] by joining these reductions to it. If there are no new elements joined, terminate. (If there are new elements, the step is repe... |
2.4. Haskell Haskell is a purely functional programming language with a powerful type system. Programming in Haskell has a declarative feel to it, in the sense that functions are defined by declaring equations for function evaluation — the equations are then used by the compiler with the first matching equation in the ... |
We have built the implementation we are discussing in Haskell, and will use occasional source code excerpts for illustration through the paper. See the appendix for the list of all the Haskell-specific functions in use in our code examples. |
2.4.1. Types Haskell depends on a strong adherence to its type system. Hence, any entity in the language possesses a type. There are types that are complete in themselves — such as Bool Int and types that are assembled from component types — such as the type |
for lists containing elements of the type . Functions, too, are first class citizens of the language, with a function taking input of type and returning output of type having type |
-> Real power in the Haskell treatment of data types appears with the freedom to declare your own type. The most complete way to do this is with the data declaration. This allows, easily, for both record and union types; where a record contains one value of each of the specified values, and a union contains on value ou... |
As an example, similar to the datatype for trees that we will discuss at length in Section 3.1 , a rooted tree is either a leaf node, or a root node with a list of subtrees. The arity of the root node will be precisely the length of the list of subtrees. And a node of arity 0 could be considered a leaf. |
Thus, we may define a tree data type using the declaration data Tree Leaf Node Tree Here, Tree is the resulting data type, and Leaf and Node are constructors for elements of the data type. A typical tree might look like: |
Node Node Leaf Leaf ], Node Leaf Leaf Leaf ]] The corresponding tree shape is shown in Figure This data type has been defined completely using the union type: a tree is either a leaf, or a node carrying a list of subtrees. We can extend the type using the record type construction into something that can carry labels bo... |
Thus, we can introduce two type variables , to make the resulting tree type versatile, and define a tree type that takes labels of any type for the nodes, and labels of any type — independent of the node type — for the leaves by: |
data Tree Leaf Node Tree Here, an element of the type Tree is either a leaf, equipped with a value of type , or a node, equipped with a value of type as well as a list of subtrees. |
Hence, an example of type Tree Char Int would be: Node Node Leaf ’, Leaf ’], Node Leaf ’, Leaf ’, Leaf ’]] The corresponding decorated tree is shown in Figure |
2.4.2. Functions The second important part of understanding the way Haskell works is the functions. A function is defined by its type, and by what it makes to the input arguments it takes. Haskell views a function with several input parameters as a function taking one value and returning a function expecting one less p... |
A function specification in Haskell has two components. First off is the (optional) type declaration. An example, taken from our source code: |
operadicBuchberger :: Ord Show TreeOrdering Fractional => OperadElement -> OperadElement This type declaration alone tells us a number of things about the function, and the parameters it takes and returns. First comes the name of the function: operadicBuchberger . It is the top level function to run the Buchberger algo... |
Following the name and the :: , we give an (optional) list of assumptions on the type variables involved in constructing all types of the type declaration: we need to be a type that can be sorted and printed, we need to be a TreeOrdering i.e. an implementation of the monomial ordering algorithms we use. Finally, we exp... |
Following the expectations follows the symbol => signifying the start of the actual type declaration. And we read off that the function has type |
OperadElement -> OperadElement , or in other words that operadicBuchberger takes a list of operad elements with a certain type of vertex labels (signifying the operations in the free operad), a certain type of coefficients and a certain monomial ordering. |
After the type declaration, a sequence of equational declaration follow, containing the bulk of the function definition. As a function is called, these equations are processed in the order they are stated until one is found such that the left hand side of the equation matches the parameters submitted to the call. Once ... |
Again, an example may be in order. We can write a function for the Tree type we described above that allow us to recognize leaves: |
isLeaf :: Tree -> Bool isLeaf Leaf leaflabel True isLeaf Node nodelabel subtrees False 3. Internal representations Data representations and algorithms go hand in hand. A good algorithm will suggest a data representation that makes the steps of that algorithm easier; a good data representation will make the algorithms h... |
We discuss representation for decorated trees in Section 3.1 . The elements of a free operad in the category [MATH] are formal linear combinations of decorated trees, and the representation of these is discussed in Section |
3.2 . Next up is the special type trickery needed to represent the black hole trees first introduced in Remark on page . We introduce two coproduct types useable for tagging vertices of trees while preserving some or all of the vertex tags in Section |
3.3.1 . This way, we can designate a corolla a black hole, or an embedding point in a small common multiple. We discuss the small common multiple structures in Section |
3.3.2 and the black hole tagging in Section 3.3.3 . Finally, we discuss the representation we use for permutations in Section 3.4 |
3.1. Decorated trees We recall that the free operad is built with trees decorated at the corollas with elements of the generating graded set and with leaves decorated with an ordered set. |
While we expect the trees representing the basis of a free operad to have integer leaf labels, some of the lower level tasks are easier if we can also represent trees with other types of leaf labels. Hence, we will define one underlying tree type, PreDecoratedTree and derive another tree type, DecoratedTree representin... |
Hence, we will build our software with the decorated tree as our fundamental building block. We represent trees using a data type that encodes corollas and leaves as different, allowing each to carry a label. This guides us to the data type declaration |
data Ord Show => PreDecoratedTree DTLeaf DTVertex vertexType :: subTrees :: ![ PreDecoratedTree ]} deriving Eq Ord Read Show This is essentially the same as the tree type we discussed at the end of 2.4.1 . It is decorated with more expectations, and some Haskell idioms to automatically generate functionality. Hence, th... |
deriving clause will make the tree type automatically allow equality checks, sorting and methods to serialize and deserialize the data into strings. The sorting induced by the |
deriving clause, however, is not in general a monomial ordering, and we introduce further types in the code to introduce admissible monomial ordering. |
Furthermore, the vertexType and subTrees clauses automatically generate function that allow us to extract the node label and the list of subtrees from a corolla. |
Since we occasionally, but not very often, will feel a need to decorate the leaves with something different from integers, we define our tree type as a different type from the type we use with the users in the end. We define a type synonym DecoratedTree |
that stands for PreDecoratedTree Int , so that the user should only ever have to see DecoratedTree occuring. We also define a number of utility functions for operations on these trees: methods to apply a function to each node label, and to apply a function to each leaf label, as well as functions to easily construct co... |
One pattern that reoccurs a lot here is the basic tree recursion shape. We give, here, as an example, the code to apply a function to each vertex label: |
vertexMap :: Ord Show Ord Show => -> -> PreDecoratedTree -> PreDecoratedTree vertexMap DTLeaf DTLeaf vertexMap DTVertex ts DTVertex |
map vertexMap ts There is some boiler plate — the type variables and have to match the assumptions needed to build a tree. But then the code just states that applying [MATH] to the node labels if you encounter a leaf just returns the leaf unchanged. If, however, you encounter a vertex, you apply the function to the lab... |
This structure faithfully reproduces planar rooted trees with leaf and node labels. Using the ordering on the leaf labels, we can represent any symmetric node-labeled tree this way. Using only the tree monomials from the free shuffle operad, finally, means placing restrictions on the permutations the leaf labels are al... |
3.2. Operad elements Recall that an element of the free operad in the category of vector spaces over a field is a formal linear combination of decorated trees. To represent operad elements, thus, we need to be able to represent formal linear combinations — sorted according to the appropriate monomial ordering. |
Representing this computationally in Haskell is a three-step process. First, we represent monomial orderings. Then, we represent trees equipped with a monomial ordering. Finally, we use the |
Data Map Haskell standard library implementation to represent a partially defined function taking decorated trees to coefficient values. |
These last functions become equivalent with formal linear combinations once we define an arithmetic on them: [EQUATION] This equivalence is given by, for a function [MATH] , forming the formal linear combination [MATH] . The reverse is given by taking a formal linear combination [MATH] and forming the function [MATH] |
Monomial orderings are represented as empty types constructors without values other than having distinct constructors. These types, then, are made to implement type classes — the Haskell way to do polymorphism. Implementing a type class means that the type class defines specific functions, and the type class implementa... |
As for the partial function definition, the datatype Data Map works for finite such definitions by way of a lookup table: an entity of type Data Map is a search tree that can be queried for the value associated to a particular tree, and that works, internally, by maintaining a balanced binary search tree. In particular... |
This last point is worth elaborating on. We found in early implementations that storing decorated trees in a binary search tree, and having monomial orderings depending on a significant number of tree traversals in order to construct the ordering invariants, lead to an extraordinary amount of tree traversals. In our fi... |
Data Map for storage. Every operation on such operad elements would incur many tree comparisons, each of which would incur several tree traversals. To deal with this, we wrote a wrapper around the storage type that would perform the tree traversals for the orderings described in Section 4.3 once at the creation of an o... |
3.3. Trees with holes and tagged nodes Recall that for two tree monomials [MATH] and [MATH] such that [MATH] is divisible by [MATH] it is possible to define the function [MATH] that reconstructs the surroundings of [MATH] |
in [MATH] ; this function is applicable to any other operad element of the correct arity. An algorithm for finding divisors of trees, as the Gröbner basis algorithms makes heavy use of, would need an efficient way to represent the data needed for such a reconstruction. We decided to do this by representing holes punche... |
Similar to this idea is the data representation we found to be efficient to represent a small common multiple of two trees in such a manner that the divisor data for both trees is easily reconstructed: such a small common multiple will have one of the trees dividing it at the root, and the other somewhere in the tree. ... |
3.3.1. An aside on data types and labels The union data type construction in Haskell has a standard library implementation, with quite a bit of predefined functionality: |
Either . This defines for us constructors Left and Right carrying values of types and respectively. One special case of the Either type is when one of the two types is empty. This case has been given a name of its own: |
Maybe and comes with new constructors — Just taking the place of Left and Nothing taking the place of Right These type constructions turn out to be exactly what we need to signify marked nodes and removed nodes. |
3.3.2. Trees with marked nodes We generate, in order to mark some of the nodes of our tree, a new tree from the old one with changed node labels. Instead of labelling our tree with some type , we now label them with |
Either . This has the effect of increasing the amount of information carried by each node — in addition to the original node information it now also carries a binary choice for each node: is it a Left or a Right instance of the label type? |
Hence, we can in our code for generating small common multiples return a tree labeled in Either , and making sure it only contains one single node labeled Right — namely the point of attachment for the second tree. We know that one of the two trees has to be rooted at the root of the small common multiple — otherwise i... |
The algorithm we use to find small common multiples, elaborated on in Section 4.2 , has the following basic structure. In order to find small common multiples of [MATH] and [MATH] we go through the steps: |
(1) To find small common multiples of [MATH] and [MATH] sharing the common root, traverse both trees, checking compatibility at each step and whenever one tree yields a leaf, attach the remaining subtree of the other tree. Tag the root of the returned small common multiple as Right |
label (2) Recurse through vertices [MATH] of [MATH] , applying the previous step to find small common multiples of [MATH] and the subtree [MATH] of [MATH] rooted at [MATH] For each such common multiple [MATH] , form a new tree by taking [MATH] and replacing [MATH] |
with [MATH] As a result, the only point where a node is tagged with the Right is when a rooted common multiple is found, and the recursion ensures that the rest of the tree is rebuilt so that |
[MATH] is embedded with a shared root with the common multiple. And in order to find all small common multiples, we need to perform this algorithm once again with the trees interchanged, so that we may find small common multiples with [MATH] embedded at the root. |
3.3.3. Trees with holes As for the divisor reconstruction, we have some embedding of the tree monomial [MATH] into the tree [MATH] , and we want to retain the information of the entire tree excepting the part that corresponds to [MATH] |
The way we do this is to collapse the embedded copy of [MATH] into a single corolla of the correct arity, and keeping the rest of the tree intact. This corolla, then, is marked — forgetting any original corolla type markings — to signify that it forms an embedding point. |
This marking, in turn, is achieved by changing the type of all labels from the type to the type Maybe . That way, the part of the tree that needs to stay intact is marked with |
Just label for what previously was marked with label , and the corolla holding the position of the hole is marked with Nothing , distinguishing it from the other nodes. |
For this reason, we introduce the type alias Embedding defined to be of the type DecoratedTree Maybe . Hence, the division algorithm described in Section 4.1 |
will take the two trees [MATH] and [MATH] as parameters, and return an embedding of the shape of [MATH] with a subtree isomorphic to [MATH] taken out. See Figure for an example. |
The reconstruction algorithm, on the other hand, takes a shape representing some embedding of [MATH] in [MATH] , and a new tree monomial [MATH] of the same arity as [MATH] , and returns the corresponding tree [MATH] |
3.4. Permutations Since the most common use for permutations in this project is to label leaves of trees, and to reorder subtrees for composition, we have decided to store our permutations as lists of images. This choice is reinforced by the lack of need for compositions and decompositions of permutations. |
This representation yields a simple method to reorder a list of objects in the order specified by a permutation — an operation we have reason to perform often in the code, for instance in order to decorate leaves of a labelled tree according to their integer decorations: we pair off the elements we want to reorder with... |
This is a code idiom we have used at several points in the code base. 4. Algorithms With the data structures we use settled in Section |
, we now turn to the algorithms that implement the core components of the Buchberger algorithm. Thus, in Section 4.1 , we meet the division algorithm, creating the black hole trees, and the reconstruction algorithm, re-inserting a tree in the black hole. In Section 4.2 , we adapt the idea for finding block permutations... |
4.3 we discuss the family of monomial orderings that the software package implements. 4.1. Divisibility and reconstructions Finding all embeddings (as a divisor) of [MATH] into [MATH] can be easily reduced to finding out whether or not [MATH] is embedded into [MATH] in such a way that they share the common root. If we ... |
Specifically, if we try to find an embedding of [MATH] into [MATH] sharing the common root, we first verify that the root vertices share the label and arity. If this is the case, we can pair up the subtrees [MATH] of [MATH] and the subtrees of [MATH] of |
[MATH] , and then find rooted embeddings of each [MATH] in each [MATH] . If all these succeed, we expect to get as a result from each a tree |
[MATH] for each pair with a hole punched out at the root corresponding to a subtree looking like [MATH] At this point, we need to patch things up. The root nodes match, and the subtrees have already found embeddings. Checking the leaf orders, we then need to merge all the subtrees with holes into a tree with hole that ... |
Once we find an embedding of [MATH] , we store this embedding as a tree monomial obtained from [MATH] by collapsing the occurrence of [MATH] into a single vertex. To reconstruct [MATH] from that, we insert [MATH] in the “hole” in such a way that the leaves of [MATH] match the outputs of the “hole” (order-wise). |
Inserting [MATH] into the hole, specifically, means that we replace the leaves of [MATH] with the subtrees of the hole in the tree with the hole, in the order specified by the labels of the leaves of [MATH] , and then replace the hole and all its subtrees in the full tree with a hole by this extended |
[MATH] , as shown in Figure 4.2. Finding small common multiples An algorithm that lists all small common multiples of two given trees [MATH] and [MATH] consists of several steps. If we forget all leaf labels of a tree monomial, we end up with a planar tree with labelled vertices. We call such tree a nonsymmetric tree m... |
The first step is more or less trivial: small common multiples of two nonsymmetric tree monomials are superpositions of the trees for which all labels of vertices agree with each other. Thus, to list all such small common multiples, we should go through all ways to identify the root vertex of one of the trees with a ve... |
The second step is a bit more tricky, but still requires a straightforward recursive algorithm. To recover all admissible leaf labellings giving a common multiple [MATH] , we have to solve the problem of finding all possible linear orders on a poset of a special type. The elements of that poset are leaves of the nonsym... |
[MATH] is the smallest leaf reachable from [MATH] and [MATH] is the smallest leaf reachable from [MATH] [MATH] and [MATH] are leaves of the occurence of [MATH] in [MATH] (where [MATH] is either [MATH] or [MATH] ), and [MATH] in the ordered leaf set of [MATH] |
A labelling of the leaves of [MATH] makes it a small common multiple if and only if it extends the above ordering to a linear ordering. We shall recover all such labellings recursively. Our poset essentially consists of two intertwined and intersecting linear orders, and the maximal element of the labelling set should ... |
4.3. Monomial orderings Let us describe some admissible orderings. As one can see, each definition will be either immediate to implement because of the storage types we use or straightforward recursive. |
Let [MATH] be a tree monomial with [MATH] inputs in the free operad [MATH] . We associate to [MATH] a sequence [MATH] of [MATH] words in the alphabet [MATH] , and a permutation [MATH] as follows. For each leaf [MATH] of [MATH] , there exists a unique path from the root to [MATH] . The word [MATH] |
is the word composed, from left to right, of the labels of the vertices of this path, starting from the root vertex. The permutation [MATH] lists the labels of leaves in the order determined by the planar structure (from left to right). |
Now, to compare two tree monomials we always compare their arities first. If the arities are equal, there are several different options of how to proceed. Sequences of words can be compared lexicographically using either the degree-lexicographic ordering of words, or the reverse degree-lexicographic ordering (either th... |
PermPath etc. (the names are self-explanatory). Proposition 4 All the above orderings are admissible. In fact, to compare words one may use any admissible ordering of the monomial basis of the free algebra, for example, the lexicographic ordering, or the reverse lexicographic one: the resulting ordering of tree monomia... |
Appendix: Haskell constructions used Bool: The boolean truth values type. Has values True and False Int: The bounded integer type. Has values, on a 32 bit machine, from the interval [MATH] |
Char: The single character type. [a]: The type of lists of elements of type [MATH] b: The type of a function from a type to a type |
data: The declaration of a new data type. Ord: The type class that defines the ordering functions <= >= , and compare Eq: The type class that defines the equality testing function == ). |
Show: The type class that defines the serialization function show Fractional: The type class that defines a type to implement a field. |
(::): The syntax element indicating a type declaration. [MATH] ): The syntax element delimiting type assumptions from the type declaration. |
(!): When occurring in a type declaration, forces strictness in the corresponding part. [MATH] ): When occurring in a type declaration, delimiting the union type components. Hence, a type declared as |
data Int Char is either an Int with the constructor , or Char with the constructor TreeOrdering: A type class created by our code carrying information about the chosen monomial order. |
OperadElement: The type created by our code representing, internally, a linear combination of tree monomials with associated monomial orderings. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.