-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSyntax.v
executable file
·59 lines (48 loc) · 1.4 KB
/
Syntax.v
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
Require Import Coq.Program.Syntax.
Require Export ZArith.
Require Import Coq.Program.Basics.
Require Import SetoidTactics.
Require Import SetoidClass.
Require Import Coq.Strings.String.
Require Import Coq.Strings.Ascii.
Require Import Coq.Lists.List.
Require Import HDI.Util.
Local Open Scope Z.
Inductive operation : Set :=
| read (a: Z)
| write (a: Z) (v: Z).
CoInductive stmt : Set :=
| ret: Z -> stmt
| abort: stmt
| act: operation -> stmt
| bind: stmt -> (Z -> stmt) -> stmt.
Delimit Scope stmt with stmt.
Bind Scope stmt with stmt.
Notation "s1 >>= s2" :=
(bind s1%stmt s2%stmt)
(right associativity, at level 41)
: stmt.
Notation "s1 >> s2" :=
((s1 >>= (fun _ => s2))%stmt)
(right associativity, at level 41)
: stmt.
Notation "x <- a ; s" :=
(bind a%stmt (fun x => s%stmt))
(right associativity, at level 41)
: stmt.
Notation "a ;; s" :=
(bind a%stmt (fun _ => s%stmt))
(right associativity, at level 41)
: stmt.
Coercion act : operation >-> stmt.
Goal (forall s1 s2 k, x <- s1; s2;; k x = bind s1 (fun x => bind s2 (fun _ => k x)))%stmt. intros; reflexivity. Abort.
Definition unfold_stmt (s: stmt) :=
match s with
| ret v => ret v
| abort => abort
| act o => act o
| bind s k => bind s k
end.
Lemma unfold_stmt_eq: forall s,
s = unfold_stmt s.
Proof. destruct s; reflexivity. Qed.