You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This PR adds the high level proof of that a CEK execution corresponds to a CK execution.
I have postulated several syntactic lemmas related to whether you discharge CEK values or convert them to CK values and then discharge them, and when you perform syntactic operations such as substitution. I have also postulated that the CEK and CK builtin machinery behaves the same.
cek2ckVal : ∀{A} → (V : Value A) → Red.Value (discharge V)
955
953
@@ -994,3 +992,68 @@ cek2ckState (s ; ρ ▻ L) = cek2ckStack s CK.▻ cek2ckClos L ρ
994
992
cek2ckState (s ◅ V) = cek2ckStack s CK.◅ cek2ckVal V
995
993
cek2ckState (□ V) = CK.□ (cek2ckVal V)
996
994
cek2ckState (◆ A) = CK.◆ A
995
+
996
+
data _-→s_ {A : ∅ ⊢Nf⋆ *} : State A → State A → Set where
997
+
base : {s : State A} → s -→s s
998
+
step* : {s s' s'' : State A}
999
+
→ step s ≡ s'
1000
+
→ s' -→s s''
1001
+
→ s -→s s''
1002
+
1003
+
step** : ∀{A}{s : State A}{s' : State A}{s'' : State A}
1004
+
→ s -→s s'
1005
+
→ s' -→s s''
1006
+
→ s -→s s''
1007
+
step** base q = q
1008
+
step** (step* x p) q = step* x (step** p q)
1009
+
1010
+
-- some syntactic assumptions
1011
+
1012
+
postulate ival-lem : ∀ b {A}{s : CK.Stack A _} → (s CK.◅ Red.ival b) ≡ (s CK.◅ cek2ckVal (ival b))
1013
+
1014
+
postulate dischargeBody-lem : ∀{A B}{Γ}{C}{s : CK.Stack A B}(M : Γ , C ⊢ _) ρ V → (s CK.▻ (dischargeBody M ρ [ CK.discharge (cek2ckVal V) ])) ≡ (s CK.▻ cek2ckClos M (ρ ∷ V))
1015
+
1016
+
postulate discharge-lem : ∀{A}(V : Value A) → Red.deval (cek2ckVal V) ≡ discharge V
1017
+
1018
+
postulate dischargeBody⋆-lem : ∀{Γ K B A C}{s : CK.Stack C _}(M : Γ ,⋆ K ⊢ B) ρ → (s CK.▻ (dischargeBody⋆ M ρ [ A ]⋆)) ≡ (s CK.▻ cek2ckClos (M [ A ]⋆) ρ)
1019
+
1020
+
postulate dischargeB-lem : ∀ {K A}{B : ∅ ,⋆ K ⊢Nf⋆ *}{C b}{as a as'}{p : as <>> Type ∷ a ∷ as' ∈ arity b}{x : BAPP b p (Π B)} (s : CK.Stack C (B [ A ]Nf)) → s CK.◅ Red.V-I b (bubble p) (Red.step⋆ p (cek2ckBAPP x)) ≡ (s CK.◅ cek2ckVal (V-I b (bubble p) (app⋆ p x refl)))
1021
+
1022
+
postulate dischargeB'-lem : ∀ {A}{C b}{as a as'}{p : as <>> a ∷ as' ∈ arity b}{x : BAPP b p A} (s : CK.Stack C _) → s CK.◅ Red.V-I b p (cek2ckBAPP x) ≡ (s CK.◅ cek2ckVal (V-I b p x))
1023
+
1024
+
1025
+
-- assuming that buitins work the same way for CEK and red/CK
1026
+
1027
+
postulate BUILTIN-lem : ∀ b {A}{az}(p : az <>> [] ∈ arity b)(q : BAPP b p A) → Red.BUILTIN' b p (cek2ckBAPP q) ≡ cek2ckClos (BUILTIN' b p q) []
1028
+
1029
+
import Algorithmic.CC as CC
1030
+
thm64 : ∀{A}(s s' : State A) → s -→s s' → cek2ckState s CK.-→s cek2ckState s'
1031
+
thm64 s s base = CK.base
1032
+
thm64 (s ; ρ ▻ ` x) s' (step* refl q) = CK.step** (CK.lemV (discharge (lookup x ρ)) (cek2ckVal (lookup x ρ)) (cek2ckStack s)) (thm64 _ s' q)
1033
+
thm64 (s ; ρ ▻ ƛ L) s' (step* refl q) = CK.step* refl (thm64 _ s' q)
1034
+
thm64 (s ; ρ ▻ (L · M)) s' (step* refl q) = CK.step* refl (thm64 _ s' q)
1035
+
thm64 (s ; ρ ▻ Λ L) s' (step* refl q) = CK.step* refl (thm64 _ s' q)
1036
+
thm64 (s ; ρ ▻ (L ·⋆ A)) s' (step* refl q) = CK.step* refl (thm64 _ s' q)
1037
+
thm64 (s ; ρ ▻ wrap A B L) s' (step* refl q) = CK.step* refl (thm64 _ s' q)
1038
+
thm64 (s ; ρ ▻ unwrap L) s' (step* refl q) = CK.step* refl (thm64 _ s' q)
1039
+
thm64 (s ; ρ ▻ con c) s' (step* refl q) = CK.step* refl (thm64 _ s' q)
1040
+
thm64 (s ; ρ ▻ ibuiltin b) s' (step* refl q) = CK.step* (ival-lem b) (thm64 _ s' q)
1041
+
thm64 (s ; ρ ▻ error _) s' (step* refl q) = CK.step* refl (thm64 _ s' q)
1042
+
thm64 (ε ◅ V) s' (step* refl q) = CK.step* refl (thm64 _ s' q)
1043
+
thm64 ((s , -· L ρ) ◅ V) s' (step* refl q) = CK.step* refl (thm64 _ s' q)
1044
+
thm64 ((s , (V-ƛ M ρ ·-)) ◅ V) s' (step* refl q) = CK.step*
1045
+
(dischargeBody-lem M ρ V)
1046
+
(thm64 _ s' q)
1047
+
thm64 ((s , (V-I⇒ b {as' = []} p x ·-)) ◅ V) s' (step* refl q) = CK.step*
1048
+
(cong (cek2ckStack s CK.▻_) (BUILTIN-lem b (bubble p) (app p x V)))
1049
+
(thm64 _ s' q)
1050
+
thm64 ((s , (V-I⇒ b {as' = x₁ ∷ as'} p x ·-)) ◅ V) s' (step* refl q) = CK.step* (dischargeB'-lem (cek2ckStack s)) (thm64 _ s' q)
1051
+
thm64 ((s , -·⋆ A) ◅ V-Λ M ρ) s' (step* refl q) = CK.step* (dischargeBody⋆-lem M ρ) (thm64 _ s' q)
1052
+
thm64 ((s , -·⋆ A) ◅ V-IΠ b {as' = []} p x) s' (step* refl q) = CK.step*
1053
+
(cong (cek2ckStack s CK.▻_) (BUILTIN-lem b (bubble p) (app⋆ p x refl)))
1054
+
(thm64 _ s' q)
1055
+
thm64 ((s , -·⋆ A) ◅ V-IΠ b {as' = x₁ ∷ as'} p x) s' (step* refl q) = CK.step* (dischargeB-lem (cek2ckStack s)) (thm64 _ s' q)
1056
+
thm64 ((s , wrap-) ◅ V) s' (step* refl q) = CK.step* refl (thm64 _ s' q)
1057
+
thm64 ((s , unwrap-) ◅ V-wrap V) s' (step* refl q) = CK.step* (cong (cek2ckStack s CK.▻_) (discharge-lem V)) (CK.step** (CK.lemV _ (cek2ckVal V) (cek2ckStack s)) (thm64 _ s' q))
1058
+
thm64 (□ V) s' (step* refl q) = CK.step* refl (thm64 _ s' q)
1059
+
thm64 (◆ A) s' (step* refl q) = CK.step* refl (thm64 _ s' q)
0 commit comments