Skip to content

Commit 24dcf0a

Browse files
committed
implemented new optimisation pass, still needs to be integrated and tested
1 parent 1524555 commit 24dcf0a

16 files changed

+4972
-1048
lines changed

compiler/backend/languages/semantics/thunkLangPropsScript.sml

+37
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,43 @@ Proof
2828
\\ simp []
2929
QED
3030

31+
(* -------------------------------------------------------------------------
32+
* Property about terms stating they do not contain a value
33+
* ------------------------------------------------------------------------- *)
34+
35+
Definition no_value_def:
36+
(no_value (Var n) = T) ∧
37+
(no_value (Force x) = no_value x) ∧
38+
(no_value (Prim op xs) = EVERY no_value xs) ∧
39+
(no_value (If x y z) = (no_value x ∧ no_value y ∧ no_value z)) ∧
40+
(no_value (App x y) = (no_value x ∧ no_value y)) ∧
41+
(no_value (Lam s x) = no_value x) ∧
42+
(no_value (Let opt x y) = (no_value x ∧ no_value y)) ∧
43+
(no_value (Box x) = no_value x) ∧
44+
(no_value (MkTick x) = no_value x) ∧
45+
(no_value (Letrec f x) = (no_value x ∧ EVERY no_value (MAP SND f) ∧ EVERY ok_bind (MAP SND f))) ∧
46+
(no_value (Value v) = F) ∧
47+
(no_value (Delay x) = no_value x)
48+
Termination
49+
WF_REL_TAC ‘measure $ exp_size’ \\ rw [MEM_MAP, SND_THM]
50+
\\ assume_tac exp_size_lemma
51+
\\ pairarg_tac \\ gvs []
52+
\\ first_x_assum $ dxrule_then assume_tac \\ gvs []
53+
End
54+
55+
Theorem no_value_Lams:
56+
∀l x. no_value (Lams l x) = no_value x
57+
Proof
58+
Induct >> gs [no_value_def]
59+
QED
60+
61+
Theorem no_value_Apps:
62+
∀l x. no_value (Apps x l) = (no_value x ∧ EVERY no_value l)
63+
Proof
64+
Induct >> gs [no_value_def] >>
65+
metis_tac []
66+
QED
67+
3168
(* -------------------------------------------------------------------------
3269
* Lemmas about Lams and Apps
3370
* ------------------------------------------------------------------------- *)

compiler/backend/languages/semantics/thunkLangScript.sml

+20
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,16 @@ Definition is_Lam_def[simp]:
569569
(is_Lam _ = F)
570570
End
571571

572+
Definition is_Delay_def[simp]:
573+
(is_Delay (Delay x) = T) ∧
574+
(is_Delay _ = F)
575+
End
576+
577+
Definition is_Box_def[simp]:
578+
(is_Box (Box x) = T) ∧
579+
(is_Box _ = F)
580+
End
581+
572582
Definition ok_bind_def[simp]:
573583
(ok_bind (Lam _ _) = T) ∧
574584
(ok_bind (Delay _) = T) ∧
@@ -583,6 +593,16 @@ Proof
583593
\\ gs []
584594
QED
585595

596+
Theorem FINITE_freevars:
597+
∀e. FINITE (freevars e)
598+
Proof
599+
Induct using freevars_ind
600+
\\ gs [freevars_def, MEM_MAP, PULL_EXISTS, FORALL_PROD]
601+
\\ irule FINITE_DIFF
602+
\\ simp [MEM_MAP, PULL_EXISTS, FORALL_PROD]
603+
\\ rw [] \\ last_x_assum $ dxrule_then irule
604+
QED
605+
586606
Theorem boundvars_Lams:
587607
∀vL e. boundvars (Lams vL e) = set vL ∪ boundvars e
588608
Proof

compiler/backend/languages/semantics/thunk_exp_ofScript.sml

+6
Original file line numberDiff line numberDiff line change
@@ -111,4 +111,10 @@ Definition is_Delay_def:
111111
(is_Delay _ = F)
112112
End
113113

114+
Theorem lets_for_APPEND:
115+
lets_for l m n (l1 ++ l2) e = lets_for l m n l1 (lets_for l m n l2 e)
116+
Proof
117+
Induct_on ‘l1’ \\ gvs [lets_for_def, FORALL_PROD]
118+
QED
119+
114120
val _ = export_theory ();

0 commit comments

Comments
 (0)