| author | desharna | 
| Tue, 29 Mar 2022 17:12:44 +0200 | |
| changeset 75368 | b269a3c84b99 | 
| parent 73411 | 1f1366966296 | 
| child 75464 | 84e6f9b542e2 | 
| permissions | -rw-r--r-- | 
| 63612 | 1 | (* Title: HOL/Complete_Partial_Order.thy | 
| 2 | Author: Brian Huffman, Portland State University | |
| 3 | Author: Alexander Krauss, TU Muenchen | |
| 40106 
c58951943cba
Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
 krauss parents: diff
changeset | 4 | *) | 
| 
c58951943cba
Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
 krauss parents: diff
changeset | 5 | |
| 60758 | 6 | section \<open>Chain-complete partial orders and their fixpoints\<close> | 
| 40106 
c58951943cba
Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
 krauss parents: diff
changeset | 7 | |
| 
c58951943cba
Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
 krauss parents: diff
changeset | 8 | theory Complete_Partial_Order | 
| 63612 | 9 | imports Product_Type | 
| 40106 
c58951943cba
Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
 krauss parents: diff
changeset | 10 | begin | 
| 
c58951943cba
Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
 krauss parents: diff
changeset | 11 | |
| 60758 | 12 | subsection \<open>Monotone functions\<close> | 
| 40106 
c58951943cba
Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
 krauss parents: diff
changeset | 13 | |
| 69593 | 14 | text \<open>Dictionary-passing version of \<^const>\<open>Orderings.mono\<close>.\<close> | 
| 40106 
c58951943cba
Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
 krauss parents: diff
changeset | 15 | |
| 
c58951943cba
Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
 krauss parents: diff
changeset | 16 | definition monotone :: "('a \<Rightarrow> 'a \<Rightarrow> bool) \<Rightarrow> ('b \<Rightarrow> 'b \<Rightarrow> bool) \<Rightarrow> ('a \<Rightarrow> 'b) \<Rightarrow> bool"
 | 
| 63612 | 17 | where "monotone orda ordb f \<longleftrightarrow> (\<forall>x y. orda x y \<longrightarrow> ordb (f x) (f y))" | 
| 40106 
c58951943cba
Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
 krauss parents: diff
changeset | 18 | |
| 63612 | 19 | lemma monotoneI[intro?]: "(\<And>x y. orda x y \<Longrightarrow> ordb (f x) (f y)) \<Longrightarrow> monotone orda ordb f" | 
| 20 | unfolding monotone_def by iprover | |
| 40106 
c58951943cba
Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
 krauss parents: diff
changeset | 21 | |
| 
c58951943cba
Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
 krauss parents: diff
changeset | 22 | lemma monotoneD[dest?]: "monotone orda ordb f \<Longrightarrow> orda x y \<Longrightarrow> ordb (f x) (f y)" | 
| 63612 | 23 | unfolding monotone_def by iprover | 
| 40106 
c58951943cba
Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
 krauss parents: diff
changeset | 24 | |
| 
c58951943cba
Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
 krauss parents: diff
changeset | 25 | |
| 60758 | 26 | subsection \<open>Chains\<close> | 
| 40106 
c58951943cba
Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
 krauss parents: diff
changeset | 27 | |
| 63612 | 28 | text \<open> | 
| 29 | A chain is a totally-ordered set. Chains are parameterized over | |
| 40106 
c58951943cba
Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
 krauss parents: diff
changeset | 30 | the order for maximal flexibility, since type classes are not enough. | 
| 60758 | 31 | \<close> | 
| 40106 
c58951943cba
Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
 krauss parents: diff
changeset | 32 | |
| 63612 | 33 | definition chain :: "('a \<Rightarrow> 'a \<Rightarrow> bool) \<Rightarrow> 'a set \<Rightarrow> bool"
 | 
| 34 | where "chain ord S \<longleftrightarrow> (\<forall>x\<in>S. \<forall>y\<in>S. ord x y \<or> ord y x)" | |
| 40106 
c58951943cba
Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
 krauss parents: diff
changeset | 35 | |
| 
c58951943cba
Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
 krauss parents: diff
changeset | 36 | lemma chainI: | 
| 
c58951943cba
Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
 krauss parents: diff
changeset | 37 | assumes "\<And>x y. x \<in> S \<Longrightarrow> y \<in> S \<Longrightarrow> ord x y \<or> ord y x" | 
| 
c58951943cba
Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
 krauss parents: diff
changeset | 38 | shows "chain ord S" | 
| 63612 | 39 | using assms unfolding chain_def by fast | 
| 40106 
c58951943cba
Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
 krauss parents: diff
changeset | 40 | |
| 
c58951943cba
Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
 krauss parents: diff
changeset | 41 | lemma chainD: | 
| 
c58951943cba
Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
 krauss parents: diff
changeset | 42 | assumes "chain ord S" and "x \<in> S" and "y \<in> S" | 
| 
c58951943cba
Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
 krauss parents: diff
changeset | 43 | shows "ord x y \<or> ord y x" | 
| 63612 | 44 | using assms unfolding chain_def by fast | 
| 40106 
c58951943cba
Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
 krauss parents: diff
changeset | 45 | |
| 
c58951943cba
Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
 krauss parents: diff
changeset | 46 | lemma chainE: | 
| 
c58951943cba
Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
 krauss parents: diff
changeset | 47 | assumes "chain ord S" and "x \<in> S" and "y \<in> S" | 
| 
c58951943cba
Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
 krauss parents: diff
changeset | 48 | obtains "ord x y" | "ord y x" | 
| 63612 | 49 | using assms unfolding chain_def by fast | 
| 40106 
c58951943cba
Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
 krauss parents: diff
changeset | 50 | |
| 54630 
9061af4d5ebc
restrict admissibility to non-empty chains to allow more syntax-directed proof rules
 Andreas Lochbihler parents: 
53361diff
changeset | 51 | lemma chain_empty: "chain ord {}"
 | 
| 63612 | 52 | by (simp add: chain_def) | 
| 54630 
9061af4d5ebc
restrict admissibility to non-empty chains to allow more syntax-directed proof rules
 Andreas Lochbihler parents: 
53361diff
changeset | 53 | |
| 67399 | 54 | lemma chain_equality: "chain (=) A \<longleftrightarrow> (\<forall>x\<in>A. \<forall>y\<in>A. x = y)" | 
| 63612 | 55 | by (auto simp add: chain_def) | 
| 56 | ||
| 57 | lemma chain_subset: "chain ord A \<Longrightarrow> B \<subseteq> A \<Longrightarrow> chain ord B" | |
| 58 | by (rule chainI) (blast dest: chainD) | |
| 60057 | 59 | |
| 63612 | 60 | lemma chain_imageI: | 
| 61 | assumes chain: "chain le_a Y" | |
| 62 | and mono: "\<And>x y. x \<in> Y \<Longrightarrow> y \<in> Y \<Longrightarrow> le_a x y \<Longrightarrow> le_b (f x) (f y)" | |
| 63 | shows "chain le_b (f ` Y)" | |
| 64 | by (blast intro: chainI dest: chainD[OF chain] mono) | |
| 60061 | 65 | |
| 66 | ||
| 60758 | 67 | subsection \<open>Chain-complete partial orders\<close> | 
| 40106 
c58951943cba
Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
 krauss parents: diff
changeset | 68 | |
| 60758 | 69 | text \<open> | 
| 63612 | 70 | A \<open>ccpo\<close> has a least upper bound for any chain. In particular, the | 
| 71 | empty set is a chain, so every \<open>ccpo\<close> must have a bottom element. | |
| 60758 | 72 | \<close> | 
| 40106 
c58951943cba
Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
 krauss parents: diff
changeset | 73 | |
| 46041 
1e3ff542e83e
remove constant 'ccpo.lub', re-use constant 'Sup' instead
 huffman parents: 
40252diff
changeset | 74 | class ccpo = order + Sup + | 
| 67399 | 75 | assumes ccpo_Sup_upper: "chain (\<le>) A \<Longrightarrow> x \<in> A \<Longrightarrow> x \<le> Sup A" | 
| 76 | assumes ccpo_Sup_least: "chain (\<le>) A \<Longrightarrow> (\<And>x. x \<in> A \<Longrightarrow> x \<le> z) \<Longrightarrow> Sup A \<le> z" | |
| 40106 
c58951943cba
Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
 krauss parents: diff
changeset | 77 | begin | 
| 
c58951943cba
Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
 krauss parents: diff
changeset | 78 | |
| 67399 | 79 | lemma chain_singleton: "Complete_Partial_Order.chain (\<le>) {x}"
 | 
| 63612 | 80 | by (rule chainI) simp | 
| 60061 | 81 | |
| 82 | lemma ccpo_Sup_singleton [simp]: "\<Squnion>{x} = x"
 | |
| 73411 | 83 | by (rule order.antisym) (auto intro: ccpo_Sup_least ccpo_Sup_upper simp add: chain_singleton) | 
| 63612 | 84 | |
| 60061 | 85 | |
| 60758 | 86 | subsection \<open>Transfinite iteration of a function\<close> | 
| 40106 
c58951943cba
Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
 krauss parents: diff
changeset | 87 | |
| 63612 | 88 | context notes [[inductive_internals]] | 
| 89 | begin | |
| 61689 | 90 | |
| 40106 
c58951943cba
Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
 krauss parents: diff
changeset | 91 | inductive_set iterates :: "('a \<Rightarrow> 'a) \<Rightarrow> 'a set"
 | 
| 63612 | 92 | for f :: "'a \<Rightarrow> 'a" | 
| 93 | where | |
| 94 | step: "x \<in> iterates f \<Longrightarrow> f x \<in> iterates f" | |
| 67399 | 95 | | Sup: "chain (\<le>) M \<Longrightarrow> \<forall>x\<in>M. x \<in> iterates f \<Longrightarrow> Sup M \<in> iterates f" | 
| 40106 
c58951943cba
Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
 krauss parents: diff
