-
Notifications
You must be signed in to change notification settings - Fork 1
/
HandlersEx.v.in
40 lines (29 loc) · 1.21 KB
/
HandlersEx.v.in
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
Require String.
Require Import Handlers.
Open Scope string_scope.
(* Hack: there's no coqvars, so define values for coq vars
use xx instead of x to avoid any confusion,
although :concrete: should get over that
*)
Definition get := "get".
Definition put := "put".
Definition xx := "xx".
Definition uu := "uu".
Definition yy := "yy".
Definition uu' := "uu'".
Definition zz := "zz".
Definition kk := "kk".
Definition xxx := "xxx".
Definition st := "st".
Definition computation := [[ get () (\xx. put inl xx (\uu. get () (\yy. put (xx,yy) (\uu'. get () (\zz. return zz))))) ]].
Definition runState := fun m => [[ handle m with { return xxx -> \st. (xxx,st)! } + { get xxx kk -> \st. ((kk! st) st) } + { put xxx kk -> \st. ((kk! ()) xxx) } ]].
Definition outer := fun m => [[ m inr () ]].
Inductive reds : compt -> compt -> Prop :=
| r_zero : forall m, reds m m
| r_step : forall m1 m2 m3, reduce m1 m2 -> reds m2 m3 -> reds m1 m3.
Definition expectedResult := [[ ((inr (), inl inr ()) , (inr (), inl inr ()))! ]].
Definition bad : compt :=
[[ let xx <- handle let yy <- get () (\xx. return xx) in return xx with
{ return xxx -> return () }
+ { get xxx kk -> return () } in
return () ]].