Skip to content

Commit 0d153a3

Browse files
committed
Move state_cexp to the right place
1 parent 84e0c33 commit 0d153a3

File tree

5 files changed

+49
-43
lines changed

5 files changed

+49
-43
lines changed
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
INCLUDES = $(PUREDIR)/misc $(PUREDIR)/language
1+
INCLUDES = $(PUREDIR)/misc $(PUREDIR)/language \
2+
$(CAKEMLDIR)/basis/pure
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
INCLUDES = ../ $(PUREDIR)/language $(PUREDIR)/misc
1+
INCLUDES = ../ $(PUREDIR)/language $(PUREDIR)/misc \
2+
$(CAKEMLDIR)/basis/pure

compiler/backend/languages/semantics/stateLangScript.sml

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,12 @@
1212

1313
open HolKernel Parse boolLib bossLib BasicProvers dep_rewrite;
1414
open stringTheory optionTheory sumTheory pairTheory listTheory alistTheory
15-
pure_expTheory pure_semanticsTheory arithmeticTheory;
15+
pure_expTheory pure_semanticsTheory arithmeticTheory
16+
state_cexpTheory mlstringTheory;
1617

1718
val _ = new_theory "stateLang";
1819

19-
val _ = set_grammar_ancestry ["pure_semantics"];
20+
val _ = set_grammar_ancestry ["pure_semantics","state_cexp"];
2021

2122
val _ = numLib.prefer_num();
2223

@@ -40,6 +41,8 @@ Datatype:
4041
| FFI string (* make an FFI call *)
4142
End
4243

44+
Type vname = “:string”
45+
4346
Datatype:
4447
exp = (* stateLang expressions *)
4548
| Var vname (* variable *)
@@ -846,4 +849,40 @@ Proof
846849
cheat
847850
QED
848851

852+
(* meaning of cexp *)
853+
854+
Definition sop_of_def[simp]:
855+
sop_of (AppOp:csop) = (AppOp:sop) ∧
856+
sop_of (Cons n) = Cons (explode n) ∧
857+
sop_of (AtomOp m) = AtomOp m ∧
858+
sop_of Alloc = Alloc ∧
859+
sop_of Ref = Ref ∧
860+
sop_of Length = Length ∧
861+
sop_of Sub = Sub ∧
862+
sop_of UnsafeSub = UnsafeSub ∧
863+
sop_of Length = Length ∧
864+
sop_of Update = Update ∧
865+
sop_of UnsafeUpdate = UnsafeUpdate ∧
866+
sop_of (FFI s) = FFI (explode s)
867+
End
868+
869+
Definition exp_of_def:
870+
exp_of ((Var n):cexp) = (Var (explode n)):exp ∧
871+
exp_of (App op xs) = App (sop_of op) (MAP exp_of xs) ∧
872+
exp_of (Lam vn x) = Lam (OPTION_MAP explode vn) (exp_of x) ∧
873+
exp_of (Letrec funs x) =
874+
Letrec (MAP (λ(f,v,y). (explode f,Lam (SOME (explode v)) (exp_of y))) funs) (exp_of x) ∧
875+
exp_of (Let vn x y) = Let (OPTION_MAP explode vn) (exp_of x) (exp_of y) ∧
876+
exp_of (If x y z) = If (exp_of x) (exp_of y) (exp_of z) ∧
877+
exp_of (Case x v rows) =
878+
Case (exp_of x) (explode v) (MAP (λ(v,vs,y). (explode v,MAP explode vs,exp_of y)) rows) ∧
879+
exp_of (Raise x) = Raise (exp_of x) ∧
880+
exp_of (Handle x v y) = Handle (exp_of x) (explode v) (exp_of y) ∧
881+
exp_of (HandleApp x y) = HandleApp (exp_of x) (exp_of y)
882+
Termination
883+
WF_REL_TAC ‘measure cexp_size’
884+
End
885+
886+
Theorem exp_of_def[simp] = exp_of_def |> CONV_RULE (DEPTH_CONV ETA_CONV);
887+
849888
val _ = export_theory ();

compiler/backend/passes/proofs/state_cexpScript.sml renamed to compiler/backend/languages/state_cexpScript.sml