changeset | 96 | |
| 61689 | 97 | end | 
| 98 | ||
| 67399 | 99 | lemma iterates_le_f: "x \<in> iterates f \<Longrightarrow> monotone (\<le>) (\<le>) f \<Longrightarrow> x \<le> f x" | 
| 63612 | 100 | by (induct x rule: iterates.induct) | 
| 101 | (force dest: monotoneD intro!: ccpo_Sup_upper ccpo_Sup_least)+ | |
| 40106 
c58951943cba
Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
 krauss parents: diff
changeset | 102 | |
| 
c58951943cba
Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
 krauss parents: diff
changeset | 103 | lemma chain_iterates: | 
| 67399 | 104 | assumes f: "monotone (\<le>) (\<le>) f" | 
| 105 | shows "chain (\<le>) (iterates f)" (is "chain _ ?C") | |
| 40106 
c58951943cba
Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
 krauss parents: diff
changeset | 106 | proof (rule chainI) | 
| 63612 | 107 | fix x y | 
| 108 | assume "x \<in> ?C" "y \<in> ?C" | |
| 40106 
c58951943cba
Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
 krauss parents: diff
changeset | 109 | then show "x \<le> y \<or> y \<le> x" | 
| 
c58951943cba
Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
 krauss parents: diff
changeset | 110 | proof (induct x arbitrary: y rule: iterates.induct) | 
| 63612 | 111 | fix x y | 
| 112 | assume y: "y \<in> ?C" | |
| 113 | and IH: "\<And>z. z \<in> ?C \<Longrightarrow> x \<le> z \<or> z \<le> x" | |
| 40106 
c58951943cba
Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
 krauss parents: diff
changeset | 114 | from y show "f x \<le> y \<or> y \<le> f x" | 
| 
c58951943cba
Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
 krauss parents: diff
changeset | 115 | proof (induct y rule: iterates.induct) | 
| 63612 | 116 | case (step y) | 
| 117 | with IH f show ?case by (auto dest: monotoneD) | |
| 40106 
c58951943cba
Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
 krauss parents: diff
changeset | 118 | next | 
| 46041 
1e3ff542e83e
remove constant 'ccpo.lub', re-use constant 'Sup' instead
 huffman parents: 
40252diff
changeset | 119 | case (Sup M) | 
| 67399 | 120 | then have chM: "chain (\<le>) M" | 
| 40106 
c58951943cba
Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
 krauss parents: diff
changeset | 121 | and IH': "\<And>z. z \<in> M \<Longrightarrow> f x \<le> z \<or> z \<le> f x" by auto | 
| 46041 
1e3ff542e83e
remove constant 'ccpo.lub', re-use constant 'Sup' instead
 huffman parents: 
40252diff
changeset | 122 | show "f x \<le> Sup M \<or> Sup M \<le> f x" | 
| 40106 
c58951943cba
Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
 krauss parents: diff
changeset | 123 | proof (cases "\<exists>z\<in>M. f x \<le> z") | 
| 63612 | 124 | case True | 
| 125 | then have "f x \<le> Sup M" | |
| 73252 | 126 | by (blast intro: ccpo_Sup_upper[OF chM] order_trans) | 
| 63612 | 127 | then show ?thesis .. | 
| 40106 
c58951943cba
Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
 krauss parents: diff
changeset | 128 | next | 
| 63612 | 129 | case False | 
| 130 | with IH' show ?thesis | |
| 131 | by (auto intro: ccpo_Sup_least[OF chM]) | |
| 40106 
c58951943cba
Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
 krauss parents: diff
changeset | 132 | qed | 
| 
c58951943cba
Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
 krauss parents: diff
changeset | 133 | qed | 
| 
c58951943cba
Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
 krauss parents: diff
changeset | 134 | next | 
| 46041 
1e3ff542e83e
remove constant 'ccpo.lub', re-use constant 'Sup' instead
 huffman parents: 
40252diff
changeset | 135 | case (Sup M y) | 
| 40106 
c58951943cba
Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
 krauss parents: diff
changeset | 136 | show ?case | 
| 
c58951943cba
Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
 krauss parents: diff
changeset | 137 | proof (cases "\<exists>x\<in>M. y \<le> x") | 
| 63612 | 138 | case True | 
| 139 | then have "y \<le> Sup M" | |
| 73252 | 140 | by (blast intro: ccpo_Sup_upper[OF Sup(1)] order_trans) | 
| 63612 | 141 | then show ?thesis .. | 
| 40106 
c58951943cba
Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
 krauss parents: diff
changeset | 142 | next | 
| 46041 
1e3ff542e83e
remove constant 'ccpo.lub', re-use constant 'Sup' instead
 huffman parents: 
40252diff
changeset | 143 | case False with Sup | 
| 
1e3ff542e83e
remove constant 'ccpo.lub', re-use constant 'Sup' instead
 huffman parents: 
