201
|
1 |
theory LamEx
|
|
2 |
imports Nominal QuotMain
|
|
3 |
begin
|
|
4 |
|
|
5 |
atom_decl name
|
|
6 |
|
|
7 |
nominal_datatype rlam =
|
|
8 |
rVar "name"
|
|
9 |
| rApp "rlam" "rlam"
|
|
10 |
| rLam "name" "rlam"
|
|
11 |
|
|
12 |
inductive
|
|
13 |
alpha :: "rlam \<Rightarrow> rlam \<Rightarrow> bool" ("_ \<approx> _" [100, 100] 100)
|
|
14 |
where
|
|
15 |
a1: "a = b \<Longrightarrow> (rVar a) \<approx> (rVar b)"
|
|
16 |
| a2: "\<lbrakk>t1 \<approx> t2; s1 \<approx> s2\<rbrakk> \<Longrightarrow> rApp t1 s1 \<approx> rApp t2 s2"
|
229
13f985a93dbc
fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
17 |
| a3: "\<lbrakk>t \<approx> ([(a,b)]\<bullet>s); a\<sharp>[b].s\<rbrakk> \<Longrightarrow> rLam a t \<approx> rLam b s"
|
201
|
18 |
|
|
19 |
quotient lam = rlam / alpha
|
|
20 |
sorry
|
|
21 |
|
203
|
22 |
print_quotients
|
|
23 |
|
229
13f985a93dbc
fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
24 |
quotient_def (for lam)
|
13f985a93dbc
fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
25 |
Var :: "name \<Rightarrow> lam"
|
13f985a93dbc
fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
26 |
where
|
13f985a93dbc
fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
27 |
"Var \<equiv> rVar"
|
13f985a93dbc
fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
28 |
|
13f985a93dbc
fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
29 |
quotient_def (for lam)
|
13f985a93dbc
fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
30 |
App :: "lam \<Rightarrow> lam \<Rightarrow> lam"
|
13f985a93dbc
fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
31 |
where
|
13f985a93dbc
fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
32 |
"App \<equiv> rApp"
|
13f985a93dbc
fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
33 |
|
13f985a93dbc
fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
34 |
quotient_def (for lam)
|
13f985a93dbc
fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
35 |
Lam :: "name \<Rightarrow> lam \<Rightarrow> lam"
|
13f985a93dbc
fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
36 |
where
|
13f985a93dbc
fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
37 |
"Lam \<equiv> rLam"
|
201
|
38 |
|
218
|
39 |
thm Var_def
|
|
40 |
thm App_def
|
|
41 |
thm Lam_def
|
|
42 |
|
229
13f985a93dbc
fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
43 |
(* definition of overloaded permutation function *)
|
13f985a93dbc
fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
44 |
(* for the lifted type lam *)
|
13f985a93dbc
fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
45 |
overloading
|
13f985a93dbc
fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
46 |
perm_lam \<equiv> "perm :: 'x prm \<Rightarrow> lam \<Rightarrow> lam" (unchecked)
|
13f985a93dbc
fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
47 |
begin
|
13f985a93dbc
fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
48 |
|
13f985a93dbc
fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
49 |
quotient_def (for lam)
|
13f985a93dbc
fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
50 |
perm_lam :: "'x prm \<Rightarrow> lam \<Rightarrow> lam"
|
13f985a93dbc
fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
51 |
where
|
13f985a93dbc
fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
52 |
"perm_lam \<equiv> (perm::'x prm \<Rightarrow> rlam \<Rightarrow> rlam)"
|
13f985a93dbc
fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
53 |
|
13f985a93dbc
fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
54 |
end
|
13f985a93dbc
fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
55 |
|
13f985a93dbc
fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
56 |
thm perm_lam_def
|
13f985a93dbc
fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
57 |
|
13f985a93dbc
fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
58 |
(* lemmas that need to lift *)
|
13f985a93dbc
fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
59 |
lemma
|
13f985a93dbc
fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
60 |
fixes pi::"'x prm"
|
13f985a93dbc
fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
61 |
shows "(pi\<bullet>Var a) = Var (pi\<bullet>a)"
|
13f985a93dbc
fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
62 |
sorry
|
13f985a93dbc
fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
63 |
|
13f985a93dbc
fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
64 |
lemma
|
13f985a93dbc
fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
65 |
fixes pi::"'x prm"
|
13f985a93dbc
fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
66 |
shows "(pi\<bullet>App t1 t2) = App (pi\<bullet>t1) (pi\<bullet>t2)"
|
13f985a93dbc
fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
67 |
sorry
|
13f985a93dbc
fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
68 |
|
13f985a93dbc
fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
69 |
lemma
|
13f985a93dbc
fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
70 |
fixes pi::"'x prm"
|
13f985a93dbc
fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
71 |
shows "(pi\<bullet>Lam a t) = Lam (pi\<bullet>a) (pi\<bullet>t)"
|
13f985a93dbc
fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
72 |
sorry
|
13f985a93dbc
fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
73 |
|
201
|
74 |
lemma real_alpha:
|
|
75 |
assumes "t = ([(a,b)]\<bullet>s)" "a\<sharp>s"
|
|
76 |
shows "Lam a t = Lam b s"
|
217
|
77 |
sorry
|
|
78 |
|
|
79 |
|
|
80 |
|
|
81 |
|
|
82 |
|
|
83 |
(* Construction Site code *)
|
|
84 |
|
229
13f985a93dbc
fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
85 |
lemma perm_rsp: "op = ===> alpha ===> alpha op \<bullet> op \<bullet>"
|
13f985a93dbc
fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
86 |
apply(auto)
|
13f985a93dbc
fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
87 |
(* this is propably true if some type conditions are imposed ;o) *)
|
13f985a93dbc
fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
88 |
sorry
|
13f985a93dbc
fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
89 |
|
13f985a93dbc
fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
90 |
lemma fresh_rsp: "op = ===> (alpha ===> op =) fresh fresh"
|
13f985a93dbc
fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
91 |
apply(auto)
|
13f985a93dbc
fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
92 |
(* this is probably only true if some type conditions are imposed *)
|
13f985a93dbc
fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
93 |
sorry
|
13f985a93dbc
fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
94 |
|
13f985a93dbc
fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
95 |
lemma rLam_rsp: "op = ===> (alpha ===> alpha) rLam rLam"
|
13f985a93dbc
fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
96 |
apply(auto)
|
13f985a93dbc
fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
97 |
apply(rule a3)
|
13f985a93dbc
fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
98 |
apply(rule_tac t="[(x,x)]\<bullet>y" and s="y" in subst)
|
13f985a93dbc
fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
99 |
apply(rule sym)
|
13f985a93dbc
fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
100 |
apply(rule trans)
|
13f985a93dbc
fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
101 |
apply(rule pt_name3)
|
13f985a93dbc
fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
102 |
apply(rule at_ds1[OF at_name_inst])
|
13f985a93dbc
fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
103 |
apply(simp add: pt_name1)
|
13f985a93dbc
fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
104 |
apply(assumption)
|
13f985a93dbc
fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
105 |
apply(simp add: abs_fresh)
|
13f985a93dbc
fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
106 |
done
|
217
|
107 |
|
|
108 |
ML {* val defs = @{thms Var_def App_def Lam_def} *}
|
|
109 |
ML {* val consts = [@{const_name "rVar"}, @{const_name "rApp"}, @{const_name "rLam"}]; *}
|
|
110 |
|
|
111 |
ML {* val rty = @{typ "rlam"} *}
|
|
112 |
ML {* val qty = @{typ "lam"} *}
|
|
113 |
ML {* val rel = @{term "alpha"} *}
|
225
|
114 |
ML {* val rel_eqv = (#equiv_thm o hd) (quotdata_lookup @{context}) *}
|
217
|
115 |
ML {* val rel_refl = @{thm EQUIV_REFL} OF [rel_eqv] *}
|
|
116 |
ML {* val quot = @{thm QUOTIENT_lam} *}
|
|
117 |
ML {* val rsp_thms = @{thms perm_rsp fresh_rsp rLam_rsp} @ @{thms ho_all_prs ho_ex_prs} *}
|
|
118 |
ML {* val trans2 = @{thm QUOT_TYPE_I_lam.R_trans2} *}
|
|
119 |
ML {* val reps_same = @{thm QUOT_TYPE_I_lam.REPS_same} *}
|
|
120 |
|
227
|
121 |
ML {*
|
|
122 |
fun lift_thm_lam lthy t =
|
|
123 |
lift_thm lthy consts rty qty rel rel_eqv rel_refl quot rsp_thms trans2 reps_same defs t
|
|
124 |
*}
|
|
125 |
ML {* lift_thm_lam @{context} @{thm a3} *}
|
221
|
126 |
|
217
|
127 |
local_setup {*
|
225
|
128 |
old_make_const_def @{binding lperm} @{term "perm :: ('a \<times> 'a) list \<Rightarrow> rlam \<Rightarrow> rlam"} NoSyn @{typ "rlam"} @{typ "lam"} #> snd
|
217
|
129 |
*}
|
|
130 |
|
221
|
131 |
ML {* val consts = @{const_name perm} :: consts *}
|
|
132 |
ML {* val defs = @{thms lperm_def} @ defs *}
|
227
|
133 |
ML {*
|
|
134 |
fun lift_thm_lam lthy t =
|
|
135 |
lift_thm lthy consts rty qty rel rel_eqv rel_refl quot rsp_thms trans2 reps_same defs t
|
|
136 |
*}
|
|
137 |
ML {* val t_b = lift_thm_lam @{context} @{thm a3} *}
|
|
138 |
ML {* val rr = @{thm eq_reflection} OF [hd (rev (add_lower_defs @{context} @{thms lperm_def}))] *}
|
225
|
139 |
lemma prod_fun_id: "prod_fun id id = id"
|
|
140 |
apply (simp add: prod_fun_def)
|
|
141 |
done
|
|
142 |
lemma map_id: "map id x = x"
|
|
143 |
apply (induct x)
|
|
144 |
apply (simp_all add: map.simps)
|
|
145 |
done
|
217
|
146 |
|
227
|
147 |
ML {* val rrr = repeat_eqsubst_thm @{context} @{thms prod_fun_id map_id} rr *}
|
|
148 |
ML {* val t_b' = eqsubst_thm @{context} [rrr] (atomize_thm t_b) *}
|
225
|
149 |
ML {* ObjectLogic.rulify t_b' *}
|
217
|
150 |
|
227
|
151 |
ML {* val t_u = MetaSimplifier.rewrite_rule @{thms fresh_def supp_def} @{thm a3} *}
|
|
152 |
ML {* Toplevel.program (fn () => lift_thm_lam @{context} t_u) *} (* Is not ture *)
|