Chapter 6: Lambda Cube
Lambda Cube, as its name, was a cube. The vertex of cube was type system, each edge shows a change to type system as a direction, and take a type system as source to produce another type system as target.
Its starts from STLC, we have three directions can pick.
polymorphism: $\lambda 2$
Also known as system F, this allows terms to depend on types, by the following rule.
$\frac {\Gamma \vdash t : B} {\Gamma \vdash \Lambda a.t : \Pi a. B} $
For example, the following program
(define (id x) x)
would have a type:
?a -> ?a
. We can postpone evaluation to get what's?a
by unification algorithm. The output of(id k)
depends on the type ofk
.dependent type: \(\lambda Pi\)(lambda Pi or lambda P)
This system allows type depends on term, by the following rule.
$\frac {\Gamma , x : A \vdash B : *} {\Gamma \vdash (\Pi x : A . B) : *} $
A : *
saysA
is a type, this rule says: when- In context,
x
is aA
B
is a type make sense
then $\Pi x : A . B$ is a type in such context.
- In context,
type operator: $\lambda \omega$(lambda omega)
This system provides type depends on type, for example:
(List A)
,(Tree A)
.
Combine them we can get
\[F \omega\]
\[\lambda \Pi 2\]
\[\lambda \Pi\omega\]
and all of them $\lambda C$, the calculus of construction system, in following chapters dependent type usually just refer to this system rather than $\lambda \Pi$.