theory Universal imports Bifinite Completion "HOL-Library.Nat_Bijection" begin
unbundle no binomial_syntax
subsection \<open>Basis for universal domain\<close>
subsubsection \<open>Basis datatype\<close>
type_synonym ubasis = nat
definition
node :: "nat \ ubasis \ ubasis set \ ubasis" where "node i a S = Suc (prod_encode (i, prod_encode (a, set_encode S)))"
lemma node_not_0 [simp]: "node i a S \ 0" unfolding node_def by simp
lemma node_gt_0 [simp]: "0 < node i a S" unfolding node_def by simp
lemma node_inject [simp]: "\finite S; finite T\ \<Longrightarrow> node i a S = node j b T \<longleftrightarrow> i = j \<and> a = b \<and> S = T" unfolding node_def by (simp add: prod_encode_eq set_encode_eq)
lemma node_gt0: "i < node i a S" unfolding node_def less_Suc_eq_le by (rule le_prod_encode_1)
lemma node_gt1: "a < node i a S" unfolding node_def less_Suc_eq_le by (rule order_trans [OF le_prod_encode_1 le_prod_encode_2])
lemma nat_less_power2: "n < 2^n" by (fact less_exp)
lemma node_induct: assumes 1: "P 0" assumes 2: "\i a S. \P a; finite S; \b\S. P b\ \ P (node i a S)" shows"P x" apply (induct x rule: nat_less_induct) apply (case_tac n rule: node_cases) apply (simp add: 1) apply (simp add: 2 node_gt1 node_gt2) done
subsubsection \<open>Basis ordering\<close>
inductive
ubasis_le :: "nat \ nat \ bool" where
ubasis_le_refl: "ubasis_le a a"
| ubasis_le_trans: "\ubasis_le a b; ubasis_le b c\ \ ubasis_le a c"
| ubasis_le_lower: "finite S \ ubasis_le a (node i a S)"
| ubasis_le_upper: "\finite S; b \ S; ubasis_le a b\ \ ubasis_le (node i a S) b"
subsubsection \<open>Generic take function\<close>
function ubasis_until :: "(ubasis \<Rightarrow> bool) \<Rightarrow> ubasis \<Rightarrow> ubasis" where "ubasis_until P 0 = 0" | "finite S \<Longrightarrow> ubasis_until P (node i a S) = (if P (node i a S) then node i a S else ubasis_until P a)" apply clarify apply (rule_tac x=b in node_cases) apply simp_all done
lemma ubasis_until: "P 0 \<Longrightarrow> P (ubasis_until P x)" by (induct x rule: node_induct) simp_all
lemma ubasis_until': "0 < ubasis_until P x \<Longrightarrow> P (ubasis_until P x)" by (induct x rule: node_induct) auto
lemma ubasis_until_same: "P x \<Longrightarrow> ubasis_until P x = x" by (induct x rule: node_induct) simp_all
lemma ubasis_until_idem: "P 0 \<Longrightarrow> ubasis_until P (ubasis_until P x) = ubasis_until P x" by (rule ubasis_until_same [OF ubasis_until])
lemma ubasis_until_0: "\<forall>x. x \<noteq> 0 \<longrightarrow> \<not> P x \<Longrightarrow> ubasis_until P x = 0" by (induct x rule: node_induct) simp_all
lemma ubasis_until_less: "ubasis_le (ubasis_until P x) x" apply (induct x rule: node_induct) apply (simp add: ubasis_le_refl) by (metis ubasis_le.simps ubasis_until.simps(2))
lemma ubasis_until_chain: assumes PQ: "\<And>x. P x \<Longrightarrow> Q x" shows "ubasis_le (ubasis_until P x) (ubasis_until Q x)" apply (induct x rule: node_induct) apply (simp add: ubasis_le_refl) by (metis assms ubasis_until.simps(2) ubasis_until_less)
lemma ubasis_until_mono: assumes "\<And>i a S b. \<lbrakk>finite S; P (node i a S); b \<in> S; ubasis_le a b\<rbrakk> \<Longrightarrow> P b" shows "ubasis_le a b \<Longrightarrow> ubasis_le (ubasis_until P a) (ubasis_until P b)" proof (induct set: ubasis_le) case (ubasis_le_refl a) show ?case by (rule ubasis_le.ubasis_le_refl) next case (ubasis_le_trans a b c) thus ?case by - (rule ubasis_le.ubasis_le_trans) next case (ubasis_le_lower S a i) thus ?case by (metis ubasis_le.simps ubasis_until.simps(2) ubasis_until_less) next case (ubasis_le_upper S b a i) thus ?case by (metis assms ubasis_le.simps ubasis_until.simps(2) ubasis_until_same) qed
interpretation udom: ideal_completion ubasis_le udom_principal Rep_udom using type_definition_udom below_udom_def using udom_principal_def ubasis_countable by (rule udom.typedef_ideal_completion)
subsection \<open>Universality of \emph{udom}\<close>
text \<open>We use a locale to parameterize the construction over a chain of approx functions on the type to be embedded.\<close>
locale bifinite_approx_chain = approx_chain approx for approx :: "nat \<Rightarrow> 'a::bifinite \<rightarrow> 'a" begin
subsubsection \<open>Choosing a maximal element from a finite set\<close>
lemma finite_has_maximal: fixes A :: "'a compact_basis set" shows "\<lbrakk>finite A; A \<noteq> {}\<rbrakk> \<Longrightarrow> \<exists>x\<in>A. \<forall>y\<in>A. x \<sqsubseteq> y \<longrightarrow> x = y" proof (induct rule: finite_ne_induct) case (singleton x) show ?case by simp next case (insert a A) from \<open>\<exists>x\<in>A. \<forall>y\<in>A. x \<sqsubseteq> y \<longrightarrow> x = y\<close> obtain x where x: "x \<in> A" and x_eq: "\<And>y. \<lbrakk>y \<in> A; x \<sqsubseteq> y\<rbrakk> \<Longrightarrow> x = y" by fast show ?case proof (intro bexI ballI impI) fix y assume "y \<in> insert a A" and "(if x \<sqsubseteq> a then a else x) \<sqsubseteq> y" thus "(if x \<sqsubseteq> a then a else x) = y" apply auto apply (frule (1) below_trans) apply (frule (1) x_eq) apply (rule below_antisym, assumption) apply simp apply (erule (1) x_eq) done next show "(if x \<sqsubseteq> a then a else x) \<in> insert a A" by (simp add: x) qed qed
definition choose :: "'a compact_basis set \<Rightarrow> 'a compact_basis" where "choose A = (SOME x. x \<in> {x\<in>A. \<forall>y\<in>A. x \<sqsubseteq> y \<longrightarrow> x = y})"
lemma choose_lemma: "\<lbrakk>finite A; A \<noteq> {}\<rbrakk> \<Longrightarrow> choose A \<in> {x\<in>A. \<forall>y\<in>A. x \<sqsubseteq> y \<longrightarrow> x = y}" unfolding choose_def apply (rule someI_ex) apply (frule (1) finite_has_maximal, fast) done
lemma maximal_choose: "\<lbrakk>finite A; y \<in> A; choose A \<sqsubseteq> y\<rbrakk> \<Longrightarrow> choose A = y" apply (cases "A = {}", simp) apply (frule (1) choose_lemma, simp) done
lemma choose_in: "\<lbrakk>finite A; A \<noteq> {}\<rbrakk> \<Longrightarrow> choose A \<in> A" by (frule (1) choose_lemma, simp)
function choose_pos :: "'a compact_basis set \<Rightarrow> 'a compact_basis \<Rightarrow> nat" where "choose_pos A x = (if finite A \<and> x \<in> A \<and> x \<noteq> choose A then Suc (choose_pos (A - {choose A}) x) else 0)" by auto
lemma cb_take_less: "cb_take n x \<sqsubseteq> x" unfolding compact_le_def by (cases n, simp, simp add: Rep_cb_take approx_below)
lemma cb_take_idem: "cb_take n (cb_take n x) = cb_take n x" unfolding Rep_compact_basis_inject [symmetric] by (cases n, simp, simp add: Rep_cb_take approx_idem)
lemma cb_take_mono: "x \<sqsubseteq> y \<Longrightarrow> cb_take n x \<sqsubseteq> cb_take n y" unfolding compact_le_def by (cases n, simp, simp add: Rep_cb_take monofun_cfun_arg)
lemma cb_take_chain_le: "m \<le> n \<Longrightarrow> cb_take m x \<sqsubseteq> cb_take n x" unfolding compact_le_def apply (cases m, simp, cases n, simp) apply (simp add: Rep_cb_take, rule chain_mono, simp, simp) done
lemma place_ge: "card (rank_lt x) \<le> place x" unfolding place_def by simp
lemma place_rank_mono: fixes x y :: "'a compact_basis" shows "rank x < rank y \<Longrightarrow> place x < place y" apply (rule less_le_trans [OF place_bounded]) apply (rule order_trans [OF _ place_ge]) apply (rule card_mono) apply (rule finite_rank_lt) apply (simp add: rank_le_def rank_lt_def subset_eq) done
lemma place_eqD: "place x = place y \<Longrightarrow> x = y" apply (rule linorder_cases [where x="rank x" and y="rank y"]) apply (drule place_rank_mono, simp) apply (simp add: place_def) apply (rule inj_on_choose_pos [where A="rank_eq x", THEN inj_onD]) apply (rule finite_rank_eq) apply (simp cong: rank_lt_cong rank_eq_cong) apply (simp add: rank_eq_def) apply (simp add: rank_eq_def) apply (drule place_rank_mono, simp) done
lemma inj_place: "inj place" by (rule inj_onI, erule place_eqD)
subsubsection \<open>Embedding and projection on basis elements\<close>
definition sub :: "'a compact_basis \<Rightarrow> 'a compact_basis" where "sub x = (case rank x of 0 \<Rightarrow> compact_bot | Suc k \<Rightarrow> cb_take k x)"
function basis_emb :: "'a compact_basis \<Rightarrow> ubasis" where "basis_emb x = (if x = compact_bot then 0 else node (place x) (basis_emb (sub x)) (basis_emb ` {y. place y < place x \<and> x \<sqsubseteq> y}))" by simp_all
termination basis_emb by (relation "measure place") (simp_all add: place_sub_less)
declare basis_emb.simps [simp del]
lemma basis_emb_compact_bot [simp]: "basis_emb compact_bot = 0" using basis_emb.simps [of compact_bot] by simp
lemma basis_emb_rec: "basis_emb x = node (place x) (basis_emb (sub x)) (basis_emb ` {y. place y < place x \<and> x \<sqsubseteq> y})" if "x \<noteq> compact_bot" using that basis_emb.simps [of x] by simp
lemma basis_emb_eq_0_iff [simp]: "basis_emb x = 0 \<longleftrightarrow> x = compact_bot" by (cases "x = compact_bot") (simp_all add: basis_emb_rec)
lemma fin1: "finite {y. place y < place x \<and> x \<sqsubseteq> y}" apply (subst Collect_conj_eq) apply (rule finite_Int) apply (rule disjI1) apply (subgoal_tac "finite (place -` {n. n < place x})", simp) apply (rule finite_vimageI [OF _ inj_place]) apply (simp add: lessThan_def [symmetric]) done
lemma fin2: "finite (basis_emb ` {y. place y < place x \<and> x \<sqsubseteq> y})" by (rule finite_imageI [OF fin1])
lemma basis_emb_mono: "x \<sqsubseteq> y \<Longrightarrow> ubasis_le (basis_emb x) (basis_emb y)" proof (induct "max (place x) (place y)" arbitrary: x y rule: less_induct) case less show ?case proof (rule linorder_cases) assume "place x < place y" then have "rank x < rank y" using \<open>x \<sqsubseteq> y\<close> by (rule rank_place_mono) with \<open>place x < place y\<close> show ?case apply (case_tac "y = compact_bot", simp) apply (simp add: basis_emb.simps [of y]) apply (rule ubasis_le_trans [OF _ ubasis_le_lower [OF fin2]]) apply (rule less) apply (simp add: less_max_iff_disj) apply (erule place_sub_less) apply (erule rank_less_imp_below_sub [OF \<open>x \<sqsubseteq> y\<close>]) done next assume "place x = place y" hence "x = y" by (rule place_eqD) thus ?case by (simp add: ubasis_le_refl) next assume "place x > place y" with \<open>x \<sqsubseteq> y\<close> show ?case apply (case_tac "x = compact_bot", simp add: ubasis_le_minimal) apply (simp add: basis_emb.simps [of x]) apply (rule ubasis_le_upper [OF fin2], simp) apply (rule less) apply (simp add: less_max_iff_disj) apply (erule place_sub_less) apply (erule rev_below_trans) apply (rule sub_below) done qed qed
lemma inj_basis_emb: "inj basis_emb" proof (rule injI) fix x y assume "basis_emb x = basis_emb y" then show "x = y" by (cases "x = compact_bot \<or> y = compact_bot") (auto simp add: basis_emb_rec fin2 place_eqD) qed
definition basis_prj :: "ubasis \<Rightarrow> 'a compact_basis" where "basis_prj x = inv basis_emb (ubasis_until (\<lambda>x. x \<in> range (basis_emb :: 'a compact_basis \<Rightarrow> ubasis)) x)"
lemma basis_prj_node: "\<lbrakk>finite S; node i a S \<notin> range (basis_emb :: 'a compact_basis \<Rightarrow> nat)\<rbrakk> \<Longrightarrow> basis_prj (node i a S) = (basis_prj a :: 'a compact_basis)" unfolding basis_prj_def by simp
lemma node_eq_basis_emb_iff: "finite S \<Longrightarrow> node i a S = basis_emb x \<longleftrightarrow> x \<noteq> compact_bot \<and> i = place x \<and> a = basis_emb (sub x) \<and> S = basis_emb ` {y. place y < place x \<and> x \<sqsubseteq> y}" apply (cases "x = compact_bot", simp) apply (simp add: basis_emb.simps [of x]) apply (simp add: fin2) done
lemma basis_prj_mono: "ubasis_le a b \<Longrightarrow> basis_prj a \<sqsubseteq> basis_prj b" proof (induct a b rule: ubasis_le.induct) case (ubasis_le_refl a) show ?case by (rule below_refl) next case (ubasis_le_trans a b c) thus ?case by - (rule below_trans) next case (ubasis_le_lower S a i) thus ?case apply (cases "node i a S \<in> range (basis_emb :: 'a compact_basis \<Rightarrow> nat)") apply (erule rangeE, rename_tac x) apply (simp add: basis_prj_basis_emb) apply (simp add: node_eq_basis_emb_iff) apply (simp add: basis_prj_basis_emb) apply (rule sub_below) apply (simp add: basis_prj_node) done next case (ubasis_le_upper S b a i) thus ?case apply (cases "node i a S \<in> range (basis_emb :: 'a compact_basis \<Rightarrow> nat)") apply (erule rangeE, rename_tac x) apply (simp add: basis_prj_basis_emb) apply (clarsimp simp add: node_eq_basis_emb_iff) apply (simp add: basis_prj_basis_emb) apply (simp add: basis_prj_node) done qed
lemma ideal_completion: "ideal_completion below Rep_compact_basis (approximants :: 'a \<Rightarrow> _)" proof fix w :: "'a" show "below.ideal (approximants w)" proof (rule below.idealI) have "Abs_compact_basis (approx 0\<cdot>w) \<in> approximants w" by (simp add: approximants_def approx_below) thus "\<exists>x. x \<in> approximants w" .. next fix x y :: "'a compact_basis" assume x: "x \<in> approximants w" and y: "y \<in> approximants w" obtain i where i: "approx i\<cdot>(Rep_compact_basis x) = Rep_compact_basis x" using compact_eq_approx Rep_compact_basis' by fast obtain j where j: "approx j\<cdot>(Rep_compact_basis y) = Rep_compact_basis y" using compact_eq_approx Rep_compact_basis' by fast let ?z = "Abs_compact_basis (approx (max i j)\<cdot>w)" have "?z \<in> approximants w" by (simp add: approximants_def approx_below) moreover from x y have "x \<sqsubseteq> ?z \<and> y \<sqsubseteq> ?z" by (simp add: approximants_def compact_le_def) (metis i j monofun_cfun chain_mono chain_approx max.cobounded1 max.cobounded2) ultimately show "\<exists>z \<in> approximants w. x \<sqsubseteq> z \<and> y \<sqsubseteq> z" .. next fix x y :: "'a compact_basis" assume "x \<sqsubseteq> y" "y \<in> approximants w" thus "x \<in> approximants w" unfolding approximants_def compact_le_def by (auto elim: below_trans) qed next fix Y :: "nat \<Rightarrow> 'a" assume "chain Y" thus "approximants (\<Squnion>i. Y i) = (\<Union>i. approximants (Y i))" unfolding approximants_def by (auto simp add: compact_below_lub_iff) next fix a :: "'a compact_basis" show "approximants (Rep_compact_basis a) = {b. b \<sqsubseteq> a}" unfolding approximants_def compact_le_def .. next fix x y :: "'a" assume "approximants x \<subseteq> approximants y" hence "\<forall>z. compact z \<longrightarrow> z \<sqsubseteq> x \<longrightarrow> z \<sqsubseteq> y" by (simp add: approximants_def subset_eq) (metis Abs_compact_basis_inverse') hence "(\<Squnion>i. approx i\<cdot>x) \<sqsubseteq> y" by (simp add: lub_below approx_below) thus "x \<sqsubseteq> y" by (simp add: lub_distribs) next show "\<exists>f::'a compact_basis \<Rightarrow> nat. inj f" by (rule exI, rule inj_place) qed
end
interpretation compact_basis: ideal_completion below Rep_compact_basis "approximants :: 'a::bifinite \<Rightarrow> 'a compact_basis set" proof - obtain a :: "nat \<Rightarrow> 'a \<rightarrow> 'a" where "approx_chain a" using bifinite .. hence "bifinite_approx_chain a" unfolding bifinite_approx_chain_def . thus "ideal_completion below Rep_compact_basis (approximants :: 'a \<Rightarrow> _)" by (rule bifinite_approx_chain.ideal_completion) qed
subsubsection \<open>EP-pair from any bifinite domain into \emph{udom}\<close>
lemma finite_deflation_udom_approx: "finite_deflation (udom_approx i)" proof fix x show "udom_approx i\<cdot>(udom_approx i\<cdot>x) = udom_approx i\<cdot>x" by (induct x rule: udom.principal_induct, simp) (simp add: udom_approx_principal ubasis_until_idem) next fix x show "udom_approx i\<cdot>x \<sqsubseteq> x" by (induct x rule: udom.principal_induct, simp) (simp add: udom_approx_principal ubasis_until_less) next have *: "finite (range (\<lambda>x. udom_principal (ubasis_until (\<lambda>y. y \<le> i) x)))" apply (subst range_composition [where f=udom_principal]) apply (simp add: finite_range_ubasis_until) done show "finite {x. udom_approx i\<cdot>x = x}" apply (rule finite_range_imp_finite_fixes) apply (rule rev_finite_subset [OF *]) apply (clarsimp, rename_tac x) apply (induct_tac x rule: udom.principal_induct)
apply (simp add: adm_mem_finite *) apply (simp: cb_take(2)
qed
interpretationudom_approx "udom_approxijava.lang.StringIndexOutOfBoundsException: Index 60 out of bounds for length 60 by (rule finite_deflation_udom_approx)
lemma : "cb_take n( n x) = n x" unfolding udom_approx_def apply rule) apply (lemma cb_ta apply (erule udom_approx_monocases, simp: monofun_cfun_arg apply (erule udom_approx_monocb_take_chain_le <le> n \<Longrightarrow> cb_take m x \<sqsubseteq> cb_take n x" apply (rule udom compact_le_def apply (rule ubasis_until_chaincases, casessimp done
lemma lub_udom_approx ( n)
ruleadd apply (rule below_antisym finite_imageD f=Rep_compact_basis
rule apply simp apply (ruleapplyrule:) applyjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 "x LEASTn. nx=)java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39 apply (rule_tac i=a in below_lub) apply simp apply (simp add: udom_approx_principalapplyrule) applylemma rank_leDrank done
lemma udom_approx [simp]:applyerule) proof "chain \i. udom_approx i)" byunfoldingby( Least_le show by (rulerule [OFrank_leD]) qed
instance : by [simpx=
open
binomial_syntax
end :"
¤ Diese beiden folgenden Angebotsgruppen bietet das Unternehmen0.11Angebot
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.