15741
|
1 |
(* Title: HOLCF/Domain.thy
|
|
2 |
ID: $Id$
|
|
3 |
Author: Brian Huffman
|
|
4 |
*)
|
|
5 |
|
|
6 |
header {* Domain package *}
|
|
7 |
|
|
8 |
theory Domain
|
16230
|
9 |
imports Ssum Sprod Up One Tr Fixrec
|
15741
|
10 |
begin
|
|
11 |
|
|
12 |
defaultsort pcpo
|
|
13 |
|
|
14 |
subsection {* Continuous isomorphisms *}
|
|
15 |
|
|
16 |
text {* A locale for continuous isomorphisms *}
|
|
17 |
|
|
18 |
locale iso =
|
|
19 |
fixes abs :: "'a \<rightarrow> 'b"
|
|
20 |
fixes rep :: "'b \<rightarrow> 'a"
|
|
21 |
assumes abs_iso [simp]: "rep\<cdot>(abs\<cdot>x) = x"
|
|
22 |
assumes rep_iso [simp]: "abs\<cdot>(rep\<cdot>y) = y"
|
|
23 |
|
|
24 |
lemma (in iso) swap: "iso rep abs"
|
|
25 |
by (rule iso.intro [OF rep_iso abs_iso])
|
|
26 |
|
17835
|
27 |
lemma (in iso) abs_less: "(abs\<cdot>x \<sqsubseteq> abs\<cdot>y) = (x \<sqsubseteq> y)"
|
|
28 |
proof
|
|
29 |
assume "abs\<cdot>x \<sqsubseteq> abs\<cdot>y"
|
|
30 |
hence "rep\<cdot>(abs\<cdot>x) \<sqsubseteq> rep\<cdot>(abs\<cdot>y)" by (rule monofun_cfun_arg)
|
|
31 |
thus "x \<sqsubseteq> y" by simp
|
|
32 |
next
|
|
33 |
assume "x \<sqsubseteq> y"
|
|
34 |
thus "abs\<cdot>x \<sqsubseteq> abs\<cdot>y" by (rule monofun_cfun_arg)
|
|
35 |
qed
|
|
36 |
|
|
37 |
lemma (in iso) rep_less: "(rep\<cdot>x \<sqsubseteq> rep\<cdot>y) = (x \<sqsubseteq> y)"
|
|
38 |
by (rule iso.abs_less [OF swap])
|
|
39 |
|
|
40 |
lemma (in iso) abs_eq: "(abs\<cdot>x = abs\<cdot>y) = (x = y)"
|
|
41 |
by (simp add: po_eq_conv abs_less)
|
|
42 |
|
|
43 |
lemma (in iso) rep_eq: "(rep\<cdot>x = rep\<cdot>y) = (x = y)"
|
|
44 |
by (rule iso.abs_eq [OF swap])
|
|
45 |
|
15741
|
46 |
lemma (in iso) abs_strict: "abs\<cdot>\<bottom> = \<bottom>"
|
|
47 |
proof -
|
|
48 |
have "\<bottom> \<sqsubseteq> rep\<cdot>\<bottom>" ..
|
|
49 |
hence "abs\<cdot>\<bottom> \<sqsubseteq> abs\<cdot>(rep\<cdot>\<bottom>)" by (rule monofun_cfun_arg)
|
|
50 |
hence "abs\<cdot>\<bottom> \<sqsubseteq> \<bottom>" by simp
|
|
51 |
thus ?thesis by (rule UU_I)
|
|
52 |
qed
|
|
53 |
|
|
54 |
lemma (in iso) rep_strict: "rep\<cdot>\<bottom> = \<bottom>"
|
|
55 |
by (rule iso.abs_strict [OF swap])
|
|
56 |
|
17835
|
57 |
lemma (in iso) abs_defin': "abs\<cdot>x = \<bottom> \<Longrightarrow> x = \<bottom>"
|
15741
|
58 |
proof -
|
17835
|
59 |
have "x = rep\<cdot>(abs\<cdot>x)" by simp
|
|
60 |
also assume "abs\<cdot>x = \<bottom>"
|
15741
|
61 |
also note rep_strict
|
17835
|
62 |
finally show "x = \<bottom>" .
|
15741
|
63 |
qed
|
|
64 |
|
|
65 |
lemma (in iso) rep_defin': "rep\<cdot>z = \<bottom> \<Longrightarrow> z = \<bottom>"
|
|
66 |
by (rule iso.abs_defin' [OF swap])
|
|
67 |
|
|
68 |
lemma (in iso) abs_defined: "z \<noteq> \<bottom> \<Longrightarrow> abs\<cdot>z \<noteq> \<bottom>"
|
|
69 |
by (erule contrapos_nn, erule abs_defin')
|
|
70 |
|
|
71 |
lemma (in iso) rep_defined: "z \<noteq> \<bottom> \<Longrightarrow> rep\<cdot>z \<noteq> \<bottom>"
|
17835
|
72 |
by (rule iso.abs_defined [OF iso.swap])
|
|
73 |
|
|
74 |
lemma (in iso) abs_defined_iff: "(abs\<cdot>x = \<bottom>) = (x = \<bottom>)"
|
|
75 |
by (auto elim: abs_defin' intro: abs_strict)
|
|
76 |
|
|
77 |
lemma (in iso) rep_defined_iff: "(rep\<cdot>x = \<bottom>) = (x = \<bottom>)"
|
|
78 |
by (rule iso.abs_defined_iff [OF iso.swap])
|
15741
|
79 |
|
17836
|
80 |
lemma (in iso) compact_abs_rev: "compact (abs\<cdot>x) \<Longrightarrow> compact x"
|
|
81 |
proof (unfold compact_def)
|
|
82 |
assume "adm (\<lambda>y. \<not> abs\<cdot>x \<sqsubseteq> y)"
|
|
83 |
with cont_Rep_CFun2
|
|
84 |
have "adm (\<lambda>y. \<not> abs\<cdot>x \<sqsubseteq> abs\<cdot>y)" by (rule adm_subst)
|
|
85 |
thus "adm (\<lambda>y. \<not> x \<sqsubseteq> y)" using abs_less by simp
|
|
86 |
qed
|
|
87 |
|
|
88 |
lemma (in iso) compact_rep_rev: "compact (rep\<cdot>x) \<Longrightarrow> compact x"
|
|
89 |
by (rule iso.compact_abs_rev [OF iso.swap])
|
|
90 |
|
|
91 |
lemma (in iso) compact_abs: "compact x \<Longrightarrow> compact (abs\<cdot>x)"
|
|
92 |
by (rule compact_rep_rev, simp)
|
|
93 |
|
|
94 |
lemma (in iso) compact_rep: "compact x \<Longrightarrow> compact (rep\<cdot>x)"
|
|
95 |
by (rule iso.compact_abs [OF iso.swap])
|
|
96 |
|
15741
|
97 |
lemma (in iso) iso_swap: "(x = abs\<cdot>y) = (rep\<cdot>x = y)"
|
|
98 |
proof
|
|
99 |
assume "x = abs\<cdot>y"
|
|
100 |
hence "rep\<cdot>x = rep\<cdot>(abs\<cdot>y)" by simp
|
|
101 |
thus "rep\<cdot>x = y" by simp
|
|
102 |
next
|
|
103 |
assume "rep\<cdot>x = y"
|
|
104 |
hence "abs\<cdot>(rep\<cdot>x) = abs\<cdot>y" by simp
|
|
105 |
thus "x = abs\<cdot>y" by simp
|
|
106 |
qed
|
|
107 |
|
|
108 |
subsection {* Casedist *}
|
|
109 |
|
|
110 |
lemma ex_one_defined_iff:
|
|
111 |
"(\<exists>x. P x \<and> x \<noteq> \<bottom>) = P ONE"
|
|
112 |
apply safe
|
|
113 |
apply (rule_tac p=x in oneE)
|
|
114 |
apply simp
|
|
115 |
apply simp
|
|
116 |
apply force
|
|
117 |
done
|
|
118 |
|
|
119 |
lemma ex_up_defined_iff:
|
|
120 |
"(\<exists>x. P x \<and> x \<noteq> \<bottom>) = (\<exists>x. P (up\<cdot>x))"
|
|
121 |
apply safe
|
16754
|
122 |
apply (rule_tac p=x in upE)
|
15741
|
123 |
apply simp
|
|
124 |
apply fast
|
16320
|
125 |
apply (force intro!: up_defined)
|
15741
|
126 |
done
|
|
127 |
|
|
128 |
lemma ex_sprod_defined_iff:
|
|
129 |
"(\<exists>y. P y \<and> y \<noteq> \<bottom>) =
|
|
130 |
(\<exists>x y. (P (:x, y:) \<and> x \<noteq> \<bottom>) \<and> y \<noteq> \<bottom>)"
|
|
131 |
apply safe
|
|
132 |
apply (rule_tac p=y in sprodE)
|
|
133 |
apply simp
|
|
134 |
apply fast
|
16217
|
135 |
apply (force intro!: spair_defined)
|
15741
|
136 |
done
|
|
137 |
|
|
138 |
lemma ex_sprod_up_defined_iff:
|
|
139 |
"(\<exists>y. P y \<and> y \<noteq> \<bottom>) =
|
|
140 |
(\<exists>x y. P (:up\<cdot>x, y:) \<and> y \<noteq> \<bottom>)"
|
|
141 |
apply safe
|
|
142 |
apply (rule_tac p=y in sprodE)
|
|
143 |
apply simp
|
16754
|
144 |
apply (rule_tac p=x in upE)
|
15741
|
145 |
apply simp
|
|
146 |
apply fast
|
16217
|
147 |
apply (force intro!: spair_defined)
|
15741
|
148 |
done
|
|
149 |
|
|
150 |
lemma ex_ssum_defined_iff:
|
|
151 |
"(\<exists>x. P x \<and> x \<noteq> \<bottom>) =
|
|
152 |
((\<exists>x. P (sinl\<cdot>x) \<and> x \<noteq> \<bottom>) \<or>
|
|
153 |
(\<exists>x. P (sinr\<cdot>x) \<and> x \<noteq> \<bottom>))"
|
|
154 |
apply (rule iffI)
|
|
155 |
apply (erule exE)
|
|
156 |
apply (erule conjE)
|
|
157 |
apply (rule_tac p=x in ssumE)
|
|
158 |
apply simp
|
|
159 |
apply (rule disjI1, fast)
|
|
160 |
apply (rule disjI2, fast)
|
|
161 |
apply (erule disjE)
|
17835
|
162 |
apply force
|
|
163 |
apply force
|
15741
|
164 |
done
|
|
165 |
|
|
166 |
lemma exh_start: "p = \<bottom> \<or> (\<exists>x. p = x \<and> x \<noteq> \<bottom>)"
|
|
167 |
by auto
|
|
168 |
|
|
169 |
lemmas ex_defined_iffs =
|
|
170 |
ex_ssum_defined_iff
|
|
171 |
ex_sprod_up_defined_iff
|
|
172 |
ex_sprod_defined_iff
|
|
173 |
ex_up_defined_iff
|
|
174 |
ex_one_defined_iff
|
|
175 |
|
|
176 |
text {* Rules for turning exh into casedist *}
|
|
177 |
|
|
178 |
lemma exh_casedist0: "\<lbrakk>R; R \<Longrightarrow> P\<rbrakk> \<Longrightarrow> P" (* like make_elim *)
|
|
179 |
by auto
|
|
180 |
|
|
181 |
lemma exh_casedist1: "((P \<or> Q \<Longrightarrow> R) \<Longrightarrow> S) \<equiv> (\<lbrakk>P \<Longrightarrow> R; Q \<Longrightarrow> R\<rbrakk> \<Longrightarrow> S)"
|
|
182 |
by rule auto
|
|
183 |
|
|
184 |
lemma exh_casedist2: "(\<exists>x. P x \<Longrightarrow> Q) \<equiv> (\<And>x. P x \<Longrightarrow> Q)"
|
18846
|
185 |
by rule auto
|
15741
|
186 |
|
|
187 |
lemma exh_casedist3: "(P \<and> Q \<Longrightarrow> R) \<equiv> (P \<Longrightarrow> Q \<Longrightarrow> R)"
|
|
188 |
by rule auto
|
|
189 |
|
|
190 |
lemmas exh_casedists = exh_casedist1 exh_casedist2 exh_casedist3
|
|
191 |
|
|
192 |
|
|
193 |
subsection {* Setting up the package *}
|
|
194 |
|
16121
|
195 |
ML {*
|
15741
|
196 |
val iso_intro = thm "iso.intro";
|
|
197 |
val iso_abs_iso = thm "iso.abs_iso";
|
|
198 |
val iso_rep_iso = thm "iso.rep_iso";
|
|
199 |
val iso_abs_strict = thm "iso.abs_strict";
|
|
200 |
val iso_rep_strict = thm "iso.rep_strict";
|
|
201 |
val iso_abs_defin' = thm "iso.abs_defin'";
|
|
202 |
val iso_rep_defin' = thm "iso.rep_defin'";
|
|
203 |
val iso_abs_defined = thm "iso.abs_defined";
|
|
204 |
val iso_rep_defined = thm "iso.rep_defined";
|
17839
|
205 |
val iso_compact_abs = thm "iso.compact_abs";
|
|
206 |
val iso_compact_rep = thm "iso.compact_rep";
|
15741
|
207 |
val iso_iso_swap = thm "iso.iso_swap";
|
|
208 |
|
|
209 |
val exh_start = thm "exh_start";
|
|
210 |
val ex_defined_iffs = thms "ex_defined_iffs";
|
|
211 |
val exh_casedist0 = thm "exh_casedist0";
|
|
212 |
val exh_casedists = thms "exh_casedists";
|
|
213 |
*}
|
|
214 |
|
|
215 |
end
|