author | kuncar |
Wed, 18 Apr 2012 17:04:03 +0200 | |
changeset 47545 | a2850a16e30f |
parent 47544 | e455cdaac479 |
child 47575 | b90cd7016d4f |
permissions | -rw-r--r-- |
47308 | 1 |
(* Title: HOL/Lifting.thy |
2 |
Author: Brian Huffman and Ondrej Kuncar |
|
3 |
Author: Cezary Kaliszyk and Christian Urban |
|
4 |
*) |
|
5 |
||
6 |
header {* Lifting package *} |
|
7 |
||
8 |
theory Lifting |
|
47325 | 9 |
imports Plain Equiv_Relations Transfer |
47308 | 10 |
keywords |
11 |
"print_quotmaps" "print_quotients" :: diag and |
|
12 |
"lift_definition" :: thy_goal and |
|
13 |
"setup_lifting" :: thy_decl |
|
14 |
uses |
|
15 |
("Tools/Lifting/lifting_info.ML") |
|
16 |
("Tools/Lifting/lifting_term.ML") |
|
17 |
("Tools/Lifting/lifting_def.ML") |
|
18 |
("Tools/Lifting/lifting_setup.ML") |
|
19 |
begin |
|
20 |
||
47325 | 21 |
subsection {* Function map *} |
47308 | 22 |
|
23 |
notation map_fun (infixr "--->" 55) |
|
24 |
||
25 |
lemma map_fun_id: |
|
26 |
"(id ---> id) = id" |
|
27 |
by (simp add: fun_eq_iff) |
|
28 |
||
29 |
subsection {* Quotient Predicate *} |
|
30 |
||
31 |
definition |
|
32 |
"Quotient R Abs Rep T \<longleftrightarrow> |
|
33 |
(\<forall>a. Abs (Rep a) = a) \<and> |
|
34 |
(\<forall>a. R (Rep a) (Rep a)) \<and> |
|
35 |
(\<forall>r s. R r s \<longleftrightarrow> R r r \<and> R s s \<and> Abs r = Abs s) \<and> |
|
36 |
T = (\<lambda>x y. R x x \<and> Abs x = y)" |
|
37 |
||
38 |
lemma QuotientI: |
|
39 |
assumes "\<And>a. Abs (Rep a) = a" |
|
40 |
and "\<And>a. R (Rep a) (Rep a)" |
|
41 |
and "\<And>r s. R r s \<longleftrightarrow> R r r \<and> R s s \<and> Abs r = Abs s" |
|
42 |
and "T = (\<lambda>x y. R x x \<and> Abs x = y)" |
|
43 |
shows "Quotient R Abs Rep T" |
|
44 |
using assms unfolding Quotient_def by blast |
|
45 |
||
47536 | 46 |
context |
47 |
fixes R Abs Rep T |
|
47308 | 48 |
assumes a: "Quotient R Abs Rep T" |
47536 | 49 |
begin |
50 |
||
51 |
lemma Quotient_abs_rep: "Abs (Rep a) = a" |
|
52 |
using a unfolding Quotient_def |
|
47308 | 53 |
by simp |
54 |
||
47536 | 55 |
lemma Quotient_rep_reflp: "R (Rep a) (Rep a)" |
56 |
using a unfolding Quotient_def |
|
47308 | 57 |
by blast |
58 |
||
59 |
lemma Quotient_rel: |
|
47536 | 60 |
"R r r \<and> R s s \<and> Abs r = Abs s \<longleftrightarrow> R r s" -- {* orientation does not loop on rewriting *} |
61 |
using a unfolding Quotient_def |
|
47308 | 62 |
by blast |
63 |
||
47536 | 64 |
lemma Quotient_cr_rel: "T = (\<lambda>x y. R x x \<and> Abs x = y)" |
47308 | 65 |
using a unfolding Quotient_def |
66 |
by blast |
|
67 |
||
47536 | 68 |
lemma Quotient_refl1: "R r s \<Longrightarrow> R r r" |
69 |
using a unfolding Quotient_def |
|
70 |
by fast |
|
71 |
||
72 |
lemma Quotient_refl2: "R r s \<Longrightarrow> R s s" |
|
73 |
using a unfolding Quotient_def |
|
74 |
by fast |
|
75 |
||
76 |
lemma Quotient_rel_rep: "R (Rep a) (Rep b) \<longleftrightarrow> a = b" |
|
77 |
using a unfolding Quotient_def |
|
78 |
by metis |
|
79 |
||
80 |
lemma Quotient_rep_abs: "R r r \<Longrightarrow> R (Rep (Abs r)) r" |
|
47308 | 81 |
using a unfolding Quotient_def |
82 |
by blast |
|
83 |
||
47536 | 84 |
lemma Quotient_rel_abs: "R r s \<Longrightarrow> Abs r = Abs s" |
85 |
using a unfolding Quotient_def |
|
86 |
by blast |
|
87 |
||
88 |
lemma Quotient_symp: "symp R" |
|
47308 | 89 |
using a unfolding Quotient_def using sympI by (metis (full_types)) |
90 |
||
47536 | 91 |
lemma Quotient_transp: "transp R" |
47308 | 92 |
using a unfolding Quotient_def using transpI by (metis (full_types)) |
93 |
||
47536 | 94 |
lemma Quotient_part_equivp: "part_equivp R" |
95 |
by (metis Quotient_rep_reflp Quotient_symp Quotient_transp part_equivpI) |
|
96 |
||
97 |
end |
|
47308 | 98 |
|
99 |
lemma identity_quotient: "Quotient (op =) id id (op =)" |
|
100 |
unfolding Quotient_def by simp |
|
101 |
||
102 |
lemma Quotient_alt_def: |
|
103 |
"Quotient R Abs Rep T \<longleftrightarrow> |
|
104 |
(\<forall>a b. T a b \<longrightarrow> Abs a = b) \<and> |
|
105 |
(\<forall>b. T (Rep b) b) \<and> |
|
106 |
(\<forall>x y. R x y \<longleftrightarrow> T x (Abs x) \<and> T y (Abs y) \<and> Abs x = Abs y)" |
|
107 |
apply safe |
|
108 |
apply (simp (no_asm_use) only: Quotient_def, fast) |
|
109 |
apply (simp (no_asm_use) only: Quotient_def, fast) |
|
110 |
apply (simp (no_asm_use) only: Quotient_def, fast) |
|
111 |
apply (simp (no_asm_use) only: Quotient_def, fast) |
|
112 |
apply (simp (no_asm_use) only: Quotient_def, fast) |
|
113 |
apply (simp (no_asm_use) only: Quotient_def, fast) |
|
114 |
apply (rule QuotientI) |
|
115 |
apply simp |
|
116 |
apply metis |
|
117 |
apply simp |
|
118 |
apply (rule ext, rule ext, metis) |
|
119 |
done |
|
120 |
||
121 |
lemma Quotient_alt_def2: |
|
122 |
"Quotient R Abs Rep T \<longleftrightarrow> |
|
123 |
(\<forall>a b. T a b \<longrightarrow> Abs a = b) \<and> |
|
124 |
(\<forall>b. T (Rep b) b) \<and> |
|
125 |
(\<forall>x y. R x y \<longleftrightarrow> T x (Abs y) \<and> T y (Abs x))" |
|
126 |
unfolding Quotient_alt_def by (safe, metis+) |
|
127 |
||
128 |
lemma fun_quotient: |
|
129 |
assumes 1: "Quotient R1 abs1 rep1 T1" |
|
130 |
assumes 2: "Quotient R2 abs2 rep2 T2" |
|
131 |
shows "Quotient (R1 ===> R2) (rep1 ---> abs2) (abs1 ---> rep2) (T1 ===> T2)" |
|
132 |
using assms unfolding Quotient_alt_def2 |
|
133 |
unfolding fun_rel_def fun_eq_iff map_fun_apply |
|
134 |
by (safe, metis+) |
|
135 |
||
136 |
lemma apply_rsp: |
|
137 |
fixes f g::"'a \<Rightarrow> 'c" |
|
138 |
assumes q: "Quotient R1 Abs1 Rep1 T1" |
|
139 |
and a: "(R1 ===> R2) f g" "R1 x y" |
|
140 |
shows "R2 (f x) (g y)" |
|
141 |
using a by (auto elim: fun_relE) |
|
142 |
||
143 |
lemma apply_rsp': |
|
144 |
assumes a: "(R1 ===> R2) f g" "R1 x y" |
|
145 |
shows "R2 (f x) (g y)" |
|
146 |
using a by (auto elim: fun_relE) |
|
147 |
||
148 |
lemma apply_rsp'': |
|
149 |
assumes "Quotient R Abs Rep T" |
|
150 |
and "(R ===> S) f f" |
|
151 |
shows "S (f (Rep x)) (f (Rep x))" |
|
152 |
proof - |
|
153 |
from assms(1) have "R (Rep x) (Rep x)" by (rule Quotient_rep_reflp) |
|
154 |
then show ?thesis using assms(2) by (auto intro: apply_rsp') |
|
155 |
qed |
|
156 |
||
157 |
subsection {* Quotient composition *} |
|
158 |
||
159 |
lemma Quotient_compose: |
|
160 |
assumes 1: "Quotient R1 Abs1 Rep1 T1" |
|
161 |
assumes 2: "Quotient R2 Abs2 Rep2 T2" |
|
162 |
shows "Quotient (T1 OO R2 OO conversep T1) (Abs2 \<circ> Abs1) (Rep1 \<circ> Rep2) (T1 OO T2)" |
|
163 |
proof - |
|
164 |
from 1 have Abs1: "\<And>a b. T1 a b \<Longrightarrow> Abs1 a = b" |
|
165 |
unfolding Quotient_alt_def by simp |
|
166 |
from 1 have Rep1: "\<And>b. T1 (Rep1 b) b" |
|
167 |
unfolding Quotient_alt_def by simp |
|
168 |
from 2 have Abs2: "\<And>a b. T2 a b \<Longrightarrow> Abs2 a = b" |
|
169 |
unfolding Quotient_alt_def by simp |
|
170 |
from 2 have Rep2: "\<And>b. T2 (Rep2 b) b" |
|
171 |
unfolding Quotient_alt_def by simp |
|
172 |
from 2 have R2: |
|
173 |
"\<And>x y. R2 x y \<longleftrightarrow> T2 x (Abs2 x) \<and> T2 y (Abs2 y) \<and> Abs2 x = Abs2 y" |
|
174 |
unfolding Quotient_alt_def by simp |
|
175 |
show ?thesis |
|
176 |
unfolding Quotient_alt_def |
|
177 |
apply simp |
|
178 |
apply safe |
|
179 |
apply (drule Abs1, simp) |
|
180 |
apply (erule Abs2) |
|
47435 | 181 |
apply (rule relcomppI) |
47308 | 182 |
apply (rule Rep1) |
183 |
apply (rule Rep2) |
|
47435 | 184 |
apply (rule relcomppI, assumption) |
47308 | 185 |
apply (drule Abs1, simp) |
186 |
apply (clarsimp simp add: R2) |
|
47435 | 187 |
apply (rule relcomppI, assumption) |
47308 | 188 |
apply (drule Abs1, simp)+ |
189 |
apply (clarsimp simp add: R2) |
|
190 |
apply (drule Abs1, simp)+ |
|
191 |
apply (clarsimp simp add: R2) |
|
47435 | 192 |
apply (rule relcomppI, assumption) |
193 |
apply (rule relcomppI [rotated]) |
|
47308 | 194 |
apply (erule conversepI) |
195 |
apply (drule Abs1, simp)+ |
|
196 |
apply (simp add: R2) |
|
197 |
done |
|
198 |
qed |
|
199 |
||
47521
69f95ac85c3d
tuned the setup of lifting; generate transfer rules for typedef and Quotient thms
kuncar
parents:
47501
diff
changeset
|
200 |
lemma equivp_reflp2: |
69f95ac85c3d
tuned the setup of lifting; generate transfer rules for typedef and Quotient thms
kuncar
parents:
47501
diff
changeset
|
201 |
"equivp R \<Longrightarrow> reflp R" |
69f95ac85c3d
tuned the setup of lifting; generate transfer rules for typedef and Quotient thms
kuncar
parents:
47501
diff
changeset
|
202 |
by (erule equivpE) |
69f95ac85c3d
tuned the setup of lifting; generate transfer rules for typedef and Quotient thms
kuncar
parents:
47501
diff
changeset
|
203 |
|
47544 | 204 |
subsection {* Respects predicate *} |
205 |
||
206 |
definition Respects :: "('a \<Rightarrow> 'a \<Rightarrow> bool) \<Rightarrow> 'a set" |
|
207 |
where "Respects R = {x. R x x}" |
|
208 |
||
209 |
lemma in_respects: "x \<in> Respects R \<longleftrightarrow> R x x" |
|
210 |
unfolding Respects_def by simp |
|
211 |
||
47308 | 212 |
subsection {* Invariant *} |
213 |
||
214 |
definition invariant :: "('a \<Rightarrow> bool) \<Rightarrow> 'a \<Rightarrow> 'a \<Rightarrow> bool" |
|
215 |
where "invariant R = (\<lambda>x y. R x \<and> x = y)" |
|
216 |
||
217 |
lemma invariant_to_eq: |
|
218 |
assumes "invariant P x y" |
|
219 |
shows "x = y" |
|
220 |
using assms by (simp add: invariant_def) |
|
221 |
||
222 |
lemma fun_rel_eq_invariant: |
|
223 |
shows "((invariant R) ===> S) = (\<lambda>f g. \<forall>x. R x \<longrightarrow> S (f x) (g x))" |
|
224 |
by (auto simp add: invariant_def fun_rel_def) |
|
225 |
||
226 |
lemma invariant_same_args: |
|
227 |
shows "invariant P x x \<equiv> P x" |
|
228 |
using assms by (auto simp add: invariant_def) |
|
229 |
||
47361
87c0eaf04bad
support non-open typedefs; define cr_rel in terms of a rep function for typedefs
kuncar
parents:
47354
diff
changeset
|
230 |
lemma UNIV_typedef_to_Quotient: |
47308 | 231 |
assumes "type_definition Rep Abs UNIV" |
47361
87c0eaf04bad
support non-open typedefs; define cr_rel in terms of a rep function for typedefs
kuncar
parents:
47354
diff
changeset
|
232 |
and T_def: "T \<equiv> (\<lambda>x y. x = Rep y)" |
47308 | 233 |
shows "Quotient (op =) Abs Rep T" |
234 |
proof - |
|
235 |
interpret type_definition Rep Abs UNIV by fact |
|
47361
87c0eaf04bad
support non-open typedefs; define cr_rel in terms of a rep function for typedefs
kuncar
parents:
47354
diff
changeset
|
236 |
from Abs_inject Rep_inverse Abs_inverse T_def show ?thesis |
87c0eaf04bad
support non-open typedefs; define cr_rel in terms of a rep function for typedefs
kuncar
parents:
47354
diff
changeset
|
237 |
by (fastforce intro!: QuotientI fun_eq_iff) |
47308 | 238 |
qed |
239 |
||
47361
87c0eaf04bad
support non-open typedefs; define cr_rel in terms of a rep function for typedefs
kuncar
parents:
47354
diff
changeset
|
240 |
lemma UNIV_typedef_to_equivp: |
47308 | 241 |
fixes Abs :: "'a \<Rightarrow> 'b" |
242 |
and Rep :: "'b \<Rightarrow> 'a" |
|
243 |
assumes "type_definition Rep Abs (UNIV::'a set)" |
|
244 |
shows "equivp (op=::'a\<Rightarrow>'a\<Rightarrow>bool)" |
|
245 |
by (rule identity_equivp) |
|
246 |
||
47354 | 247 |
lemma typedef_to_Quotient: |
47361
87c0eaf04bad
support non-open typedefs; define cr_rel in terms of a rep function for typedefs
kuncar
parents:
47354
diff
changeset
|
248 |
assumes "type_definition Rep Abs S" |
87c0eaf04bad
support non-open typedefs; define cr_rel in terms of a rep function for typedefs
kuncar
parents:
47354
diff
changeset
|
249 |
and T_def: "T \<equiv> (\<lambda>x y. x = Rep y)" |
47501 | 250 |
shows "Quotient (invariant (\<lambda>x. x \<in> S)) Abs Rep T" |
47361
87c0eaf04bad
support non-open typedefs; define cr_rel in terms of a rep function for typedefs
kuncar
parents:
47354
diff
changeset
|
251 |
proof - |
87c0eaf04bad
support non-open typedefs; define cr_rel in terms of a rep function for typedefs
kuncar
parents:
47354
diff
changeset
|
252 |
interpret type_definition Rep Abs S by fact |
87c0eaf04bad
support non-open typedefs; define cr_rel in terms of a rep function for typedefs
kuncar
parents:
47354
diff
changeset
|
253 |
from Rep Abs_inject Rep_inverse Abs_inverse T_def show ?thesis |
87c0eaf04bad
support non-open typedefs; define cr_rel in terms of a rep function for typedefs
kuncar
parents:
47354
diff
changeset
|
254 |
by (auto intro!: QuotientI simp: invariant_def fun_eq_iff) |
87c0eaf04bad
support non-open typedefs; define cr_rel in terms of a rep function for typedefs
kuncar
parents:
47354
diff
changeset
|
255 |
qed |
87c0eaf04bad
support non-open typedefs; define cr_rel in terms of a rep function for typedefs
kuncar
parents:
47354
diff
changeset
|
256 |
|
87c0eaf04bad
support non-open typedefs; define cr_rel in terms of a rep function for typedefs
kuncar
parents:
47354
diff
changeset
|
257 |
lemma typedef_to_part_equivp: |
87c0eaf04bad
support non-open typedefs; define cr_rel in terms of a rep function for typedefs
kuncar
parents:
47354
diff
changeset
|
258 |
assumes "type_definition Rep Abs S" |
47501 | 259 |
shows "part_equivp (invariant (\<lambda>x. x \<in> S))" |
47361
87c0eaf04bad
support non-open typedefs; define cr_rel in terms of a rep function for typedefs
kuncar
parents:
47354
diff
changeset
|
260 |
proof (intro part_equivpI) |
87c0eaf04bad
support non-open typedefs; define cr_rel in terms of a rep function for typedefs
kuncar
parents:
47354
diff
changeset
|
261 |
interpret type_definition Rep Abs S by fact |
47501 | 262 |
show "\<exists>x. invariant (\<lambda>x. x \<in> S) x x" using Rep by (auto simp: invariant_def) |
47361
87c0eaf04bad
support non-open typedefs; define cr_rel in terms of a rep function for typedefs
kuncar
parents:
47354
diff
changeset
|
263 |
next |
47501 | 264 |
show "symp (invariant (\<lambda>x. x \<in> S))" by (auto intro: sympI simp: invariant_def) |
47361
87c0eaf04bad
support non-open typedefs; define cr_rel in terms of a rep function for typedefs
kuncar
parents:
47354
diff
changeset
|
265 |
next |
47501 | 266 |
show "transp (invariant (\<lambda>x. x \<in> S))" by (auto intro: transpI simp: invariant_def) |
47361
87c0eaf04bad
support non-open typedefs; define cr_rel in terms of a rep function for typedefs
kuncar
parents:
47354
diff
changeset
|
267 |
qed |
87c0eaf04bad
support non-open typedefs; define cr_rel in terms of a rep function for typedefs
kuncar
parents:
47354
diff
changeset
|
268 |
|
87c0eaf04bad
support non-open typedefs; define cr_rel in terms of a rep function for typedefs
kuncar
parents:
47354
diff
changeset
|
269 |
lemma open_typedef_to_Quotient: |
47308 | 270 |
assumes "type_definition Rep Abs {x. P x}" |
47354 | 271 |
and T_def: "T \<equiv> (\<lambda>x y. x = Rep y)" |
47308 | 272 |
shows "Quotient (invariant P) Abs Rep T" |
273 |
proof - |
|
274 |
interpret type_definition Rep Abs "{x. P x}" by fact |
|
47354 | 275 |
from Rep Abs_inject Rep_inverse Abs_inverse T_def show ?thesis |
276 |
by (auto intro!: QuotientI simp: invariant_def fun_eq_iff) |
|
47308 | 277 |
qed |
278 |
||
47361
87c0eaf04bad
support non-open typedefs; define cr_rel in terms of a rep function for typedefs
kuncar
parents:
47354
diff
changeset
|
279 |
lemma open_typedef_to_part_equivp: |
47308 | 280 |
assumes "type_definition Rep Abs {x. P x}" |
281 |
shows "part_equivp (invariant P)" |
|
282 |
proof (intro part_equivpI) |
|
283 |
interpret type_definition Rep Abs "{x. P x}" by fact |
|
284 |
show "\<exists>x. invariant P x x" using Rep by (auto simp: invariant_def) |
|
285 |
next |
|
286 |
show "symp (invariant P)" by (auto intro: sympI simp: invariant_def) |
|
287 |
next |
|
288 |
show "transp (invariant P)" by (auto intro: transpI simp: invariant_def) |
|
289 |
qed |
|
290 |
||
47376 | 291 |
text {* Generating transfer rules for quotients. *} |
292 |
||
47537 | 293 |
context |
294 |
fixes R Abs Rep T |
|
295 |
assumes 1: "Quotient R Abs Rep T" |
|
296 |
begin |
|
47376 | 297 |
|
47537 | 298 |
lemma Quotient_right_unique: "right_unique T" |
299 |
using 1 unfolding Quotient_alt_def right_unique_def by metis |
|
300 |
||
301 |
lemma Quotient_right_total: "right_total T" |
|
302 |
using 1 unfolding Quotient_alt_def right_total_def by metis |
|
303 |
||
304 |
lemma Quotient_rel_eq_transfer: "(T ===> T ===> op =) R (op =)" |
|
305 |
using 1 unfolding Quotient_alt_def fun_rel_def by simp |
|
47376 | 306 |
|
47538 | 307 |
lemma Quotient_abs_induct: |
308 |
assumes "\<And>y. R y y \<Longrightarrow> P (Abs y)" shows "P x" |
|
309 |
using 1 assms unfolding Quotient_def by metis |
|
310 |
||
47544 | 311 |
lemma Quotient_All_transfer: |
312 |
"((T ===> op =) ===> op =) (Ball (Respects R)) All" |
|
313 |
unfolding fun_rel_def Respects_def Quotient_cr_rel [OF 1] |
|
314 |
by (auto, metis Quotient_abs_induct) |
|
315 |
||
316 |
lemma Quotient_Ex_transfer: |
|
317 |
"((T ===> op =) ===> op =) (Bex (Respects R)) Ex" |
|
318 |
unfolding fun_rel_def Respects_def Quotient_cr_rel [OF 1] |
|
319 |
by (auto, metis Quotient_rep_reflp [OF 1] Quotient_abs_rep [OF 1]) |
|
320 |
||
321 |
lemma Quotient_forall_transfer: |
|
322 |
"((T ===> op =) ===> op =) (transfer_bforall (\<lambda>x. R x x)) transfer_forall" |
|
323 |
using Quotient_All_transfer |
|
324 |
unfolding transfer_forall_def transfer_bforall_def |
|
325 |
Ball_def [abs_def] in_respects . |
|
326 |
||
47537 | 327 |
end |
328 |
||
329 |
text {* Generating transfer rules for total quotients. *} |
|
47376 | 330 |
|
47537 | 331 |
context |
332 |
fixes R Abs Rep T |
|
333 |
assumes 1: "Quotient R Abs Rep T" and 2: "reflp R" |
|
334 |
begin |
|
47376 | 335 |
|
47537 | 336 |
lemma Quotient_bi_total: "bi_total T" |
337 |
using 1 2 unfolding Quotient_alt_def bi_total_def reflp_def by auto |
|
338 |
||
339 |
lemma Quotient_id_abs_transfer: "(op = ===> T) (\<lambda>x. x) Abs" |
|
340 |
using 1 2 unfolding Quotient_alt_def reflp_def fun_rel_def by simp |
|
341 |
||
342 |
end |
|
47376 | 343 |
|
47368
4c522dff1f4d
add lemmas for generating transfer rules for typedefs
huffman
parents:
47354
diff
changeset
|
344 |
text {* Generating transfer rules for a type defined with @{text "typedef"}. *} |
4c522dff1f4d
add lemmas for generating transfer rules for typedefs
huffman
parents:
47354
diff
changeset
|
345 |
|
47534
06cc372a80ed
use context block to organize typedef lifting theorems
huffman
parents:
47521
diff
changeset
|
346 |
context |
06cc372a80ed
use context block to organize typedef lifting theorems
huffman
parents:
47521
diff
changeset
|
347 |
fixes Rep Abs A T |
47368
4c522dff1f4d
add lemmas for generating transfer rules for typedefs
huffman
parents:
47354
diff
changeset
|
348 |
assumes type: "type_definition Rep Abs A" |
47534
06cc372a80ed
use context block to organize typedef lifting theorems
huffman
parents:
47521
diff
changeset
|
349 |
assumes T_def: "T \<equiv> (\<lambda>(x::'a) (y::'b). x = Rep y)" |
06cc372a80ed
use context block to organize typedef lifting theorems
huffman
parents:
47521
diff
changeset
|
350 |
begin |
06cc372a80ed
use context block to organize typedef lifting theorems
huffman
parents:
47521
diff
changeset
|
351 |
|
06cc372a80ed
use context block to organize typedef lifting theorems
huffman
parents:
47521
diff
changeset
|
352 |
lemma typedef_bi_unique: "bi_unique T" |
47368
4c522dff1f4d
add lemmas for generating transfer rules for typedefs
huffman
parents:
47354
diff
changeset
|
353 |
unfolding bi_unique_def T_def |
4c522dff1f4d
add lemmas for generating transfer rules for typedefs
huffman
parents:
47354
diff
changeset
|
354 |
by (simp add: type_definition.Rep_inject [OF type]) |
4c522dff1f4d
add lemmas for generating transfer rules for typedefs
huffman
parents:
47354
diff
changeset
|
355 |
|
47535
0f94b02fda1c
lifting_setup generates transfer rule for rep of typedefs
huffman
parents:
47534
diff
changeset
|
356 |
lemma typedef_rep_transfer: "(T ===> op =) (\<lambda>x. x) Rep" |
0f94b02fda1c
lifting_setup generates transfer rule for rep of typedefs
huffman
parents:
47534
diff
changeset
|
357 |
unfolding fun_rel_def T_def by simp |
0f94b02fda1c
lifting_setup generates transfer rule for rep of typedefs
huffman
parents:
47534
diff
changeset
|
358 |
|
47545 | 359 |
lemma typedef_All_transfer: "((T ===> op =) ===> op =) (Ball A) All" |
47534
06cc372a80ed
use context block to organize typedef lifting theorems
huffman
parents:
47521
diff
changeset
|
360 |
unfolding T_def fun_rel_def |
06cc372a80ed
use context block to organize typedef lifting theorems
huffman
parents:
47521
diff
changeset
|
361 |
by (metis type_definition.Rep [OF type] |
06cc372a80ed
use context block to organize typedef lifting theorems
huffman
parents:
47521
diff
changeset
|
362 |
type_definition.Abs_inverse [OF type]) |
06cc372a80ed
use context block to organize typedef lifting theorems
huffman
parents:
47521
diff
changeset
|
363 |
|
47545 | 364 |
lemma typedef_Ex_transfer: "((T ===> op =) ===> op =) (Bex A) Ex" |
365 |
unfolding T_def fun_rel_def |
|
366 |
by (metis type_definition.Rep [OF type] |
|
367 |
type_definition.Abs_inverse [OF type]) |
|
368 |
||
369 |
lemma typedef_forall_transfer: |
|
47534
06cc372a80ed
use context block to organize typedef lifting theorems
huffman
parents:
47521
diff
changeset
|
370 |
"((T ===> op =) ===> op =) |
06cc372a80ed
use context block to organize typedef lifting theorems
huffman
parents:
47521
diff
changeset
|
371 |
(transfer_bforall (\<lambda>x. x \<in> A)) transfer_forall" |
06cc372a80ed
use context block to organize typedef lifting theorems
huffman
parents:
47521
diff
changeset
|
372 |
unfolding transfer_bforall_def transfer_forall_def Ball_def [symmetric] |
47545 | 373 |
by (rule typedef_All_transfer) |
47534
06cc372a80ed
use context block to organize typedef lifting theorems
huffman
parents:
47521
diff
changeset
|
374 |
|
06cc372a80ed
use context block to organize typedef lifting theorems
huffman
parents:
47521
diff
changeset
|
375 |
end |
06cc372a80ed
use context block to organize typedef lifting theorems
huffman
parents:
47521
diff
changeset
|
376 |
|
47368
4c522dff1f4d
add lemmas for generating transfer rules for typedefs
huffman
parents:
47354
diff
changeset
|
377 |
text {* Generating the correspondence rule for a constant defined with |
4c522dff1f4d
add lemmas for generating transfer rules for typedefs
huffman
parents:
47354
diff
changeset
|
378 |
@{text "lift_definition"}. *} |
4c522dff1f4d
add lemmas for generating transfer rules for typedefs
huffman
parents:
47354
diff
changeset
|
379 |
|
47351 | 380 |
lemma Quotient_to_transfer: |
381 |
assumes "Quotient R Abs Rep T" and "R c c" and "c' \<equiv> Abs c" |
|
382 |
shows "T c c'" |
|
383 |
using assms by (auto dest: Quotient_cr_rel) |
|
384 |
||
47308 | 385 |
subsection {* ML setup *} |
386 |
||
387 |
text {* Auxiliary data for the lifting package *} |
|
388 |
||
389 |
use "Tools/Lifting/lifting_info.ML" |
|
390 |
setup Lifting_Info.setup |
|
391 |
||
392 |
declare [[map "fun" = (fun_rel, fun_quotient)]] |
|
393 |
||
394 |
use "Tools/Lifting/lifting_term.ML" |
|
395 |
||
396 |
use "Tools/Lifting/lifting_def.ML" |
|
397 |
||
398 |
use "Tools/Lifting/lifting_setup.ML" |
|
399 |
||
400 |
hide_const (open) invariant |
|
401 |
||
402 |
end |