Dependent types I › The boolean type [01D5]
- August 11, 2025
- Jon Sterling
Rule Formation [01DQ]
- August 11, 2025
- Jon Sterling
The formation rule for the booleans states that we may assert \mathsf {bool}~\mathit {type}:
\frac {}{\mathsf {bool}~\mathit {type}}Rule Introduction [01DR]
- August 11, 2025
- Jon Sterling
We have two introduction rules; one states that we may assert \mathsf {true}:\mathsf {bool} and the other states that we may assert \mathsf {false}:\mathsf {bool}.
\frac {}{\mathsf {true}:\mathsf {bool}} \qquad \frac {}{\mathsf {false}:\mathsf {bool}}Rule Elimination [01DS]
- August 11, 2025
- Jon Sterling
The elimination rule is where things start to get interesting; this will be a dependently typed version of the classical if-expression. Given a family of types x:\mathsf {bool}\vdash C[x]~\mathit {type} and elements u:\mathsf {bool} and v:C[\mathsf {true}] and w:C[\mathsf {false}], we may assert \mathsf {if}_{x\mathpunct {.}C[x]}(u;v;w):C[u].
Rule Computation [01DT]
- August 11, 2025
- Jon Sterling
The computation rules corresponding to the above elimination rule correspond to the way that when an if-expression is applied to a concrete boolean (i.e. true or false) the whole expression reduces to the corresponding branch.
- Given x:\mathsf {bool}\vdash C[x]~\mathit {type} and u:C[\mathsf {true}] and v:C[\mathsf {false}], we may assert \mathsf {if}_{x\mathpunct {.}C[x]}(\mathsf {true};v;w)\equiv v:C[\mathsf {true}]. \frac { x:\mathsf {bool}\vdash C[x]~\mathit {type} \quad v:C[\mathsf {true}] \quad w:C[\mathsf {false}] }{ \mathsf {if}_{x\mathpunct {.}C[x]}(\mathsf {true};v;w)\equiv v:C[\mathsf {true}] }
- Given x:\mathsf {bool}\vdash C[x]~\mathit {type} and u:C[\mathsf {true}] and v:C[\mathsf {false}], we may assert \mathsf {if}_{x\mathpunct {.}C[x]}(\mathsf {false};v;w)\equiv w:C[\mathsf {false}]. \frac { x:\mathsf {bool}\vdash C[x]~\mathit {type} \quad v:C[\mathsf {true}] \quad w:C[\mathsf {false}] }{ \mathsf {if}_{x\mathpunct {.}C[x]}(\mathsf {false};v;w)\equiv w:C[\mathsf {false}] }
We could include a uniqueness rule on the elimination side, but this is typically omitted.
Aside Type-level if-expressions [01DB]
- August 11, 2025
- Jon Sterling
This is all well and good, but how can we get an actually interesting dependent type x:\mathsf {bool}\vdash C[x]~\mathit {type}? Later on we will introduce type formers that will readily provide examples, but to get an idea of what is possible, we consider the optional large elimination rule with its corresponding computation rules:
- Given A,B~\mathit {type} and u:\mathsf {bool} we may assert \mathsf {If}(u;A;B)~\mathit {type}. \frac { A,B~\mathit {type} \quad u:\mathsf {bool} }{ \mathsf {If}(u;A;B)~\mathit {type} }
- Given A,B~\mathit {type}, we may assert \mathsf {If}(\mathsf {true};A;B)\equiv A~\mathit {type}. \frac { A,B~\mathit {type} }{ \mathsf {If}(\mathsf {true};A;B)\equiv A~\mathit {type} }
- Given A,B~\mathit {type}, we may assert \mathsf {If}(\mathsf {false};A;B)\equiv B~\mathit {type}. \frac { A,B~\mathit {type} }{ \mathsf {If}(\mathsf {true};A;B)\equiv B~\mathit {type} }
With the above it is therefore possible to define types like \mathsf {If}(u;\mathsf {unit};\mathsf {empty}) whose behaviour differs wildly depending on the value of u. Once we introduce universes (types whose elements describe types), we will be able to construct examples like this without using the large elimination.