Motivation and Introduction

Is there a fuctional theory where functions and their arguments are at the same level?

Example

It looks like functions are somewhat larger than its arguments…

  • calculus to CS is like algebra to mathematics
  • It inspired funcional pragramming: LISP, ML, Haskell…

At the core of calculus is a way to define annonymous functions.

Example

is represented as . is the argument, and is the function. Note that here it is just an example. There is actually no notation like in cal. In Python, we can write cal as:

lambda x: x*x

Proof theory notation

  • Things above the line are premises (what you know or assume)
  • Thing below the line is conclusion (what you are now allowed to claim)
  • Every rule has a name
  • When there is no side condition, it is called an axiom.

Term

cal is basically studying terms. The set of terms is defined by:

  • A sequence of applications associates to the left. So  means 
  • The body of a lambda abstraction (the part after the dot) extends as far to the right as possible. So  means  not 
  • Nested abstractions associate to the right and can be collected under a single  sign. So  means
    • It can be seen as a function that receive multiple inputs

Free and Bound Variable

Free Variable FV(s)

  • A variable is free in a term if
  • A variable is bound if it is in a subterm of
  • A term is closed if it has no free variable. They are also called as combinators
  • A term can simutaneously be free and bound

What does "bound" means?

Basically, that a variable that is bound means it is “captured” by a , so it will be replaced when you provide an input. Think of it as a local variable in coding, which only has meaning inside the specific block.

Alpha Conversion

Alpha convertible

and are converible if one can derive the other by simply renaming bound variables, written as .

  • Bound variables’ name is meaningless, since it will be replaced when given an input.

Beta Conversion

Application in cal means substitution, which is basically the conversion.

Here is not a term, but it represent a term that is obtained by the substitution.

  • Substitution should only be applied to free occurences of in
  • Avoid unintended capture of free variables! It can be avoided by simply rename the bound variables.

Example

. What is the result of ? is not correct. Rename into first, and we got

Equation Theory

A formal proof of an equation in theory is a proof tree constructed by rules.

Example

\begin{prooftree} \AXC{} \LeftLabel{($\beta$)} \UIC{$(\lambda xy.x)p = \lambda y.p$} \AXC{} \LeftLabel{(refl)} \UIC{$q=q$} \LeftLabel{(app)} \BIC{$(\lambda xy.x)pq = (\lambda y.p)q$} \AXC{} \LeftLabel{($\beta$)} \UIC{$(\lambda y.p)q = p$} \LeftLabel{(trans)} \BIC{$(\lambda xy.x)pq = p$} \LeftLabel{(sym)} \UIC{$p = (\lambda xy.x)pq$} \end{prooftree}

is the proof that

The difference between and theory is the additional eta rule:

  • It says that a function that take as input and apply to it is just itself
  • Or it says that if two functions return same output when given same input, they are the same function

Fixed Point

Fixed Point

is a fixed point of if

First Recursion Theorem

Let be a term, then there is a term that is the fixed-point of . Moreover, it can be computed in cal using fixed-point combinators.

Proof

There are many fixed-point combinators, an example is Curry’s ‘paradoxical’ Y combinator: