diff options
Diffstat (limited to 'theories/dynlang/operational.v')
-rw-r--r-- | theories/dynlang/operational.v | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/theories/dynlang/operational.v b/theories/dynlang/operational.v new file mode 100644 index 0000000..34cca7b --- /dev/null +++ b/theories/dynlang/operational.v | |||
@@ -0,0 +1,41 @@ | |||
1 | From mininix Require Export utils. | ||
2 | From stdpp Require Import options. | ||
3 | |||
4 | Module Import dynlang. | ||
5 | |||
6 | Inductive expr := | ||
7 | | EString (s : string) | ||
8 | | EId (ds : gmap string expr) (ex : expr) | ||
9 | | EAbs (ex e : expr) | ||
10 | | EApp (e1 e2 : expr). | ||
11 | |||
12 | Fixpoint subst (ds : gmap string expr) (e : expr) : expr := | ||
13 | match e with | ||
14 | | EString s => EString s | ||
15 | | EId ds' e => EId (ds ∪ ds') (subst ds e) | ||
16 | | EAbs ex e => EAbs (subst ds ex) (subst ds e) | ||
17 | | EApp e1 e2 => EApp (subst ds e1) (subst ds e2) | ||
18 | end. | ||
19 | |||
20 | Reserved Infix "-->" (right associativity, at level 55). | ||
21 | Inductive step : expr → expr → Prop := | ||
22 | | Sβ x e1 e2 : EApp (EAbs (EString x) e1) e2 --> subst {[x:=e2]} e1 | ||
23 | | SIdString ds x e : ds !! x = Some e → EId ds (EString x) --> e | ||
24 | | SAbsL ex1 ex1' e : ex1 --> ex1' → EAbs ex1 e --> EAbs ex1' e | ||
25 | | SAppL e1 e1' e2 : e1 --> e1' → EApp e1 e2 --> EApp e1' e2 | ||
26 | | SId ds e1 e1' : e1 --> e1' → EId ds e1 --> EId ds e1' | ||
27 | where "e1 --> e2" := (step e1 e2). | ||
28 | |||
29 | Infix "-->*" := (rtc step) (right associativity, at level 55). | ||
30 | |||
31 | Definition final (e : expr) : Prop := | ||
32 | match e with | ||
33 | | EString _ => True | ||
34 | | EAbs (EString _) _ => True | ||
35 | | _ => False | ||
36 | end. | ||
37 | |||
38 | Definition stuck (e : expr) : Prop := | ||
39 | nf step e ∧ ¬final e. | ||
40 | |||
41 | End dynlang. | ||