-
Notifications
You must be signed in to change notification settings - Fork 91
/
Copy pathdata.ott
250 lines (184 loc) · 5.2 KB
/
data.ott
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
% Language additions for datatypes
metavar dcname, K ::=
{{ com data constructor names }}
{{ lex alphanum }}
metavar tcname, T ::=
{{ com data type names }}
{{ lex alphanum }}
indexvar i ::=
{{ com indexvar }}
grammar
tm, a , b , A , B :: '' ::= {{ com terms and types }}
| K args :: :: TCon
| T args :: :: DCon
| case a of { </ pati -> ai // i /> } :: :: Case
| a [ pat / x ] :: :: PatSubst
| Nat :: :: TyNat
| Zero :: :: Zero
| Succ a :: :: Succ
| Void :: :: TyVoid
| ImTrue a b :: :: ImTrue
| SillyBool :: :: SillyBool
v :: 'v_' ::=
| K args :: :: TCon
| T args :: :: DCon
neutral, ne :: 'n_' ::=
| case ne of { </ pati -> ai // i /> } :: :: Case
nf :: 'nf_' ::=
| K args :: :: TCon
| T args :: :: DCon
| case ne of { </ pati -> ai // i /> } :: :: Case
args {{ tex \overline{a} }} , bs {{ tex \overline{b} }} :: '' ::=
| :: :: Nil
| a args :: :: Cons
| [a] args :: :: ECons
pat ::'' ::=
| x :: :: PatVar
| K ps :: :: PatCon
ms :: 'm_' ::= {{ com sequence of matches }}
| m ; ms :: :: Cons
| :: :: Nil
ps :: 'p_' ::= {{ com sequence of patterns }}
| pat ps :: :: Cons
| pat ep ps :: :: ConsEp
| :: :: Nil
context, G :: 'ctx_' ::=
| G , D :: :: Extend
telescope, D {{ tex \Delta }} :: 'd_' ::=
| x : A , D :: :: AssnSig
| x : ep A , D :: :: AssnSigEp
| x = b , D :: :: AssnEq
| D1 , D2 :: :: Concat
| :: :: Nil
| D [ a / x ] :: M :: Subst
| D [ args / D1 ] :: M :: SubstTele
formula :: 'formula_' ::=
| K : D -> T args elem G :: :: DConInG
| K : D1 -> D2 -> T args elem G :: :: DConInG2
| T : D -> Type elem G :: :: TConInG
| branches exhaustive :: :: Exhaustive
| |- a ~ pat => D :: :: UnifyPat
| |- a ~ b => D :: :: Unify
| match a (pati -> ai) ~> b :: :: patternMatches
defns
Jwhnf :: '' ::=
defn
whnf G |- a ~> nf :: :: whnf :: 'whnf_'
by
-------------------- :: tcon
whnf G |- T args ~> T args
-------------------- :: dcon
whnf G |- K args ~> K args
match (K args) (pati -> ai) ~> b
whnf G |- b ~> nf
---------------------------------------------------------------------- :: case
whnf G |- case (K args) of { </ pati -> ai // i /> } ~> nf
a ~> ne
------------------------------------------------------------------------------- :: case_cong
whnf G |- case a of { </ pati -> ai // i /> } ~> case ne of { </ pati -> ai // i /> }
defns
JOp :: '' ::=
defn
a ~> b :: :: step :: 's_'
{{ com single-step operational semantics, i. e. head reduction }}
by
defns
JEq :: '' ::=
defn
G |- A = B :: :: eq :: 'e_'
{{ com Definitional equality }}
by
defns
JTyping :: '' ::=
defn
G |- a : A :: :: typing :: 't_'
{{ com Typing }}
by
--------------- :: Nat
G |- Nat : Type
---------------- :: Void
G |- Void : Type
---------------- :: Zero
G |- Zero : Nat
G |- n : Nat
----------------- :: Succ
G |- Succ n : Nat
G |- a1 : Bool
G |- a2 : a1 = True
--------------------------------------- :: ImTrue
G |- ImTrue a1 a2 : SillyBool
G |- a : T
</ G |- pati : T => Di // i />
</ G, Di |- bi : B // i />
G |- B : Type
branches exhaustive
---------------------------------------------------- :: case_simple
G |- case a of { </ pati -> bi // i /> } : B
defns
JBidirectional :: '' ::=
defn
G |- a => A :: :: inferType :: 'i_'
{{ com type synthesis (algorithmic) }}
by
T : D -> Type elem G
G |- args <= D
------------------------- :: tcon
G |- T args => Type
K : D -> T elem G
G |- args <= D
------------------ :: dcon_simple
G |- K args => T
defn
G |- a <= B :: :: checkType :: 'c_'
{{ com type checking (algorithmic) }}
by
G |- a => A
whnf G |- A ~> T
</ G |- pati : T => Di // i />
</ |- a ~ pati => Di' // i />
</ G, Di , Di' |- bi <= B // i />
branches exhaustive
-------------------------------------------------------- :: case_simple
G |- case a of { </ pati -> bi // i /> } <= B
G |- a => A
whnf G |- A ~> T bs
</ G |- pati : T bs => Di // i />
</ |- a ~ pati => Di' // i />
</ G, Di , Di' |- ai : A // i />
branches exhaustive
-------------------------------------------------------- :: case
G |- case a of { </ pati -> ai // i /> } <= A
K : D1 -> D2 -> T elem G
G |- args <= D2 [ bs / D1 ]
--------------------------- :: dcon
G |- K args <= T bs
defn
G |- args <= D :: :: tcArgTele :: 'tele_'
by
----------------- :: nil
G |- <=
G |- a : A
G |- args <= D [ a / x ]
----------------------------------------- :: sig
G |- a args <= x:A , D
G |- args <= D [ a / x ]
----------------------------------------- :: def
G |- args <= x = a , D
defn
G |- ps : D1 => D2 :: :: declarePats :: 'ps_'
by
-------------------------- :: Nil
G |- : =>
G |- pat : A => D1
G |- ps : D => D2
--------------------------------------------- :: Cons
G |- pat ps : x : A , D => D1 , D2
defn
G |- pat : A => D :: :: declarePat :: 'p_'
by
---------------------- :: var
G |- x : A => x : A ,
K : D1 -> T elem G
G |- ps : D1 => D2
---------------------- :: tcon
G |- K ps : T => D2