Better understanding of the types now

This commit is contained in:
Michael Zhang 2021-12-09 04:32:32 -06:00
parent 953bb21dc8
commit 69688762bf
Signed by: michael
GPG key ID: BDA47A31A3C8EE6B
3 changed files with 42 additions and 7 deletions

View file

@ -28,11 +28,23 @@ step (mkState Tc Γ (case C isZ isS) E K) with astep C E
... | suc n = part $ mkState Tc Γ (isS · value n) E K ... | suc n = part $ mkState Tc Γ (isS · value n) E K
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
... | cont halt = done $ {! !} ... | cont halt = {! !}
... | cont (kont k) = {! apply-kont (kont k) ? !} ... | cont (kont x) = {! !}
-- ... | cont k = apply-kont {! k !} (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
step (mkState Tc Γ (call/cc x) E K) with astep x E step (mkState Tc Γ (call/cc {A} aexp) E K) with astep aexp E
... | proc = {! !} ... | clo {Γc} body env =
part $ mkState Tc (Γc , A ) body (env [ A cont K ]) K
... | cont k = apply-kont K {! !}
-- part $ mkState ((A ⇒ ⊥) ⇒ Tc) Γ aexp E K
-- let Γ′ = Γ , A ⇒ ⊥ in
-- let E = E [ A ⇒ ⊥ cont {! !} ] in
-- part $ mkState (((A ⇒ ⊥) ⇒ Tc)) Γ′ aexp E {! !}
step (mkState Tc Γ (abort V⊥) E K) with astep V⊥ E
... | ()
step (mkState Tc Γ (`let {A} C₁ C₂) E K) =
let K = letk Γ C₂ E K in
part $ mkState A Γ C₁ E (kont K)
--... | clo {Γc} {A} {B} body env = --... | clo {Γc} {A} {B} body env =
-- let T = Κ[ Tc ⇒ ⊥ ] in -- let T = Κ[ Tc ⇒ ⊥ ] in
-- let v = cont K in -- let v = cont K in

View file

@ -12,8 +12,8 @@ infixr 7 _⇒_
data Type : Set where data Type : Set where
: Type : Type
_⇒_ : Type Type Type
` : Type ` : Type
_⇒_ : Type Type Type
data Context : Set where data Context : Set where
: Context : Context
@ -49,6 +49,8 @@ data Aexp Γ where
ƛ : {B} {A : Type} Exp (Γ , A) B Aexp Γ (A B) ƛ : {B} {A : Type} Exp (Γ , A) B Aexp Γ (A B)
data Exp Γ where data Exp Γ where
abort : {A} Aexp Γ Exp Γ A
-- Atomic expressions -- Atomic expressions
atomic : {A} Aexp Γ A Exp Γ A atomic : {A} Aexp Γ A Exp Γ A
@ -59,7 +61,21 @@ data Exp Γ where
_·_ : {A B} Aexp Γ (A B) Aexp Γ A Exp Γ B _·_ : {A B} Aexp Γ (A B) Aexp Γ A Exp Γ B
-- Call/cc -- Call/cc
call/cc : {A B } Aexp Γ ((A ) B) Exp Γ call/cc : {A } Aexp (Γ) ((A ) ) Exp Γ
-- Let
`let : {A B : Type} Exp Γ A Exp (Γ , A) B Exp Γ B
-- exp = let (call/cc ƛ . let (abort `0) (`0 · 2)) ((\ . suc `0) · `0)
-- exp = let (s = call/cc ƛk . let (k' = abort k) (k' · 2)) (suc s)
-- exp = 3
exp : Exp `
exp =
`let (call/cc (
-- `let (` zero · suc (suc zero)) (abort (` zero))
ƛ (` zero · suc (suc zero))
)) (`let (abort (` zero)) ((ƛ (atomic (suc (` suc zero)))) · ` zero))
data Kont ( : Type) : Type Set data Kont ( : Type) : Type Set
record Letk (Tv : Type) : Set record Letk (Tv : Type) : Set
@ -73,7 +89,8 @@ data Value where
clo : {Γ} {A B : Type} Exp (Γ , A) B Env Γ Value (A B) clo : {Γ} {A B : Type} Exp (Γ , A) B Env Γ Value (A B)
-- Call/CC -- Call/CC
cont : { A} Kont A Value (A ) -- cont : ∀ {Tω A} → Kont Tω A → Value (A ⇒ ⊥)
cont : { A B} Kont A Value (B )
record Letk Tv where record Letk Tv where
inductive inductive

View file

@ -36,6 +36,12 @@ len (call/cc k . if k "hello" is even then true else false)
--- ---
(call/cc \k . k 3)
done 3
---
3 + (call/cc \k . abort (k 2)) 3 + (call/cc \k . abort (k 2))
abort : _|_ -> A abort : _|_ -> A