Dependent types I › Binary products [01FS]

There is a bit of a terminological snafu here, if we consider the binary product A\times B of types A,B~\mathit {type} which ought to consist of pairs of an element of A with an element of B. We have seen already that the binary product A\times B can be decribed by a special case of a sum:

A\times B :\equiv {\mathop {\mathchoice {\textstyle \sum }{\textstyle \sum }{\scriptstyle \sum }{\scriptscriptstyle \sum } }_{(x:A)}}{B}

This is confusing (if you don’t think about it!) because products and sums are supposed to be different. But it really does make sense, because the product A\times B is indeed the sum of A-many copies of B. So why is it called a (binary) product? Because it is the product of the family x:\mathsf {bool} \vdash \mathsf {If}(x;A;B) that we may form using large elimination. A dependent function f: {\mathop {\mathchoice {\textstyle \prod }{\textstyle \prod }{\scriptstyle \prod }{\scriptscriptstyle \prod } }_{(x:\mathsf {bool})}} \mathsf {If}(x;A;B) must assign values to the two booleans \mathsf {true} and \mathsf {false}. So a dependent function like f could consist of an element f~\mathsf {true}:\mathsf {If}(\mathsf {true};A;B) \equiv A and an element f~\mathsf {false}:\mathsf {If}(\mathsf {false};A;B)\equiv B\text {.}

It is in practice easier to work with the definition of A\times B in terms of the sum, because this representation satisfies a judgemental extensionality law that is not enjoyed by the version defined using the booleans. Nonetheless, once we learn to say what it means for two types to be mathematically equivalent, the two repressentations will indeed be equivalent.