# Calculus Term Paper

If you want a wordy dissertation, stay with me as I carefully explain what it means and how I got there. That’d allow us to duplicate duplications (and to have layers of superposed superpositions), giving us all the sharing power I’ve observed in my previous posts.If you’re out of the loop, the Abstract Algorithm is a machinery capable of evaluating functional programs optimally. I’d love to show how all of it works with some animations, and to attempt writing some proofs, but this story is already quite big as is and I’m quite tired at this point.(Update: renamed to Symmetric Interaction Calculus.)This is another post about the Abstract Algorithm. term)--------------------------------------- superposed application K = x0 & x1term = f0 K & f1 Kλt. That’s because it is directly isomorphic to Symmetric Interaction Combinators.

That is, the asymptotics are the same, but the practical performance of the algorithm goes downhill because rewrite counts are increased by large constants.

Here is a visualization: This table compares the number of graph rewrite rules (thus, time) required to evaluate certain terms in 5 different implementations; 4 of them with some oracle, and one without, here called Absal. As you can see, the oracle-free version outperforms most implementations by 2 to 3 orders of magnitude.

As an illustration, here is addition in EAL Calculus of Constructions: As you can see, the later is much simpler. At this point, you may be asking why, to which I reply, why do we even had a scope to begin with?

So, extending the Abstract Algorithm to cover all lambda terms ruins its efficiency, and restricting the λ-calculus to be Absal-compatible makes it hard to program with. For one, we know there are things λ-terms can do that Absal can’t. c) 2 3)--------------------------- lambda applicationλt. One may argue adding it is an arbitrary, artificial limitation. Either we give up of lambdas, duplications, constant-time operations or closed scopes.

This allows two optimizations: first, the λ can keep a pointer to the occurrence of its variable, so, there’s no need for a traversal.

Second, since the variable only occurs once, we can merely redirect the reference of (λp. For some input programs, it, instead, simply fails to halt, or even returns downright wrong results; in this issue I present an example. Moreover, even λ-terms that succeed to reduce pass through intermediate representations that correspond to no λ-term at all. Some common programming idioms are even impossible: nested for-loops, for example. You must instead unroll all loops in your programs. t 1 2 3Notice how the first two applications of the inner function moved its argument to outside its own body. term)----------------------------- lambda copyterm = (f0 & f1) (x0 & x1)λt. The proposal is to use the algorithm without an oracle (i.e., incomplete, but efficient), and restrict our term language to only be able to express terms that are compatible with it. The most promising way to do it is to shift to a different underlying logic: Elementary Affine Logic, which essentially stratifies terms in “layers”, preventing a term to duplicate another term in the same level, making it Absal-compatible. This proposal is particularly interesting because of its nice normalization properties. EAL is not only strongly normalizing, but its complexity is predictable, even for the untyped language. Because of that, a type theory based on EAL could even have type-level recursion without becoming inconsistent! It requires programmers to write explicit duplications with very unfamiliar restrictions. But the converse is also true: there are things Absal can do that λ-terms can’t! In any case, there seems to be no other way: see this S. To have the first 3, closed scopes must be abandoned. In a sense, it is more powerful than the λ-calculus, because applications can move arguments to outside the function’s scope. For example, it has no problems expressing abstractions whose variables occur outside of their own bodies, which makes no sense on the λ-calculus. c) 1 2 3)--------------------------------- lambda applicationλt. Yet, it is much less powerful, because of the lack of duplication. The problem here is that, after copying a λ, the “same” bound variable will exist in two different places, but its occurrence remains in a single place. That is, since a duplication allows one lambda to be in two places at the same time, then we need a way to store two variables in one place at the same time.