author | wenzelm |
Tue, 10 Dec 2024 22:40:07 +0100 | |
changeset 81574 | c4abe6582ee5 |
parent 81095 | 49c04500c5f9 |
permissions | -rw-r--r-- |
42151 | 1 |
(* Title: HOL/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 |
|
62175 | 5 |
section \<open>Partial orders\<close> |
15576
efb95d0d01f7
converted to new-style theories, and combined numbered files
huffman
parents:
15562
diff
changeset
|
6 |
|
15577 | 7 |
theory Porder |
67312 | 8 |
imports Main |
15577 | 9 |
begin |
15576
efb95d0d01f7
converted to new-style theories, and combined numbered files
huffman
parents:
15562
diff
changeset
|
10 |
|
61260 | 11 |
declare [[typedef_overloaded]] |
12 |
||
13 |
||
62175 | 14 |
subsection \<open>Type class for partial orders\<close> |
15587
f363e6e080e7
added subsections and text for document generation
huffman
parents:
15577
diff
changeset
|
15 |
|
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
|
16 |
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
|
17 |
fixes below :: "'a \<Rightarrow> 'a \<Rightarrow> bool" |
31071 | 18 |
begin |
15576
efb95d0d01f7
converted to new-style theories, and combined numbered files
huffman
parents:
15562
diff
changeset
|
19 |
|
61998 | 20 |
notation (ASCII) |
80914
d97fdabd9e2b
standardize mixfix annotations via "isabelle update -a -u mixfix_cartouches" --- to simplify systematic editing;
wenzelm
parents:
80768
diff
changeset
|
21 |
below (infix \<open><<\<close> 50) |
15576
efb95d0d01f7
converted to new-style theories, and combined numbered files
huffman
parents:
15562
diff
changeset
|
22 |
|
61998 | 23 |
notation |
80914
d97fdabd9e2b
standardize mixfix annotations via "isabelle update -a -u mixfix_cartouches" --- to simplify systematic editing;
wenzelm
parents:
80768
diff
changeset
|
24 |
below (infix \<open>\<sqsubseteq>\<close> 50) |
15576
efb95d0d01f7
converted to new-style theories, and combined numbered files
huffman
parents:
15562
diff
changeset
|
25 |
|
80914
d97fdabd9e2b
standardize mixfix annotations via "isabelle update -a -u mixfix_cartouches" --- to simplify systematic editing;
wenzelm
parents:
80768
diff
changeset
|
26 |
abbreviation not_below :: "'a \<Rightarrow> 'a \<Rightarrow> bool" (infix \<open>\<notsqsubseteq>\<close> 50) |
41182 | 27 |
where "not_below x y \<equiv> \<not> below x y" |
28 |
||
61998 | 29 |
notation (ASCII) |
80914
d97fdabd9e2b
standardize mixfix annotations via "isabelle update -a -u mixfix_cartouches" --- to simplify systematic editing;
wenzelm
parents:
80768
diff
changeset
|
30 |
not_below (infix \<open>~<<\<close> 50) |
41182 | 31 |
|
67312 | 32 |
lemma below_eq_trans: "a \<sqsubseteq> b \<Longrightarrow> b = c \<Longrightarrow> a \<sqsubseteq> c" |
31071 | 33 |
by (rule subst) |
34 |
||
67312 | 35 |
lemma eq_below_trans: "a = b \<Longrightarrow> b \<sqsubseteq> c \<Longrightarrow> a \<sqsubseteq> c" |
31071 | 36 |
by (rule ssubst) |
37 |
||
38 |
end |
|
39 |
||
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 |
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
|
41 |
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
|
42 |
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
|
43 |
assumes below_antisym: "x \<sqsubseteq> y \<Longrightarrow> y \<sqsubseteq> x \<Longrightarrow> x = y" |
31071 | 44 |
begin |
15576
efb95d0d01f7
converted to new-style theories, and combined numbered files
huffman
parents:
15562
diff
changeset
|
45 |
|
40432 | 46 |
lemma eq_imp_below: "x = y \<Longrightarrow> x \<sqsubseteq> y" |
47 |
by simp |
|
48 |
||
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
|
49 |
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
|
50 |
by (rule below_trans [OF below_trans]) |
17810
3bdf516d93d8
cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents:
17372
diff
changeset
|
51 |
|
31071 | 52 |
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
|
53 |
by (fast intro!: below_antisym) |
15576
efb95d0d01f7
converted to new-style theories, and combined numbered files
huffman
parents:
15562
diff
changeset
|
54 |
|
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
|
55 |
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
|
56 |
by (rule below_trans) |
18647 | 57 |
|
41182 | 58 |
lemma not_below2not_eq: "x \<notsqsubseteq> y \<Longrightarrow> x \<noteq> y" |
31071 | 59 |
by auto |
60 |
||
61 |
end |
|
18647 | 62 |
|
63 |
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
|
64 |
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
|
65 |
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
|
66 |
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
|
67 |
eq_below_trans |
18647 | 68 |
|
31071 | 69 |
context po |
70 |
begin |
|
71 |
||
62175 | 72 |
subsection \<open>Upper bounds\<close> |
18071
940c2c0ff33a
cleaned up; chain_const and thelub_const are simp rules
huffman
parents:
17810
diff
changeset
|
73 |
|
80914
d97fdabd9e2b
standardize mixfix annotations via "isabelle update -a -u mixfix_cartouches" --- to simplify systematic editing;
wenzelm
parents:
80768
diff
changeset
|
74 |
definition is_ub :: "'a set \<Rightarrow> 'a \<Rightarrow> bool" (infix \<open><|\<close> 55) |
67312 | 75 |
where "S <| x \<longleftrightarrow> (\<forall>y\<in>S. y \<sqsubseteq> x)" |
18071
940c2c0ff33a
cleaned up; chain_const and thelub_const are simp rules
huffman
parents:
17810
diff
changeset
|
76 |
|
25777 | 77 |
lemma is_ubI: "(\<And>x. x \<in> S \<Longrightarrow> x \<sqsubseteq> u) \<Longrightarrow> S <| u" |
31071 | 78 |
by (simp add: is_ub_def) |
25777 | 79 |
|
80 |
lemma is_ubD: "\<lbrakk>S <| u; x \<in> S\<rbrakk> \<Longrightarrow> x \<sqsubseteq> u" |
|
31071 | 81 |
by (simp add: is_ub_def) |
25777 | 82 |
|
83 |
lemma ub_imageI: "(\<And>x. x \<in> S \<Longrightarrow> f x \<sqsubseteq> u) \<Longrightarrow> (\<lambda>x. f x) ` S <| u" |
|
31071 | 84 |
unfolding is_ub_def by fast |
25777 | 85 |
|
86 |
lemma ub_imageD: "\<lbrakk>f ` S <| u; x \<in> S\<rbrakk> \<Longrightarrow> f x \<sqsubseteq> u" |
|
31071 | 87 |
unfolding is_ub_def by fast |
25777 | 88 |
|
89 |
lemma ub_rangeI: "(\<And>i. S i \<sqsubseteq> x) \<Longrightarrow> range S <| x" |
|
31071 | 90 |
unfolding is_ub_def by fast |
25777 | 91 |
|
92 |
lemma ub_rangeD: "range S <| x \<Longrightarrow> S i \<sqsubseteq> x" |
|
31071 | 93 |
unfolding is_ub_def by fast |
25777 | 94 |
|
25828
228c53fdb3b4
add new is_ub lemmas; clean up directed_finite proofs
huffman
parents:
25813
diff
changeset
|
95 |
lemma is_ub_empty [simp]: "{} <| u" |
31071 | 96 |
unfolding is_ub_def by fast |
25828
228c53fdb3b4
add new is_ub lemmas; clean up directed_finite proofs
huffman
parents:
25813
diff
changeset
|
97 |
|
228c53fdb3b4
add new is_ub lemmas; clean up directed_finite proofs
huffman
parents:
25813
diff
changeset
|
98 |
lemma is_ub_insert [simp]: "(insert x A) <| y = (x \<sqsubseteq> y \<and> A <| y)" |
31071 | 99 |
unfolding is_ub_def by fast |
25828
228c53fdb3b4
add new is_ub lemmas; clean up directed_finite proofs
huffman
parents:
25813
diff
changeset
|
100 |
|
228c53fdb3b4
add new is_ub lemmas; clean up directed_finite proofs
huffman
parents:
25813
diff
changeset
|
101 |
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
|
102 |
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
|
103 |
|
67312 | 104 |
|
62175 | 105 |
subsection \<open>Least upper bounds\<close> |
25777 | 106 |
|
80914
d97fdabd9e2b
standardize mixfix annotations via "isabelle update -a -u mixfix_cartouches" --- to simplify systematic editing;
wenzelm
parents:
80768
diff
changeset
|
107 |
definition is_lub :: "'a set \<Rightarrow> 'a \<Rightarrow> bool" (infix \<open><<|\<close> 55) |
67312 | 108 |
where "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
|
109 |
|
67312 | 110 |
definition lub :: "'a set \<Rightarrow> 'a" |
111 |
where "lub S = (THE x. S <<| x)" |
|
243
c22b85994e17
Franz Regensburger's Higher-Order Logic of Computable Functions embedding LCF
nipkow
parents:
diff
changeset
|
112 |
|
31071 | 113 |
end |
114 |
||
61998 | 115 |
syntax (ASCII) |
81095 | 116 |
"_BLub" :: "[pttrn, 'a set, 'b] \<Rightarrow> 'b" (\<open>(\<open>indent=3 notation=\<open>binder LUB\<close>\<close>LUB _:_./ _)\<close> [0,0, 10] 10) |
25777 | 117 |
|
61998 | 118 |
syntax |
81095 | 119 |
"_BLub" :: "[pttrn, 'a set, 'b] \<Rightarrow> 'b" (\<open>(\<open>indent=3 notation=\<open>binder \<Squnion>\<close>\<close>\<Squnion>_\<in>_./ _)\<close> [0,0, 10] 10) |
25777 | 120 |
|
80768 | 121 |
syntax_consts |
122 |
"_BLub" \<rightleftharpoons> lub |
|
123 |
||
25777 | 124 |
translations |
67312 | 125 |
"LUB x:A. t" \<rightleftharpoons> "CONST lub ((\<lambda>x. t) ` A)" |
25777 | 126 |
|
31071 | 127 |
context po |
128 |
begin |
|
129 |
||
80914
d97fdabd9e2b
standardize mixfix annotations via "isabelle update -a -u mixfix_cartouches" --- to simplify systematic editing;
wenzelm
parents:
80768
diff
changeset
|
130 |
abbreviation Lub (binder \<open>\<Squnion>\<close> 10) |
67312 | 131 |
where "\<Squnion>n. t n \<equiv> lub (range t)" |
2394 | 132 |
|
61998 | 133 |
notation (ASCII) |
80914
d97fdabd9e2b
standardize mixfix annotations via "isabelle update -a -u mixfix_cartouches" --- to simplify systematic editing;
wenzelm
parents:
80768
diff
changeset
|
134 |
Lub (binder \<open>LUB \<close> 10) |
243
c22b85994e17
Franz Regensburger's Higher-Order Logic of Computable Functions embedding LCF
nipkow
parents:
diff
changeset
|
135 |
|
62175 | 136 |
text \<open>access to some definition as inference rule\<close> |
25813 | 137 |
|
138 |
lemma is_lubD1: "S <<| x \<Longrightarrow> S <| x" |
|
31071 | 139 |
unfolding is_lub_def by fast |
25813 | 140 |
|
40771 | 141 |
lemma is_lubD2: "\<lbrakk>S <<| x; S <| u\<rbrakk> \<Longrightarrow> x \<sqsubseteq> u" |
31071 | 142 |
unfolding is_lub_def by fast |
25813 | 143 |
|
144 |
lemma is_lubI: "\<lbrakk>S <| x; \<And>u. S <| u \<Longrightarrow> x \<sqsubseteq> u\<rbrakk> \<Longrightarrow> S <<| x" |
|
31071 | 145 |
unfolding is_lub_def by fast |
25813 | 146 |
|
39969 | 147 |
lemma is_lub_below_iff: "S <<| x \<Longrightarrow> x \<sqsubseteq> u \<longleftrightarrow> S <| u" |
148 |
unfolding is_lub_def is_ub_def by (metis below_trans) |
|
149 |
||
62175 | 150 |
text \<open>lubs are unique\<close> |
15562 | 151 |
|
67312 | 152 |
lemma is_lub_unique: "S <<| x \<Longrightarrow> S <<| y \<Longrightarrow> x = y" |
40771 | 153 |
unfolding is_lub_def is_ub_def by (blast intro: below_antisym) |
15562 | 154 |
|
69597 | 155 |
text \<open>technical lemmas about \<^term>\<open>lub\<close> and \<^term>\<open>is_lub\<close>\<close> |
15562 | 156 |
|
40771 | 157 |
lemma is_lub_lub: "M <<| x \<Longrightarrow> M <<| lub M" |
158 |
unfolding lub_def by (rule theI [OF _ is_lub_unique]) |
|
15562 | 159 |
|
40771 | 160 |
lemma lub_eqI: "M <<| l \<Longrightarrow> lub M = l" |
161 |
by (rule is_lub_unique [OF is_lub_lub]) |
|
15562 | 162 |
|
68780 | 163 |
lemma is_lub_singleton [simp]: "{x} <<| x" |
31071 | 164 |
by (simp add: is_lub_def) |
25780 | 165 |
|
17810
3bdf516d93d8
cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents:
17372
diff
changeset
|
166 |
lemma lub_singleton [simp]: "lub {x} = x" |
40771 | 167 |
by (rule is_lub_singleton [THEN lub_eqI]) |
25780 | 168 |
|
169 |
lemma is_lub_bin: "x \<sqsubseteq> y \<Longrightarrow> {x, y} <<| y" |
|
31071 | 170 |
by (simp add: is_lub_def) |
25780 | 171 |
|
172 |
lemma lub_bin: "x \<sqsubseteq> y \<Longrightarrow> lub {x, y} = y" |
|
40771 | 173 |
by (rule is_lub_bin [THEN lub_eqI]) |
15562 | 174 |
|
67312 | 175 |
lemma is_lub_maximal: "S <| x \<Longrightarrow> x \<in> S \<Longrightarrow> S <<| x" |
31071 | 176 |
by (erule is_lubI, erule (1) is_ubD) |
15562 | 177 |
|
67312 | 178 |
lemma lub_maximal: "S <| x \<Longrightarrow> x \<in> S \<Longrightarrow> lub S = x" |
40771 | 179 |
by (rule is_lub_maximal [THEN lub_eqI]) |
243
c22b85994e17
Franz Regensburger's Higher-Order Logic of Computable Functions embedding LCF
nipkow
parents:
diff
changeset
|
180 |
|
67312 | 181 |
|
62175 | 182 |
subsection \<open>Countable chains\<close> |
25695 | 183 |
|
67312 | 184 |
definition chain :: "(nat \<Rightarrow> 'a) \<Rightarrow> bool" |
185 |
where \<comment> \<open>Here we use countable chains and I prefer to code them as functions!\<close> |
|
25922
cb04d05e95fb
rename lemma chain_mono3 -> chain_mono, chain_mono -> chain_mono_less
huffman
parents:
25897
diff
changeset
|
186 |
"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
|
187 |
|
cb04d05e95fb
rename lemma chain_mono3 -> chain_mono, chain_mono -> chain_mono_less
huffman
parents:
25897
diff
changeset
|
188 |
lemma chainI: "(\<And>i. Y i \<sqsubseteq> Y (Suc i)) \<Longrightarrow> chain Y" |
31071 | 189 |
unfolding chain_def by fast |
25922
cb04d05e95fb
rename lemma chain_mono3 -> chain_mono, chain_mono -> chain_mono_less
huffman
parents:
25897
diff
changeset
|
190 |
|
cb04d05e95fb
rename lemma chain_mono3 -> chain_mono, chain_mono -> chain_mono_less
huffman
parents:
25897
diff
changeset
|
191 |
lemma chainE: "chain Y \<Longrightarrow> Y i \<sqsubseteq> Y (Suc i)" |
31071 | 192 |
unfolding chain_def by fast |
25695 | 193 |
|
62175 | 194 |
text \<open>chains are monotone functions\<close> |
25695 | 195 |
|
67312 | 196 |
lemma chain_mono_less: "chain Y \<Longrightarrow> i < j \<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
|
197 |
by (erule less_Suc_induct, erule chainE, erule below_trans) |
25695 | 198 |
|
67312 | 199 |
lemma chain_mono: "chain Y \<Longrightarrow> i \<le> j \<Longrightarrow> Y i \<sqsubseteq> Y j" |
200 |
by (cases "i = j") (simp_all add: chain_mono_less) |
|
15562 | 201 |
|
17810
3bdf516d93d8
cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents:
17372
diff
changeset
|
202 |
lemma chain_shift: "chain Y \<Longrightarrow> chain (\<lambda>i. Y (i + j))" |
31071 | 203 |
by (rule chainI, simp, erule chainE) |
15562 | 204 |
|
62175 | 205 |
text \<open>technical lemmas about (least) upper bounds of chains\<close> |
15562 | 206 |
|
40771 | 207 |
lemma is_lub_rangeD1: "range S <<| x \<Longrightarrow> S i \<sqsubseteq> x" |
31071 | 208 |
by (rule is_lubD1 [THEN ub_rangeD]) |
15562 | 209 |
|
67312 | 210 |
lemma is_ub_range_shift: "chain S \<Longrightarrow> range (\<lambda>i. S (i + j)) <| x = range S <| x" |
211 |
apply (rule iffI) |
|
212 |
apply (rule ub_rangeI) |
|
213 |
apply (rule_tac y="S (i + j)" in below_trans) |
|
214 |
apply (erule chain_mono) |
|
215 |
apply (rule le_add1) |
|
216 |
apply (erule ub_rangeD) |
|
217 |
apply (rule ub_rangeI) |
|
218 |
apply (erule ub_rangeD) |
|
219 |
done |
|
16318
45b12a01382f
added theorems is_ub_range_shift and is_lub_range_shift
huffman
parents:
16092
diff
changeset
|
220 |
|
67312 | 221 |
lemma is_lub_range_shift: "chain S \<Longrightarrow> range (\<lambda>i. S (i + j)) <<| x = range S <<| x" |
31071 | 222 |
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
|
223 |
|
62175 | 224 |
text \<open>the lub of a constant chain is the constant\<close> |
25695 | 225 |
|
226 |
lemma chain_const [simp]: "chain (\<lambda>i. c)" |
|
31071 | 227 |
by (simp add: chainI) |
25695 | 228 |
|
40771 | 229 |
lemma is_lub_const: "range (\<lambda>x. c) <<| c" |
25695 | 230 |
by (blast dest: ub_rangeD intro: is_lubI ub_rangeI) |
231 |
||
40771 | 232 |
lemma lub_const [simp]: "(\<Squnion>i. c) = c" |
233 |
by (rule is_lub_const [THEN lub_eqI]) |
|
25695 | 234 |
|
67312 | 235 |
|
62175 | 236 |
subsection \<open>Finite chains\<close> |
25695 | 237 |
|
67312 | 238 |
definition max_in_chain :: "nat \<Rightarrow> (nat \<Rightarrow> 'a) \<Rightarrow> bool" |
239 |
where \<comment> \<open>finite chains, needed for monotony of continuous functions\<close> |
|
31071 | 240 |
"max_in_chain i C \<longleftrightarrow> (\<forall>j. i \<le> j \<longrightarrow> C i = C j)" |
25695 | 241 |
|
67312 | 242 |
definition finite_chain :: "(nat \<Rightarrow> 'a) \<Rightarrow> bool" |
243 |
where "finite_chain C = (chain C \<and> (\<exists>i. max_in_chain i C))" |
|
25695 | 244 |
|
62175 | 245 |
text \<open>results about finite chains\<close> |
15562 | 246 |
|
25878 | 247 |
lemma max_in_chainI: "(\<And>j. i \<le> j \<Longrightarrow> Y i = Y j) \<Longrightarrow> max_in_chain i Y" |
31071 | 248 |
unfolding max_in_chain_def by fast |
25878 | 249 |
|
67312 | 250 |
lemma max_in_chainD: "max_in_chain i Y \<Longrightarrow> i \<le> j \<Longrightarrow> Y i = Y j" |
31071 | 251 |
unfolding max_in_chain_def by fast |
25878 | 252 |
|
67312 | 253 |
lemma finite_chainI: "chain C \<Longrightarrow> max_in_chain i C \<Longrightarrow> finite_chain C" |
31071 | 254 |
unfolding finite_chain_def by fast |
27317 | 255 |
|
67312 | 256 |
lemma finite_chainE: "\<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 |
|
67312 | 259 |
lemma lub_finch1: "chain C \<Longrightarrow> max_in_chain i C \<Longrightarrow> range C <<| C i" |
260 |
apply (rule is_lubI) |
|
261 |
apply (rule ub_rangeI, rename_tac j) |
|
262 |
apply (rule_tac x=i and y=j in linorder_le_cases) |
|
263 |
apply (drule (1) max_in_chainD, simp) |
|
264 |
apply (erule (1) chain_mono) |
|
265 |
apply (erule ub_rangeD) |
|
266 |
done |
|
15562 | 267 |
|
67312 | 268 |
lemma lub_finch2: "finite_chain C \<Longrightarrow> range C <<| C (LEAST i. max_in_chain i C)" |
269 |
apply (erule finite_chainE) |
|
270 |
apply (erule LeastI2 [where Q="\<lambda>i. range C <<| C i"]) |
|
271 |
apply (erule (1) lub_finch1) |
|
272 |
done |
|
15562 | 273 |
|
19621 | 274 |
lemma finch_imp_finite_range: "finite_chain Y \<Longrightarrow> finite (range Y)" |
67312 | 275 |
apply (erule finite_chainE) |
276 |
apply (rule_tac B="Y ` {..i}" in finite_subset) |
|
277 |
apply (rule subsetI) |
|
278 |
apply (erule rangeE, rename_tac j) |
|
279 |
apply (rule_tac x=i and y=j in linorder_le_cases) |
|
280 |
apply (subgoal_tac "Y j = Y i", simp) |
|
281 |
apply (simp add: max_in_chain_def) |
|
282 |
apply simp |
|
19621 | 283 |
apply simp |
67312 | 284 |
done |
19621 | 285 |
|
27317 | 286 |
lemma finite_range_has_max: |
67312 | 287 |
fixes f :: "nat \<Rightarrow> 'a" |
288 |
and r :: "'a \<Rightarrow> 'a \<Rightarrow> bool" |
|
27317 | 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 |
||
67312 | 310 |
lemma finite_range_imp_finch: "chain Y \<Longrightarrow> finite (range Y) \<Longrightarrow> finite_chain Y" |
311 |
apply (subgoal_tac "\<exists>k. \<forall>i. Y i \<sqsubseteq> Y k") |
|
312 |
apply (erule exE) |
|
313 |
apply (rule finite_chainI, assumption) |
|
314 |
apply (rule max_in_chainI) |
|
315 |
apply (rule below_antisym) |
|
316 |
apply (erule (1) chain_mono) |
|
317 |
apply (erule spec) |
|
318 |
apply (rule finite_range_has_max) |
|
27317 | 319 |
apply (erule (1) chain_mono) |
67312 | 320 |
apply assumption |
321 |
done |
|
19621 | 322 |
|
17810
3bdf516d93d8
cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents:
17372
diff
changeset
|
323 |
lemma bin_chain: "x \<sqsubseteq> y \<Longrightarrow> chain (\<lambda>i. if i=0 then x else y)" |
67312 | 324 |
by (rule chainI) simp |
17810
3bdf516d93d8
cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents:
17372
diff
changeset
|
325 |
|
67312 | 326 |
lemma bin_chainmax: "x \<sqsubseteq> y \<Longrightarrow> max_in_chain (Suc 0) (\<lambda>i. if i=0 then x else y)" |
327 |
by (simp add: max_in_chain_def) |
|
15562 | 328 |
|
67312 | 329 |
lemma is_lub_bin_chain: "x \<sqsubseteq> y \<Longrightarrow> range (\<lambda>i::nat. if i=0 then x else y) <<| y" |
330 |
apply (frule bin_chain) |
|
331 |
apply (drule bin_chainmax) |
|
332 |
apply (drule (1) lub_finch1) |
|
333 |
apply simp |
|
334 |
done |
|
15562 | 335 |
|
62175 | 336 |
text \<open>the maximal element in a chain is its lub\<close> |
15562 | 337 |
|
67312 | 338 |
lemma lub_chain_maxelem: "Y i = c \<Longrightarrow> \<forall>i. Y i \<sqsubseteq> c \<Longrightarrow> lub (range Y) = c" |
40771 | 339 |
by (blast dest: ub_rangeD intro: lub_eqI is_lubI ub_rangeI) |
15562 | 340 |
|
18071
940c2c0ff33a
cleaned up; chain_const and thelub_const are simp rules
huffman
parents:
17810
diff
changeset
|
341 |
end |
31071 | 342 |
|
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
|
343 |
end |