Implementation of Closed Reduction
Jul. 27th, 2014 06:26 pmAn Interaction Net Implementation of Closed Reduction by Ian Mackie using Interaction Nets Compiler:
\lambda[a, b] { /* Apply a closed term. */ } \lambda[a, b]; \copy[\lambda(a, b), \lambda(c, d)] { /* Initiate copy of a closed term. */ } \lambda[\dup(a, c), \dup(b, d)]; \bind[a, \lambda(b, c), a] { /* Bind variable to a closed term. */ } \lambda[b, c]; \dup[\lambda(a, b), \lambda(c, d)] { /* Duplicate abstraction or application. */ } \lambda[\dup(a, c), \dup(b, d)]; \dup[\copy(a, b), \copy(c, d)] { /* Duplicate copy initiator. */ } \copy[\dup(a, c), \dup(b, d)]; \dup[\bind(a, b, c), \bind(d, e, f)] { /* Duplicate variable binding. */ } \bind[\dup(a, d), \dup(b, e), \dup(c, f)]; \dup[a, b] { /* Finish duplication. */ } \dup[a, b]; \erase { /* Erase abstraction or application. */ } \lambda[\erase, \erase]; \erase { /* Erase variable binding. */ } \bind[\erase, \erase, \erase]; \erase { /* Erase copy initiator. */ } \copy[\erase, \erase]; \erase { /* Erase duplicator. */ } \dup[\erase, \erase]; \erase { /* Finish erasing. */ } \erase; $$ {"Application"} = result; function = \lambda(argument, result); shared1 = \copy(first1, second1); shared2 = \copy(first2, second2); shared3 = \copy(first3, second3); {"Abstraction"} = bind0; bv1 = \bind(bind1, fv1, bind0); bv2 = \bind(bind2, fv2, bind1); bv3 = \bind(bind3, fv3, bind2); bindn = \lambda(variable, body);