40252diff
changeset | 144 | show ?thesis by (auto intro: ccpo_Sup_least) | 
| 40106 
c58951943cba
Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
 krauss parents: diff
changeset | 145 | qed | 
| 
c58951943cba
Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
 krauss parents: diff
changeset | 146 | qed | 
| 
c58951943cba
Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
 krauss parents: diff
changeset | 147 | qed | 
| 
c58951943cba
Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
 krauss parents: diff
changeset | 148 | |
| 54630 
9061af4d5ebc
restrict admissibility to non-empty chains to allow more syntax-directed proof rules
 Andreas Lochbihler parents: 
53361diff
changeset | 149 | lemma bot_in_iterates: "Sup {} \<in> iterates f"
 | 
| 63612 | 150 | by (auto intro: iterates.Sup simp add: chain_empty) | 
| 151 | ||
| 54630 
9061af4d5ebc
restrict admissibility to non-empty chains to allow more syntax-directed proof rules
 Andreas Lochbihler parents: 
53361diff
changeset | 152 | |
| 60758 | 153 | subsection \<open>Fixpoint combinator\<close> | 
| 40106 
c58951943cba
Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
 krauss parents: diff
changeset | 154 | |
| 63612 | 155 | definition fixp :: "('a \<Rightarrow> 'a) \<Rightarrow> 'a"
 | 
| 156 | where "fixp f = Sup (iterates f)" | |
| 40106 
c58951943cba
Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
 krauss parents: diff
changeset | 157 | |
| 
c58951943cba
Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
 krauss parents: diff
changeset | 158 | lemma iterates_fixp: | 
| 67399 | 159 | assumes f: "monotone (\<le>) (\<le>) f" | 
| 63612 | 160 | shows "fixp f \<in> iterates f" | 
| 161 | unfolding fixp_def | |
| 162 | by (simp add: iterates.Sup chain_iterates f) | |
| 40106 
c58951943cba
Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
 krauss parents: diff
changeset | 163 | |
| 
c58951943cba
Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
 krauss parents: diff
changeset | 164 | lemma fixp_unfold: | 
| 67399 | 165 | assumes f: "monotone (\<le>) (\<le>) f" | 
| 40106 
c58951943cba
Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
 krauss parents: diff
changeset | 166 | shows "fixp f = f (fixp f)" | 
| 73411 | 167 | proof (rule order.antisym) | 
| 40106 
c58951943cba
Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
 krauss parents: diff
changeset | 168 | show "fixp f \<le> f (fixp f)" | 
| 
c58951943cba
Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
 krauss parents: diff
changeset | 169 | by (intro iterates_le_f iterates_fixp f) | 
| 46041 
1e3ff542e83e
remove constant 'ccpo.lub', re-use constant 'Sup' instead
 huffman parents: 
40252diff
changeset | 170 | have "f (fixp f) \<le> Sup (iterates f)" | 
| 
1e3ff542e83e
remove constant 'ccpo.lub', re-use constant 'Sup' instead
 huffman parents: 
40252diff
changeset | 171 | by (intro ccpo_Sup_upper chain_iterates f iterates.step iterates_fixp) | 
| 63612 | 172 | then show "f (fixp f) \<le> fixp f" | 
| 173 | by (simp only: fixp_def) | |
| 40106 
c58951943cba
Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
 krauss parents: diff
changeset | 174 | qed | 
| 
c58951943cba
Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
 krauss parents: diff
changeset | 175 | |
| 
c58951943cba
Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
 krauss parents: diff
changeset | 176 | lemma fixp_lowerbound: | 
| 67399 | 177 | assumes f: "monotone (\<le>) (\<le>) f" | 
| 63612 | 178 | and z: "f z \<le> z" | 
| 179 | shows "fixp f \<le> z" | |
| 180 | unfolding fixp_def | |
| 46041 
1e3ff542e83e
remove constant 'ccpo.lub', re-use constant 'Sup' instead
 huffman parents: 
40252diff
changeset | 181 | proof (rule ccpo_Sup_least[OF chain_iterates[OF f]]) | 
| 63612 | 182 | fix x | 
| 183 | assume "x \<in> iterates f" | |
| 184 | then show "x \<le> z" | |
| 40106 
c58951943cba
Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
 krauss parents: diff
changeset | 185 | proof (induct x rule: iterates.induct) | 
| 63612 | 186 | case (step x) | 
| 187 | from f \<open>x \<le> z\<close> have "f x \<le> f z" by (rule monotoneD) | |
| 188 | also note z | |
| 189 | finally show "f x \<le> z" . | |
| 190 | next | |
| 191 | case (Sup M) | |
| 192 | then show ?case | |
| 193 | by (auto intro: ccpo_Sup_least) | |
| 194 | qed | |
| 40106 
c58951943cba
Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
 krauss parents: diff
changeset | 195 | qed | 
| 
c58951943cba
Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
 krauss parents: diff
changeset | 196 | |
| 53361 
1cb7d3c0cf31
move admissible out of class ccpo to avoid unnecessary class predicate in foundational theorems
 Andreas Lochbihler parents: 
