# HG changeset patch # User huffman # Date 1214855537 -7200 # Node ID 4edc81f93e35bb0929eef9485fe7d0efa2e353e1 # Parent 42ee5e7c3b50a6f3a9fcf825a1a307a1b16724b3 New theory of deflations and embedding-projection pairs diff -r 42ee5e7c3b50 -r 4edc81f93e35 src/HOLCF/Deflation.thy --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/HOLCF/Deflation.thy Mon Jun 30 21:52:17 2008 +0200 @@ -0,0 +1,352 @@ +(* Title: HOLCF/Deflation.thy + ID: $Id$ + Author: Brian Huffman +*) + +header {* Continuous Deflations and Embedding-Projection Pairs *} + +theory Deflation +imports Cfun +begin + +defaultsort cpo + +subsection {* Continuous deflations *} + +locale deflation = + fixes d :: "'a \ 'a" + assumes idem: "\x. d\(d\x) = d\x" + assumes less: "\x. d\x \ x" +begin + +lemma less_ID: "d \ ID" +by (rule less_cfun_ext, simp add: less) + +text {* The set of fixed points is the same as the range. *} + +lemma fixes_eq_range: "{x. d\x = x} = range (\x. d\x)" +by (auto simp add: eq_sym_conv idem) + +lemma range_eq_fixes: "range (\x. d\x) = {x. d\x = x}" +by (auto simp add: eq_sym_conv idem) + +text {* + The pointwise ordering on deflation functions coincides with + the subset ordering of their sets of fixed-points. +*} + +lemma lessI: + assumes f: "\x. d\x = x \ f\x = x" shows "d \ f" +proof (rule less_cfun_ext) + fix x + from less have "f\(d\x) \ f\x" by (rule monofun_cfun_arg) + also from idem have "f\(d\x) = d\x" by (rule f) + finally show "d\x \ f\x" . +qed + +lemma lessD: "\f \ d; f\x = x\ \ d\x = x" +proof (rule antisym_less) + from less show "d\x \ x" . +next + assume "f \ d" + hence "f\x \ d\x" by (rule monofun_cfun_fun) + also assume "f\x = x" + finally show "x \ d\x" . +qed + +end + +lemma adm_deflation: "adm (\d. deflation d)" +by (simp add: deflation_def) + +lemma deflation_ID: "deflation ID" +by (simp add: deflation.intro) + +lemma deflation_UU: "deflation \" +by (simp add: deflation.intro) + +lemma deflation_less_iff: + "\deflation p; deflation q\ \ p \ q \ (\x. p\x = x \ q\x = x)" + apply safe + apply (simp add: deflation.lessD) + apply (simp add: deflation.lessI) +done + +text {* + The composition of two deflations is equal to + the lesser of the two (if they are comparable). +*} + +lemma deflation_less_comp1: + includes deflation f + includes deflation g + shows "f \ g \ f\(g\x) = f\x" +proof (rule antisym_less) + from g.less show "f\(g\x) \ f\x" by (rule monofun_cfun_arg) +next + assume "f \ g" hence "f\x \ g\x" by (rule monofun_cfun_fun) + hence "f\(f\x) \ f\(g\x)" by (rule monofun_cfun_arg) + also have "f\(f\x) = f\x" by (rule f.idem) + finally show "f\x \ f\(g\x)" . +qed + +lemma deflation_less_comp2: + "\deflation f; deflation g; f \ g\ \ g\(f\x) = f\x" +by (simp only: deflation.lessD deflation.idem) + + +subsection {* Deflations with finite range *} + +lemma finite_range_imp_finite_fixes: + "finite (range f) \ finite {x. f x = x}" +proof - + have "{x. f x = x} \ range f" + by (clarify, erule subst, rule rangeI) + moreover assume "finite (range f)" + ultimately show "finite {x. f x = x}" + by (rule finite_subset) +qed + +locale finite_deflation = deflation + + assumes finite_fixes: "finite {x. d\x = x}" +begin + +lemma finite_range: "finite (range (\x. d\x))" +by (simp add: range_eq_fixes finite_fixes) + +lemma finite_image: "finite ((\x. d\x) ` A)" +by (rule finite_subset [OF image_mono [OF subset_UNIV] finite_range]) + +lemma compact: "compact (d\x)" +proof (rule compactI2) + fix Y :: "nat \ 'a" + assume Y: "chain Y" + have "finite_chain (\i. d\(Y i))" + proof (rule finite_range_imp_finch) + show "chain (\i. d\(Y i))" + using Y by simp + have "range (\i. d\(Y i)) \ range (\x. d\x)" + by clarsimp + thus "finite (range (\i. d\(Y i)))" + using finite_range by (rule finite_subset) + qed + hence "\j. (\i. d\(Y i)) = d\(Y j)" + by (simp add: finite_chain_def maxinch_is_thelub Y) + then obtain j where j: "(\i. d\(Y i)) = d\(Y j)" .. + + assume "d\x \ (\i. Y i)" + hence "d\(d\x) \ d\(\i. Y i)" + by (rule monofun_cfun_arg) + hence "d\x \ (\i. d\(Y i))" + by (simp add: contlub_cfun_arg Y idem) + hence "d\x \ d\(Y j)" + using j by simp + hence "d\x \ Y j" + using less by (rule trans_less) + thus "\j. d\x \ Y j" .. +qed + +end + + +subsection {* Continuous embedding-projection pairs *} + +locale ep_pair = + fixes e :: "'a \ 'b" and p :: "'b \ 'a" + assumes e_inverse [simp]: "\x. p\(e\x) = x" + and e_p_less: "\y. e\(p\y) \ y" +begin + +lemma e_less_iff [simp]: "e\x \ e\y \ x \ y" +proof + assume "e\x \ e\y" + hence "p\(e\x) \ p\(e\y)" by (rule monofun_cfun_arg) + thus "x \ y" by simp +next + assume "x \ y" + thus "e\x \ e\y" by (rule monofun_cfun_arg) +qed + +lemma e_eq_iff [simp]: "e\x = e\y \ x = y" +unfolding po_eq_conv e_less_iff .. + +lemma p_eq_iff: + "\e\(p\x) = x; e\(p\y) = y\ \ p\x = p\y \ x = y" +by (safe, erule subst, erule subst, simp) + +lemma p_inverse: "(\x. y = e\x) = (e\(p\y) = y)" +by (auto, rule exI, erule sym) + +lemma e_less_iff_less_p: "e\x \ y \ x \ p\y" +proof + assume "e\x \ y" + then have "p\(e\x) \ p\y" by (rule monofun_cfun_arg) + then show "x \ p\y" by simp +next + assume "x \ p\y" + then have "e\x \ e\(p\y)" by (rule monofun_cfun_arg) + then show "e\x \ y" using e_p_less by (rule trans_less) +qed + +lemma compact_e_rev: "compact (e\x) \ compact x" +proof - + assume "compact (e\x)" + hence "adm (\y. \ e\x \ y)" by (rule compactD) + hence "adm (\y. \ e\x \ e\y)" by (rule adm_subst [OF cont_Rep_CFun2]) + hence "adm (\y. \ x \ y)" by simp + thus "compact x" by (rule compactI) +qed + +lemma compact_e: "compact x \ compact (e\x)" +proof - + assume "compact x" + hence "adm (\y. \ x \ y)" by (rule compactD) + hence "adm (\y. \ x \ p\y)" by (rule adm_subst [OF cont_Rep_CFun2]) + hence "adm (\y. \ e\x \ y)" by (simp add: e_less_iff_less_p) + thus "compact (e\x)" by (rule compactI) +qed + +lemma compact_e_iff: "compact (e\x) \ compact x" +by (rule iffI [OF compact_e_rev compact_e]) + +text {* Deflations from ep-pairs *} + +lemma deflation_e_p: "deflation (e oo p)" +by (simp add: deflation.intro e_p_less) + +lemma deflation_e_d_p: + includes deflation d + shows "deflation (e oo d oo p)" +proof + fix x :: 'b + show "(e oo d oo p)\((e oo d oo p)\x) = (e oo d oo p)\x" + by (simp add: idem) + show "(e oo d oo p)\x \ x" + by (simp add: e_less_iff_less_p less) +qed + +lemma finite_deflation_e_d_p: + includes finite_deflation d + shows "finite_deflation (e oo d oo p)" +proof + fix x :: 'b + show "(e oo d oo p)\((e oo d oo p)\x) = (e oo d oo p)\x" + by (simp add: idem) + show "(e oo d oo p)\x \ x" + by (simp add: e_less_iff_less_p less) + have "finite ((\x. e\x) ` (\x. d\x) ` range (\x. p\x))" + by (simp add: finite_image) + hence "finite (range (\x. (e oo d oo p)\x))" + by (simp add: image_image) + thus "finite {x. (e oo d oo p)\x = x}" + by (rule finite_range_imp_finite_fixes) +qed + +lemma deflation_p_d_e: + includes deflation d + assumes d: "\x. d\x \ e\(p\x)" + shows "deflation (p oo d oo e)" + apply (default, simp_all) + apply (rule antisym_less) + apply (rule monofun_cfun_arg) + apply (rule trans_less [OF d]) + apply (simp add: e_p_less) + apply (rule monofun_cfun_arg) + apply (rule rev_trans_less) + apply (rule monofun_cfun_arg) + apply (rule d) + apply (simp add: d.idem) + apply (rule sq_ord_less_eq_trans) + apply (rule monofun_cfun_arg) + apply (rule d.less) + apply (rule e_inverse) +done + +lemma finite_deflation_p_d_e: + includes finite_deflation d + assumes d: "\x. d\x \ e\(p\x)" + shows "finite_deflation (p oo d oo e)" + apply (rule finite_deflation.intro) + apply (rule deflation_p_d_e) + apply (rule `deflation d`) + apply (rule d) + apply (rule finite_deflation_axioms.intro) + apply (rule finite_range_imp_finite_fixes) + apply (simp add: range_composition [where f="\x. p\x"]) + apply (simp add: range_composition [where f="\x. d\x"]) + apply (simp add: d.finite_image) +done + +end + +subsection {* Uniqueness of ep-pairs *} + +lemma ep_pair_unique_e: + "\ep_pair e1 p; ep_pair e2 p\ \ e1 = e2" + apply (rule ext_cfun) + apply (rule antisym_less) + apply (subgoal_tac "e1\(p\(e2\x)) \ e2\x") + apply (simp add: ep_pair.e_inverse) + apply (erule ep_pair.e_p_less) + apply (subgoal_tac "e2\(p\(e1\x)) \ e1\x") + apply (simp add: ep_pair.e_inverse) + apply (erule ep_pair.e_p_less) +done + +lemma ep_pair_unique_p: + "\ep_pair e p1; ep_pair e p2\ \ p1 = p2" + apply (rule ext_cfun) + apply (rule antisym_less) + apply (subgoal_tac "p2\(e\(p1\x)) \ p2\x") + apply (simp add: ep_pair.e_inverse) + apply (rule monofun_cfun_arg) + apply (erule ep_pair.e_p_less) + apply (subgoal_tac "p1\(e\(p2\x)) \ p1\x") + apply (simp add: ep_pair.e_inverse) + apply (rule monofun_cfun_arg) + apply (erule ep_pair.e_p_less) +done + +subsection {* Composing ep-pairs *} + +lemma ep_pair_ID_ID: "ep_pair ID ID" +by default simp_all + +lemma ep_pair_comp: + "\ep_pair e1 p1; ep_pair e2 p2\ + \ ep_pair (e2 oo e1) (p1 oo p2)" + apply (rule ep_pair.intro) + apply (simp add: ep_pair.e_inverse) + apply (simp, rule trans_less) + apply (rule monofun_cfun_arg) + apply (erule ep_pair.e_p_less) + apply (erule ep_pair.e_p_less) +done + +locale (open) pcpo_ep_pair = ep_pair + + constrains e :: "'a::pcpo \ 'b::pcpo" + constrains p :: "'b::pcpo \ 'a::pcpo" +begin + +lemma e_strict [simp]: "e\\ = \" +proof - + have "\ \ p\\" by (rule minimal) + hence "e\\ \ e\(p\\)" by (rule monofun_cfun_arg) + also have "e\(p\\) \ \" by (rule e_p_less) + finally show "e\\ = \" by simp +qed + +lemma e_defined_iff [simp]: "e\x = \ \ x = \" +by (rule e_eq_iff [where y="\", unfolded e_strict]) + +lemma e_defined: "x \ \ \ e\x \ \" +by simp + +lemma p_strict [simp]: "p\\ = \" +by (rule e_inverse [where x="\", unfolded e_strict]) + +lemmas stricts = e_strict p_strict + +end + +end