-
Notifications
You must be signed in to change notification settings - Fork 18
/
Exe6.agda
135 lines (106 loc) · 4.25 KB
/
Exe6.agda
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
module Exe6 where
open import IR public
mutual
EQ : (X Y : TU) -> TU * (<! X !>TU -> <! Y !>TU -> TU)
_<->_ : TU -> TU -> TU
X <-> Y = fst (EQ X Y)
Eq : (X : TU)(x : <! X !>TU) -> (Y : TU)(y : <! Y !>TU) -> TU
Eq X x Y y = snd (EQ X Y) x y
EQ Zero' Zero' = One' , \ _ _ -> One'
EQ One' One' = One' , \ _ _ -> One'
EQ Two' Two' = One' , \
{ tt tt -> One'
; ff ff -> One'
; _ _ -> Zero'
}
EQ (Sg' S T) (Sg' S' T')
= ( Sg' (S <-> S') \ _ ->
Pi' S \ s -> Pi' S' \ s' -> Pi' (Eq S s S' s') \ _ ->
T s <-> T' s' )
, \ { (s , t) (s' , t') ->
Sg' (Eq S s S' s') \ _ -> Eq (T s) t (T' s') t' }
EQ (Pi' S T) (Pi' S' T')
= ( Sg' (S' <-> S) \ _ ->
Pi' S' \ s' -> Pi' S \ s -> Pi' (Eq S' s' S s) \ _ ->
T s <-> T' s' )
, \ { f f' ->
Pi' S \ s -> Pi' S' \ s' -> Pi' (Eq S s S' s') \ _ ->
Eq (T s) (f s) (T' s') (f' s') }
EQ (Tree' I F i) (Tree' I' F' i')
= ( Sg' (I <-> I') \ _ -> Sg' (Eq I i I' i') \ _ ->
Pi' I \ i -> Pi' I' \ i' -> Pi' (Eq I i I' i') \ _ ->
let (S , K) = F i ; S' , K' = F' i'
in Sg' (S <-> S') \ _ ->
Pi' S \ s -> Pi' S' \ s' -> Pi' (Eq S s S' s') \ _ ->
let (P , r) = K s ; (P' , r') = K' s'
in Sg' (P' <-> P) \ _ ->
Pi' P' \ p' -> Pi' P \ p -> Pi' (Eq P' p' P p) \ _ ->
Eq I (r p) I' (r' p') )
, teq i i' where
teq : (i : <! I !>TU) -> (i' : <! I' !>TU) ->
<! Tree' I F i !>TU -> <! Tree' I' F' i' !>TU -> TU
teq i i' <$ s , k $> <$ s' , k' $>
= let (S , K) = F i ; (S' , K') = F' i'
(P , r) = K s ; (P' , r') = K' s'
in Sg' (Eq S s S' s') \ _ ->
Pi' P \ p -> Pi' P' \ p' -> Pi' (Eq P p P' p') \ _ ->
teq (r p) (r' p') (k p) (k' p')
EQ _ _ = Zero' , \ _ _ -> One'
{- {exe}[define |coe|, postulate |coh|]
Implement |coe|rcion, assuming |coh|erence. -}
coe : (X Y : TU) -> <! X <-> Y !>TU -> <! X !>TU -> <! Y !>TU
postulate
coh : (X Y : TU)(Q : <! X <-> Y !>TU)(x : <! X !>TU) -> <! Eq X x Y (coe X Y Q x) !>TU
coe X Y Q x = {!!}
{- {exe}[explore failing to prove |reflTU|]
Try proving -}
reflTU : (X : TU)(x : <! X !>TU) -> <! Eq X x X x !>TU
reflTU X x = {!!}
------------------------------------------------------------------------
data Sort : Set where set prop : Sort
IsSet : Sort -> Set
IsSet set = One
IsSet prop = Zero
mutual
data PU (u : Sort) : Set where
Zero' One' : PU u
Two' : {_ : IsSet u} -> PU u
Sg' : (S : PU u)(T : <! S !>PU -> PU u) -> PU u
Pi' : (S : PU set)(T : <! S !>PU -> PU u) -> PU u
Tree' : {_ : IsSet u}
(I : PU set)
(F : <! I !>PU -> Sg (PU set) \ S ->
<! S !>PU -> Sg (PU set) \ P ->
<! P !>PU -> <! I !>PU )
(i : <! I !>PU) -> PU u
Prf' : {_ : IsSet u} -> PU prop -> PU u
<!_!>PU : forall {u} -> PU u -> Set
<! Zero' !>PU = Zero
<! One' !>PU = One
<! Two' !>PU = Two
<! Sg' S T !>PU = Sg <! S !>PU \ s -> <! T s !>PU
<! Pi' S T !>PU = (s : <! S !>PU) -> <! T s !>PU
<! Tree' I F i !>PU = ITree
( (\ i -> <! fst (F i) !>PU)
<i (\ i s -> <! fst (snd (F i) s) !>PU)
$ (\ i s p -> snd (snd (F i) s) p)
) i
<! Prf' P !>PU = <! P !>PU
{- {exe}[observational propositional equality]
Reconstruct the definition of observational equality in this more refined
setting. Take equality of propositions to be mutual implication and
equality of proofs to be trivial: after all, equality for proofs of the
atomic |Zero'| and |One'| propositions are trivial. -}
_/\_ : PU prop -> PU prop -> PU prop
P /\ Q = Sg' P \ _ -> Q
_=>_ : PU prop -> PU prop -> PU prop
P => Q = Pi' (Prf' P) \ _ -> Q
mutual
PEQ : (X Y : PU set) -> PU prop * (<! X !>PU -> <! Y !>PU -> PU prop)
_<=>_ : PU set -> PU set -> PU prop
X <=> Y = fst (PEQ X Y)
PEq : (X : PU set)(x : <! X !>PU) -> (Y : PU set)(y : <! Y !>PU) -> PU prop
PEq X x Y y = snd (PEQ X Y) x y
PEQ (Prf' P) (Prf' Q) = ((P => Q) /\ (Q => P)) , \ _ _ -> One'
-- \orange{more code goes here}
PEQ _ _ = Zero' , \ _ _ -> One'