aboutsummaryrefslogtreecommitdiffstats
path: root/theories/lambda/operational.v
diff options
context:
space:
mode:
Diffstat (limited to 'theories/lambda/operational.v')
-rw-r--r--theories/lambda/operational.v38
1 files changed, 38 insertions, 0 deletions
diff --git a/theories/lambda/operational.v b/theories/lambda/operational.v
new file mode 100644
index 0000000..b0fa366
--- /dev/null
+++ b/theories/lambda/operational.v
@@ -0,0 +1,38 @@
1From mininix Require Export utils.
2From stdpp Require Import options.
3
4Module Import lambda.
5
6Inductive expr :=
7 | EString (s : string)
8 | EId (x : string)
9 | EAbs (x : string) (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 x => if ds !! x is Some d then d else EId x
16 | EAbs x e => EAbs x (subst (delete x 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 x e1) e2 --> subst {[x:=e2]} e1
23 | SAppL e1 e1' e2 : e1 --> e1' → EApp e1 e2 --> EApp e1' e2
24where "e1 --> e2" := (step e1 e2).
25
26Infix "-->*" := (rtc step) (right associativity, at level 55).
27
28Definition final (e : expr) : Prop :=
29 match e with
30 | EString _ => True
31 | EAbs _ _ => True
32 | _ => False
33 end.
34
35Definition stuck (e : expr) : Prop :=
36 nf step e ∧ ¬final e.
37
38End lambda.