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