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