Fundamentals
calculus “can be called the smallest universal programming language of the world” (source), because it is Turing complete. It consists of a single transformation rule and a single function definition scheme. Expressions comprise all of calculus.
The following are all valid forms of grammar:
To avoid parsing ambiguity, are always left associated:
is evaluated as:
This is the same principle that the post script notation uses.
Functions
Anonymous Functions
functions have a single identifier, , and follow this format:
This defines a new anonymous function. All functions are anonymous in calculus. Here is an example:
This is the identity function. The name after is the parameter for the body .
Function Applications
Functions in calculus are applied like so:
This calls and sets its formal parameter to .
Let’s use our example from Anonymous Functions to demonstrate:
Here, we applied the expression to the expression . When doing so, we substitute the free variable for each occurrence of the bound variable :
Left of the first equals, we have the application. Next, we have , meaning substitute for all occurrences of in the body of . Because the body is comprised entirely of , only one substitution takes place. Thus, is returned as the result of .
This format is seen in most common languages like python:
def x(x):
return x
Note, however, that in calculus, functions do not have names; all functions are anonymous. A proper (but syntactically invalid) model of this in python is:
def (x):
return x
If you would like to see a true application of s in python, see this documentation.
Names, like variables, do not have any functional purpose other than to distinguish one variable from another. For example:
Bound Versus Free Variables
All variables are local in calculus. In the identity function, the body variable is bound because it is preceded by . Thus, the expression is inexplicably and permanently tied to , because it is directly related to its own parameters.
Here, is bound, but is free:
Here, the first is bound, the first is bound, and the third is free:
Note: the second is completely independent and unrelated to .
A variable of some is free if one of the three following cases hold:
- is free in .
- is free in if the identifier and is free in .
- is free in if is free in or if it is free in
Variable is bound if one of two cases hold:
- is bound in if the identifier or if is bound in .
- is bound in if is bound in or if it is bound in .
An identifier can be free and bound in the same expression:
Initially, is free in . After the application of , becomes bound.
Equivalence
Single Renaming
-Equivalence occurs when two functions vary only by the names of the bound variables.
One equivalent expression can be converted to another with a simple renaming procedure.
The renamed cannot already exist in , neither bound nor free.
All possible single- scenarios are covered by the above two expressions. For an expression , changes all s to , thus returning . For an expression , is only valid if does not equal . That is the case here, so nothing is renamed and we are returned the original expression .
Distributed Renaming
When working with multiple expressions, the renaming procedure is distributed to both:
Simply put, is renamed to , and because is currently unknown, we simply note the change along with .
Substitutions
In calculus, functions do not have names. The whole function is written when it is required, but this process can be simplified with capital letters, numbers, and symbols as synonyms.
As an example, the identity function can be represented as , and so
is the identity function applied to itself.