cek-call-cc/src/Project/Definitions.agda

101 lines
2.3 KiB
Agda
Raw Normal View History

2021-12-08 00:33:28 -06:00
module Project.Definitions where
open import Data.Maybe using (Maybe; just; nothing)
open import Data.Nat using (; zero; suc)
open import Data.Product renaming (_,_ to _ʻ_)
open import Project.Util using (_$_)
infix 4 _∋_
infix 4 _·_
infixl 6 _,_
infixr 7 _⇒_
data Type : Set where
2021-12-09 02:05:20 -06:00
: Type
2021-12-08 00:33:28 -06:00
_⇒_ : Type Type Type
` : Type
data Context : Set where
: Context
_,_ : Context Type Context
data Value : Type Set
data Env : Context Set where
: Env
_[__] : {Γ} Env Γ (A : Type) Value A Env (Γ , A)
data _∋_ : Context Type Set where
zero : {Γ A} Γ , A A
suc : {Γ A B} Γ A Γ , B A
lookup : {Γ A} Env Γ Γ A Value A
lookup ()
lookup (env [ A x ]) zero = x
lookup (env [ A x ]) (suc id) = lookup env id
data Aexp Context : Type Set
data Exp Context : Type Set
data Aexp Γ where
2021-12-09 02:05:20 -06:00
value : {A} Value A Aexp Γ A
2021-12-08 00:33:28 -06:00
-- Natural numbers
zero : Aexp Γ `
suc : Aexp Γ ` Aexp Γ `
-- Functions
`_ : {A} Γ A Aexp Γ A
ƛ : {B} {A : Type} Exp (Γ , A) B Aexp Γ (A B)
data Exp Γ where
-- Atomic expressions
atomic : {A} Aexp Γ A Exp Γ A
-- Natural numbers
case : {A} Aexp Γ ` Exp Γ A Aexp Γ (` A) Exp Γ A
-- Functions
_·_ : {A B} Aexp Γ (A B) Aexp Γ A Exp Γ B
-- Call/cc
2021-12-09 02:05:20 -06:00
call/cc : {A B } Aexp Γ ((A ) B) Exp Γ
2021-12-08 00:33:28 -06:00
data Kont ( : Type) : Type Set
2021-12-09 02:05:20 -06:00
record Letk (Tv : Type) : Set
2021-12-08 00:33:28 -06:00
data Value where
-- Natural numbers
zero : Value `
suc : Value ` Value `
-- Functions
clo : {Γ} {A B : Type} Exp (Γ , A) B Env Γ Value (A B)
-- Call/CC
2021-12-09 02:05:20 -06:00
cont : { A} Kont A Value (A )
2021-12-08 00:33:28 -06:00
2021-12-09 02:05:20 -06:00
record Letk Tv where
2021-12-08 00:33:28 -06:00
inductive
constructor letk
field
{Tc} : Type
Γ : Context
C : Exp (Γ , Tv) Tc
E : Env Γ
K : Kont Tc
data Kont where
halt : Kont
2021-12-09 02:05:20 -06:00
kont : {Tc} Letk Tc Kont Tc
2021-12-08 00:33:28 -06:00
-- A is the type of C
-- B is the eventual type
record State ( : Type) : Set where
constructor mkState
field
Tc : Type
Γ : Context
C : Exp Γ Tc
E : Env Γ
K : Kont Tc