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

前端 未结 6 1933
情深已故
情深已故 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:09

    First, see what a co-product is.

    A co-product is a terminal object A for all objects B_i such that for all arrows B_i -> X there is an arrow B_i -> A, and a unique A -> X such that the corresponding triangles commute.

    You can view this as a Haskell data type A with B_i -> A being a bunch of constructors with a single argument of type B_i. It is clear then that for every B_i -> X it is possible to supply an arrow from A -> X such that through pattern-matching you could apply that arrow to B_i to get X.

    The important connection to sigma types is that the index i in B_i can be of any type, not just a type of natural numbers.

    The important difference from the answers above is that it does not have to have a B_i for every value i of that type: once you've defined B_i ∀ i, you have a total function.

    The difference between Π and Σ, as may be seen from Petr Pudlak's answer, is that for Σ some of the values B_i in the tuple may be missing - for some i there may be no corresponding B_i.

    The other clear difference between Π and Σ is that Π characterizes a product of B_i by providing i-th projection from the product Π to each B_i (this is what the function i -> B_i means), but Σ provides the arrows the other way around - it provides the i-th injection from B_i into Σ.

提交回复
热议问题