1 header {* CPS transformation of Danvy and Filinski *} |
|
2 theory CPS3_DanvyFilinski imports Lt begin |
|
3 |
|
4 nominal_primrec |
|
5 CPS1 :: "lt \<Rightarrow> (lt \<Rightarrow> lt) \<Rightarrow> lt" ("_*_" [100,100] 100) |
|
6 and |
|
7 CPS2 :: "lt \<Rightarrow> lt \<Rightarrow> lt" ("_^_" [100,100] 100) |
|
8 where |
|
9 "eqvt k \<Longrightarrow> (x~)*k = k (x~)" |
|
10 | "eqvt k \<Longrightarrow> (M$$N)*k = M*(%m. (N*(%n.((m $$ n) $$ (Lam c (k (c~)))))))" |
|
11 | "eqvt k \<Longrightarrow> atom c \<sharp> (x, M) \<Longrightarrow> (Lam x M)*k = k (Lam x (Lam c (M^(c~))))" |
|
12 | "\<not>eqvt k \<Longrightarrow> (CPS1 t k) = t" |
|
13 | "(x~)^l = l $$ (x~)" |
|
14 | "(M$$N)^l = M*(%m. (N*(%n.((m $$ n) $$ l))))" |
|
15 | "atom c \<sharp> (x, M) \<Longrightarrow> (Lam x M)^l = l $$ (Lam x (Lam c (M^(c~))))" |
|
16 apply (simp add: eqvt_def CPS1_CPS2_graph_aux_def) |
|
17 using [[simproc del: alpha_lst]] |
|
18 apply auto |
|
19 apply (case_tac x) |
|
20 apply (case_tac a) |
|
21 apply (case_tac "eqvt b") |
|
22 apply (rule_tac y="aa" in lt.strong_exhaust) |
|
23 apply auto[4] |
|
24 apply (rule_tac x="(name, lt)" and ?'a="name" in obtain_fresh) |
|
25 apply (simp add: fresh_at_base Abs1_eq_iff) |
|
26 apply (case_tac b) |
|
27 apply (rule_tac y="a" in lt.strong_exhaust) |
|
28 apply auto[3] |
|
29 apply blast+ |
|
30 apply (rule_tac x="(name, lt)" and ?'a="name" in obtain_fresh) |
|
31 apply (simp add: fresh_at_base Abs1_eq_iff) |
|
32 --"-" |
|
33 apply (subgoal_tac "Lam c (ka (c~)) = Lam ca (ka (ca~))") |
|
34 apply (simp only:) |
|
35 apply (simp add: Abs1_eq_iff) |
|
36 apply (case_tac "c=ca") |
|
37 apply simp_all[2] |
|
38 apply rule |
|
39 apply (perm_simp) |
|
40 apply (simp add: eqvt_def) |
|
41 apply (simp add: fresh_def) |
|
42 apply (rule contra_subsetD[OF supp_fun_app]) |
|
43 back |
|
44 apply (simp add: supp_fun_eqvt lt.supp supp_at_base) |
|
45 oops |
|
46 |
|
47 |
|
48 end |
|
49 |
|
50 |
|
51 |
|