| author | wenzelm | 
| Fri, 24 May 2024 17:14:02 +0200 | |
| changeset 80190 | 9f3e0d98fbec | 
| parent 69597 | ff784d5a5bfb | 
| child 80768 | c7723cc15de8 | 
| 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)  | 
| 40436 | 21  | 
below (infix "<<" 50)  | 
| 
15576
 
efb95d0d01f7
converted to new-style theories, and combined numbered files
 
huffman 
parents: 
15562 
diff
changeset
 | 
22  | 
|
| 61998 | 23  | 
notation  | 
| 40436 | 24  | 
below (infix "\<sqsubseteq>" 50)  | 
| 
15576
 
efb95d0d01f7
converted to new-style theories, and combined numbered files
 
huffman 
parents: 
15562 
diff
changeset
 | 
25  | 
|
| 67312 | 26  | 
abbreviation not_below :: "'a \<Rightarrow> 'a \<Rightarrow> bool" (infix "\<notsqsubseteq>" 50)  | 
| 41182 | 27  | 
where "not_below x y \<equiv> \<not> below x y"  | 
28  | 
||
| 61998 | 29  | 
notation (ASCII)  | 
30  | 
not_below (infix "~<<" 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  | 
|
| 67312 | 74  | 
definition is_ub :: "'a set \<Rightarrow> 'a \<Rightarrow> bool" (infix "<|" 55)  | 
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  | 
|
| 67312 | 107  | 
definition is_lub :: "'a set \<Rightarrow> 'a \<Rightarrow> bool" (infix "<<|" 55)  | 
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)  | 
| 25777 | 116  | 
  "_BLub" :: "[pttrn, 'a set, 'b] \<Rightarrow> 'b" ("(3LUB _:_./ _)" [0,0, 10] 10)
 | 
117  | 
||
| 61998 | 118  | 
syntax  | 
| 25777 | 119  | 
  "_BLub" :: "[pttrn, 'a set, 'b] \<Rightarrow> 'b" ("(3\<Squnion>_\<in>_./ _)" [0,0, 10] 10)
 | 
120  | 
||
121  | 
translations  | 
|
| 67312 | 122  | 
"LUB x:A. t" \<rightleftharpoons> "CONST lub ((\<lambda>x. t) ` A)"  | 
| 25777 | 123  | 
|
| 31071 | 124  | 
context po  | 
125  | 
begin  | 
|
126  | 
||
| 67312 | 127  | 
abbreviation Lub (binder "\<Squnion>" 10)  | 
128  | 
where "\<Squnion>n. t n \<equiv> lub (range t)"  | 
|
| 2394 | 129  | 
|
| 61998 | 130  | 
notation (ASCII)  | 
131  | 
Lub (binder "LUB " 10)  | 
|
| 
243
 
c22b85994e17
Franz Regensburger's Higher-Order Logic of Computable Functions embedding LCF
 
nipkow 
parents:  
diff
changeset
 | 
132  | 
|
| 62175 | 133  | 
text \<open>access to some definition as inference rule\<close>  | 
| 25813 | 134  | 
|
135  | 
lemma is_lubD1: "S <<| x \<Longrightarrow> S <| x"  | 
|
| 31071 | 136  | 
unfolding is_lub_def by fast  | 
| 25813 | 137  | 
|
| 40771 | 138  | 
lemma is_lubD2: "\<lbrakk>S <<| x; S <| u\<rbrakk> \<Longrightarrow> x \<sqsubseteq> u"  | 
| 31071 | 139  | 
unfolding is_lub_def by fast  | 
| 25813 | 140  | 
|
141  | 
lemma is_lubI: "\<lbrakk>S <| x; \<And>u. S <| u \<Longrightarrow> x \<sqsubseteq> u\<rbrakk> \<Longrightarrow> S <<| x"  | 
|
| 31071 | 142  | 
unfolding is_lub_def by fast  | 
| 25813 | 143  | 
|
| 39969 | 144  | 
lemma is_lub_below_iff: "S <<| x \<Longrightarrow> x \<sqsubseteq> u \<longleftrightarrow> S <| u"  | 
145  | 
unfolding is_lub_def is_ub_def by (metis below_trans)  | 
|
146  | 
||
| 62175 | 147  | 
text \<open>lubs are unique\<close>  | 
| 15562 | 148  | 
|
| 67312 | 149  | 
lemma is_lub_unique: "S <<| x \<Longrightarrow> S <<| y \<Longrightarrow> x = y"  | 
| 40771 | 150  | 
unfolding is_lub_def is_ub_def by (blast intro: below_antisym)  | 
| 15562 | 151  | 
|
| 69597 | 152  | 
text \<open>technical lemmas about \<^term>\<open>lub\<close> and \<^term>\<open>is_lub\<close>\<close>  | 
| 15562 | 153  | 
|
| 40771 | 154  | 
lemma is_lub_lub: "M <<| x \<Longrightarrow> M <<| lub M"  | 
155  | 
unfolding lub_def by (rule theI [OF _ is_lub_unique])  | 
|
| 15562 | 156  | 
|
| 40771 | 157  | 
lemma lub_eqI: "M <<| l \<Longrightarrow> lub M = l"  | 
158  | 
by (rule is_lub_unique [OF is_lub_lub])  | 
|
| 15562 | 159  | 
|
| 68780 | 160  | 
lemma is_lub_singleton [simp]: "{x} <<| x"
 | 
