Type theory MOC
Type of booleans
The type of booleans ๐ has two canonical terms: true and false.
In (non-dependent) programming and classical mathematics, predicates are usually thought of as having values in ๐.
0 == 1 # False
1 == 1 # True
This is justified by the fact that, in the category ๐ฒ๐พ๐ of classical mathematics,1 the corresponding set ๐ is a Subobject classifier.
In constructive contexts where the Law of excluded middle is not assumed, however, this is not the case (we instead need a Universe of propositions ฮฉ),
so the role played by ๐ is quite different.
Standard presentation
Here we give a formal presentation of ๐ in the cartesian calculus of substitutions, following Principles of dependent type theory. #m/def/type/ind
The formation rule is
ฮโขฮโข๐(๐)ฮโข๐พ:ฮฮโข๐[๐พ]=๐(๐-N).
๐ is an inductive type with two constructors for โtrueโ and โfalseโ
ฮโขฮโข๐ญ๐ซ๐ฎ๐:๐(๐It)ฮโขฮโข๐๐๐ฅ๐ฌ๐:๐(๐If)
ฮโข๐พ:ฮฮโข๐ญ๐ซ๐ฎ๐[๐พ]=๐ญ๐ซ๐ฎ๐:๐(๐It-N)ฮโข๐พ:ฮฮโข๐๐๐ฅ๐ฌ๐[๐พ]=๐๐๐ฅ๐ฌ๐:๐(๐If-N)
Thus the induction principle gives the elimination rule
ฮ.๐โข๐ดฮโข๐t:๐ด[๐ข๐.๐ญ๐ซ๐ฎ๐]ฮโข๐f:๐ด[๐ข๐.๐๐๐ฅ๐ฌ๐]ฮโข๐:๐ฮโข๐ข๐(๐,๐t,๐f):๐ด[๐ข๐.๐](๐E)
ฮโข๐พ:ฮฮ.๐โข๐ดฮโข๐t:๐ด[๐ข๐.๐ญ๐ซ๐ฎ๐]ฮโข๐f:๐ด[๐ข๐.๐๐๐ฅ๐ฌ๐]ฮโข๐:๐ฮโข๐ข๐(๐,๐t,๐f)[๐พ]=๐ข๐(๐[๐พ],๐t[๐พ],๐f[๐พ]):๐ด[๐พ.๐[๐พ]](๐E-N)
and ๐ฝ-computation rules
ฮ.๐โข๐ดฮโข๐t:๐ด[๐ข๐.๐ญ๐ซ๐ฎ๐]ฮโข๐f:๐ด[๐ข๐].๐๐๐ฅ๐ฌ๐ฮโข๐ข๐(๐ญ๐ซ๐ฎ๐,๐t,๐f)=๐t:๐ด[๐ข๐.๐ญ๐ซ๐ฎ๐](๐๐ฝt)
ฮ.๐โข๐ดฮโข๐t:๐ด[๐ข๐.๐ญ๐ซ๐ฎ๐]ฮโข๐f:๐ด[๐ข๐].๐๐๐ฅ๐ฌ๐ฮโข๐ข๐(๐๐๐ฅ๐ฌ๐,๐t,๐f)=๐f:๐ด[๐ข๐.๐๐๐ฅ๐ฌ๐](๐๐ฝf)
We omit an ๐-unicity rule in the standard presentation, since it can be shown given an Extensional equality type.
Agda
1Lab
data Bool : Type where
true false : Bool
Internalizing judgemental structure
In terms of Internalizing judgemental structure, we have for any context ฮ
๐ฮโTyโก(ฮ);๐ญ๐ซ๐ฎ๐ฮ,๐๐๐ฅ๐ฌ๐ฮโTmโก(ฮ,๐)
and for any dependent type ฮ.๐ โข๐ด,
((๐ข๐.๐ญ๐ซ๐ฎ๐)โ,(๐ข๐.๐๐๐ฅ๐ฌ๐)โ):Tmโก(ฮ.๐,๐ด)โ
Tmโก(ฮ,๐ด[๐ข๐.๐ญ๐ซ๐ฎ๐])รTmโก(ฮ,๐ด[๐ข๐.๐๐๐ฅ๐ฌ๐]),
is a bijection natural in ฮ, where we have used the pullback meta-function ^PB3 and the universal property of the product in the metatheory.
#state/tidy | #lang/en | #SemBr