Add some headers

This commit is contained in:
Michael Zhang 2021-12-09 06:20:39 -06:00
parent 4c87fb529b
commit 360cd32d87
Signed by: michael
GPG key ID: BDA47A31A3C8EE6B

View file

@ -11,6 +11,9 @@ open Aexp
open Value open Value
open State open State
-------------------------------------------------------------------------------
-- Step for atomics
astep : { Γ A} Aexp Γ A Env Γ Value A astep : { Γ A} Aexp Γ A Env Γ Value A
astep (value v) _ = v astep (value v) _ = v
astep zero _ = zero astep zero _ = zero
@ -18,16 +21,23 @@ astep (suc c) e = suc $ astep c e
astep (` id) e = lookup e id astep (` id) e = lookup e id
astep (ƛ body) e = clo body e astep (ƛ body) e = clo body e
inject : {A : Type} Exp A A State A -------------------------------------------------------------------------------
inject {A} C = mkState A C halt -- Step
step : { : Type} State StepResult step : { : Type} State StepResult
-- Atomic expressions
step (mkState Tc Γ (atomic x) E K) = apply-kont K $ astep x E step (mkState Tc Γ (atomic x) E K) = apply-kont K $ astep x E
-- Natural numbers
step (mkState Tc Γ (case C isZ isS) E K) with astep C E step (mkState Tc Γ (case C isZ isS) E K) with astep C E
... | zero = part $ mkState Tc Γ isZ E K ... | zero = part $ mkState Tc Γ isZ E K
... | suc n = part $ mkState Tc Γ (isS · value n) E K ... | suc n = part $ mkState Tc Γ (isS · value n) E K
-- Function application
step (mkState Tc Γ (x₁ · x₂) E K) with astep x₁ E step (mkState Tc Γ (x₁ · x₂) E K) with astep x₁ E
... | clo body env = apply-proc-clo body env (astep x₂ E) K ... | clo body env = apply-proc-clo body env (astep x₂ E) K
-- Call/cc
step (mkState Tc Γ (x₁ x₂) E K) with astep x₁ E step (mkState Tc Γ (x₁ x₂) E K) with astep x₁ E
... | cont k = ... | cont k =
let val = astep x₂ E in let val = astep x₂ E in
@ -40,10 +50,18 @@ step {Tω} (mkState Tc Γ (call/cc {A} aexp) E K) with astep aexp E
part $ mkState Γ′ body E halt part $ mkState Γ′ body E halt
step (mkState Tc Γ (abort V⊥) E K) with astep V⊥ E step (mkState Tc Γ (abort V⊥) E K) with astep V⊥ E
... | () ... | ()
-- Let-bindings
step (mkState Tc Γ (`let {A} C₁ C₂) E K) = step (mkState Tc Γ (`let {A} C₁ C₂) E K) =
let K = letk Γ C₂ E K in let K = letk Γ C₂ E K in
part $ mkState A Γ C₁ E (kont K) part $ mkState A Γ C₁ E (kont K)
-------------------------------------------------------------------------------
-- Evaluation
inject : {A : Type} Exp A A State A
inject {A} C = mkState A C halt
data EvalResult : Set where data EvalResult : Set where
complete : {A} StepResult A EvalResult complete : {A} StepResult A EvalResult
exhausted : {A} State A EvalResult exhausted : {A} State A EvalResult