author | huffman |
Fri, 04 Jan 2008 23:56:47 +0100 | |
changeset 25834 | 3acdbb5626dc |
parent 25828 | 228c53fdb3b4 |
child 25878 | bfd53f791c10 |
permissions | -rw-r--r-- |
15600 | 1 |
(* Title: HOLCF/Porder.thy |
243
c22b85994e17
Franz Regensburger's Higher-Order Logic of Computable Functions embedding LCF
nipkow
parents:
diff
changeset
|
2 |
ID: $Id$ |
25773 | 3 |
Author: Franz Regensburger and Brian Huffman |
243
c22b85994e17
Franz Regensburger's Higher-Order Logic of Computable Functions embedding LCF
nipkow
parents:
diff
changeset
|
4 |
*) |
c22b85994e17
Franz Regensburger's Higher-Order Logic of Computable Functions embedding LCF
nipkow
parents:
diff
changeset
|
5 |
|
15587
f363e6e080e7
added subsections and text for document generation
huffman
parents:
15577
diff
changeset
|
6 |
header {* Partial orders *} |
15576
efb95d0d01f7
converted to new-style theories, and combined numbered files
huffman
parents:
15562
diff
changeset
|
7 |
|
15577 | 8 |
theory Porder |
24728 | 9 |
imports Datatype Finite_Set |
15577 | 10 |
begin |
15576
efb95d0d01f7
converted to new-style theories, and combined numbered files
huffman
parents:
15562
diff
changeset
|
11 |
|
15587
f363e6e080e7
added subsections and text for document generation
huffman
parents:
15577
diff
changeset
|
12 |
subsection {* Type class for partial orders *} |
f363e6e080e7
added subsections and text for document generation
huffman
parents:
15577
diff
changeset
|
13 |
|
23284
07ae93e58fea
use new-style class for sq_ord; rename op << to sq_le
huffman
parents:
21524
diff
changeset
|
14 |
class sq_ord = type + |
07ae93e58fea
use new-style class for sq_ord; rename op << to sq_le
huffman
parents:
21524
diff
changeset
|
15 |
fixes sq_le :: "'a \<Rightarrow> 'a \<Rightarrow> bool" |
15576
efb95d0d01f7
converted to new-style theories, and combined numbered files
huffman
parents:
15562
diff
changeset
|
16 |
|
23284
07ae93e58fea
use new-style class for sq_ord; rename op << to sq_le
huffman
parents:
21524
diff
changeset
|
17 |
notation |
07ae93e58fea
use new-style class for sq_ord; rename op << to sq_le
huffman
parents:
21524
diff
changeset
|
18 |
sq_le (infixl "<<" 55) |
15576
efb95d0d01f7
converted to new-style theories, and combined numbered files
huffman
parents:
15562
diff
changeset
|
19 |
|
23284
07ae93e58fea
use new-style class for sq_ord; rename op << to sq_le
huffman
parents:
21524
diff
changeset
|
20 |
notation (xsymbols) |
07ae93e58fea
use new-style class for sq_ord; rename op << to sq_le
huffman
parents:
21524
diff
changeset
|
21 |
sq_le (infixl "\<sqsubseteq>" 55) |
15576
efb95d0d01f7
converted to new-style theories, and combined numbered files
huffman
parents:
15562
diff
changeset
|
22 |
|
efb95d0d01f7
converted to new-style theories, and combined numbered files
huffman
parents:
15562
diff
changeset
|
23 |
axclass po < sq_ord |
23284
07ae93e58fea
use new-style class for sq_ord; rename op << to sq_le
huffman
parents:
21524
diff
changeset
|
24 |
refl_less [iff]: "x \<sqsubseteq> x" |
25131
2c8caac48ade
modernized specifications ('definition', 'abbreviation', 'notation');
wenzelm
parents:
24728
diff
changeset
|
25 |
antisym_less: "\<lbrakk>x \<sqsubseteq> y; y \<sqsubseteq> x\<rbrakk> \<Longrightarrow> x = y" |
17810
3bdf516d93d8
cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents:
17372
diff
changeset
|
26 |
trans_less: "\<lbrakk>x \<sqsubseteq> y; y \<sqsubseteq> z\<rbrakk> \<Longrightarrow> x \<sqsubseteq> z" |
15576
efb95d0d01f7
converted to new-style theories, and combined numbered files
huffman
parents:
15562
diff
changeset
|
27 |
|
efb95d0d01f7
converted to new-style theories, and combined numbered files
huffman
parents:
15562
diff
changeset
|
28 |
text {* minimal fixes least element *} |
efb95d0d01f7
converted to new-style theories, and combined numbered files
huffman
parents:
15562
diff
changeset
|
29 |
|
17810
3bdf516d93d8
cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents:
17372
diff
changeset
|
30 |
lemma minimal2UU[OF allI] : "\<forall>x::'a::po. uu \<sqsubseteq> x \<Longrightarrow> uu = (THE u. \<forall>y. u \<sqsubseteq> y)" |
15930
145651bc64a8
Replaced all unnecessary uses of SOME with THE or LEAST
huffman
parents:
15600
diff
changeset
|
31 |
by (blast intro: theI2 antisym_less) |
15576
efb95d0d01f7
converted to new-style theories, and combined numbered files
huffman
parents:
15562
diff
changeset
|
32 |
|
efb95d0d01f7
converted to new-style theories, and combined numbered files
huffman
parents:
15562
diff
changeset
|
33 |
text {* the reverse law of anti-symmetry of @{term "op <<"} *} |
efb95d0d01f7
converted to new-style theories, and combined numbered files
huffman
parents:
15562
diff
changeset
|
34 |
|
17810
3bdf516d93d8
cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents:
17372
diff
changeset
|
35 |
lemma antisym_less_inverse: "(x::'a::po) = y \<Longrightarrow> x \<sqsubseteq> y \<and> y \<sqsubseteq> x" |
3bdf516d93d8
cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents:
17372
diff
changeset
|
36 |
by simp |
15576
efb95d0d01f7
converted to new-style theories, and combined numbered files
huffman
parents:
15562
diff
changeset
|
37 |
|
17810
3bdf516d93d8
cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents:
17372
diff
changeset
|
38 |
lemma box_less: "\<lbrakk>(a::'a::po) \<sqsubseteq> b; c \<sqsubseteq> a; b \<sqsubseteq> d\<rbrakk> \<Longrightarrow> c \<sqsubseteq> d" |
18088 | 39 |
by (rule trans_less [OF trans_less]) |
15576
efb95d0d01f7
converted to new-style theories, and combined numbered files
huffman
parents:
15562
diff
changeset
|
40 |
|
17810
3bdf516d93d8
cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents:
17372
diff
changeset
|
41 |
lemma po_eq_conv: "((x::'a::po) = y) = (x \<sqsubseteq> y \<and> y \<sqsubseteq> x)" |
3bdf516d93d8
cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents:
17372
diff
changeset
|
42 |
by (fast elim!: antisym_less_inverse intro!: antisym_less) |
3bdf516d93d8
cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents:
17372
diff
changeset
|
43 |
|
3bdf516d93d8
cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents:
17372
diff
changeset
|
44 |
lemma rev_trans_less: "\<lbrakk>(y::'a::po) \<sqsubseteq> z; x \<sqsubseteq> y\<rbrakk> \<Longrightarrow> x \<sqsubseteq> z" |
3bdf516d93d8
cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents:
17372
diff
changeset
|
45 |
by (rule trans_less) |
15576
efb95d0d01f7
converted to new-style theories, and combined numbered files
huffman
parents:
15562
diff
changeset
|
46 |
|
18647 | 47 |
lemma sq_ord_less_eq_trans: "\<lbrakk>a \<sqsubseteq> b; b = c\<rbrakk> \<Longrightarrow> a \<sqsubseteq> c" |
48 |
by (rule subst) |
|
49 |
||
50 |
lemma sq_ord_eq_less_trans: "\<lbrakk>a = b; b \<sqsubseteq> c\<rbrakk> \<Longrightarrow> a \<sqsubseteq> c" |
|
51 |
by (rule ssubst) |
|
52 |
||
53 |
lemmas HOLCF_trans_rules [trans] = |
|
54 |
trans_less |
|
55 |
antisym_less |
|
56 |
sq_ord_less_eq_trans |
|
57 |
sq_ord_eq_less_trans |
|
58 |
||
25777 | 59 |
subsection {* Upper bounds *} |
18071
940c2c0ff33a
cleaned up; chain_const and thelub_const are simp rules
huffman
parents:
17810
diff
changeset
|
60 |
|
25131
2c8caac48ade
modernized specifications ('definition', 'abbreviation', 'notation');
wenzelm
parents:
24728
diff
changeset
|
61 |
definition |
2c8caac48ade
modernized specifications ('definition', 'abbreviation', 'notation');
wenzelm
parents:
24728
diff
changeset
|
62 |
is_ub :: "['a set, 'a::po] \<Rightarrow> bool" (infixl "<|" 55) where |
2c8caac48ade
modernized specifications ('definition', 'abbreviation', 'notation');
wenzelm
parents:
24728
diff
changeset
|
63 |
"(S <| x) = (\<forall>y. y \<in> S \<longrightarrow> y \<sqsubseteq> x)" |
18071
940c2c0ff33a
cleaned up; chain_const and thelub_const are simp rules
huffman
parents:
17810
diff
changeset
|
64 |
|
25777 | 65 |
lemma is_ubI: "(\<And>x. x \<in> S \<Longrightarrow> x \<sqsubseteq> u) \<Longrightarrow> S <| u" |
66 |
by (simp add: is_ub_def) |
|
67 |
||
68 |
lemma is_ubD: "\<lbrakk>S <| u; x \<in> S\<rbrakk> \<Longrightarrow> x \<sqsubseteq> u" |
|
69 |
by (simp add: is_ub_def) |
|
70 |
||
71 |
lemma ub_imageI: "(\<And>x. x \<in> S \<Longrightarrow> f x \<sqsubseteq> u) \<Longrightarrow> (\<lambda>x. f x) ` S <| u" |
|
72 |
unfolding is_ub_def by fast |
|
73 |
||
74 |
lemma ub_imageD: "\<lbrakk>f ` S <| u; x \<in> S\<rbrakk> \<Longrightarrow> f x \<sqsubseteq> u" |
|
75 |
unfolding is_ub_def by fast |
|
76 |
||
77 |
lemma ub_rangeI: "(\<And>i. S i \<sqsubseteq> x) \<Longrightarrow> range S <| x" |
|
78 |
unfolding is_ub_def by fast |
|
79 |
||
80 |
lemma ub_rangeD: "range S <| x \<Longrightarrow> S i \<sqsubseteq> x" |
|
81 |
unfolding is_ub_def by fast |
|
82 |
||
25828
228c53fdb3b4
add new is_ub lemmas; clean up directed_finite proofs
huffman
parents:
25813
diff
changeset
|
83 |
lemma is_ub_empty [simp]: "{} <| u" |
228c53fdb3b4
add new is_ub lemmas; clean up directed_finite proofs
huffman
parents:
25813
diff
changeset
|
84 |
unfolding is_ub_def by fast |
228c53fdb3b4
add new is_ub lemmas; clean up directed_finite proofs
huffman
parents:
25813
diff
changeset
|
85 |
|
228c53fdb3b4
add new is_ub lemmas; clean up directed_finite proofs
huffman
parents:
25813
diff
changeset
|
86 |
lemma is_ub_insert [simp]: "(insert x A) <| y = (x \<sqsubseteq> y \<and> A <| y)" |
228c53fdb3b4
add new is_ub lemmas; clean up directed_finite proofs
huffman
parents:
25813
diff
changeset
|
87 |
unfolding is_ub_def by fast |
228c53fdb3b4
add new is_ub lemmas; clean up directed_finite proofs
huffman
parents:
25813
diff
changeset
|
88 |
|
228c53fdb3b4
add new is_ub lemmas; clean up directed_finite proofs
huffman
parents:
25813
diff
changeset
|
89 |
lemma is_ub_upward: "\<lbrakk>S <| x; x \<sqsubseteq> y\<rbrakk> \<Longrightarrow> S <| y" |
228c53fdb3b4
add new is_ub lemmas; clean up directed_finite proofs
huffman
parents:
25813
diff
changeset
|
90 |
unfolding is_ub_def by (fast intro: trans_less) |
228c53fdb3b4
add new is_ub lemmas; clean up directed_finite proofs
huffman
parents:
25813
diff
changeset
|
91 |
|
25777 | 92 |
subsection {* Least upper bounds *} |
93 |
||
25131
2c8caac48ade
modernized specifications ('definition', 'abbreviation', 'notation');
wenzelm
parents:
24728
diff
changeset
|
94 |
definition |
2c8caac48ade
modernized specifications ('definition', 'abbreviation', 'notation');
wenzelm
parents:
24728
diff
changeset
|
95 |
is_lub :: "['a set, 'a::po] \<Rightarrow> bool" (infixl "<<|" 55) where |
2c8caac48ade
modernized specifications ('definition', 'abbreviation', 'notation');
wenzelm
parents:
24728
diff
changeset
|
96 |
"(S <<| x) = (S <| x \<and> (\<forall>u. S <| u \<longrightarrow> x \<sqsubseteq> u))" |
18071
940c2c0ff33a
cleaned up; chain_const and thelub_const are simp rules
huffman
parents:
17810
diff
changeset
|
97 |
|
25131
2c8caac48ade
modernized specifications ('definition', 'abbreviation', 'notation');
wenzelm
parents:
24728
diff
changeset
|
98 |
definition |
2c8caac48ade
modernized specifications ('definition', 'abbreviation', 'notation');
wenzelm
parents:
24728
diff
changeset
|
99 |
lub :: "'a set \<Rightarrow> 'a::po" where |
2c8caac48ade
modernized specifications ('definition', 'abbreviation', 'notation');
wenzelm
parents:
24728
diff
changeset
|
100 |
"lub S = (THE x. S <<| x)" |
243
c22b85994e17
Franz Regensburger's Higher-Order Logic of Computable Functions embedding LCF
nipkow
parents:
diff
changeset
|
101 |
|
25777 | 102 |
syntax |
103 |
"_BLub" :: "[pttrn, 'a set, 'b] \<Rightarrow> 'b" ("(3LUB _:_./ _)" [0,0, 10] 10) |
|
104 |
||
105 |
syntax (xsymbols) |
|
106 |
"_BLub" :: "[pttrn, 'a set, 'b] \<Rightarrow> 'b" ("(3\<Squnion>_\<in>_./ _)" [0,0, 10] 10) |
|
107 |
||
108 |
translations |
|
109 |
"LUB x:A. t" == "CONST lub ((%x. t) ` A)" |
|
110 |
||
21524 | 111 |
abbreviation |
112 |
Lub (binder "LUB " 10) where |
|
113 |
"LUB n. t n == lub (range t)" |
|
2394 | 114 |
|
21524 | 115 |
notation (xsymbols) |
116 |
Lub (binder "\<Squnion> " 10) |
|
243
c22b85994e17
Franz Regensburger's Higher-Order Logic of Computable Functions embedding LCF
nipkow
parents:
diff
changeset
|
117 |
|
25813 | 118 |
text {* access to some definition as inference rule *} |
119 |
||
120 |
lemma is_lubD1: "S <<| x \<Longrightarrow> S <| x" |
|
121 |
unfolding is_lub_def by fast |
|
122 |
||
123 |
lemma is_lub_lub: "\<lbrakk>S <<| x; S <| u\<rbrakk> \<Longrightarrow> x \<sqsubseteq> u" |
|
124 |
unfolding is_lub_def by fast |
|
125 |
||
126 |
lemma is_lubI: "\<lbrakk>S <| x; \<And>u. S <| u \<Longrightarrow> x \<sqsubseteq> u\<rbrakk> \<Longrightarrow> S <<| x" |
|
127 |
unfolding is_lub_def by fast |
|
128 |
||
15576
efb95d0d01f7
converted to new-style theories, and combined numbered files
huffman
parents:
15562
diff
changeset
|
129 |
text {* lubs are unique *} |
15562 | 130 |
|
17810
3bdf516d93d8
cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents:
17372
diff
changeset
|
131 |
lemma unique_lub: "\<lbrakk>S <<| x; S <<| y\<rbrakk> \<Longrightarrow> x = y" |
15562 | 132 |
apply (unfold is_lub_def is_ub_def) |
133 |
apply (blast intro: antisym_less) |
|
134 |
done |
|
135 |
||
15576
efb95d0d01f7
converted to new-style theories, and combined numbered files
huffman
parents:
15562
diff
changeset
|
136 |
text {* technical lemmas about @{term lub} and @{term is_lub} *} |
15562 | 137 |
|
17810
3bdf516d93d8
cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents:
17372
diff
changeset
|
138 |
lemma lubI: "M <<| x \<Longrightarrow> M <<| lub M" |
15930
145651bc64a8
Replaced all unnecessary uses of SOME with THE or LEAST
huffman
parents:
15600
diff
changeset
|
139 |
apply (unfold lub_def) |
17810
3bdf516d93d8
cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents:
17372
diff
changeset
|
140 |
apply (rule theI) |
15930
145651bc64a8
Replaced all unnecessary uses of SOME with THE or LEAST
huffman
parents:
15600
diff
changeset
|
141 |
apply assumption |
17810
3bdf516d93d8
cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents:
17372
diff
changeset
|
142 |
apply (erule (1) unique_lub) |
15562 | 143 |
done |
144 |
||
17810
3bdf516d93d8
cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents:
17372
diff
changeset
|
145 |
lemma thelubI: "M <<| l \<Longrightarrow> lub M = l" |
18088 | 146 |
by (rule unique_lub [OF lubI]) |
15562 | 147 |
|
25780 | 148 |
lemma is_lub_singleton: "{x} <<| x" |
25834 | 149 |
by (simp add: is_lub_def) |
25780 | 150 |
|
17810
3bdf516d93d8
cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents:
17372
diff
changeset
|
151 |
lemma lub_singleton [simp]: "lub {x} = x" |
25780 | 152 |
by (rule thelubI [OF is_lub_singleton]) |
153 |
||
154 |
lemma is_lub_bin: "x \<sqsubseteq> y \<Longrightarrow> {x, y} <<| y" |
|
25834 | 155 |
by (simp add: is_lub_def) |
25780 | 156 |
|
157 |
lemma lub_bin: "x \<sqsubseteq> y \<Longrightarrow> lub {x, y} = y" |
|
158 |
by (rule is_lub_bin [THEN thelubI]) |
|
15562 | 159 |
|
25813 | 160 |
lemma is_lub_maximal: "\<lbrakk>S <| x; x \<in> S\<rbrakk> \<Longrightarrow> S <<| x" |
161 |
by (erule is_lubI, erule (1) is_ubD) |
|
15562 | 162 |
|
25813 | 163 |
lemma lub_maximal: "\<lbrakk>S <| x; x \<in> S\<rbrakk> \<Longrightarrow> lub S = x" |
164 |
by (rule is_lub_maximal [THEN thelubI]) |
|
243
c22b85994e17
Franz Regensburger's Higher-Order Logic of Computable Functions embedding LCF
nipkow
parents:
diff
changeset
|
165 |
|
25695 | 166 |
subsection {* Countable chains *} |
167 |
||
168 |
definition |
|
169 |
-- {* Here we use countable chains and I prefer to code them as functions! *} |
|
170 |
chain :: "(nat \<Rightarrow> 'a::po) \<Rightarrow> bool" where |
|
171 |
"chain F = (\<forall>i. F i \<sqsubseteq> F (Suc i))" |
|
172 |
||
173 |
text {* chains are monotone functions *} |
|
174 |
||
175 |
lemma chain_mono [rule_format]: "chain F \<Longrightarrow> x < y \<longrightarrow> F x \<sqsubseteq> F y" |
|
176 |
apply (unfold chain_def) |
|
177 |
apply (induct_tac y) |
|
178 |
apply simp |
|
179 |
apply (blast elim: less_SucE intro: trans_less) |
|
180 |
done |
|
181 |
||
182 |
lemma chain_mono3: "\<lbrakk>chain F; x \<le> y\<rbrakk> \<Longrightarrow> F x \<sqsubseteq> F y" |
|
183 |
apply (drule le_imp_less_or_eq) |
|
184 |
apply (blast intro: chain_mono) |
|
185 |
done |
|
186 |
||
17810
3bdf516d93d8
cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents:
17372
diff
changeset
|
187 |
lemma chainE: "chain F \<Longrightarrow> F i \<sqsubseteq> F (Suc i)" |
3bdf516d93d8
cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents:
17372
diff
changeset
|
188 |
by (unfold chain_def, simp) |
15562 | 189 |
|
17810
3bdf516d93d8
cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents:
17372
diff
changeset
|
190 |
lemma chainI: "(\<And>i. F i \<sqsubseteq> F (Suc i)) \<Longrightarrow> chain F" |
3bdf516d93d8
cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents:
17372
diff
changeset
|
191 |
by (unfold chain_def, simp) |
15562 | 192 |
|
17810
3bdf516d93d8
cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents:
17372
diff
changeset
|
193 |
lemma chain_shift: "chain Y \<Longrightarrow> chain (\<lambda>i. Y (i + j))" |
15562 | 194 |
apply (rule chainI) |
16318
45b12a01382f
added theorems is_ub_range_shift and is_lub_range_shift
huffman
parents:
16092
diff
changeset
|
195 |
apply simp |
15562 | 196 |
apply (erule chainE) |
197 |
done |
|
198 |
||
15576
efb95d0d01f7
converted to new-style theories, and combined numbered files
huffman
parents:
15562
diff
changeset
|
199 |
text {* technical lemmas about (least) upper bounds of chains *} |
15562 | 200 |
|
17810
3bdf516d93d8
cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents:
17372
diff
changeset
|
201 |
lemma is_ub_lub: "range S <<| x \<Longrightarrow> S i \<sqsubseteq> x" |
3bdf516d93d8
cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents:
17372
diff
changeset
|
202 |
by (rule is_lubD1 [THEN ub_rangeD]) |
15562 | 203 |
|
16318
45b12a01382f
added theorems is_ub_range_shift and is_lub_range_shift
huffman
parents:
16092
diff
changeset
|
204 |
lemma is_ub_range_shift: |
45b12a01382f
added theorems is_ub_range_shift and is_lub_range_shift
huffman
parents:
16092
diff
changeset
|
205 |
"chain S \<Longrightarrow> range (\<lambda>i. S (i + j)) <| x = range S <| x" |
45b12a01382f
added theorems is_ub_range_shift and is_lub_range_shift
huffman
parents:
16092
diff
changeset
|
206 |
apply (rule iffI) |
45b12a01382f
added theorems is_ub_range_shift and is_lub_range_shift
huffman
parents:
16092
diff
changeset
|
207 |
apply (rule ub_rangeI) |
45b12a01382f
added theorems is_ub_range_shift and is_lub_range_shift
huffman
parents:
16092
diff
changeset
|
208 |
apply (rule_tac y="S (i + j)" in trans_less) |
45b12a01382f
added theorems is_ub_range_shift and is_lub_range_shift
huffman
parents:
16092
diff
changeset
|
209 |
apply (erule chain_mono3) |
45b12a01382f
added theorems is_ub_range_shift and is_lub_range_shift
huffman
parents:
16092
diff
changeset
|
210 |
apply (rule le_add1) |
45b12a01382f
added theorems is_ub_range_shift and is_lub_range_shift
huffman
parents:
16092
diff
changeset
|
211 |
apply (erule ub_rangeD) |
45b12a01382f
added theorems is_ub_range_shift and is_lub_range_shift
huffman
parents:
16092
diff
changeset
|
212 |
apply (rule ub_rangeI) |
45b12a01382f
added theorems is_ub_range_shift and is_lub_range_shift
huffman
parents:
16092
diff
changeset
|
213 |
apply (erule ub_rangeD) |
45b12a01382f
added theorems is_ub_range_shift and is_lub_range_shift
huffman
parents:
16092
diff
changeset
|
214 |
done |
45b12a01382f
added theorems is_ub_range_shift and is_lub_range_shift
huffman
parents:
16092
diff
changeset
|
215 |
|
45b12a01382f
added theorems is_ub_range_shift and is_lub_range_shift
huffman
parents:
16092
diff
changeset
|
216 |
lemma is_lub_range_shift: |
45b12a01382f
added theorems is_ub_range_shift and is_lub_range_shift
huffman
parents:
16092
diff
changeset
|
217 |
"chain S \<Longrightarrow> range (\<lambda>i. S (i + j)) <<| x = range S <<| x" |
45b12a01382f
added theorems is_ub_range_shift and is_lub_range_shift
huffman
parents:
16092
diff
changeset
|
218 |
by (simp add: is_lub_def is_ub_range_shift) |
45b12a01382f
added theorems is_ub_range_shift and is_lub_range_shift
huffman
parents:
16092
diff
changeset
|
219 |
|
25695 | 220 |
text {* the lub of a constant chain is the constant *} |
221 |
||
222 |
lemma chain_const [simp]: "chain (\<lambda>i. c)" |
|
223 |
by (simp add: chainI) |
|
224 |
||
225 |
lemma lub_const: "range (\<lambda>x. c) <<| c" |
|
226 |
by (blast dest: ub_rangeD intro: is_lubI ub_rangeI) |
|
227 |
||
228 |
lemma thelub_const [simp]: "(\<Squnion>i. c) = c" |
|
229 |
by (rule lub_const [THEN thelubI]) |
|
230 |
||
231 |
subsection {* Totally ordered sets *} |
|
232 |
||
233 |
definition |
|
234 |
-- {* Arbitrary chains are total orders *} |
|
235 |
tord :: "'a::po set \<Rightarrow> bool" where |
|
236 |
"tord S = (\<forall>x y. x \<in> S \<and> y \<in> S \<longrightarrow> (x \<sqsubseteq> y \<or> y \<sqsubseteq> x))" |
|
237 |
||
238 |
text {* The range of a chain is a totally ordered *} |
|
239 |
||
240 |
lemma chain_tord: "chain F \<Longrightarrow> tord (range F)" |
|
241 |
apply (unfold tord_def, clarify) |
|
242 |
apply (rule nat_less_cases) |
|
243 |
apply (fast intro: chain_mono)+ |
|
244 |
done |
|
245 |
||
246 |
lemma finite_tord_has_max [rule_format]: |
|
247 |
"finite S \<Longrightarrow> S \<noteq> {} \<longrightarrow> tord S \<longrightarrow> (\<exists>y\<in>S. \<forall>x\<in>S. x \<sqsubseteq> y)" |
|
248 |
apply (erule finite_induct, simp) |
|
249 |
apply (rename_tac a S, clarify) |
|
250 |
apply (case_tac "S = {}", simp) |
|
251 |
apply (drule (1) mp) |
|
252 |
apply (drule mp, simp add: tord_def) |
|
253 |
apply (erule bexE, rename_tac z) |
|
254 |
apply (subgoal_tac "a \<sqsubseteq> z \<or> z \<sqsubseteq> a") |
|
255 |
apply (erule disjE) |
|
256 |
apply (rule_tac x="z" in bexI, simp, simp) |
|
257 |
apply (rule_tac x="a" in bexI) |
|
258 |
apply (clarsimp elim!: rev_trans_less) |
|
259 |
apply simp |
|
260 |
apply (simp add: tord_def) |
|
261 |
done |
|
262 |
||
263 |
subsection {* Finite chains *} |
|
264 |
||
265 |
definition |
|
266 |
-- {* finite chains, needed for monotony of continuous functions *} |
|
267 |
max_in_chain :: "[nat, nat \<Rightarrow> 'a::po] \<Rightarrow> bool" where |
|
268 |
"max_in_chain i C = (\<forall>j. i \<le> j \<longrightarrow> C i = C j)" |
|
269 |
||
270 |
definition |
|
271 |
finite_chain :: "(nat \<Rightarrow> 'a::po) \<Rightarrow> bool" where |
|
272 |
"finite_chain C = (chain C \<and> (\<exists>i. max_in_chain i C))" |
|
273 |
||
15576
efb95d0d01f7
converted to new-style theories, and combined numbered files
huffman
parents:
15562
diff
changeset
|
274 |
text {* results about finite chains *} |
15562 | 275 |
|
17810
3bdf516d93d8
cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents:
17372
diff
changeset
|
276 |
lemma lub_finch1: "\<lbrakk>chain C; max_in_chain i C\<rbrakk> \<Longrightarrow> range C <<| C i" |
15562 | 277 |
apply (unfold max_in_chain_def) |
278 |
apply (rule is_lubI) |
|
17810
3bdf516d93d8
cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents:
17372
diff
changeset
|
279 |
apply (rule ub_rangeI, rename_tac j) |
3bdf516d93d8
cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents:
17372
diff
changeset
|
280 |
apply (rule_tac x=i and y=j in linorder_le_cases) |
3bdf516d93d8
cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents:
17372
diff
changeset
|
281 |
apply simp |
3bdf516d93d8
cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents:
17372
diff
changeset
|
282 |
apply (erule (1) chain_mono3) |
15562 | 283 |
apply (erule ub_rangeD) |
284 |
done |
|
285 |
||
25131
2c8caac48ade
modernized specifications ('definition', 'abbreviation', 'notation');
wenzelm
parents:
24728
diff
changeset
|
286 |
lemma lub_finch2: |
17810
3bdf516d93d8
cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents:
17372
diff
changeset
|
287 |
"finite_chain C \<Longrightarrow> range C <<| C (LEAST i. max_in_chain i C)" |
15562 | 288 |
apply (unfold finite_chain_def) |
17810
3bdf516d93d8
cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents:
17372
diff
changeset
|
289 |
apply (erule conjE) |
3bdf516d93d8
cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents:
17372
diff
changeset
|
290 |
apply (erule LeastI2_ex) |
3bdf516d93d8
cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents:
17372
diff
changeset
|
291 |
apply (erule (1) lub_finch1) |
15562 | 292 |
done |
293 |
||
19621 | 294 |
lemma finch_imp_finite_range: "finite_chain Y \<Longrightarrow> finite (range Y)" |
295 |
apply (unfold finite_chain_def, clarify) |
|
296 |
apply (rule_tac f="Y" and n="Suc i" in nat_seg_image_imp_finite) |
|
297 |
apply (rule equalityI) |
|
298 |
apply (rule subsetI) |
|
299 |
apply (erule rangeE, rename_tac j) |
|
300 |
apply (rule_tac x=i and y=j in linorder_le_cases) |
|
301 |
apply (subgoal_tac "Y j = Y i", simp) |
|
302 |
apply (simp add: max_in_chain_def) |
|
303 |
apply simp |
|
304 |
apply fast |
|
305 |
done |
|
306 |
||
307 |
lemma finite_range_imp_finch: |
|
308 |
"\<lbrakk>chain Y; finite (range Y)\<rbrakk> \<Longrightarrow> finite_chain Y" |
|
309 |
apply (subgoal_tac "\<exists>y\<in>range Y. \<forall>x\<in>range Y. x \<sqsubseteq> y") |
|
310 |
apply (clarsimp, rename_tac i) |
|
311 |
apply (subgoal_tac "max_in_chain i Y") |
|
312 |
apply (simp add: finite_chain_def exI) |
|
313 |
apply (simp add: max_in_chain_def po_eq_conv chain_mono3) |
|
314 |
apply (erule finite_tord_has_max, simp) |
|
315 |
apply (erule chain_tord) |
|
316 |
done |
|
317 |
||
17810
3bdf516d93d8
cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents:
17372
diff
changeset
|
318 |
lemma bin_chain: "x \<sqsubseteq> y \<Longrightarrow> chain (\<lambda>i. if i=0 then x else y)" |
3bdf516d93d8
cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents:
17372
diff
changeset
|
319 |
by (rule chainI, simp) |
3bdf516d93d8
cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents:
17372
diff
changeset
|
320 |
|
3bdf516d93d8
cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents:
17372
diff
changeset
|
321 |
lemma bin_chainmax: |
3bdf516d93d8
cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents:
17372
diff
changeset
|
322 |
"x \<sqsubseteq> y \<Longrightarrow> max_in_chain (Suc 0) (\<lambda>i. if i=0 then x else y)" |
3bdf516d93d8
cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents:
17372
diff
changeset
|
323 |
by (unfold max_in_chain_def, simp) |
15562 | 324 |
|
17810
3bdf516d93d8
cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents:
17372
diff
changeset
|
325 |
lemma lub_bin_chain: |
3bdf516d93d8
cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents:
17372
diff
changeset
|
326 |
"x \<sqsubseteq> y \<Longrightarrow> range (\<lambda>i::nat. if i=0 then x else y) <<| y" |
3bdf516d93d8
cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents:
17372
diff
changeset
|
327 |
apply (frule bin_chain) |
3bdf516d93d8
cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents:
17372
diff
changeset
|
328 |
apply (drule bin_chainmax) |
3bdf516d93d8
cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents:
17372
diff
changeset
|
329 |
apply (drule (1) lub_finch1) |
3bdf516d93d8
cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents:
17372
diff
changeset
|
330 |
apply simp |
15562 | 331 |
done |
332 |
||
15576
efb95d0d01f7
converted to new-style theories, and combined numbered files
huffman
parents:
15562
diff
changeset
|
333 |
text {* the maximal element in a chain is its lub *} |
15562 | 334 |
|
17810
3bdf516d93d8
cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents:
17372
diff
changeset
|
335 |
lemma lub_chain_maxelem: "\<lbrakk>Y i = c; \<forall>i. Y i \<sqsubseteq> c\<rbrakk> \<Longrightarrow> lub (range Y) = c" |
3bdf516d93d8
cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents:
17372
diff
changeset
|
336 |
by (blast dest: ub_rangeD intro: thelubI is_lubI ub_rangeI) |
15562 | 337 |
|
25773 | 338 |
subsection {* Directed sets *} |
339 |
||
340 |
definition |
|
341 |
directed :: "'a::po set \<Rightarrow> bool" where |
|
342 |
"directed S = ((\<exists>x. x \<in> S) \<and> (\<forall>x\<in>S. \<forall>y\<in>S. \<exists>z\<in>S. x \<sqsubseteq> z \<and> y \<sqsubseteq> z))" |
|
343 |
||
344 |
lemma directedI: |
|
345 |
assumes 1: "\<exists>z. z \<in> S" |
|
346 |
assumes 2: "\<And>x y. \<lbrakk>x \<in> S; y \<in> S\<rbrakk> \<Longrightarrow> \<exists>z\<in>S. x \<sqsubseteq> z \<and> y \<sqsubseteq> z" |
|
347 |
shows "directed S" |
|
348 |
unfolding directed_def using prems by fast |
|
349 |
||
350 |
lemma directedD1: "directed S \<Longrightarrow> \<exists>z. z \<in> S" |
|
351 |
unfolding directed_def by fast |
|
352 |
||
353 |
lemma directedD2: "\<lbrakk>directed S; x \<in> S; y \<in> S\<rbrakk> \<Longrightarrow> \<exists>z\<in>S. x \<sqsubseteq> z \<and> y \<sqsubseteq> z" |
|
354 |
unfolding directed_def by fast |
|
355 |
||
25780 | 356 |
lemma directedE1: |
357 |
assumes S: "directed S" |
|
358 |
obtains z where "z \<in> S" |
|
359 |
by (insert directedD1 [OF S], fast) |
|
360 |
||
361 |
lemma directedE2: |
|
362 |
assumes S: "directed S" |
|
363 |
assumes x: "x \<in> S" and y: "y \<in> S" |
|
364 |
obtains z where "z \<in> S" "x \<sqsubseteq> z" "y \<sqsubseteq> z" |
|
365 |
by (insert directedD2 [OF S x y], fast) |
|
366 |
||
25773 | 367 |
lemma directed_finiteI: |
25828
228c53fdb3b4
add new is_ub lemmas; clean up directed_finite proofs
huffman
parents:
25813
diff
changeset
|
368 |
assumes U: "\<And>U. \<lbrakk>finite U; U \<subseteq> S\<rbrakk> \<Longrightarrow> \<exists>z\<in>S. U <| z" |
25773 | 369 |
shows "directed S" |
370 |
proof (rule directedI) |
|
371 |
have "finite {}" and "{} \<subseteq> S" by simp_all |
|
25828
228c53fdb3b4
add new is_ub lemmas; clean up directed_finite proofs
huffman
parents:
25813
diff
changeset
|
372 |
hence "\<exists>z\<in>S. {} <| z" by (rule U) |
25773 | 373 |
thus "\<exists>z. z \<in> S" by simp |
374 |
next |
|
375 |
fix x y |
|
376 |
assume "x \<in> S" and "y \<in> S" |
|
377 |
hence "finite {x, y}" and "{x, y} \<subseteq> S" by simp_all |
|
25828
228c53fdb3b4
add new is_ub lemmas; clean up directed_finite proofs
huffman
parents:
25813
diff
changeset
|
378 |
hence "\<exists>z\<in>S. {x, y} <| z" by (rule U) |
25773 | 379 |
thus "\<exists>z\<in>S. x \<sqsubseteq> z \<and> y \<sqsubseteq> z" by simp |
380 |
qed |
|
381 |
||
382 |
lemma directed_finiteD: |
|
383 |
assumes S: "directed S" |
|
25828
228c53fdb3b4
add new is_ub lemmas; clean up directed_finite proofs
huffman
parents:
25813
diff
changeset
|
384 |
shows "\<lbrakk>finite U; U \<subseteq> S\<rbrakk> \<Longrightarrow> \<exists>z\<in>S. U <| z" |
228c53fdb3b4
add new is_ub lemmas; clean up directed_finite proofs
huffman
parents:
25813
diff
changeset
|
385 |
proof (induct U set: finite) |
228c53fdb3b4
add new is_ub lemmas; clean up directed_finite proofs
huffman
parents:
25813
diff
changeset
|
386 |
case empty |
228c53fdb3b4
add new is_ub lemmas; clean up directed_finite proofs
huffman
parents:
25813
diff
changeset
|
387 |
from S have "\<exists>z. z \<in> S" by (rule directedD1) |
228c53fdb3b4
add new is_ub lemmas; clean up directed_finite proofs
huffman
parents:
25813
diff
changeset
|
388 |
thus "\<exists>z\<in>S. {} <| z" by simp |
228c53fdb3b4
add new is_ub lemmas; clean up directed_finite proofs
huffman
parents:
25813
diff
changeset
|
389 |
next |
228c53fdb3b4
add new is_ub lemmas; clean up directed_finite proofs
huffman
parents:
25813
diff
changeset
|
390 |
case (insert x F) |
228c53fdb3b4
add new is_ub lemmas; clean up directed_finite proofs
huffman
parents:
25813
diff
changeset
|
391 |
from `insert x F \<subseteq> S` |
228c53fdb3b4
add new is_ub lemmas; clean up directed_finite proofs
huffman
parents:
25813
diff
changeset
|
392 |
have xS: "x \<in> S" and FS: "F \<subseteq> S" by simp_all |
228c53fdb3b4
add new is_ub lemmas; clean up directed_finite proofs
huffman
parents:
25813
diff
changeset
|
393 |
from FS have "\<exists>y\<in>S. F <| y" by fact |
228c53fdb3b4
add new is_ub lemmas; clean up directed_finite proofs
huffman
parents:
25813
diff
changeset
|
394 |
then obtain y where yS: "y \<in> S" and Fy: "F <| y" .. |
228c53fdb3b4
add new is_ub lemmas; clean up directed_finite proofs
huffman
parents:
25813
diff
changeset
|
395 |
obtain z where zS: "z \<in> S" and xz: "x \<sqsubseteq> z" and yz: "y \<sqsubseteq> z" |
228c53fdb3b4
add new is_ub lemmas; clean up directed_finite proofs
huffman
parents:
25813
diff
changeset
|
396 |
using S xS yS by (rule directedE2) |
228c53fdb3b4
add new is_ub lemmas; clean up directed_finite proofs
huffman
parents:
25813
diff
changeset
|
397 |
from Fy yz have "F <| z" by (rule is_ub_upward) |
228c53fdb3b4
add new is_ub lemmas; clean up directed_finite proofs
huffman
parents:
25813
diff
changeset
|
398 |
with xz have "insert x F <| z" by simp |
228c53fdb3b4
add new is_ub lemmas; clean up directed_finite proofs
huffman
parents:
25813
diff
changeset
|
399 |
with zS show "\<exists>z\<in>S. insert x F <| z" .. |
25773 | 400 |
qed |
401 |
||
25813 | 402 |
lemma not_directed_empty [simp]: "\<not> directed {}" |
25773 | 403 |
by (rule notI, drule directedD1, simp) |
404 |
||
405 |
lemma directed_singleton: "directed {x}" |
|
406 |
by (rule directedI, auto) |
|
407 |
||
408 |
lemma directed_bin: "x \<sqsubseteq> y \<Longrightarrow> directed {x, y}" |
|
409 |
by (rule directedI, auto) |
|
410 |
||
411 |
lemma directed_chain: "chain S \<Longrightarrow> directed (range S)" |
|
412 |
apply (rule directedI) |
|
413 |
apply (rule_tac x="S 0" in exI, simp) |
|
414 |
apply (clarify, rename_tac m n) |
|
415 |
apply (rule_tac x="S (max m n)" in bexI) |
|
416 |
apply (simp add: chain_mono3) |
|
417 |
apply simp |
|
418 |
done |
|
419 |
||
18071
940c2c0ff33a
cleaned up; chain_const and thelub_const are simp rules
huffman
parents:
17810
diff
changeset
|
420 |
end |