46041diff
changeset | 197 | end | 
| 40106 
c58951943cba
Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
 krauss parents: diff
changeset | 198 | |
| 63612 | 199 | |
| 60758 | 200 | subsection \<open>Fixpoint induction\<close> | 
| 40106 
c58951943cba
Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
 krauss parents: diff
changeset | 201 | |
| 60758 | 202 | setup \<open>Sign.map_naming (Name_Space.mandatory_path "ccpo")\<close> | 
| 53361 
1cb7d3c0cf31
move admissible out of class ccpo to avoid unnecessary class predicate in foundational theorems
 Andreas Lochbihler parents: 
46041diff
changeset | 203 | |
| 
1cb7d3c0cf31
move admissible out of class ccpo to avoid unnecessary class predicate in foundational theorems
 Andreas Lochbihler parents: 
46041diff
changeset | 204 | definition admissible :: "('a set \<Rightarrow> 'a) \<Rightarrow> ('a \<Rightarrow> 'a \<Rightarrow> bool) \<Rightarrow> ('a \<Rightarrow> bool) \<Rightarrow> bool"
 | 
| 63612 | 205 |   where "admissible lub ord P \<longleftrightarrow> (\<forall>A. chain ord A \<longrightarrow> A \<noteq> {} \<longrightarrow> (\<forall>x\<in>A. P x) \<longrightarrow> P (lub A))"
 | 
| 40106 
c58951943cba
Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
 krauss parents: diff
changeset | 206 | |
| 
c58951943cba
Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
 krauss parents: diff
changeset | 207 | lemma admissibleI: | 
| 54630 
9061af4d5ebc
restrict admissibility to non-empty chains to allow more syntax-directed proof rules
 Andreas Lochbihler parents: 
53361diff
changeset | 208 |   assumes "\<And>A. chain ord A \<Longrightarrow> A \<noteq> {} \<Longrightarrow> \<forall>x\<in>A. P x \<Longrightarrow> P (lub A)"
 | 
| 53361 
1cb7d3c0cf31
move admissible out of class ccpo to avoid unnecessary class predicate in foundational theorems
 Andreas Lochbihler parents: 
46041diff
changeset | 209 | shows "ccpo.admissible lub ord P" | 
| 63612 | 210 | using assms unfolding ccpo.admissible_def by fast | 
| 40106 
c58951943cba
Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
 krauss parents: diff
changeset | 211 | |
| 
c58951943cba
Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
 krauss parents: diff
changeset | 212 | lemma admissibleD: | 
| 53361 
1cb7d3c0cf31
move admissible out of class ccpo to avoid unnecessary class predicate in foundational theorems
 Andreas Lochbihler parents: 
46041diff
changeset | 213 | assumes "ccpo.admissible lub ord P" | 
| 
1cb7d3c0cf31
move admissible out of class ccpo to avoid unnecessary class predicate in foundational theorems
 Andreas Lochbihler parents: 
46041diff
changeset | 214 | assumes "chain ord A" | 
| 54630 
9061af4d5ebc
restrict admissibility to non-empty chains to allow more syntax-directed proof rules
 Andreas Lochbihler parents: 
53361diff
changeset | 215 |   assumes "A \<noteq> {}"
 | 
| 40106 
c58951943cba
Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
 krauss parents: diff
changeset | 216 | assumes "\<And>x. x \<in> A \<Longrightarrow> P x" | 
| 53361 
1cb7d3c0cf31
move admissible out of class ccpo to avoid unnecessary class predicate in foundational theorems
 Andreas Lochbihler parents: 
46041diff
changeset | 217 | shows "P (lub A)" | 
| 63612 | 218 | using assms by (auto simp: ccpo.admissible_def) | 
| 40106 
c58951943cba
Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
 krauss parents: diff
changeset | 219 | |
| 60758 | 220 | setup \<open>Sign.map_naming Name_Space.parent_path\<close> | 
| 53361 
1cb7d3c0cf31
move admissible out of class ccpo to avoid unnecessary class predicate in foundational theorems
 Andreas Lochbihler parents: 
46041diff
changeset | 221 | |
| 
1cb7d3c0cf31
move admissible out of class ccpo to avoid unnecessary class predicate in foundational theorems
 Andreas Lochbihler parents: 
46041diff
changeset | 222 | lemma (in ccpo) fixp_induct: | 
| 67399 | 223 | assumes adm: "ccpo.admissible Sup (\<le>) P" | 
| 224 | assumes mono: "monotone (\<le>) (\<le>) f" | |
| 54630 
9061af4d5ebc
restrict admissibility to non-empty chains to allow more syntax-directed proof rules
 Andreas Lochbihler parents: 
53361diff
changeset | 225 |   assumes bot: "P (Sup {})"
 | 
| 40106 
c58951943cba
Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
 krauss parents: diff
changeset | 226 | assumes step: "\<And>x. P x \<Longrightarrow> P (f x)" | 
| 
c58951943cba
Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
 krauss parents: diff
