Interaction nets explained

Interaction nets are a graphical model of computation devised by French mathematician Yves Lafont in 1990[1] as a generalisation of the proof structures of linear logic. An interaction net system is specified by a set of agent types and a set of interaction rules. Interaction nets are an inherently distributed model of computation in the sense that computations can take place simultaneously in many parts of an interaction net, and no synchronisation is needed. The latter is guaranteed by the strong confluence property of reduction in this model of computation. Thus interaction nets provide a natural language for massive parallelism. Interaction nets are at the heart of many implementations of the lambda calculus, such as efficient closed reduction[2] and optimal, in Lévy's sense, Lambdascope.[3]

Definitions

Interactions nets are graph-like structures consisting of agents and edges.

An agent of type

\alpha

and with arity

ar(\alpha)=n\ge0

has one principal port and

n

auxiliary ports. Any port can be connected to at most one edge. Ports that are not connected to any edge are called free ports. Free ports together form the interface of an interaction net. All agent types belong to a set

\Sigma

called signature.

An interaction net that consists solely of edges is called a wiring and usually denoted as

\omega

. A tree

t

with its root

x

is inductively defined either as an edge

x

, or as an agent

\alpha

with its free principal port

x

and its auxiliary ports

xi

connected to the roots of other trees

ti

.

Graphically, the primitive structures of interaction nets can be represented as follows:

When two agents are connected to each other with their principal ports, they form an active pair. Foractive pairs one can introduce interaction rules which describe how the active pair rewrites to another interactionnet. An interaction net with no active pairs is said to be in normal form. A signature

\Sigma

(with

ar:\SigmaN

defined on it) along with a set of interaction rules defined for agents

\alpha\in\Sigma

together constitute an interaction system.

Interaction calculus

Textual representation of interaction nets is called the interaction calculus[4] and can be seen as a programming language.

Inductively defined trees correspond to terms

t::=\alpha(t1,...,tn)|x

in the interaction calculus, where

x

is called a name.

Any interaction net

N

can be redrawn using the previously defined wiring and tree primitives as follows:

which in the interaction calculus corresponds to a configuration

c\equiv\langlet1,...,tm|v1=w1,...,vn=wn\rangle

,

where

ti

,

vi

, and

wi

are arbitrary terms. The ordered sequence

t1,...,tm

in the left-hand side is called an interface, while the right-hand side contains an unordered multiset of equations

vi=wi

. Wiring

\omega

translates to names, and each name has to occur exactly twice in a configuration.

Just like in the

λ

-calculus, the interaction calculus has the notions of

\alpha

-conversion
and substitution naturally defined on configurations. Specifically, both occurrences of any name can be replaced with anew name if the latter does not occur in a given configuration. Configurations are considered equivalent up to

\alpha

-conversion. In turn, substitution

t[x:=u]

is the result of replacing the name

x

in a term

t

with another term

u

if

x

has exactly one occurrence in the term

t

.

Any interaction rule can be graphically represented as follows:

where

\alpha,\beta\in\Sigma

, and the interaction net

N

on the right-hand side is redrawn using the wiring and tree primitives in order to translate into the interaction calculus as

\alpha[v1,...,vm]\bowtie\beta[w1,...,wn]

using Lafont's notation.

The interaction calculus defines reduction on configurations in more details than seen from graphrewriting defined on interaction nets. Namely, if

\alpha[v1,...,vm]\bowtie\beta[w1,...,wn]

, the following reduction:

\langle\vect|\alpha(t1,...,tm)=\beta(u1,...,un),\Delta\rangle\langle\vect|t1=v1,...,tm=vm,u1=w1,...,un=wn,\Delta\rangle

is called interaction. When one of equations has the form of

x=u

, indirection can be applied resultingin substitution of the other occurrence of the name

x

in some term

t

:

\langle...t...|x=u,\Delta\rangle\langle...t[x:=u]...|\Delta\rangle

or

\langle\vect|x=u,t=w,\Delta\rangle\langle\vect|t[x:=u]=w,\Delta\rangle

.

An equation

x=t

is called a deadlock if

