# The design implication of PD[X[ #, #, #, #], X[#, #, #, #]]

In Package KnotTheory, there's a function called PD[] that takes a tabulated knot and returns its PD codes, for example: PD[Knot[4, Alternating, 1]] returns PD[X[4, 2, 5, 1], X[6, 3, 7, 4], X[8, 6, 1, 5], X[2, 7, 3, 8]].

My question: what is the data type of this output above and what could be its design purpose?

• It's not clear what you are asking. As for the datatype, in Mathematica, Everything is an Expression. – Szabolcs Sep 22 '18 at 5:34
• Welcome to StackExchange Mathematica! This page seems to explain the structure of the expressions used by the KnotTheory package and hopefully helps. – Thies Heidecke Sep 22 '18 at 11:22

One could agree on a following convention for describing the same knot by agreeing on what is represented in each dimension:

{{4, 2, 5, 1}, {6, 3, 7, 4}, {8, 6, 1, 5}, {2, 7, 3, 8}}


The first dimension is a list of crossings and the second dimension is a list of edges. The same expression in a FullForm would be

List[List[4, 2, 5, 1], List[6, 3, 7, 4], List[8, 6, 1, 5], List[2, 7, 3, 8]]


You can make your symbolic expressions much more self-explaining, semantic and flexible by using a different head instead of List:

PD[X[4, 2, 5, 1], X[6, 3, 7, 4], X[8, 6, 1, 5], X[2, 7, 3, 8]]


PD and X look like "functions" which do not do anything, but they are useful symbolic wrappers. For example, in some application you could have complex nested structures, you can easily check if the head of a function argument is correct and so on.

Mathematica is an expression rewriting language. "Functions" are implemented with rewriting rules. In this case, PD appears to be associated with a rule that rewrites PD[Knot[...] as PD[X[...],... but no rule to rewrite it further. This design pattern allows an expression to rewrite itself into a standard form. You might want to think of the PD in the input expression as a function (because there's a rule to rewrite it), while the PD in the output is more like a data type (because there's no rule to rewrite it).