changeset | 227 | shows "P (fixp f)" | 
| 63612 | 228 | unfolding fixp_def | 
| 229 | using adm chain_iterates[OF mono] | |
| 53361 
1cb7d3c0cf31
move admissible out of class ccpo to avoid unnecessary class predicate in foundational theorems
 Andreas Lochbihler parents: 
46041diff
changeset | 230 | proof (rule ccpo.admissibleD) | 
| 63612 | 231 |   show "iterates f \<noteq> {}"
 | 
| 232 | using bot_in_iterates by auto | |
| 233 | next | |
| 234 | fix x | |
| 235 | assume "x \<in> iterates f" | |
| 236 | then show "P x" | |
| 237 | proof (induct rule: iterates.induct) | |
| 238 | case prems: (step x) | |
| 239 | from this(2) show ?case by (rule step) | |
| 240 | next | |
| 241 | case (Sup M) | |
| 242 |     then show ?case by (cases "M = {}") (auto intro: step bot ccpo.admissibleD adm)
 | |
| 243 | qed | |
| 40106 
c58951943cba
Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
 krauss parents: diff
changeset | 244 | qed | 
| 
c58951943cba
Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
 krauss parents: diff
changeset | 245 | |
| 53361 
1cb7d3c0cf31
move admissible out of class ccpo to avoid unnecessary class predicate in foundational theorems
 Andreas Lochbihler parents: 
46041diff
changeset | 246 | lemma admissible_True: "ccpo.admissible lub ord (\<lambda>x. True)" | 
| 63612 | 247 | unfolding ccpo.admissible_def by simp | 
| 40106 
c58951943cba
Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
 krauss parents: diff
changeset | 248 | |
| 54630 
9061af4d5ebc
restrict admissibility to non-empty chains to allow more syntax-directed proof rules
 Andreas Lochbihler parents: 
53361diff
changeset | 249 | (*lemma admissible_False: "\<not> ccpo.admissible lub ord (\<lambda>x. False)" | 
| 53361 
1cb7d3c0cf31
move admissible out of class ccpo to avoid unnecessary class predicate in foundational theorems
 Andreas Lochbihler parents: 
46041diff
changeset | 250 | unfolding ccpo.admissible_def chain_def by simp | 
| 54630 
9061af4d5ebc
restrict admissibility to non-empty chains to allow more syntax-directed proof rules
 Andreas Lochbihler parents: 
53361diff
changeset | 251 | *) | 
| 
9061af4d5ebc
restrict admissibility to non-empty chains to allow more syntax-directed proof rules
 Andreas Lochbihler parents: 
53361diff
changeset | 252 | lemma admissible_const: "ccpo.admissible lub ord (\<lambda>x. t)" | 
| 63612 | 253 | by (auto intro: ccpo.admissibleI) | 
| 40106 
c58951943cba
Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
 krauss parents: diff
changeset | 254 | |
| 
c58951943cba
Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
 krauss parents: diff
changeset | 255 | lemma admissible_conj: | 
| 53361 
1cb7d3c0cf31
move admissible out of class ccpo to avoid unnecessary class predicate in foundational theorems
 Andreas Lochbihler parents: 
46041diff
changeset | 256 | assumes "ccpo.admissible lub ord (\<lambda>x. P x)" | 
| 
1cb7d3c0cf31
move admissible out of class ccpo to avoid unnecessary class predicate in foundational theorems
 Andreas Lochbihler parents: 
46041diff
changeset | 257 | assumes "ccpo.admissible lub ord (\<lambda>x. Q x)" | 
| 
1cb7d3c0cf31
move admissible out of class ccpo to avoid unnecessary class predicate in foundational theorems
 Andreas Lochbihler parents: 
46041diff
changeset | 258 | shows "ccpo.admissible lub ord (\<lambda>x. P x \<and> Q x)" | 
| 63612 | 259 | using assms unfolding ccpo.admissible_def by simp | 
| 40106 
c58951943cba
Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
 krauss parents: diff
changeset | 260 | |
| 
c58951943cba
Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
 krauss parents: diff
changeset | 261 | lemma admissible_all: | 
| 53361 
1cb7d3c0cf31
move admissible out of class ccpo to avoid unnecessary class predicate in foundational theorems
 Andreas Lochbihler parents: 
46041diff
changeset | 262 | assumes "\<And>y. ccpo.admissible lub ord (\<lambda>x. P x y)" | 
| 
1cb7d3c0cf31
move admissible out of class ccpo to avoid unnecessary class predicate in foundational theorems
 Andreas Lochbihler parents: 
46041diff
changeset | 263 | shows "ccpo.admissible lub ord (\<lambda>x. \<forall>y. P x y)" | 
| 63612 | 264 | using assms unfolding ccpo.admissible_def by fast | 
| 40106 
c58951943cba
Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
 krauss parents: diff
changeset | 265 | |
| 
c58951943cba
Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
 krauss parents: diff
