aboutsummaryrefslogtreecommitdiffstats
path: root/theories/dynlang/operational.v
diff options
context:
space:
mode:
Diffstat (limited to 'theories/dynlang/operational.v')
-rw-r--r--theories/dynlang/operational.v41
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 @@
1From mininix Require Export utils.
2From stdpp Require Import options.
3
4Module Import dynlang.
5
6Inductive expr :=
7 | EString (s : string)
8 | EId (ds : gmap string expr) (ex : expr)
9 | EAbs (ex e : expr)
10 | EApp (e1 e2 : expr).
11
12Fixpoint 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
20Reserved Infix "-->" (right associativity, at level 55).
21Inductive 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'
27where "e1 --> e2" := (step e1 e2).
28
29Infix "-->*" := (rtc step) (right associativity, at level 55).
30
31Definition final (e : expr) : Prop :=
32 match e with
33 | EString _ => True
34 | EAbs (EString _) _ => True
35 | _ => False
36 end.
37
38Definition stuck (e : expr) : Prop :=
39 nf step e ∧ ¬final e.
40
41End dynlang.