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

前端 未结 6 1985
情深已故
情深已故 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条回答
  •  萌比男神i
    2021-01-30 11:23

    Good question. The name could originate from Martin-Löf who used the term "Cartesian product of a family of sets" for the pi type. See the following notes, for example: http://www.cs.cmu.edu/afs/cs/Web/People/crary/819-f09/Martin-Lof80.pdf The point is while a pi type is in principle akin to an exponential, you can always see an exponential as an n-ary product where n is the exponent. More concretely, the non-dependent function A -> B can be seen as an exponential type B^A or an infinite product Pi_{a in A} B = B x B x B x ... x B (A times). A dependent product is in this sense a potentially infinite product Pi_{a in A} B(a) = B(a_1) x B(a_2) x ... x B (a_n) (once for every a_i in A).

    The reasoning for dependent sum could be similar, as you can see a product as an n-ary sum where n is one of the factors of the product.

提交回复
热议问题