@alexo/lambda
Version:
Macro Lambda Calculus
127 lines (103 loc) • 2.4 kB
Plain Text
\fan_{i}[\scope_{j}(a), \scope_{j}(b)] {
/* Duplicate higher delimiter. */
if (i < j)
this.debug.o();
else
return false;
} \scope_{j}[\fan_{i}(a, b)];
\scope_{i}[\fan_{j + 1}(a, b)] {
/* Level up higher or matching fan. */
if (i <= j)
this.debug.o();
else
return false;
} \fan_{j}[\scope_{i}(a), \scope_{i}(b)];
\scope_{i}[\scope_{j + 1}(a)] {
/* Level up higher delimiter. */
if (i < j)
this.debug.o();
else
return false;
} \scope_{j}[\scope_{i}(a)];
\print {
/* Ignore delimiter. */
this.debug.o();
} \scope_{i}[!print];
\read_{C}[\scope_{i}(a)] {
/* Pass through context. */
this.debug.o();
} \scope_{i}[\read_{C}(a)];
\scope_{i}[a] {
/* Annihilate matching delimiters. */
if (i == j)
this.debug.o();
else
return false;
} \scope_{j}[a];
\scope_{i}[\apply(a, b)] {
/* Pass through application. */
this.debug.o();
} \apply[\scope_{i}(a), \scope_{i}(b)];
\scope_{i}[\lambda(a, b)] {
/* Level up delimiter. */
this.debug.o();
} \lambda[\scope_{i + 1}(a), \scope_{i + 1}(b)];
\scope_{i}[\atom_{M}] {
/* Return an atom. */
this.debug.o();
} \atom_{M};
\read_{C}[\fan_{i}(a, b)] {
/* Duplicate context. */
this.debug.o();
} \fan_{i}[\read_{C}(a), \read_{this.clone(C)}(b)];
\print {
/* Output results of read-back. */
this.nf = M;
this.debug.o();
} \atom_{M};
\read_{C}[\scope_{0}(a)] {
/* Read back abstraction. */
this.debug.o();
} \lambda[\atom_{this.mkid()}, \read_{this.abst(C)}(a)];
\apply[\read_{this.appl(M)}(a), a] {
/* Read back application. */
this.debug.o();
} \atom_{M};
\read_{C}[\atom_{this.atom(C, M)}] {
/* Read back an atom. */
this.debug.o();
} \atom_{M};
\fan_{i}[\atom_{M}, \atom_{M}] {
/* Duplicate an atom. */
this.debug.o();
} \atom_{M};
\apply[\scope_{0}(a), \scope_{0}(b)] {
/* Apply beta reduction. */
this.debug.b();
} \lambda[a, b];
\fan_{i}[\apply(a, b), \apply(c, d)] {
/* Duplicate application. */
this.debug.o();
} \apply[\fan_{i}(a, c), \fan_{i}(b, d)];
\fan_{i}[\lambda(a, b), \lambda(c, d)] {
/* Level up fan. */
this.debug.o();
} \lambda[\fan_{i + 1}(a, c), \fan_{i + 1}(b, d)];
\fan_{i}[a, b] {
/* Annihilate matching fans. */
if (i == j)
this.debug.a();
else
return false;
} \fan_{j}[a, b];
\fan_{i}[\fan_{j}(a, b), \fan_{j}(c, d)] {
/* Duplicate higher fan. */
if (i < j)
this.debug.d();
else
return false;
} \fan_{j}[\fan_{i}(a, c), \fan_{i}(b, d)];
$$
INCONFIG
$$
READBACK