changeset | 266 | lemma admissible_ball: | 
| 53361 
1cb7d3c0cf31
move admissible out of class ccpo to avoid unnecessary class predicate in foundational theorems
 Andreas Lochbihler parents: 
46041diff
changeset | 267 | assumes "\<And>y. y \<in> A \<Longrightarrow> ccpo.admissible lub ord (\<lambda>x. P x y)" | 
| 
1cb7d3c0cf31
move admissible out of class ccpo to avoid unnecessary class predicate in foundational theorems
 Andreas Lochbihler parents: 
46041diff
changeset | 268 | shows "ccpo.admissible lub ord (\<lambda>x. \<forall>y\<in>A. P x y)" | 
| 63612 | 269 | using assms unfolding ccpo.admissible_def by fast | 
| 40106 
c58951943cba
Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
 krauss parents: diff
changeset | 270 | |
| 53361 
1cb7d3c0cf31
move admissible out of class ccpo to avoid unnecessary class predicate in foundational theorems
 Andreas Lochbihler parents: 
46041diff
changeset | 271 | lemma chain_compr: "chain ord A \<Longrightarrow> chain ord {x \<in> A. P x}"
 | 
| 63612 | 272 | unfolding chain_def by fast | 
| 40106 
c58951943cba
Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
 krauss parents: diff
changeset | 273 | |
| 63612 | 274 | context ccpo | 
| 275 | begin | |
| 53361 
1cb7d3c0cf31
move admissible out of class ccpo to avoid unnecessary class predicate in foundational theorems
 Andreas Lochbihler parents: 
46041diff
changeset | 276 | |
| 40106 
c58951943cba
Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
 krauss parents: diff
changeset | 277 | lemma admissible_disj: | 
| 
c58951943cba
Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
 krauss parents: diff
changeset | 278 | fixes P Q :: "'a \<Rightarrow> bool" | 
| 67399 | 279 | assumes P: "ccpo.admissible Sup (\<le>) (\<lambda>x. P x)" | 
| 280 | assumes Q: "ccpo.admissible Sup (\<le>) (\<lambda>x. Q x)" | |
| 281 | shows "ccpo.admissible Sup (\<le>) (\<lambda>x. P x \<or> Q x)" | |
| 53361 
1cb7d3c0cf31
move admissible out of class ccpo to avoid unnecessary class predicate in foundational theorems
 Andreas Lochbihler parents: 
46041diff
changeset | 282 | proof (rule ccpo.admissibleI) | 
| 63612 | 283 | fix A :: "'a set" | 
| 67399 | 284 | assume chain: "chain (\<le>) A" | 
| 63810 | 285 |   assume A: "A \<noteq> {}" and P_Q: "\<forall>x\<in>A. P x \<or> Q x"
 | 
| 286 | have "(\<exists>x\<in>A. P x) \<and> (\<forall>x\<in>A. \<exists>y\<in>A. x \<le> y \<and> P y) \<or> (\<exists>x\<in>A. Q x) \<and> (\<forall>x\<in>A. \<exists>y\<in>A. x \<le> y \<and> Q y)" | |
| 287 | (is "?P \<or> ?Q" is "?P1 \<and> ?P2 \<or> _") | |
| 288 | proof (rule disjCI) | |
| 289 | assume "\<not> ?Q" | |
| 290 | then consider "\<forall>x\<in>A. \<not> Q x" | a where "a \<in> A" "\<forall>y\<in>A. a \<le> y \<longrightarrow> \<not> Q y" | |
| 291 | by blast | |
| 292 | then show ?P | |
| 293 | proof cases | |
| 294 | case 1 | |
| 295 | with P_Q have "\<forall>x\<in>A. P x" by blast | |
| 296 | with A show ?P by blast | |
| 297 | next | |
| 298 | case 2 | |
| 299 | note a = \<open>a \<in> A\<close> | |
| 300 | show ?P | |
| 301 | proof | |
| 302 | from P_Q 2 have *: "\<forall>y\<in>A. a \<le> y \<longrightarrow> P y" by blast | |
| 303 | with a have "P a" by blast | |
| 304 | with a show ?P1 by blast | |
| 305 | show ?P2 | |
| 306 | proof | |
| 307 | fix x | |
| 308 | assume x: "x \<in> A" | |
| 309 | with chain a show "\<exists>y\<in>A. x \<le> y \<and> P y" | |
| 310 | proof (rule chainE) | |
| 311 | assume le: "a \<le> x" | |
| 312 | with * a x have "P x" by blast | |
| 313 | with x le show ?thesis by blast | |
| 314 | next | |
| 315 | assume "a \<ge> x" | |
| 316 | with a \<open>P a\<close> show ?thesis by blast | |
| 317 | qed | |
| 318 | qed | |
| 319 | qed | |
| 320 | qed | |
| 321 | qed | |
| 322 | moreover | |
| 73252 | 323 |   have "Sup A = Sup {x \<in> A. P x}" if "\<And>x. x\<in>A \<Longrightarrow> \<exists>y\<in>A. x \<le> y \<and> P y" for P
 | 
