haskell - Dependent Types: How is the dependent pair type analogous to a disjoint union? -
haskell - Dependent Types: How is the dependent pair type analogous to a disjoint union? -
i've been studying dependent types , understand following:
why universal quantification represented dependent function type.∀(x:a).b(x)
means “for x
of type a
there value of type b(x)
”. hence it's represented function when given any value x
of type a
returns value of type b(x)
. why existential quantification represented dependent pair type. ∃(x:a).b(x)
means “there exists x
of type a
there value of type b(x)
”. hence it's represented pair first element a particular value x
of type a
, sec element value of type b(x)
. aside: it's interesting note universal quantification used material implication while existential quantification used logical conjunction.
anyway, wikipedia article on dependent types states that:
the opposite of dependent type dependent pair type, dependent sum type or sigma-type. analogous coproduct or disjoint union.
how pair type (which product type) analogous disjoint union (which sum type)? has confused me.
in addition, how dependent function type analogous product type?
the confusion arises using similar terminology construction of Σ type , how values like.
a value of Σ(x:a) b(x) pair (a,b) a∈a , b∈b(a). type of sec element depends on value of first one.
if @ structure of Σ(x:a) b(x), it's disjoint union (coproduct) of b(x) possible x∈a.
if b(x) constant (independent of x) Σ(x:a) b |a| copies of b, a⨯b (a product of 2 types).
if @ structure of Π(x:a) b(x), it's product of b(x) possible x∈a. values viewed |a|-tuples a-th component of type b(a).
if b(x) constant (independent of x) Π(x:a) b a→b - functions a b, bᴬ (b a) using set-theory notation - product of |a| copies of b.
so Σ(x∈a) b(x) |a|-ary coproduct indexed elements of a, while Π(x∈a) b(x) |a|-ary product indexed elements of a.
haskell agda dependent-type idris curry-howard
Comments
Post a Comment