This post is divided in two parts, viz. Definitions and Question.
Definitons
The following definitions are adapted from Lecture notes on the Curry-Howard Isomorphism (by Sorensen and Urzyczyn), pp. 2-5.
Definition. (Pre-terms) Let $V$ be an infinite set (of variables). The set $\Lambda^-$ of pre-terms is given by the following grammar:
$\Lambda^- ::= V|(\Lambda^- \Lambda^-)|(\lambda V\Lambda^-)$
Definition. (Substitution on pre-terms) For $M,N\in\Lambda^-$ and $x\in V$, $M[x:=N]$ is defined as follows (where $x\neq y$):
- $x[x:=N] = N$
- $y[x:=N] = y$
- $(PQ)[x:=N] = P[x:=N]Q[x:=N]$
- $(\lambda x P)[x:=N] = \lambda x P$
- $(\lambda y P)[x:=N] = \lambda y P[x:=N]\quad$ if $y\notin FV(N)$ or $x\notin FV(P)$
- $(\lambda y P)[x:=N] = \lambda z P[y:=z][x:=N]\quad$ if $y\in FV(N)$ and $x\in FV(P)$; $z$ is a fresh variable.
Definition. ($\alpha$-equivalence) Let $=_\alpha \subseteq (\Lambda^-)^2$ be the smallest relation such that:
- $P=_\alpha P\quad$ for all $P$
- $\lambda x P =_\alpha \lambda y P[x:=y]\quad$ if $y\notin FV(P)$
and closed under the rules:
if $P =_\alpha P'$ then:
- $\forall x\in V: \lambda x P =_\alpha \lambda x P'\quad$
- $\forall Z\in\Lambda^-: PZ =_\alpha P'Z$
- $\forall Z\in\Lambda^-: ZP =_\alpha ZP'$
$P =_\alpha P'\quad$ if $P'=_\alpha P$
- $P =_\alpha P''\quad$ if $P =_\alpha P'$ and $P'=_\alpha P''$
Definition. ($\lambda$-terms) Define the set of $\lambda$-terms by $\Lambda = \Lambda^-/=_\alpha$, i.e. $\Lambda = \{[M]_{=_\alpha} : M\in\Lambda^-\}$.
Definition. (Substitution on $\lambda$-terms) For $M,N\in\Lambda$ and $x\in V$, $M\{x:=N\}$ is defined as follows:
- $x[x:=N] = N$
- $y[x:=N] = y\quad$ if $x\neq y$
- $(PQ)[x:=N] = P[x:=N]Q[x:=N]$
- $(\lambda yP)[x:=N] = \lambda y P[x:=N]\quad$ if $x\neq y$, where $y\notin FV(N)$
Question
My question concerns just the last definition -- substitution on $\lambda$-terms.
First, the definition presents the notation $M\{x:=N\}$ but then $M[x:=N]$ is used. I believe this is a typo, but I'm not absolutely sure.
Second, is this a definition by induction? I'm not familiar with definitions over equivalence classes, but I recall to have heard that we can define functions over them as if by induction over the terms.
Third, and perhaps most importantly, how to make sense of this definition? For instance, is it capture-avoiding as its pre-term counterpart?
I tried to replace $[x:=N]$ with $\{x:=N\}$ and fill in all the $[\cdot]_{=_\alpha}$ in the definition. Is the following translation even close to what is really happening?
- $[x]_{=_\alpha}\{x:=N\} = [x]_{=_\alpha}$
- $[y]_{=_\alpha}\{x:=N\} = N\quad$ if $x\neq y$
- $[(PQ)]_{=_\alpha}\{x:=N\} = [P]_{=_\alpha}\{x:=N\}[Q]_{=_\alpha}\{x:=N\}$
- $[(\lambda yP)]_{=_\alpha}\{x:=N\} = [\lambda y [P]_{=_\alpha}\{x:=N\}]_{=_\alpha}\quad$ if $x\neq y$, where $y\notin FV(N)$
Thank you for reading this long (sorry!) post.