x

has occurrence in term

t

. Generally only deadlock-free interaction nets are considered. Together, interaction and indirection define the reduction relation on configurations. The fact that configuration

c

reduces to its normal form

c'

with no equations left is denoted as

c\downarrowc'

.

Properties

Interaction nets benefit from the following properties:

cc1

and

cc2

, then

c1c'

and

c2c'

for some

c'

).

These properties together allow massive parallelism.

Interaction combinators

One of the simplest interaction systems that can simulate any other interaction system is that of interaction combinators.[5] Its signature is

\Sigma=\{\epsilon,\delta,\gamma\}

with

ar(\epsilon)=0

and

ar(\delta)=ar(\gamma)=2

. Interaction rules for these agents are:

\epsilon\bowtie\alpha[\epsilon,...,\epsilon]

called erasing;

\delta[\alpha(x1,...,xn),\alpha(y1,...,yn)]\bowtie\alpha[\delta(x1,y1),...,\delta(xn,yn)]

called duplication;

\delta[x,y]\bowtie\delta[x,y]

and

\gamma[x,y]\bowtie\gamma[y,x]

called annihilation.

Graphically, the erasing and duplication rules can be represented as follows:

with an example of a non-terminating interaction net that reduces to itself. Its infinite reduction sequence starting from the corresponding configuration in the interaction calculus is as follows:

\begin{align} &\langle\varnothing|\delta(\epsilon,x)=\gamma(x,\epsilon)\rangle\\ &\langle\varnothing|\epsilon=\gamma(x1,x2),x=\gamma(y1,y2),x=\delta(x1,y1),\epsilon=\delta(x2,y2)\rangle*\\ &\langle\varnothing|x1=\epsilon,x2=\epsilon,x=\gamma(y1,y2),x=\delta(x1,y1),x2=\epsilon,y2=\epsilon\rangle*\\ &\langle\varnothing|\delta(\epsilon,x)=\gamma(x,\epsilon)\rangle... \end{align}

Non-deterministic extension

Interaction nets are essentially deterministic and cannot model non-deterministic computations directly. In order to express non-deterministic choice, interaction nets need to be extended. In fact, it is sufficient to introduce just one agent

amb

[6] with two principal ports and the following interaction rules:

This distinguished agent represents ambiguous choice and can be used to simulate any other agent with arbitrary number of principal ports. For instance, it allows to define a

ParallelOr

boolean operation that returns true if any of its arguments is true, independently of the computation taking place in the other arguments.

See also

Further reading

External links

Notes and References

  1. Book: Lafont, Yves. Proceedings of the 17th ACM SIGPLAN-SIGACT symposium on Principles of programming languages - POPL '90 . Interaction nets . 1990. 95–108. 10.1145/96709.96718. ACM. 0897913434. 1165803 .
  2. Ian. Mackie. An Interaction Net Implementation of Closed Reduction. 43–59. 2008. 10.1007/978-3-642-24452-0_3. Implementation and Application of Functional Languages: 20th International Symposium. 5836. Lecture Notes in Computer Science. 978-3-642-24451-3.
  3. Vincent. van Oostrom. Kees-Jan. van de Looij. Marijn . Zwitserlood. Lambdascope: Another optimal implementation of the lambda-calculus. 2010. https://web.archive.org/web/20170706084403/http://www.phil.uu.nl/~oostrom/publication/pdf/lambdascope.pdf . 2017-07-06 . dead.
  4. Fernández. Maribel. Mackie. Ian. A calculus for interaction nets. Principles and Practice of Declarative Programming. 1702. 1999. 170–187. 10.1007/10704567. Springer. Lecture Notes in Computer Science. 978-3-540-66540-3. 19458687 .
  5. Yves. Lafont. Interaction Combinators. Information and Computation. 137. 1. 69–101. 1997. Academic Press, Inc.. 10.1006/inco.1997.2643. free.
  6. Fernández. Maribel. Khalil. Lionel. Interaction Nets with McCarthy's Amb: Properties and Applications. Nordic Journal of Computing. 2003. 10. 2. 134–162.