194 *) |
194 *) |
195 |
195 |
196 eval_fun_def |
196 eval_fun_def |
197 " eval_fun(s) == \ |
197 " eval_fun(s) == \ |
198 \ { pp. \ |
198 \ { pp. \ |
199 \ (? ve c. pp=<<ve,e_const(c)>,v_const(c)>) | \ |
199 \ (? ve c. pp=((ve,e_const(c)),v_const(c))) | \ |
200 \ (? ve x. pp=<<ve,e_var(x)>,ve_app ve x> & x:ve_dom(ve)) |\ |
200 \ (? ve x. pp=((ve,e_var(x)),ve_app ve x) & x:ve_dom(ve)) |\ |
201 \ (? ve e x. pp=<<ve,fn x => e>,v_clos(<|x,e,ve|>)>)| \ |
201 \ (? ve e x. pp=((ve,fn x => e),v_clos(<|x,e,ve|>)))| \ |
202 \ ( ? ve e x f cl. \ |
202 \ ( ? ve e x f cl. \ |
203 \ pp=<<ve,fix f(x) = e>,v_clos(cl)> & \ |
203 \ pp=((ve,fix f(x) = e),v_clos(cl)) & \ |
204 \ cl=<|x, e, ve+{f |-> v_clos(cl)} |> \ |
204 \ cl=<|x, e, ve+{f |-> v_clos(cl)} |> \ |
205 \ ) | \ |
205 \ ) | \ |
206 \ ( ? ve e1 e2 c1 c2. \ |
206 \ ( ? ve e1 e2 c1 c2. \ |
207 \ pp=<<ve,e1 @ e2>,v_const(c_app c1 c2)> & \ |
207 \ pp=((ve,e1 @ e2),v_const(c_app c1 c2)) & \ |
208 \ <<ve,e1>,v_const(c1)>:s & <<ve,e2>,v_const(c2)>:s \ |
208 \ ((ve,e1),v_const(c1)):s & ((ve,e2),v_const(c2)):s \ |
209 \ ) | \ |
209 \ ) | \ |
210 \ ( ? ve vem e1 e2 em xm v v2. \ |
210 \ ( ? ve vem e1 e2 em xm v v2. \ |
211 \ pp=<<ve,e1 @ e2>,v> & \ |
211 \ pp=((ve,e1 @ e2),v) & \ |
212 \ <<ve,e1>,v_clos(<|xm,em,vem|>)>:s & \ |
212 \ ((ve,e1),v_clos(<|xm,em,vem|>)):s & \ |
213 \ <<ve,e2>,v2>:s & \ |
213 \ ((ve,e2),v2):s & \ |
214 \ <<vem+{xm |-> v2},em>,v>:s \ |
214 \ ((vem+{xm |-> v2},em),v):s \ |
215 \ ) \ |
215 \ ) \ |
216 \ }" |
216 \ }" |
217 |
217 |
218 eval_rel_def "eval_rel == lfp(eval_fun)" |
218 eval_rel_def "eval_rel == lfp(eval_fun)" |
219 eval_def "ve |- e ---> v == <<ve,e>,v>:eval_rel" |
219 eval_def "ve |- e ---> v == ((ve,e),v):eval_rel" |
220 |
220 |
221 (* The static semantics is defined in the same way as the dynamic |
221 (* The static semantics is defined in the same way as the dynamic |
222 semantics. The relation te |- e ===> t express the expression e has the |
222 semantics. The relation te |- e ===> t express the expression e has the |
223 type t in the type environment te. |
223 type t in the type environment te. |
224 *) |
224 *) |
225 |
225 |
226 elab_fun_def |
226 elab_fun_def |
227 "elab_fun(s) == \ |
227 "elab_fun(s) == \ |
228 \ { pp. \ |
228 \ { pp. \ |
229 \ (? te c t. pp=<<te,e_const(c)>,t> & c isof t) | \ |
229 \ (? te c t. pp=((te,e_const(c)),t) & c isof t) | \ |
230 \ (? te x. pp=<<te,e_var(x)>,te_app te x> & x:te_dom(te)) | \ |
230 \ (? te x. pp=((te,e_var(x)),te_app te x) & x:te_dom(te)) | \ |
231 \ (? te x e t1 t2. pp=<<te,fn x => e>,t1->t2> & <<te+{x |=> t1},e>,t2>:s) | \ |
231 \ (? te x e t1 t2. pp=((te,fn x => e),t1->t2) & ((te+{x |=> t1},e),t2):s) | \ |
232 \ (? te f x e t1 t2. \ |
232 \ (? te f x e t1 t2. \ |
233 \ pp=<<te,fix f(x)=e>,t1->t2> & <<te+{f |=> t1->t2}+{x |=> t1},e>,t2>:s \ |
233 \ pp=((te,fix f(x)=e),t1->t2) & ((te+{f |=> t1->t2}+{x |=> t1},e),t2):s \ |
234 \ ) | \ |
234 \ ) | \ |
235 \ (? te e1 e2 t1 t2. \ |
235 \ (? te e1 e2 t1 t2. \ |
236 \ pp=<<te,e1 @ e2>,t2> & <<te,e1>,t1->t2>:s & <<te,e2>,t1>:s \ |
236 \ pp=((te,e1 @ e2),t2) & ((te,e1),t1->t2):s & ((te,e2),t1):s \ |
237 \ ) \ |
237 \ ) \ |
238 \ }" |
238 \ }" |
239 |
239 |
240 elab_rel_def "elab_rel == lfp(elab_fun)" |
240 elab_rel_def "elab_rel == lfp(elab_fun)" |
241 elab_def "te |- e ===> t == <<te,e>,t>:elab_rel" |
241 elab_def "te |- e ===> t == ((te,e),t):elab_rel" |
242 |
242 |
243 (* The original correspondence relation *) |
243 (* The original correspondence relation *) |
244 |
244 |
245 isof_env_def |
245 isof_env_def |
246 " ve isofenv te == \ |
246 " ve isofenv te == \ |
256 (* The extented correspondence relation *) |
256 (* The extented correspondence relation *) |
257 |
257 |
258 hasty_fun_def |
258 hasty_fun_def |
259 " hasty_fun(r) == \ |
259 " hasty_fun(r) == \ |
260 \ { p. \ |
260 \ { p. \ |
261 \ ( ? c t. p = <v_const(c),t> & c isof t) | \ |
261 \ ( ? c t. p = (v_const(c),t) & c isof t) | \ |
262 \ ( ? ev e ve t te. \ |
262 \ ( ? ev e ve t te. \ |
263 \ p = <v_clos(<|ev,e,ve|>),t> & \ |
263 \ p = (v_clos(<|ev,e,ve|>),t) & \ |
264 \ te |- fn ev => e ===> t & \ |
264 \ te |- fn ev => e ===> t & \ |
265 \ ve_dom(ve) = te_dom(te) & \ |
265 \ ve_dom(ve) = te_dom(te) & \ |
266 \ (! ev1.ev1:ve_dom(ve) --> <ve_app ve ev1,te_app te ev1> : r) \ |
266 \ (! ev1.ev1:ve_dom(ve) --> (ve_app ve ev1,te_app te ev1) : r) \ |
267 \ ) \ |
267 \ ) \ |
268 \ } \ |
268 \ } \ |
269 \ " |
269 \ " |
270 |
270 |
271 hasty_rel_def "hasty_rel == gfp(hasty_fun)" |
271 hasty_rel_def "hasty_rel == gfp(hasty_fun)" |
272 hasty_def "v hasty t == <v,t> : hasty_rel" |
272 hasty_def "v hasty t == (v,t) : hasty_rel" |
273 hasty_env_def |
273 hasty_env_def |
274 " ve hastyenv te == \ |
274 " ve hastyenv te == \ |
275 \ ve_dom(ve) = te_dom(te) & \ |
275 \ ve_dom(ve) = te_dom(te) & \ |
276 \ (! x. x: ve_dom(ve) --> ve_app ve x hasty te_app te x)" |
276 \ (! x. x: ve_dom(ve) --> ve_app ve x hasty te_app te x)" |
277 |
277 |