Path: blob/main/course-contents/notes-formal-02.md
908 views
------\newcommand{\type}{\ \text{type}} \newcommand{\id}{\operatorname{id}} \newcommand{\prd}[1]{\Pi_{(#1)}} \newcommand{\comp}{\operatorname{comp}}
A derivation about renaming variables
We are going to derive the inference rule
which essentially says "we an replace variable by variable ".
The derivation uses substitution, weakening and the generic element:
ParseError: KaTeX parse error: Undefined control sequence: \type at position 34: …Gamma \vdash A \̲t̲y̲p̲e̲}{\Gamma,x':A \…Dependent function types
Let be a section of a family over in context . Thus
Two points of view here:
can think of as a "program" that takes as input and produces a term .
or, can view as just a "choice of element" in each for . i.e. is a dependent function
The type of all such dependent functions is called the dependent function type, written:
Part of what we must formulate in our type theory are inference rules guaranteeing that these types are well-formed. For this we need various sorts of rules:
formation rule specifying how we may form dependent function types
introduction rule specifying how to introduce new terms of dependent function types
elimination rule specifying how to use arbitrary terms of dependent function types
computation rules specifying how introduction rules and elimination rules interact
For the first three of these rules, we also need rules asserting that the constructions play nice with judgmental equality.
-formation rule
ParseError: KaTeX parse error: No such environment: prooftree at position 7: \begin{̲p̲r̲o̲o̲f̲t̲r̲e̲e̲}̲ \AxiomC{$\Ga…Also need the congruence rule:
ParseError: KaTeX parse error: No such environment: prooftree at position 7: \begin{̲p̲r̲o̲o̲f̲t̲r̲e̲e̲}̲ \AxiomC{$\Ga…-introduction rule
This rule specifies that we may "construct" dependent functions provided that we have constructed a section:
ParseError: KaTeX parse error: No such environment: prooftree at position 7: \begin{̲p̲r̲o̲o̲f̲t̲r̲e̲e̲}̲ \AxiomC{$\Ga…We use the notation for the "dependent function". This introduction rule is also called the -abstraction rule.
Again, we need to know that -abstraction respects judgmental equality:
ParseError: KaTeX parse error: No such environment: prooftree at position 7: \begin{̲p̲r̲o̲o̲f̲t̲r̲e̲e̲}̲ \AxiomC{$\Ga…-elimination rule
The way to use a dependent function is to evaluate it at any an element of the domain type. The -elimination rule is thus sometimes called the evaluation rule.
ParseError: KaTeX parse error: No such environment: prooftree at position 7: \begin{̲p̲r̲o̲o̲f̲t̲r̲e̲e̲}̲ \AxiomC{$\Ga…(Note that in practice -- e.g. in type-theory based programming languages Lean, Haskell, ML, ... -- we write "" for "").
-computation rule
We need to postulate rules controlling our functions.
The -rule stipulates that behaves in the way that we understand the function .
ParseError: KaTeX parse error: No such environment: prooftree at position 7: \begin{̲p̲r̲o̲o̲f̲t̲r̲e̲e̲}̲ \AxiomC{$\Ga…The second rule -- known as the -rule -- postulates that the only elements of are dependent functions.
ParseError: KaTeX parse error: No such environment: prooftree at position 7: \begin{̲p̲r̲o̲o̲f̲t̲r̲e̲e̲}̲ \AxiomC{$\Ga…Ordinary function types
We obtain ordinary functions as a special case of dependent functions. Let's describe the setting.
Suppose that and are types in context . We can view as the "constant family" over . From this point of view, we obtain the type of functions as i.e.
Here is the formal derivation:
ParseError: KaTeX parse error: No such environment: prooftree at position 7: \begin{̲p̲r̲o̲o̲f̲t̲r̲e̲e̲}̲ \AxiomC{$\Ga…And here is the formal declaration of the "new notation":
ParseError: KaTeX parse error: No such environment: prooftree at position 7: \begin{̲p̲r̲o̲o̲f̲t̲r̲e̲e̲}̲ \AxiomC{$\Ga…Construction of the identity function
Given a type in context , let's construct the identity function ParseError: KaTeX parse error: Undefined control sequence: \id at position 1: \̲i̲d̲ ̲= \id_A:A \to A using the generic term:
ParseError: KaTeX parse error: No such environment: prooftree at position 7: \begin{̲p̲r̲o̲o̲f̲t̲r̲e̲e̲}̲ \AxiomC{$\Gamm…Construction of the composition of two functions
Given types , , and terms , , we can form .
In fact, write ParseError: KaTeX parse error: Undefined control sequence: \comp at position 1: \̲c̲o̲m̲p̲(g,f) for . Then ParseError: KaTeX parse error: Undefined control sequence: \comp at position 1: \̲c̲o̲m̲p̲ is in some sense a function of two arguments and . Let's pause to discuss functions of multiple arguments.
Consider a function For an argument , so is again a function. For , we can write for the value of at .
Now we see that the type of the function ParseError: KaTeX parse error: Undefined control sequence: \comp at position 1: \̲c̲o̲m̲p̲ is Thus for , we have ParseError: KaTeX parse error: Undefined control sequence: \comp at position 1: \̲c̲o̲m̲p̲(g):(A \to B) \…
We are going to define ParseError: KaTeX parse error: Undefined control sequence: \comp at position 1: \̲c̲o̲m̲p̲ by the rule ParseError: KaTeX parse error: Undefined control sequence: \comp at position 1: \̲c̲o̲m̲p̲ ̲= \lambda g.\la….
Before we give the derivation, we need a preliminary result using the generic element; we'll refer to this as below:
ParseError: KaTeX parse error: No such environment: prooftree at position 7: \begin{̲p̲r̲o̲o̲f̲t̲r̲e̲e̲}̲ \AxiomC{$\Ga…Now here is the full derivation:
ParseError: KaTeX parse error: No such environment: prooftree at position 7: \begin{̲p̲r̲o̲o̲f̲t̲r̲e̲e̲}̲ \AxiomC{$\Ga…One can now derive a number of properties of function composition:
associativity, i.e. ParseError: KaTeX parse error: No such environment: prooftree at position 7: \begin{̲p̲r̲o̲o̲f̲t̲r̲e̲e̲}̲ \AxiomC{$\Ga…
left and right unit laws ParseError: KaTeX parse error: No such environment: prooftree at position 7: \begin{̲p̲r̲o̲o̲f̲t̲r̲e̲e̲}̲ \AxiomC{$\Ga…
ParseError: KaTeX parse error: No such environment: prooftree at position 7: \begin{̲p̲r̲o̲o̲f̲t̲r̲e̲e̲}̲ \AxiomC{$\…
Bibliography
::: {.refs} :::