Chapter 4 Cadence: A Prototype Tool
4.3 Making the OD-net Dynamic and Dynamical
4.3.1 Computation by Navigation
Observables in the graph can be accessed by navigation from some starting node (the observational context) and following any number of edges until a resulting node is found. In the object-oriented tradition, nodes, when interpreted as objects, can contain edges that represent operations upon that object. The node an operation edge points to represents a curried function and all edges coming from that node correspond to the second parameter being given. Following one of these edges leads to either a resulting value or another function if the function has more than two parameters.
A good example is that of integers where a node represents a number and has edges for addition, subtraction and so on. An example is given in the graph in figure 4.7 which shows an addition operation for the integers 0, 1 and 2. Following the addition edge moves to an intermediate node with edges for all other integers that you may add to the first. All kinds of operation can, in principle at least, be represented by this graph navigation approach but this does require some nodes to be very large or infinite 10This use of dynamic and dynamical may be controversial. Dynamical is used for systems that change
Figure 4.7: A portion of the graph for integer addition.
in extent (i.e. an infinite number of edges) and that there exist a very large or infinite number of nodes. The navigation approach also relies heavily on the fact that node OIDs can identify edges, as will become clear. What this approach to computation results in is an ability to explore logic, arithmetic and functions in the exact same way as exploring the data. There is no difference between data and code, computation becomes a form of observation as well (cf. chapter 6).
The example graph depicted in figure 4.7 can be expressed explicitly using DASM and is shown in the example script in listing 4.14. In practice a full definition of integer addition and other operators is extremely large and is considered infinite, so such a description cannot be given explicitly and must be built-in as a virtual part of the graph11. Conceptually, however, it works as shown.
If the definition in listing 4.14 were to be completed for all numbers and operators then arithmetic expressions can be specified as paths to follow through the graph. This takes advantage of the cyclicity of the OD-net graph.
Any arithmetic can now be performed by graph navigation (cf. listings 4.15 and 4.16). The agent that does the following is doing the computation and that agent may 11An alternative is to use generic definitions described later as a way of describing potentially infinite
0 + = (new) ; 0 + 0 = 0 ; 0 + 1 = 1 ; 0 + 2 = 2 ; 1 + = (new) ; 1 + 0 = 1 ; 1 + 1 = 2 ; 1 + 2 = 3 ; 2 + = (new) ; 2 + 0 = 2 ; 2 + 1 = 3 ; 2 + 2 = 4
Listing 4.14: DASM definition of addition
1 + 2 + 3 + 4 + 5
Listing 4.15: Simple arithmetic in DASM
5 ∗ ( 2 + 6 ) / ( 7 ∗ 8 )
well be the human user, not just an automated process. In a sense it is a little like a structured lookup table that a user or machine can follow to perform some computation, although not restricted to numbers. The graph describes what can be computed by observation, but not what is computed as that is entirely at the discretion of the observer. The example in listing 4.16 shows how sub-queries can be used. Sub-queries work by taking advantage of the fact that edges are labelled with the same OIDs as nodes. So the result of a query is a node that is then used to identify an edge from another node. Much more will be said about the theory behind computation by navigation in chapter 6. The next example, in listing 4.17, defines the boolean operators. Boolean operators can be described in exactly the same way and because they are small and finite they can easily be given explicitly so are not a built-in virtual part of the graph. In listing 4.17 is the boolean ‘and’ operation given in DASM:
t r u e and = (new) ; t r u e and t r u e = t r u e; t r u e and f a l s e = f a l s e; f a l s e and = (new) ; f a l s e and t r u e = f a l s e; f a l s e and f a l s e = f a l s e;
Listing 4.17: DASM boolean ‘and’ operator definition
Listing 4.18 is an example of using the ‘and’ operator for a boolean expression. It is easy to visualise the computation process by following the graph in figure 4.8 to evaluate the expression in listing 4.18. The node obtained after all edges have been followed is the result of evaluating this expression, in this case ‘false’.
t r u e and t r u e and f a l s e and t r u e
Listing 4.18: DASM boolean logic
Figure 4.8: Complete graphs showing boolean ‘and’ and ‘or’ operators in DOSTE
shown in the next section.