| 31071 | 161  | 
by (simp add: is_lub_def)  | 
| 25780 | 162  | 
|
| 
17810
 
3bdf516d93d8
cleaned up; renamed "Porder.op <<" to "Porder.<<"
 
huffman 
parents: 
17372 
diff
changeset
 | 
163  | 
lemma lub_singleton [simp]: "lub {x} = x"
 | 
| 40771 | 164  | 
by (rule is_lub_singleton [THEN lub_eqI])  | 
| 25780 | 165  | 
|
166  | 
lemma is_lub_bin: "x \<sqsubseteq> y \<Longrightarrow> {x, y} <<| y"
 | 
|
| 31071 | 167  | 
by (simp add: is_lub_def)  | 
| 25780 | 168  | 
|
169  | 
lemma lub_bin: "x \<sqsubseteq> y \<Longrightarrow> lub {x, y} = y"
 | 
|
| 40771 | 170  | 
by (rule is_lub_bin [THEN lub_eqI])  | 
| 15562 | 171  | 
|
| 67312 | 172  | 
lemma is_lub_maximal: "S <| x \<Longrightarrow> x \<in> S \<Longrightarrow> S <<| x"  | 
| 31071 | 173  | 
by (erule is_lubI, erule (1) is_ubD)  | 
| 15562 | 174  | 
|
| 67312 | 175  | 
lemma lub_maximal: "S <| x \<Longrightarrow> x \<in> S \<Longrightarrow> lub S = x"  | 
| 40771 | 176  | 
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
 | 
177  | 
|
| 67312 | 178  | 
|
| 62175 | 179  | 
subsection \<open>Countable chains\<close>  | 
| 25695 | 180  | 
|
| 67312 | 181  | 
definition chain :: "(nat \<Rightarrow> 'a) \<Rightarrow> bool"  | 
182  | 
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
 | 
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  | 
|
| 62175 | 191  | 
text \<open>chains are monotone functions\<close>  | 
| 25695 | 192  | 
|
| 67312 | 193  | 
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
 | 
