forked from nulang-org/nulang
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSemantics.v
More file actions
40 lines (32 loc) · 1.19 KB
/
Copy pathSemantics.v
File metadata and controls
40 lines (32 loc) · 1.19 KB
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
Require Import String.
Require Import List.
Import ListNotations.
Require Import Syntax.
Require Import Typing.
(** * Nulang Core Operational Semantics (Small-Step) *)
Inductive val : Type :=
| VInt : nat -> val
| VBool : bool -> val
| VString : string -> val
| VUnit : val
| VClosure : var -> expr -> list (var * val) -> val
| VCont : expr -> list (var * val) -> val. (* Continuation *)
Definition venv := list (var * val).
Fixpoint vlookup (x : var) (g : venv) : option val :=
match g with
| [] => None
| (y, v) :: g' => if string_dec x y then Some v else vlookup x g'
end.
(** Since this is a simple small-step semantics without full continuations,
we just define it conceptually or leave it as an exercise. *)
(** Nanolang proved type soundness, progress, determinism.
This skeleton provides the foundation for Nulang to do the same. *)
(** Progress Theorem Statement *)
Conjecture progress : forall sigs e t,
has_type sigs [] e t ->
(exists v, e = (* value conversion *) e) \/ (exists e', e = e'). (* simplified *)
(** Preservation Theorem Statement *)
Conjecture preservation : forall sigs e e' t,
has_type sigs [] e t ->
e = e' -> (* step *)
has_type sigs [] e' t.