Lines changed: 2 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,11 @@
33
*)
44
open HolKernel Parse boolLib bossLib BasicProvers dep_rewrite;
55
open stringTheory optionTheory sumTheory pairTheory listTheory alistTheory
6-
pure_expTheory pure_semanticsTheory arithmeticTheory stateLangTheory
7-
mlstringTheory;
6+
pure_expTheory pure_semanticsTheory arithmeticTheory mlstringTheory;
87

98
val _ = new_theory "state_cexp";
109

11-
val _ = set_grammar_ancestry ["stateLang","mlstring"];
10+
val _ = set_grammar_ancestry ["pure_exp","mlstring"];
1211

1312
val _ = numLib.prefer_num();
1413

@@ -52,38 +51,4 @@ Overload "Unit" = “App (Cons (strlit "")) [] :cexp”;
5251
Overload IntLit = “λi. App (AtomOp (Lit (Int i))) []”
5352
Overload Eq = “λx y. App (AtomOp Eq) [x; y]”
5453

55-
Definition sop_of_def[simp]:
56-
sop_of (AppOp:csop) = (AppOp:sop) ∧
57-
sop_of (Cons n) = Cons (explode n) ∧
58-
sop_of (AtomOp m) = AtomOp m ∧
59-
sop_of Alloc = Alloc ∧
60-
sop_of Ref = Ref ∧
61-
sop_of Length = Length ∧
62-
sop_of Sub = Sub ∧
63-
sop_of UnsafeSub = UnsafeSub ∧
64-
sop_of Length = Length ∧
65-
sop_of Update = Update ∧
66-
sop_of UnsafeUpdate = UnsafeUpdate ∧
67-
sop_of (FFI s) = FFI (explode s)
68-
End
69-
70-
Definition exp_of_def:
71-
exp_of ((Var n):cexp) = (Var (explode n)):exp ∧
72-
exp_of (App op xs) = App (sop_of op) (MAP exp_of xs) ∧
73-
exp_of (Lam vn x) = Lam (OPTION_MAP explode vn) (exp_of x) ∧
74-
exp_of (Letrec funs x) =
75-
Letrec (MAP (λ(f,v,y). (explode f,Lam (SOME (explode v)) (exp_of y))) funs) (exp_of x) ∧
76-
exp_of (Let vn x y) = Let (OPTION_MAP explode vn) (exp_of x) (exp_of y) ∧
77-
exp_of (If x y z) = If (exp_of x) (exp_of y) (exp_of z) ∧
78-
exp_of (Case x v rows) =
79-
Case (exp_of x) (explode v) (MAP (λ(v,vs,y). (explode v,MAP explode vs,exp_of y)) rows) ∧
80-
exp_of (Raise x) = Raise (exp_of x) ∧
81-
exp_of (Handle x v y) = Handle (exp_of x) (explode v) (exp_of y) ∧
82-
exp_of (HandleApp x y) = HandleApp (exp_of x) (exp_of y)
83-
Termination
84-
WF_REL_TAC ‘measure cexp_size’
85-
End
86-
87-
Theorem exp_of_def[simp] = exp_of_def |> CONV_RULE (DEPTH_CONV ETA_CONV);
88-
8954
val _ = export_theory();

compiler/backend/passes/proofs/state_to_cakeProofScript.sml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2516,8 +2516,8 @@ Proof
25162516
pop_assum SUBST_ALL_TAC >> simp[] >>
25172517
ntac 9 (qrefine `SUC m` >> simp[dstep, cstep, do_app_def]) >>
25182518
simp[store_lookup_def, copy_array_def, integerTheory.INT_ADD_CALCULATE] >>
2519-
qmatch_goalsub_abbrev_tac `StrLit str` >>
2520-
`str = s` by (
2519+
qmatch_goalsub_abbrev_tac `StrLit str1` >>
2520+
`str1 = s` by (
25212521
unabbrev_all_tac >> simp[TAKE_APPEND, GSYM MAP_TAKE] >>
25222522
simp[ws_to_chars_def, MAP_MAP_o, combinTheory.o_DEF, IMPLODE_EXPLODE_I]) >>
25232523
pop_assum SUBST_ALL_TAC >>

0 commit comments

Comments
 (0)