(* Title: HOL/HOLCF/Library/Defl_Bifinite.thy Author: Brian Huffman *)
section‹Algebraic deflations are a bifinite domain›
theory Defl_Bifinite imports HOLCF "HOL-Library.Infinite_Set" begin
subsection‹Lemmas about MOST›
default_sort type
subsection‹Eventually constant sequences›
definition
eventually_constant :: "(nat ==> 'a) ==> bool" where "eventually_constant S = (∃x. MOST i. S i = x)"
lemma eventually_constant_MOST_MOST: "eventually_constant S ⟷ (MOST m. MOST n. S n = S m)" unfolding eventually_constant_def MOST_nat apply safe apply (rule_tac x=m in exI, clarify) apply (rule_tac x=m in exI, clarify) apply simp apply fast done
lemma eventually_constantI: "MOST i. S i = x ==> eventually_constant S" unfolding eventually_constant_def by fast
lemma eventually_constant_comp: "eventually_constant (λi. S i) ==> eventually_constant (λi. f (S i))" unfolding eventually_constant_def apply (erule exE, rule_tac x="f x"in exI) apply (erule MOST_mono, simp) done
lemma eventually_constant_Suc_iff: "eventually_constant (λi. S (Suc i)) ⟷ eventually_constant (λi. S i)" unfolding eventually_constant_def by (subst MOST_Suc_iff, rule refl)
lemma eventually_constant_SucD: "eventually_constant (λi. S (Suc i)) ==> eventually_constant (λi. S i)" by (rule eventually_constant_Suc_iff [THEN iffD1])
subsection‹Limits of eventually constant sequences›
definition
eventual :: "(nat ==> 'a) ==> 'a"where "eventual S = (THE x. MOST i. S i = x)"
lemma eventual_eqI: "MOST i. S i = x ==> eventual S = x" unfolding eventual_def apply (rule the_equality, assumption) apply (rename_tac y) apply (subgoal_tac "MOST i::nat. y = x", simp) apply (erule MOST_rev_mp) apply (erule MOST_rev_mp) apply simp done
lemma MOST_eq_eventual: "eventually_constant S ==> MOST i. S i = eventual S" unfolding eventually_constant_def by (erule exE, simp add: eventual_eqI)
lemma eventually_constant_MOST_iff: assumes S: "eventually_constant S" shows"(MOST n. P (S n)) ⟷ P (eventual S)" apply (subgoal_tac "(MOST n. P (S n)) ⟷ (MOST n::nat. P (eventual S))") apply simp apply (rule iffI) apply (rule MOST_rev_mp [OF MOST_eq_eventual [OF S]]) apply (erule MOST_mono, force) apply (rule MOST_rev_mp [OF MOST_eq_eventual [OF S]]) apply (erule MOST_mono, simp) done
lemma MOST_eventual: "[eventually_constant S; MOST n. P (S n)]==> P (eventual S)" proof - assume"eventually_constant S" hence"MOST n. S n = eventual S" by (rule MOST_eq_eventual) moreoverassume"MOST n. P (S n)" ultimatelyhave"MOST n. S n = eventual S ∧ P (S n)" by (rule MOST_conj_distrib [THEN iffD2, OF conjI]) hence"MOST n::nat. P (eventual S)" by (rule MOST_mono) auto thus ?thesis by simp qed
lemma eventually_constant_MOST_Suc_eq: "eventually_constant S ==> MOST n. S (Suc n) = S n" apply (drule MOST_eq_eventual) apply (frule MOST_Suc_iff [THEN iffD2]) apply (erule MOST_rev_mp) apply (erule MOST_rev_mp) apply simp done
lemma eventual_comp: "eventually_constant S ==> eventual (λi. f (S i)) = f (eventual (λi. S i))" apply (rule eventual_eqI) apply (rule MOST_mono) apply (erule MOST_eq_eventual) apply simp done
subsection‹Constructing finite deflations by iteration›
default_sort cpo
lemma le_Suc_induct: assumes le: "i ≤ j" assumes step: "∧i. P i (Suc i)" assumes refl: "∧i. P i i" assumes trans: "∧i j k. [P i j; P j k]==> P i k" shows"P i j" proof (cases "i = j") assume"i = j" thus"P i j"by (simp add: refl) next assume"i ≠ j" with le have"i < j"by simp thus"P i j"using step trans by (rule less_Suc_induct) qed
definition
eventual_iterate :: "('a → 'a::cpo) ==> ('a → 'a)" where "eventual_iterate f = eventual (λn. iterate n⋅f)"
text‹A pre-deflation is like a deflation, but not idempotent.›
lemma finite_range_iterate_app: "finite (range (λi. iterate i⋅f⋅x))" proof (rule finite_subset) show"range (λi. iterate i⋅f⋅x) ⊆ insert x (range (λx. f⋅x))" by (clarify, case_tac i, simp_all) show"finite (insert x (range (λx. f⋅x)))" by (simp add: finite_range) qed
lemma eventually_constant_iterate_app: "eventually_constant (λi. iterate i⋅f⋅x)" unfolding eventually_constant_def MOST_nat_le proof - let ?Y = "λi. iterate i⋅f⋅x" have"∃j. ∀k. ?Y j ⊑ ?Y k" apply (rule finite_range_has_max) apply (erule antichain_iterate_app) apply (rule finite_range_iterate_app) done thenobtain j where j: "∧k. ?Y j ⊑ ?Y k"by fast show"∃z m. ∀n≥m. ?Y n = z" proof (intro exI allI impI) fix k assume"j ≤ k" hence"?Y k ⊑ ?Y j"by (rule antichain_iterate_app) alsohave"?Y j ⊑ ?Y k"by (rule j) finallyshow"?Y k = ?Y j" . qed qed
lemma eventually_constant_iterate: "eventually_constant (λn. iterate n⋅f)" proof - have"∀y∈range (λx. f⋅x). eventually_constant (λi. iterate i⋅f⋅y)" by (simp add: eventually_constant_iterate_app) hence"∀y∈range (λx. f⋅x). MOST i. MOST j. iterate j⋅f⋅y = iterate i⋅f⋅y" unfolding eventually_constant_MOST_MOST . hence"MOST i. MOST j. ∀y∈range (λx. f⋅x). iterate j⋅f⋅y = iterate i⋅f⋅y" by (simp only: MOST_finite_Ball_distrib [OF finite_range]) hence"MOST i. MOST j. ∀x. iterate j⋅f⋅(f⋅x) = iterate i⋅f⋅(f⋅x)" by simp hence"MOST i. MOST j. ∀x. iterate (Suc j)⋅f⋅x = iterate (Suc i)⋅f⋅x" by (simp only: iterate_Suc2) hence"MOST i. MOST j. iterate (Suc j)⋅f = iterate (Suc i)⋅f" by (simp only: cfun_eq_iff) hence"eventually_constant (λi. iterate (Suc i)⋅f)" unfolding eventually_constant_MOST_MOST . thus"eventually_constant (λi. iterate i⋅f)" by (rule eventually_constant_SucD) qed
abbreviation
d :: "'a → 'a" where "d ≡ eventual_iterate f"
lemma MOST_d: "MOST n. P (iterate n⋅f) ==> P d" unfolding eventual_iterate_def using eventually_constant_iterate by (rule MOST_eventual)
lemma d_fixed_iff: "d⋅x = x ⟷ f⋅x = x" proof assume"d⋅x = x" with f_d [where x=x] show"f⋅x = x"by simp next assume f: "f⋅x = x" have"∀n. iterate n⋅f⋅x = x" by (rule allI, rule nat.induct, simp, simp add: f) hence"MOST n. iterate n⋅f⋅x = x" by (rule ALL_MOST) thus"d⋅x = x" by (rule MOST_d) qed
lemma finite_deflation_d: "finite_deflation d" proof fix x :: 'a have"d ∈ range (λn. iterate n⋅f)" unfolding eventual_iterate_def using eventually_constant_iterate by (rule eventual_mem_range) thenobtain n where n: "d = iterate n⋅f" .. have"iterate n⋅f⋅(d⋅x) = d⋅x" using f_d by (rule iterate_fixed) thus"d⋅(d⋅x) = d⋅x" by (simp add: n) next fix x :: 'a show"d⋅x ⊑ x" by (rule MOST_d, simp add: iterate_below) next from finite_range have"finite {x. f⋅x = x}" by (rule finite_range_imp_finite_fixes) thus"finite {x. d⋅x = x}" by (simp add: d_fixed_iff) qed
lemma deflation_d: "deflation d" using finite_deflation_d by (rule finite_deflation_imp_deflation)
end
lemma finite_deflation_eventual_iterate: "pre_deflation d ==> finite_deflation (eventual_iterate d)" by (rule pre_deflation.finite_deflation_d)
lemma pre_deflation_oo: assumes"finite_deflation d" assumes f: "∧x. f⋅x ⊑ x" shows"pre_deflation (d oo f)" proof interpret d: finite_deflation d by fact fix x show"∧x. (d oo f)⋅x ⊑ x" by (simp, rule below_trans [OF d.below f]) show"finite (range (λx. (d oo f)⋅x))" by (rule finite_subset [OF _ d.finite_range], auto) qed
lemma eventual_iterate_oo_fixed_iff: assumes"finite_deflation d" assumes f: "∧x. f⋅x ⊑ x" shows"eventual_iterate (d oo f)⋅x = x ⟷ d⋅x = x ∧ f⋅x = x" proof - interpret d: finite_deflation d by fact let ?e = "d oo f" interpret e: pre_deflation "d oo f" using‹finite_deflation d› f by (rule pre_deflation_oo) let ?g = "eventual (λn. iterate n⋅?e)" show ?thesis apply (subst e.d_fixed_iff) apply simp apply safe apply (erule subst) apply (rule d.idem) apply (rule below_antisym) apply (rule f) apply (erule subst, rule d.below) apply simp done qed
lemma eventual_mono: assumes A: "eventually_constant A" assumes B: "eventually_constant B" assumes below: "∧n. A n ⊑ B n" shows"eventual A ⊑ eventual B" proof - from A have"MOST n. A n = eventual A" by (rule MOST_eq_eventual) thenhave"MOST n. eventual A ⊑ B n" by (rule MOST_mono) (erule subst, rule below) with B show"eventual A ⊑ eventual B" by (rule MOST_eventual) qed
lemma cont2cont_eventual_iterate_oo: assumes d: "finite_deflation d" assumes cont: "cont f"and below: "∧x y. f x⋅y ⊑ y" shows"cont (λx. eventual_iterate (d oo f x))"
(is"cont ?e") proof (rule contI2) show"monofun ?e" apply (rule monofunI) apply (rule eventual_iterate_mono) apply (rule pre_deflation_oo [OF d below]) apply (rule pre_deflation_oo [OF d below]) apply (rule monofun_cfun_arg) apply (erule cont2monofunE [OF cont]) done next fix Y :: "nat ==> 'b" assume Y: "chain Y" with cont have fY: "chain (λi. f (Y i))" by (rule ch2ch_cont) assume eY: "chain (λi. ?e (Y i))" have lub_below: "∧x. f (⊔i. Y i)⋅x ⊑ x" by (rule admD [OF _ Y], simp add: cont, rule below) have"deflation (?e (⊔i. Y i))" apply (rule pre_deflation.deflation_d) apply (rule pre_deflation_oo [OF d lub_below]) done thenshow"?e (⊔i. Y i) ⊑ (⊔i. ?e (Y i))" proof (rule deflation.belowI) fix x :: 'a assume"?e (⊔i. Y i)⋅x = x" hence"d⋅x = x"and"f (⊔i. Y i)⋅x = x" by (simp_all add: eventual_iterate_oo_fixed_iff [OF d lub_below]) hence"(⊔i. f (Y i)⋅x) = x" apply (simp only: cont2contlubE [OF cont Y]) apply (simp only: contlub_cfun_fun [OF fY]) done have"compact (d⋅x)" using d by (rule finite_deflation.compact) thenhave"compact x" using‹d⋅x = x›by simp thenhave"compact (⊔i. f (Y i)⋅x)" using‹(⊔i. f (Y i)⋅x) = x›by simp thenhave"∃n. max_in_chain n (λi. f (Y i)⋅x)" by - (rule compact_imp_max_in_chain, simp add: fY, assumption) thenobtain n where n: "max_in_chain n (λi. f (Y i)⋅x)" .. thenhave"f (Y n)⋅x = x" using‹(⊔i. f (Y i)⋅x) = x› fY by (simp add: maxinch_is_thelub) with‹d⋅x = x›have"?e (Y n)⋅x = x" by (simp add: eventual_iterate_oo_fixed_iff [OF d below]) moreoverhave"?e (Y n)⋅x ⊑ (⊔i. ?e (Y i)⋅x)" by (rule is_ub_thelub, simp add: eY) ultimatelyhave"x ⊑ (⊔i. ?e (Y i))⋅x" by (simp add: contlub_cfun_fun eY) alsohave"(⊔i. ?e (Y i))⋅x ⊑ x" apply (rule deflation.below) apply (rule admD [OF adm_deflation eY]) apply (rule pre_deflation.deflation_d) apply (rule pre_deflation_oo [OF d below]) done finallyshow"(⊔i. ?e (Y i))⋅x = x" .. qed qed
subsection‹Intersection of algebraic deflations›
default_sort bifinite
definition meet_fin_defl :: "'a fin_defl ==> 'a fin_defl ==> 'a fin_defl" where"meet_fin_defl a b = Abs_fin_defl (eventual_iterate (Rep_fin_defl a oo Rep_fin_defl b))"
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 und die Messung sind noch experimentell.