forked from rafoo/dklib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dk_type.dk
66 lines (51 loc) · 1.52 KB
/
dk_type.dk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#NAME dk_type.
(; Basics type constructs. ;)
(; Cartesian product ;)
Prod : cc.uT -> cc.uT -> Type.
prod : cc.uT -> cc.uT -> cc.uT.
[X,Y] cc.eT (prod X Y) --> Prod X Y.
cpl : A : cc.uT ->
B : cc.uT ->
cc.eT A ->
cc.eT B ->
Prod A B.
def fst : A : cc.uT -> B : cc.uT -> Prod A B -> cc.eT A.
def snd : A : cc.uT -> B : cc.uT -> Prod A B -> cc.eT B.
[a] fst _ _ (cpl _ _ a _) --> a.
[b] snd _ _ (cpl _ _ _ b) --> b.
(; Dependent product ;)
Sigma : A : cc.uT -> (cc.eT A -> cc.uT) -> Type.
sigma : A : cc.uT -> (cc.eT A -> cc.uT) -> cc.uT.
[X,Y] cc.eT (sigma X Y) --> Sigma X Y.
dcpl : A : cc.uT ->
B : (cc.eT A -> cc.uT) ->
a : cc.eT A ->
cc.eT (B a) ->
Sigma A B.
def dfst : A : cc.uT ->
B : (cc.eT A -> cc.uT) ->
Sigma A B ->
cc.eT A.
def dsnd : A : cc.uT ->
B : (cc.eT A -> cc.uT) ->
t : Sigma A B ->
cc.eT (B (dfst A B t)).
[a] dfst _ _ (dcpl _ _ a _) --> a.
[b] dsnd _ _ (dcpl _ _ _ b) --> b.
(; Sum ;)
Sum : cc.uT -> cc.uT -> Type.
sum : cc.uT -> cc.uT -> cc.uT.
[X,Y] cc.eT (sum X Y) --> Sum X Y.
left (A : cc.uT) (B : cc.uT) : cc.eT A -> Sum A B.
right (A : cc.uT) (B : cc.uT) : cc.eT B -> Sum A B.
def sum_elim : A : cc.uT ->
B : cc.uT ->
C : cc.uT ->
Sum A B ->
(cc.eT A -> cc.eT C) ->
(cc.eT B -> cc.eT C) ->
cc.eT C.
[a,f]
sum_elim _ _ _ (left _ _ a) f _ --> f a.
[b,g]
sum_elim _ _ _ (right _ _ b) _ g --> g b.