| 73411 | 324 | proof (rule order.antisym) | 
| 67399 | 325 |     have chain_P: "chain (\<le>) {x \<in> A. P x}"
 | 
| 63810 | 326 | by (rule chain_compr [OF chain]) | 
| 327 |     show "Sup A \<le> Sup {x \<in> A. P x}"
 | |
| 73252 | 328 | proof (rule ccpo_Sup_least [OF chain]) | 
| 329 |       show "\<And>x. x \<in> A \<Longrightarrow> x \<le> \<Squnion> {x \<in> A. P x}"
 | |
| 330 | by (blast intro: ccpo_Sup_upper[OF chain_P] order_trans dest: that) | |
| 331 | qed | |
| 63810 | 332 |     show "Sup {x \<in> A. P x} \<le> Sup A"
 | 
| 333 | apply (rule ccpo_Sup_least [OF chain_P]) | |
| 334 | apply (simp add: ccpo_Sup_upper [OF chain]) | |
| 335 | done | |
| 336 | qed | |
| 337 | ultimately | |
| 338 |   consider "\<exists>x. x \<in> A \<and> P x" "Sup A = Sup {x \<in> A. P x}"
 | |
| 339 |     | "\<exists>x. x \<in> A \<and> Q x" "Sup A = Sup {x \<in> A. Q x}"
 | |
| 340 | by blast | |
| 63612 | 341 | then show "P (Sup A) \<or> Q (Sup A)" | 
| 73252 | 342 | proof cases | 
| 343 | case 1 | |
| 344 | then show ?thesis | |
| 345 | using ccpo.admissibleD [OF P chain_compr [OF chain]] by force | |
| 346 | next | |
| 347 | case 2 | |
| 348 | then show ?thesis | |
| 349 | using ccpo.admissibleD [OF Q chain_compr [OF chain]] by force | |
| 350 | qed | |
| 40106 
c58951943cba
Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
 krauss parents: diff
changeset | 351 | qed | 
| 
c58951943cba
Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
 krauss parents: diff
changeset | 352 | |
| 
c58951943cba
Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
 krauss parents: diff
changeset | 353 | end | 
| 
c58951943cba
Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
 krauss parents: diff
changeset | 354 | |
| 46041 
1e3ff542e83e
remove constant 'ccpo.lub', re-use constant 'Sup' instead
 huffman parents: 
40252diff
changeset | 355 | instance complete_lattice \<subseteq> ccpo | 
| 61169 | 356 | by standard (fast intro: Sup_upper Sup_least)+ | 
| 46041 
1e3ff542e83e
remove constant 'ccpo.lub', re-use constant 'Sup' instead
 huffman parents: 
40252diff
changeset | 357 | |
| 
1e3ff542e83e
remove constant 'ccpo.lub', re-use constant 'Sup' instead
 huffman parents: 
40252diff
changeset | 358 | lemma lfp_eq_fixp: | 
| 63979 | 359 | assumes mono: "mono f" | 
| 63612 | 360 | shows "lfp f = fixp f" | 
| 73411 | 361 | proof (rule order.antisym) | 
| 67399 | 362 | from mono have f': "monotone (\<le>) (\<le>) f" | 
| 46041 
1e3ff542e83e
remove constant 'ccpo.lub', re-use constant 'Sup' instead
 huffman parents: 
40252diff
changeset | 363 | unfolding mono_def monotone_def . | 
| 
1e3ff542e83e
remove constant 'ccpo.lub', re-use constant 'Sup' instead
 huffman parents: 
40252diff
changeset | 364 | show "lfp f \<le> fixp f" | 
| 
1e3ff542e83e
remove constant 'ccpo.lub', re-use constant 'Sup' instead
 huffman parents: 
40252diff
changeset | 365 | by (rule lfp_lowerbound, subst fixp_unfold [OF f'], rule order_refl) | 
| 
1e3ff542e83e
remove constant 'ccpo.lub', re-use constant 'Sup' instead
 huffman parents: 
40252diff
changeset | 366 | show "fixp f \<le> lfp f" | 
| 63979 | 367 | by (rule fixp_lowerbound [OF f']) (simp add: lfp_fixpoint [OF mono]) | 
| 46041 
1e3ff542e83e
remove constant 'ccpo.lub', re-use constant 'Sup' instead
 huffman parents: 
40252diff
changeset | 368 | qed | 
| 
1e3ff542e83e
remove constant 'ccpo.lub', re-use constant 'Sup' instead
 huffman parents: 
40252diff
changeset | 369 | |
| 53361 
1cb7d3c0cf31
move admissible out of class ccpo to avoid unnecessary class predicate in foundational theorems
 Andreas Lochbihler parents: 
46041diff
changeset | 370 | hide_const (open) iterates fixp | 
| 40106 
c58951943cba
Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
 krauss parents: diff
changeset | 371 | |
| 
c58951943cba
Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
 krauss parents: diff
changeset | 372 | end |