Sunteți pe pagina 1din 3

Macro Lambda Calculus

Anton Salikhmetov
August 7, 2015
Abstract
The goal of our Macro Lambda Calculus project (MLC) is to encode -terms into
interaction nets. Its software implementation accepts input in the notation similar
to -calculus allowing macro definitions. Output is similar to interaction calculus
and is suitable for our Interaction Nets Compiler program (INC). In this paper, we
describe the interaction system for call-by-need evaluation and the mechanism of
encoding -terms into this system which MLC is based on.

Workflow

MLC exists in the context of a set of tools needed to evaluate -terms. A -term to be
reduced to its normal form (if such exists) is written down using textual representation
to be further translated into an interaction net by the MLC compiler mlc. In the spirit of
UNIX command pipelines, the mlc output can be piped into the interaction net compiler
inc. The inc compiler translates the interaction net into a C language program that will
perform interaction. In our case, this program (once compiled into binary) computes and
prints out the normal form of the original -term if such exists or enters an infinite loop
otherwise. The output syntax is the same as the one used to encode the original term.

Non-deterministic extension

We work in interaction calculus [1] extended by a special non-deterministic agent Amb [2].
We represent this agent in a more conservative fashion than it was suggested in the original
paper. Specifically, we prepend the list of auxiliary ports of Amb with its extra principal
port and introduce the following conversion:
h~t | t = Amb(u, v, w), i = h~t | u = Amb(t, v, w), i.
We assume that any interaction systems signature is implicitly extended by Amb with
Ar(Amb) = 3, while its set of rules is implicitly extended with
[~x] ./ Amb[y, (~x), y].

Encoding -terms

We denote the set of -terms [3] as , and C[ ] means a context, i. e. a -term with one
hole, while C[M ] is the result of placing M in the hole of the context C[ ].
Our interaction system has signature
= {, s, @, , c, } {aM | M } {rC[

| C[

] is a context},

with all the agents being binary, except Ar() = Ar(aM ) = 0 and Ar(rC[ ] ) = 1. For the
list of interaction rules, please refer to Appendix A which also includes a tabular index.
While encoding -terms into our interaction system, we will distinguish their free
variables from their bound variables. So, let us mark all free variables in a -term M
using the following operation: M M [~x := ~x ], where (~x) = FV(M ). Then, any -term
M can be mapped to configuration hx | r[ ] (x) = y, (M , y)i as follows:
(x , y) = {ax = y};
(x, y) = {x = y};
(x.M, y) = {y = (, z)} (M, z), when x 6 FV(M );
(x.M, y) = {y = (x, z)} (M, z), when x FV(M );
(M N, y) = {y = @(x, z)} (M [~t := ~t0 ], x) (N [~t := ~t00 ], z) (~t),
(~t) = {t0i = Amb(t00i , s(ti , ui ), ui ) | ti (~t)},
(~t) = FV(M ) FV(N ).

where

and

We claim that hx | r[ ] (x) = y, (M , y)i haN | i iff M  N and N is normal form.


Please note that our interaction system has read-back mechanism embedded. Indeed,
configuration that encodes a -term M will be reduced to normal form (if any) with only
one agent aN in its interface, N representing normal form of the encoded -term M .

References
[1] M. Fernandez, I. Mackie. A calculus for interaction nets.
Proceedings of the International Conference on Principles and Practice of Declarative
Programming, vol. 1702 of Lecture Notes in Computer Science, 170187.
Springer-Verlag, 1999.
[2] M. Fernandez, L. Khalil. Interaction Nets with McCarthys amb.
Electronic Notes in Theoretical Computer Science, 68(2): 5168.
Elsevier, 2002.
[3] H. P. Barendregt. The Lambda Calculus, Its Syntax and Semantics.
North-Holland, 1984.


 (1)
a (2)
s (3)
@ (4)
(5)
c (6)
(7)
r


a
s
@
(2) (3) (4)

(8) (12) (16)


(9) (13) (17)
(10) (14) (18)
(11) (15) (19)
a
s
@

(5)
(8)
(12)
(16)
(20)
(21)
(22)
(23)

c
(6)
(9)
(13)
(17)
(21)

(24)

(7)
(10)
(14)
(18)
(22)
(24)
(25)


(11) a
(15) s
(19) @
(23)

r
r

Interaction rules
 ./ ;
 ./ aM ;
 ./ s[x, x];
 ./ @[, ];
 ./ [, ];
 ./ c[, ];
 ./ [, ];
aM ./ [rM [ ] (x), x];
aM ./ c[aM , aM ];
aM ./ [aM , aM ];
aM ./ rC[ ] [aC[M ] ];
s[c(z, (x, y)), z] ./ [x, y];
s[c(z, c(x, y)), z] ./ c[x, y];
s[c(x, (y, z)), x] ./ [y, z];
s[c(x, rC[ ] (y)), x] ./ rC[ ] [y];
@[(z, (x, y)), z] ./ [x, y];
@[(z, c(x, y)), z] ./ c[x, y];
@[(x, y), (v, w)] ./ [@(x, v), @(y, w)];
@[(x, rC[ ] (y)), x] ./ rC[ ] [y];
[x, y] ./ [x, y];
[(x, y), (v, w)] ./ c[(x, v), (y, w)];
[(x, y), (v, w)] ./ [(x, v), (y, w)];
[ay , rC[y.[ ]] (x)] ./ rC[ ] [x], where y is a new variable;
[x, y] ./ c[(Amb(v, s(x, z), z), Amb(w, s(y, u), u)), (v, w)];
[x, y] ./ [x, y].

(1)
(2)
(3)
(4)
(5)
(6)
(7)
(8)
(9)
(10)
(11)
(12)
(13)
(14)
(15)
(16)
(17)
(18)
(19)
(20)
(21)
(22)
(23)
(24)
(25)

S-ar putea să vă placă și