author | haftmann |
Thu, 16 Sep 2010 17:52:00 +0200 | |
changeset 39481 | f15514acc942 |
parent 37099 | 3636b08cbf51 |
child 39974 | b525988432e9 |
permissions | -rw-r--r-- |
2640 | 1 |
(* Title: HOLCF/Lift.thy |
12026 | 2 |
Author: Olaf Mueller |
2640 | 3 |
*) |
4 |
||
12338
de0f4a63baa5
renamed class "term" to "type" (actually "HOL.type");
wenzelm
parents:
12026
diff
changeset
|
5 |
header {* Lifting types of class type to flat pcpo's *} |
12026 | 6 |
|
15577 | 7 |
theory Lift |
27311 | 8 |
imports Discrete Up Countable |
15577 | 9 |
begin |
12026 | 10 |
|
36452 | 11 |
default_sort type |
12026 | 12 |
|
16748 | 13 |
pcpodef 'a lift = "UNIV :: 'a discr u set" |
29063
7619f0561cd7
pcpodef package: state two goals, instead of encoded conjunction;
wenzelm
parents:
27311
diff
changeset
|
14 |
by simp_all |
12026 | 15 |
|
25827
c2adeb1bae5c
new instance proofs for classes finite_po, chfin, flat
huffman
parents:
25723
diff
changeset
|
16 |
instance lift :: (finite) finite_po |
c2adeb1bae5c
new instance proofs for classes finite_po, chfin, flat
huffman
parents:
25723
diff
changeset
|
17 |
by (rule typedef_finite_po [OF type_definition_lift]) |
c2adeb1bae5c
new instance proofs for classes finite_po, chfin, flat
huffman
parents:
25723
diff
changeset
|
18 |
|
16748 | 19 |
lemmas inst_lift_pcpo = Abs_lift_strict [symmetric] |
12026 | 20 |
|
25131
2c8caac48ade
modernized specifications ('definition', 'abbreviation', 'notation');
wenzelm
parents:
19764
diff
changeset
|
21 |
definition |
2c8caac48ade
modernized specifications ('definition', 'abbreviation', 'notation');
wenzelm
parents:
19764
diff
changeset
|
22 |
Def :: "'a \<Rightarrow> 'a lift" where |
2c8caac48ade
modernized specifications ('definition', 'abbreviation', 'notation');
wenzelm
parents:
19764
diff
changeset
|
23 |
"Def x = Abs_lift (up\<cdot>(Discr x))" |
12026 | 24 |
|
25 |
subsection {* Lift as a datatype *} |
|
26 |
||
16748 | 27 |
lemma lift_induct: "\<lbrakk>P \<bottom>; \<And>x. P (Def x)\<rbrakk> \<Longrightarrow> P y" |
28 |
apply (induct y) |
|
16755
fd02f9d06e43
renamed upE1 to upE; added simp rule cont2cont_flift1
huffman
parents:
16749
diff
changeset
|
29 |
apply (rule_tac p=y in upE) |
16748 | 30 |
apply (simp add: Abs_lift_strict) |
31 |
apply (case_tac x) |
|
32 |
apply (simp add: Def_def) |
|
33 |
done |
|
12026 | 34 |
|
27104
791607529f6d
rep_datatype command now takes list of constructors as input arguments
haftmann
parents:
26963
diff
changeset
|
35 |
rep_datatype "\<bottom>\<Colon>'a lift" Def |
791607529f6d
rep_datatype command now takes list of constructors as input arguments
haftmann
parents:
26963
diff
changeset
|
36 |
by (erule lift_induct) (simp_all add: Def_def Abs_lift_inject lift_def inst_lift_pcpo) |
12026 | 37 |
|
27104
791607529f6d
rep_datatype command now takes list of constructors as input arguments
haftmann
parents:
26963
diff
changeset
|
38 |
lemmas lift_distinct1 = lift.distinct(1) |
791607529f6d
rep_datatype command now takes list of constructors as input arguments
haftmann
parents:
26963
diff
changeset
|
39 |
lemmas lift_distinct2 = lift.distinct(2) |
791607529f6d
rep_datatype command now takes list of constructors as input arguments
haftmann
parents:
26963
diff
changeset
|
40 |
lemmas Def_not_UU = lift.distinct(2) |
791607529f6d
rep_datatype command now takes list of constructors as input arguments
haftmann
parents:
26963
diff
changeset
|
41 |
lemmas Def_inject = lift.inject |
12026 | 42 |
|
43 |
||
16748 | 44 |
text {* @{term UU} and @{term Def} *} |
12026 | 45 |
|
16748 | 46 |
lemma Lift_exhaust: "x = \<bottom> \<or> (\<exists>y. x = Def y)" |
12026 | 47 |
by (induct x) simp_all |
48 |
||
16748 | 49 |
lemma Lift_cases: "\<lbrakk>x = \<bottom> \<Longrightarrow> P; \<exists>a. x = Def a \<Longrightarrow> P\<rbrakk> \<Longrightarrow> P" |
12026 | 50 |
by (insert Lift_exhaust) blast |
51 |
||
16748 | 52 |
lemma not_Undef_is_Def: "(x \<noteq> \<bottom>) = (\<exists>y. x = Def y)" |
12026 | 53 |
by (cases x) simp_all |
54 |
||
16630
83bf468b1dc7
added theorem lift_definedE; moved cont_if to Cont.thy
huffman
parents:
16555
diff
changeset
|
55 |
lemma lift_definedE: "\<lbrakk>x \<noteq> \<bottom>; \<And>a. x = Def a \<Longrightarrow> R\<rbrakk> \<Longrightarrow> R" |
83bf468b1dc7
added theorem lift_definedE; moved cont_if to Cont.thy
huffman
parents:
16555
diff
changeset
|
56 |
by (cases x) simp_all |
83bf468b1dc7
added theorem lift_definedE; moved cont_if to Cont.thy
huffman
parents:
16555
diff
changeset
|
57 |
|
12026 | 58 |
text {* |
30607
c3d1590debd8
eliminated global SIMPSET, CLASET etc. -- refer to explicit context;
wenzelm
parents:
29138
diff
changeset
|
59 |
For @{term "x ~= UU"} in assumptions @{text defined} replaces @{text |
12026 | 60 |
x} by @{text "Def a"} in conclusion. *} |
61 |
||
30607
c3d1590debd8
eliminated global SIMPSET, CLASET etc. -- refer to explicit context;
wenzelm
parents:
29138
diff
changeset
|
62 |
method_setup defined = {* |
c3d1590debd8
eliminated global SIMPSET, CLASET etc. -- refer to explicit context;
wenzelm
parents:
29138
diff
changeset
|
63 |
Scan.succeed (fn ctxt => SIMPLE_METHOD' |
32149
ef59550a55d3
renamed simpset_of to global_simpset_of, and local_simpset_of to simpset_of -- same for claset and clasimpset;
wenzelm
parents:
31076
diff
changeset
|
64 |
(etac @{thm lift_definedE} THEN' asm_simp_tac (simpset_of ctxt))) |
30607
c3d1590debd8
eliminated global SIMPSET, CLASET etc. -- refer to explicit context;
wenzelm
parents:
29138
diff
changeset
|
65 |
*} "" |
12026 | 66 |
|
16748 | 67 |
lemma DefE: "Def x = \<bottom> \<Longrightarrow> R" |
68 |
by simp |
|
12026 | 69 |
|
16748 | 70 |
lemma DefE2: "\<lbrakk>x = Def s; x = \<bottom>\<rbrakk> \<Longrightarrow> R" |
12026 | 71 |
by simp |
72 |
||
31076
99fe356cbbc2
rename constant sq_le to below; rename class sq_ord to below; less->below in many lemma names
huffman
parents:
30607
diff
changeset
|
73 |
lemma Def_below_Def: "Def x \<sqsubseteq> Def y \<longleftrightarrow> x = y" |
99fe356cbbc2
rename constant sq_le to below; rename class sq_ord to below; less->below in many lemma names
huffman
parents:
30607
diff
changeset
|
74 |
by (simp add: below_lift_def Def_def Abs_lift_inverse lift_def) |
12026 | 75 |
|
31076
99fe356cbbc2
rename constant sq_le to below; rename class sq_ord to below; less->below in many lemma names
huffman
parents:
30607
diff
changeset
|
76 |
lemma Def_below_iff [simp]: "Def x \<sqsubseteq> y \<longleftrightarrow> Def x = y" |
99fe356cbbc2
rename constant sq_le to below; rename class sq_ord to below; less->below in many lemma names
huffman
parents:
30607
diff
changeset
|
77 |
by (induct y, simp, simp add: Def_below_Def) |
12026 | 78 |
|
79 |
||
80 |
subsection {* Lift is flat *} |
|
81 |
||
12338
de0f4a63baa5
renamed class "term" to "type" (actually "HOL.type");
wenzelm
parents:
12026
diff
changeset
|
82 |
instance lift :: (type) flat |
27292 | 83 |
proof |
84 |
fix x y :: "'a lift" |
|
85 |
assume "x \<sqsubseteq> y" thus "x = \<bottom> \<or> x = y" |
|
86 |
by (induct x) auto |
|
87 |
qed |
|
12026 | 88 |
|
89 |
text {* |
|
90 |
\medskip Two specific lemmas for the combination of LCF and HOL |
|
91 |
terms. |
|
92 |
*} |
|
93 |
||
26452
ed657432b8b9
declare cont_lemmas_ext as simp rules individually
huffman
parents:
25920
diff
changeset
|
94 |
lemma cont_Rep_CFun_app [simp]: "\<lbrakk>cont g; cont f\<rbrakk> \<Longrightarrow> cont(\<lambda>x. ((f x)\<cdot>(g x)) s)" |
18092
2c5d5da79a1e
renamed and added ch2ch, cont2cont, mono2mono theorems ending in _fun, _lambda, _LAM
huffman
parents:
17612
diff
changeset
|
95 |
by (rule cont2cont_Rep_CFun [THEN cont2cont_fun]) |
12026 | 96 |
|
26452
ed657432b8b9
declare cont_lemmas_ext as simp rules individually
huffman
parents:
25920
diff
changeset
|
97 |
lemma cont_Rep_CFun_app_app [simp]: "\<lbrakk>cont g; cont f\<rbrakk> \<Longrightarrow> cont(\<lambda>x. ((f x)\<cdot>(g x)) s t)" |
18092
2c5d5da79a1e
renamed and added ch2ch, cont2cont, mono2mono theorems ending in _fun, _lambda, _LAM
huffman
parents:
17612
diff
changeset
|
98 |
by (rule cont_Rep_CFun_app [THEN cont2cont_fun]) |
2640 | 99 |
|
16695
dc8c868e910b
simplified definitions of flift1, flift2, liftpair;
huffman
parents:
16630
diff
changeset
|
100 |
subsection {* Further operations *} |
dc8c868e910b
simplified definitions of flift1, flift2, liftpair;
huffman
parents:
16630
diff
changeset
|
101 |
|
25131
2c8caac48ade
modernized specifications ('definition', 'abbreviation', 'notation');
wenzelm
parents:
19764
diff
changeset
|
102 |
definition |
2c8caac48ade
modernized specifications ('definition', 'abbreviation', 'notation');
wenzelm
parents:
19764
diff
changeset
|
103 |
flift1 :: "('a \<Rightarrow> 'b::pcpo) \<Rightarrow> ('a lift \<rightarrow> 'b)" (binder "FLIFT " 10) where |
2c8caac48ade
modernized specifications ('definition', 'abbreviation', 'notation');
wenzelm
parents:
19764
diff
changeset
|
104 |
"flift1 = (\<lambda>f. (\<Lambda> x. lift_case \<bottom> f x))" |
16695
dc8c868e910b
simplified definitions of flift1, flift2, liftpair;
huffman
parents:
16630
diff
changeset
|
105 |
|
25131
2c8caac48ade
modernized specifications ('definition', 'abbreviation', 'notation');
wenzelm
parents:
19764
diff
changeset
|
106 |
definition |
2c8caac48ade
modernized specifications ('definition', 'abbreviation', 'notation');
wenzelm
parents:
19764
diff
changeset
|
107 |
flift2 :: "('a \<Rightarrow> 'b) \<Rightarrow> ('a lift \<rightarrow> 'b lift)" where |
2c8caac48ade
modernized specifications ('definition', 'abbreviation', 'notation');
wenzelm
parents:
19764
diff
changeset
|
108 |
"flift2 f = (FLIFT x. Def (f x))" |
16695
dc8c868e910b
simplified definitions of flift1, flift2, liftpair;
huffman
parents:
16630
diff
changeset
|
109 |
|
dc8c868e910b
simplified definitions of flift1, flift2, liftpair;
huffman
parents:
16630
diff
changeset
|
110 |
subsection {* Continuity Proofs for flift1, flift2 *} |
12026 | 111 |
|
112 |
text {* Need the instance of @{text flat}. *} |
|
113 |
||
16695
dc8c868e910b
simplified definitions of flift1, flift2, liftpair;
huffman
parents:
16630
diff
changeset
|
114 |
lemma cont_lift_case1: "cont (\<lambda>f. lift_case a f x)" |
dc8c868e910b
simplified definitions of flift1, flift2, liftpair;
huffman
parents:
16630
diff
changeset
|
115 |
apply (induct x) |
dc8c868e910b
simplified definitions of flift1, flift2, liftpair;
huffman
parents:
16630
diff
changeset
|
116 |
apply simp |
dc8c868e910b
simplified definitions of flift1, flift2, liftpair;
huffman
parents:
16630
diff
changeset
|
117 |
apply simp |
18092
2c5d5da79a1e
renamed and added ch2ch, cont2cont, mono2mono theorems ending in _fun, _lambda, _LAM
huffman
parents:
17612
diff
changeset
|
118 |
apply (rule cont_id [THEN cont2cont_fun]) |
16695
dc8c868e910b
simplified definitions of flift1, flift2, liftpair;
huffman
parents:
16630
diff
changeset
|
119 |
done |
dc8c868e910b
simplified definitions of flift1, flift2, liftpair;
huffman
parents:
16630
diff
changeset
|
120 |
|
25723 | 121 |
lemma cont_lift_case2: "cont (\<lambda>x. lift_case \<bottom> f x)" |
16695
dc8c868e910b
simplified definitions of flift1, flift2, liftpair;
huffman
parents:
16630
diff
changeset
|
122 |
apply (rule flatdom_strict2cont) |
dc8c868e910b
simplified definitions of flift1, flift2, liftpair;
huffman
parents:
16630
diff
changeset
|
123 |
apply simp |
dc8c868e910b
simplified definitions of flift1, flift2, liftpair;
huffman
parents:
16630
diff
changeset
|
124 |
done |
dc8c868e910b
simplified definitions of flift1, flift2, liftpair;
huffman
parents:
16630
diff
changeset
|
125 |
|
dc8c868e910b
simplified definitions of flift1, flift2, liftpair;
huffman
parents:
16630
diff
changeset
|
126 |
lemma cont_flift1: "cont flift1" |
27292 | 127 |
unfolding flift1_def |
16695
dc8c868e910b
simplified definitions of flift1, flift2, liftpair;
huffman
parents:
16630
diff
changeset
|
128 |
apply (rule cont2cont_LAM) |
dc8c868e910b
simplified definitions of flift1, flift2, liftpair;
huffman
parents:
16630
diff
changeset
|
129 |
apply (rule cont_lift_case2) |
dc8c868e910b
simplified definitions of flift1, flift2, liftpair;
huffman
parents:
16630
diff
changeset
|
130 |
apply (rule cont_lift_case1) |
dc8c868e910b
simplified definitions of flift1, flift2, liftpair;
huffman
parents:
16630
diff
changeset
|
131 |
done |
dc8c868e910b
simplified definitions of flift1, flift2, liftpair;
huffman
parents:
16630
diff
changeset
|
132 |
|
27310 | 133 |
lemma FLIFT_mono: |
134 |
"(\<And>x. f x \<sqsubseteq> g x) \<Longrightarrow> (FLIFT x. f x) \<sqsubseteq> (FLIFT x. g x)" |
|
135 |
apply (rule monofunE [where f=flift1]) |
|
136 |
apply (rule cont2mono [OF cont_flift1]) |
|
31076
99fe356cbbc2
rename constant sq_le to below; rename class sq_ord to below; less->below in many lemma names
huffman
parents:
30607
diff
changeset
|
137 |
apply (simp add: below_fun_ext) |
27310 | 138 |
done |
139 |
||
37099 | 140 |
lemma cont2cont_flift1 [simp, cont2cont]: |
16695
dc8c868e910b
simplified definitions of flift1, flift2, liftpair;
huffman
parents:
16630
diff
changeset
|
141 |
"\<lbrakk>\<And>y. cont (\<lambda>x. f x y)\<rbrakk> \<Longrightarrow> cont (\<lambda>x. FLIFT y. f x y)" |
dc8c868e910b
simplified definitions of flift1, flift2, liftpair;
huffman
parents:
16630
diff
changeset
|
142 |
apply (rule cont_flift1 [THEN cont2cont_app3]) |
26452
ed657432b8b9
declare cont_lemmas_ext as simp rules individually
huffman
parents:
25920
diff
changeset
|
143 |
apply simp |
16695
dc8c868e910b
simplified definitions of flift1, flift2, liftpair;
huffman
parents:
16630
diff
changeset
|
144 |
done |
dc8c868e910b
simplified definitions of flift1, flift2, liftpair;
huffman
parents:
16630
diff
changeset
|
145 |
|
26452
ed657432b8b9
declare cont_lemmas_ext as simp rules individually
huffman
parents:
25920
diff
changeset
|
146 |
lemma cont2cont_lift_case [simp]: |
25723 | 147 |
"\<lbrakk>\<And>y. cont (\<lambda>x. f x y); cont g\<rbrakk> \<Longrightarrow> cont (\<lambda>x. lift_case UU (f x) (g x))" |
16757
b8bfd086f7d4
replaced old continuity rules with new lemma cont2cont_lift_case
huffman
parents:
16755
diff
changeset
|
148 |
apply (subgoal_tac "cont (\<lambda>x. (FLIFT y. f x y)\<cdot>(g x))") |
b8bfd086f7d4
replaced old continuity rules with new lemma cont2cont_lift_case
huffman
parents:
16755
diff
changeset
|
149 |
apply (simp add: flift1_def cont_lift_case2) |
26452
ed657432b8b9
declare cont_lemmas_ext as simp rules individually
huffman
parents:
25920
diff
changeset
|
150 |
apply simp |
16757
b8bfd086f7d4
replaced old continuity rules with new lemma cont2cont_lift_case
huffman
parents:
16755
diff
changeset
|
151 |
done |
b8bfd086f7d4
replaced old continuity rules with new lemma cont2cont_lift_case
huffman
parents:
16755
diff
changeset
|
152 |
|
b8bfd086f7d4
replaced old continuity rules with new lemma cont2cont_lift_case
huffman
parents:
16755
diff
changeset
|
153 |
text {* rewrites for @{term flift1}, @{term flift2} *} |
b8bfd086f7d4
replaced old continuity rules with new lemma cont2cont_lift_case
huffman
parents:
16755
diff
changeset
|
154 |
|
16695
dc8c868e910b
simplified definitions of flift1, flift2, liftpair;
huffman
parents:
16630
diff
changeset
|
155 |
lemma flift1_Def [simp]: "flift1 f\<cdot>(Def x) = (f x)" |
dc8c868e910b
simplified definitions of flift1, flift2, liftpair;
huffman
parents:
16630
diff
changeset
|
156 |
by (simp add: flift1_def cont_lift_case2) |
dc8c868e910b
simplified definitions of flift1, flift2, liftpair;
huffman
parents:
16630
diff
changeset
|
157 |
|
dc8c868e910b
simplified definitions of flift1, flift2, liftpair;
huffman
parents:
16630
diff
changeset
|
158 |
lemma flift2_Def [simp]: "flift2 f\<cdot>(Def x) = Def (f x)" |
dc8c868e910b
simplified definitions of flift1, flift2, liftpair;
huffman
parents:
16630
diff
changeset
|
159 |
by (simp add: flift2_def) |
dc8c868e910b
simplified definitions of flift1, flift2, liftpair;
huffman
parents:
16630
diff
changeset
|
160 |
|
dc8c868e910b
simplified definitions of flift1, flift2, liftpair;
huffman
parents:
16630
diff
changeset
|
161 |
lemma flift1_strict [simp]: "flift1 f\<cdot>\<bottom> = \<bottom>" |
dc8c868e910b
simplified definitions of flift1, flift2, liftpair;
huffman
parents:
16630
diff
changeset
|
162 |
by (simp add: flift1_def cont_lift_case2) |
dc8c868e910b
simplified definitions of flift1, flift2, liftpair;
huffman
parents:
16630
diff
changeset
|
163 |
|
dc8c868e910b
simplified definitions of flift1, flift2, liftpair;
huffman
parents:
16630
diff
changeset
|
164 |
lemma flift2_strict [simp]: "flift2 f\<cdot>\<bottom> = \<bottom>" |
dc8c868e910b
simplified definitions of flift1, flift2, liftpair;
huffman
parents:
16630
diff
changeset
|
165 |
by (simp add: flift2_def) |
dc8c868e910b
simplified definitions of flift1, flift2, liftpair;
huffman
parents:
16630
diff
changeset
|
166 |
|
dc8c868e910b
simplified definitions of flift1, flift2, liftpair;
huffman
parents:
16630
diff
changeset
|
167 |
lemma flift2_defined [simp]: "x \<noteq> \<bottom> \<Longrightarrow> (flift2 f)\<cdot>x \<noteq> \<bottom>" |
dc8c868e910b
simplified definitions of flift1, flift2, liftpair;
huffman
parents:
16630
diff
changeset
|
168 |
by (erule lift_definedE, simp) |
dc8c868e910b
simplified definitions of flift1, flift2, liftpair;
huffman
parents:
16630
diff
changeset
|
169 |
|
19520 | 170 |
lemma flift2_defined_iff [simp]: "(flift2 f\<cdot>x = \<bottom>) = (x = \<bottom>)" |
171 |
by (cases x, simp_all) |
|
172 |
||
12026 | 173 |
|
26963 | 174 |
subsection {* Lifted countable types are bifinite *} |
175 |
||
176 |
instantiation lift :: (countable) bifinite |
|
177 |
begin |
|
178 |
||
179 |
definition |
|
180 |
approx_lift_def: |
|
181 |
"approx = (\<lambda>n. FLIFT x. if to_nat x < n then Def x else \<bottom>)" |
|
182 |
||
183 |
instance proof |
|
184 |
fix x :: "'a lift" |
|
27310 | 185 |
show "chain (approx :: nat \<Rightarrow> 'a lift \<rightarrow> 'a lift)" |
26963 | 186 |
unfolding approx_lift_def |
27310 | 187 |
by (rule chainI, simp add: FLIFT_mono) |
26963 | 188 |
next |
189 |
fix x :: "'a lift" |
|
190 |
show "(\<Squnion>i. approx i\<cdot>x) = x" |
|
191 |
unfolding approx_lift_def |
|
192 |
apply (cases x, simp) |
|
193 |
apply (rule thelubI) |
|
194 |
apply (rule is_lubI) |
|
195 |
apply (rule ub_rangeI, simp) |
|
196 |
apply (drule ub_rangeD) |
|
31076
99fe356cbbc2
rename constant sq_le to below; rename class sq_ord to below; less->below in many lemma names
huffman
parents:
30607
diff
changeset
|
197 |
apply (erule rev_below_trans) |
26963 | 198 |
apply simp |
199 |
apply (rule lessI) |
|
200 |
done |
|
201 |
next |
|
202 |
fix i :: nat and x :: "'a lift" |
|
203 |
show "approx i\<cdot>(approx i\<cdot>x) = approx i\<cdot>x" |
|
204 |
unfolding approx_lift_def |
|
205 |
by (cases x, simp, simp) |
|
206 |
next |
|
207 |
fix i :: nat |
|
208 |
show "finite {x::'a lift. approx i\<cdot>x = x}" |
|
209 |
proof (rule finite_subset) |
|
210 |
let ?S = "insert (\<bottom>::'a lift) (Def ` to_nat -` {..<i})" |
|
211 |
show "{x::'a lift. approx i\<cdot>x = x} \<subseteq> ?S" |
|
212 |
unfolding approx_lift_def |
|
213 |
by (rule subsetI, case_tac x, simp, simp split: split_if_asm) |
|
214 |
show "finite ?S" |
|
215 |
by (simp add: finite_vimageI) |
|
216 |
qed |
|
217 |
qed |
|
218 |
||
2640 | 219 |
end |
26963 | 220 |
|
221 |
end |