3
open PolyDepPrelude using
4
( Bool; true; false; _&&_
9
; Datoid; datoid; pElem
14
data Sigma (A : Set)(B : A -> Set) : Set where
15
si : (a : A) -> (b : B a) -> Sigma A B
17
Eq : Set -> Set -> Set
18
Eq a b = a -> b -> Bool
20
eqEmpty : Eq Absurd Absurd
25
eqUnit unit unit = true
27
eqPair : {A1 A2 B1 B2 : Set} ->
30
Eq (And A1 B1) (And A2 B2)
31
eqPair ea eb (pair a b) (pair a' b') = ea a a' && eb b b'
34
{B1 B2 : pElem D -> Set}
35
(ifTrue : (b : pElem D) -> B1 b -> B2 b -> Bool)
40
(cast : True e -> B1 a -> B1 b)
42
caseOn D ifTrue a b pa pb (false) cast = false
43
caseOn D ifTrue a b pa pb (true) cast = ifTrue b (cast unit pa) pb
45
eqEither : {A1 A2 B1 B2 : Set}
46
(eq1 : A1 -> B1 -> Bool)
47
(eq2 : A2 -> B2 -> Bool)
48
-> Either A1 A2 -> Either B1 B2 -> Bool
49
eqEither eq1 eq2 (left a1) (left b1) = eq1 a1 b1
50
eqEither eq1 eq2 (right a2) (right b2) = eq2 a2 b2
51
eqEither eq1 eq2 _ _ = false
57
(inl x0) -> eq1 x' x0;
58
(inr y') -> false@_;};
62
(inr y0) -> eq2 y' y0;};}
67
(|B1 |B2 : pElem D -> Set)
68
(ifTrue : (b : pElem D) -> Eq (B1 b) (B2 b))
69
(x : Sigma pElem D B1)
70
(y : Sigma pElem D B2)
76
caseOn D ifTrue a b pa pb (D.eq a b) (D.subst B1);};}
78
eqSigma (D : Datoid)(|B1 : (a : pElem D) -> Set)(|B2 : (a : pElem D) -> Set)
79
: ((a : pElem D) -> Eq (B1 a) (B2 a)) ->
80
Eq (Sigma pElem D B1) (Sigma pElem D B2)
83
eqSigmaLocalLet (D : Datoid)
84
(|B1 |B2 : pElem D -> Set)
85
(ifTrue : (b : pElem D) -> Eq (B1 b) (B2 b))
86
(x : Sigma pElem D B1)
87
(y : Sigma pElem D B2)
93
let caseOn (e : Bool)(cast : True e -> B1 a -> B1 b) : Bool
96
(true) -> ifTrue b (cast tt@_ pa) pb;}
97
in caseOn (D.eq a b) (D.subst B1);};}
101
(|B1 |B2 : (a : pElem D) -> Set)
102
: ((a : pElem D) -> Eq (B1 a) (B2 a)) ->
103
Eq (Sum pElem D B1) (Sum pElem D B2)
104
= \(e : (a : pElem D) -> Eq (B1 a) (B2 a)) ->
105
\(p1 : Sum pElem D B1) ->
106
\(p2 : Sum pElem D B2) ->
107
caseOn D e p1.fst p2.fst p1.snd p2.snd (D.eq p1.fst p2.fst)
112
{B1 B2 : (a : pElem D) -> Set}
113
-> ((a : pElem D) -> Eq (B1 a) (B2 a)) ->
114
Eq (Sum pElem D B1) (Sum pElem D B2)
116
caseOn D e p1.fst p2.fst p1.snd p2.snd (D.eq p1.fst p2.fst)