Substitution

\(\lambda\)-calculus Part I (Variables and Functions)

2021 James B. Wilson, Colorado State University

\[x\mapsto x+5\]

Why make a fuss about rules of substitution?

 

Watch  Why do we need \(\lambda\)-calculus?

What is a...

...variable?

...function?

  • What is c?
  • What is x?
  • Are they both variables?

 

> c = 4
> f(x) = 3*x+2
> f(c)
14
  • Variables are symbols we can replace.

  • Formulas are strings with variables.

What are the variables in \(x+5\)?

  • We may trade \(x\) with 3, so \(x\) is a variable.
  • Usually constant, we may replace \(5\) with \(\begin{bmatrix} 5 & 0 \\ 0 & 5\end{bmatrix}\). So 5, 1, -1, etc. can be variables.
  • We can even trade \(+\), e.g. to change to addition of polynomials, matrices, abelian group addition.

Variables are defined by the language

  • Arithmetic: \(x,y,a,b,c\ldots\)
  • Geometry: \(\ell, P,Q\)
  • Abstract algebra \(x,y,z,\ldots\) but also \(+,-,=,0,\ldots\)
  • Synthetic Geometry:  \(\ell, P,Q\) but also \(\bot, \|, \angle,\ldots\)
  • Category theory: \(A,B,\ldots\) but also \(\to, \Rightarrow,\prod,\coprod,\ldots\)

 

All Sorts of Variables

 

Often we insist \(x\) be replaced by "numbers" and \(+\) by binary operations on numbers.

These two variables are of different "sorts".

  • Propositional logic assumes only one sort, so a variable can be replaced by anything.
  • Predicate logic allows variables in different sorts, commonly in a hierarchy: constants \(1,5,\pi,\ldots\), relations \(+,=,\leq\), relations of relations \(\subset, \cong,\ldots\)...

Without more details, variables have no unique role in meaning.  In particular they are not always related to functions.

 

\[\sum_{i=1}^{100}\cdots, \qquad\forall x.(\cdots),\qquad x\mapsto x+3,\qquad\ldots\]

Free Variables

Variables in the language not assigned to logical connectives.

\[\begin{aligned}  a^2+b^2  = c^2 \\ x \mapsto x+c\\ n \textnormal{ is even}\end{aligned}\]

Bound Variables

Variables given syntax or semantics by a logical connective involving the variable.

\[\begin{aligned} x & \mapsto x+5\\ \forall k.&(2k\textnormal{ is even})\\ \exists x.&(x^2-1=0)\\ \sum_{i=1}^{100} & i^2\end{aligned}\]

\(\lambda\)-bound variables signal functions

  • Church copied \(\forall x.P(x)\), \(\exists x.P(x)\) and wrote \[\lambda x.P(x)\]  Today we mostly write \[x\mapsto P(x).\]
  • \(x+5\) is a formula, \[x\mapsto x+5\] is a function of the variable \(x\).  
  • Sometimes called \(\lambda\)'s, or anonymous but always known as functions.
  • Variables are symbols we can replace.

  • Formulas are strings with variables.

  • Functions are formulas with a \(\lambda\)-bound variable.

But 4 is not a function of c! 

So c is not a variable.

Rather c is a name, a definition.

x is clearly a variable:

we will replace x when evaluating f.

> c = 4
> f(x) = 3*x+2
> f(c)
14

Further Reading

  • Online guide
  • Hindley-Seldin Lambda-Calculus and Combinators, Cambridge U. Press, Chapter 1.

Substitution: lambda-calculus

By James Wilson

Substitution: lambda-calculus

Variables and functions, the start of lambda calculus

  • 320