194  | 
by (erule less_Suc_induct, erule chainE, erule below_trans)  | 
| 25695 | 195  | 
|
| 67312 | 196  | 
lemma chain_mono: "chain Y \<Longrightarrow> i \<le> j \<Longrightarrow> Y i \<sqsubseteq> Y j"  | 
197  | 
by (cases "i = j") (simp_all 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  | 
|
| 62175 | 202  | 
text \<open>technical lemmas about (least) upper bounds of chains\<close>  | 
| 15562 | 203  | 
|
| 40771 | 204  | 
lemma is_lub_rangeD1: "range S <<| x \<Longrightarrow> S i \<sqsubseteq> x"  | 
| 31071 | 205  | 
by (rule is_lubD1 [THEN ub_rangeD])  | 
| 15562 | 206  | 
|
| 67312 | 207  | 
lemma is_ub_range_shift: "chain S \<Longrightarrow> range (\<lambda>i. S (i + j)) <| x = range S <| x"  | 
208  | 
apply (rule iffI)  | 
|
209  | 
apply (rule ub_rangeI)  | 
|
210  | 
apply (rule_tac y="S (i + j)" in below_trans)  | 
|
211  | 
apply (erule chain_mono)  | 
|
212  | 
apply (rule le_add1)  | 
|
213  | 
apply (erule ub_rangeD)  | 
|
214  | 
apply (rule ub_rangeI)  | 
|
215  | 
apply (erule ub_rangeD)  | 
|
216  | 
done  | 
|
| 
16318
 
45b12a01382f
added theorems is_ub_range_shift and is_lub_range_shift
 
huffman 
parents: 
16092 
diff
changeset
 | 
217  | 
|
| 67312 | 218  | 
lemma is_lub_range_shift: "chain S \<Longrightarrow> range (\<lambda>i. S (i + j)) <<| x = range S <<| x"  | 
| 31071 | 219  | 
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
 | 
220  | 
|
| 62175 | 221  | 
text \<open>the lub of a constant chain is the constant\<close>  | 
| 25695 | 222  | 
|
223  | 
lemma chain_const [simp]: "chain (\<lambda>i. c)"  | 
|
| 31071 | 224  | 
by (simp add: chainI)  | 
| 25695 | 225  | 
|
| 40771 | 226  | 
lemma is_lub_const: "range (\<lambda>x. c) <<| c"  | 
| 25695 | 227  | 
by (blast dest: ub_rangeD intro: is_lubI ub_rangeI)  | 
228  | 
||
| 40771 | 229  | 
lemma lub_const [simp]: "(\<Squnion>i. c) = c"  | 
230  | 
by (rule is_lub_const [THEN lub_eqI])  | 
|
| 25695 | 231  | 
|
| 67312 | 232  | 
|
| 62175 | 233  | 
subsection \<open>Finite chains\<close>  | 
| 25695 | 234  | 
|
| 67312 | 235  | 
definition max_in_chain :: "nat \<Rightarrow> (nat \<Rightarrow> 'a) \<Rightarrow> bool"  | 
236  | 
where \<comment> \<open>finite chains, needed for monotony of continuous functions\<close>  | 
|
| 31071 | 237  | 
"max_in_chain i C \<longleftrightarrow> (\<forall>j. i \<le> j \<longrightarrow> C i = C j)"  | 
| 25695 | 238  | 
|
| 67312 | 239  | 
definition finite_chain :: "(nat \<Rightarrow> 'a) \<Rightarrow> bool"  | 
240  | 
where "finite_chain C = (chain C \<and> (\<exists>i. max_in_chain i C))"  | 
|
| 25695 | 241  | 
|
| 62175 | 242  | 
text \<open>results about finite chains\<close>  | 
| 15562 | 243  | 
|
| 25878 | 244  | 
lemma max_in_chainI: "(\<And>j. i \<le> j \<Longrightarrow> Y i = Y j) \<Longrightarrow> max_in_chain i Y"  | 
| 31071 | 245  | 
unfolding max_in_chain_def by fast  | 
| 25878 | 246  | 
|
| 67312 | 247  | 
lemma max_in_chainD: "max_in_chain i Y \<Longrightarrow> i \<le> j \<Longrightarrow> Y i = Y j"  | 
| 31071 | 248  | 
unfolding max_in_chain_def by fast  | 
| 25878 | 249  | 
|
| 67312 | 250  | 
lemma finite_chainI: "chain C \<Longrightarrow> max_in_chain i C \<Longrightarrow> finite_chain C"  | 
| 31071 | 251  | 
unfolding finite_chain_def by fast  | 
| 27317 | 252  | 
|
| 67312 | 253  | 
lemma finite_chainE: "\<lbrakk>finite_chain C; \<And>i. \<lbrakk>chain C; max_in_chain i C\<rbrakk> \<Longrightarrow> R\<rbrakk> \<Longrightarrow> R"  | 
| 31071 | 254  | 
unfolding finite_chain_def by fast  | 
| 27317 | 255  | 
|
| 67312 | 256  | 
lemma lub_finch1: "chain C \<Longrightarrow> max_in_chain i C \<Longrightarrow> range C <<| C i"  | 
257  | 
apply (rule is_lubI)  | 
|
258  | 
apply (rule ub_rangeI, rename_tac j)  | 
|
259  | 
apply (rule_tac x=i and y=j in linorder_le_cases)  | 
|
260  | 
apply (drule (1) max_in_chainD, simp)  | 
|
261  | 
apply (erule (1) chain_mono)  | 
|
262  | 
apply (erule ub_rangeD)  | 
|
263  | 
done  | 
|
| 15562 | 264  | 
|
| 67312 | 265  | 
lemma lub_finch2: "finite_chain C \<Longrightarrow> range C <<| C (LEAST i. max_in_chain i C)"  | 
266  | 
apply (erule finite_chainE)  | 
|
267  | 
apply (erule LeastI2 [where Q="\<lambda>i. range C <<| C i"])  | 
|
268  | 
apply (erule (1) lub_finch1)  | 
|
269  | 
done  | 
|
| 15562 | 270  | 
|
| 19621 | 271  | 
lemma finch_imp_finite_range: "finite_chain Y \<Longrightarrow> finite (range Y)"  | 
| 67312 | 272  | 
apply (erule finite_chainE)  | 
273  | 
  apply (rule_tac B="Y ` {..i}" in finite_subset)
 | 
|
274  | 
apply (rule subsetI)  | 
|
275  | 
apply (erule rangeE, rename_tac j)  | 
|
276  | 
apply (rule_tac x=i and y=j in linorder_le_cases)  | 
|
277  | 
apply (subgoal_tac "Y j = Y i", simp)  | 
|
278  | 
apply (simp add: max_in_chain_def)  | 
|
279  | 
apply simp  | 
|
| 19621 | 280  | 
apply simp  | 
| 67312 | 281  | 
done  | 
| 19621 | 282  | 
|
| 27317 | 283  | 
lemma finite_range_has_max:  | 
| 67312 | 284  | 
fixes f :: "nat \<Rightarrow> 'a"  | 
285  | 
and r :: "'a \<Rightarrow> 'a \<Rightarrow> bool"  | 
|
| 27317 | 286  | 
assumes mono: "\<And>i j. i \<le> j \<Longrightarrow> r (f i) (f j)"  | 
287  | 
assumes finite_range: "finite (range f)"  | 
|
288  | 
shows "\<exists>k. \<forall>i. r (f i) (f k)"  | 
|
289  | 
proof (intro exI allI)  | 
|
290  | 
fix i :: nat  | 
|
291  | 
let ?j = "LEAST k. f k = f i"  | 
|
292  | 
let ?k = "Max ((\<lambda>x. LEAST k. f k = x) ` range f)"  | 
|
293  | 
have "?j \<le> ?k"  | 
|
294  | 
proof (rule Max_ge)  | 
|
295  | 
show "finite ((\<lambda>x. LEAST k. f k = x) ` range f)"  | 
|
296  | 
using finite_range by (rule finite_imageI)  | 
|
297  | 
show "?j \<in> (\<lambda>x. LEAST k. f k = x) ` range f"  | 
|
298  | 
by (intro imageI rangeI)  | 
|
299  | 
qed  | 
|
300  | 
hence "r (f ?j) (f ?k)"  | 
|
301  | 
by (rule mono)  | 
|
302  | 
also have "f ?j = f i"  | 
|
303  | 
by (rule LeastI, rule refl)  | 
|
304  | 
finally show "r (f i) (f ?k)" .  | 
|
305  | 
qed  | 
|
306  | 
||
| 67312 | 307  | 
lemma finite_range_imp_finch: "chain Y \<Longrightarrow> finite (range Y) \<Longrightarrow> finite_chain Y"  | 
308  | 
apply (subgoal_tac "\<exists>k. \<forall>i. Y i \<sqsubseteq> Y k")  | 
|
309  | 
apply (erule exE)  | 
|
310  | 
apply (rule finite_chainI, assumption)  | 
|
311  | 
apply (rule max_in_chainI)  | 
|
312  | 
apply (rule below_antisym)  | 
|
313  | 
apply (erule (1) chain_mono)  | 
|
314  | 
apply (erule spec)  | 
|
315  | 
apply (rule finite_range_has_max)  | 
|
| 27317 | 316  | 
apply (erule (1) chain_mono)  | 
| 67312 | 317  | 
apply assumption  | 
318  | 
done  | 
|
| 19621 | 319  | 
|
| 
17810
 
3bdf516d93d8
cleaned up; renamed "Porder.op <<" to "Porder.<<"
 
huffman 
parents: 
17372 
diff
changeset
 | 
320  | 
lemma bin_chain: "x \<sqsubseteq> y \<Longrightarrow> chain (\<lambda>i. if i=0 then x else y)"  | 
| 67312 | 321  | 
by (rule chainI) simp  | 
| 
17810
 
3bdf516d93d8
cleaned up; renamed "Porder.op <<" to "Porder.<<"
 
huffman 
parents: 
17372 
diff
changeset
 | 
322  | 
|
| 67312 | 323  | 
lemma bin_chainmax: "x \<sqsubseteq> y \<Longrightarrow> max_in_chain (Suc 0) (\<lambda>i. if i=0 then x else y)"  | 
324  | 
by (simp add: max_in_chain_def)  | 
|
| 15562 | 325  | 
|
| 67312 | 326  | 
lemma is_lub_bin_chain: "x \<sqsubseteq> y \<Longrightarrow> range (\<lambda>i::nat. if i=0 then x else y) <<| y"  | 
327  | 
apply (frule bin_chain)  | 
|
328  | 
apply (drule bin_chainmax)  | 
|
329  | 
apply (drule (1) lub_finch1)  | 
|
330  | 
apply simp  | 
|
331  | 
done  | 
|
| 15562 | 332  | 
|
| 62175 | 333  | 
text \<open>the maximal element in a chain is its lub\<close>  | 
| 15562 | 334  | 
|
| 67312 | 335  | 
lemma lub_chain_maxelem: "Y i = c \<Longrightarrow> \<forall>i. Y i \<sqsubseteq> c \<Longrightarrow> lub (range Y) = c"  | 
| 40771 | 336  | 
by (blast dest: ub_rangeD intro: lub_eqI is_lubI ub_rangeI)  | 
| 15562 | 337  | 
|
| 
18071
 
940c2c0ff33a
cleaned up; chain_const and thelub_const are simp rules
 
huffman 
parents: 
17810 
diff
changeset
 | 
338  | 
end  | 
| 31071 | 339  | 
|
| 
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
 | 
340  | 
end  |