Dependent Types: How is the dependent pair type analogous to a disjoint union?

前端 未结 6 1928
情深已故
情深已故 2021-01-30 10:38

I\'ve been studying dependent types and I understand the following:

  1. Why universal quantification is represented as a dependent function type. ∀(x:A).B(x)
6条回答
  •  说谎
    说谎 (楼主)
    2021-01-30 11:22

    This is probably redundant with the other answers at this point, but here is the core of the issue:

    How is it that a pair type (which is normally a product type) is analogous to a disjoint union (which is a sum type)? This has always confused me.

    But what is a product but a sum of equal numbers? e.g. 4 × 3 = 3 + 3 + 3 + 3.

    The same relationship holds for types, or sets, or similar things. In fact, the nonnegative integers are just the decategorification of finite sets. The definitions of addition and multiplication on numbers are chosen so that the cardinality of a disjoint union of sets is the sum of the cardinalities of the sets, and the cardinality of a product of sets is equal to the product of the cardinalities of the sets. In fact, if you substitute "set" with "herd of sheep", this is probably how arithmetic was invented.

提交回复
热议问题