huffman@35652: (* Title: HOLCF/Domain_Aux.thy
huffman@35652: Author: Brian Huffman
huffman@35652: *)
huffman@35652:
huffman@35652: header {* Domain package support *}
huffman@35652:
huffman@35652: theory Domain_Aux
huffman@40502: imports Map_Functions Fixrec
huffman@35652: uses
huffman@35652: ("Tools/Domain/domain_take_proofs.ML")
huffman@35652: begin
huffman@35652:
huffman@35653: subsection {* Continuous isomorphisms *}
huffman@35653:
huffman@35653: text {* A locale for continuous isomorphisms *}
huffman@35653:
huffman@35653: locale iso =
huffman@35653: fixes abs :: "'a \ 'b"
huffman@35653: fixes rep :: "'b \ 'a"
huffman@35653: assumes abs_iso [simp]: "rep\(abs\x) = x"
huffman@35653: assumes rep_iso [simp]: "abs\(rep\y) = y"
huffman@35653: begin
huffman@35653:
huffman@35653: lemma swap: "iso rep abs"
huffman@35653: by (rule iso.intro [OF rep_iso abs_iso])
huffman@35653:
huffman@35653: lemma abs_below: "(abs\x \ abs\y) = (x \ y)"
huffman@35653: proof
huffman@35653: assume "abs\x \ abs\y"
huffman@35653: then have "rep\(abs\x) \ rep\(abs\y)" by (rule monofun_cfun_arg)
huffman@35653: then show "x \ y" by simp
huffman@35653: next
huffman@35653: assume "x \ y"
huffman@35653: then show "abs\x \ abs\y" by (rule monofun_cfun_arg)
huffman@35653: qed
huffman@35653:
huffman@35653: lemma rep_below: "(rep\x \ rep\y) = (x \ y)"
huffman@35653: by (rule iso.abs_below [OF swap])
huffman@35653:
huffman@35653: lemma abs_eq: "(abs\x = abs\y) = (x = y)"
huffman@35653: by (simp add: po_eq_conv abs_below)
huffman@35653:
huffman@35653: lemma rep_eq: "(rep\x = rep\y) = (x = y)"
huffman@35653: by (rule iso.abs_eq [OF swap])
huffman@35653:
huffman@35653: lemma abs_strict: "abs\\ = \"
huffman@35653: proof -
huffman@35653: have "\ \ rep\\" ..
huffman@35653: then have "abs\\ \ abs\(rep\\)" by (rule monofun_cfun_arg)
huffman@35653: then have "abs\\ \ \" by simp
huffman@35653: then show ?thesis by (rule UU_I)
huffman@35653: qed
huffman@35653:
huffman@35653: lemma rep_strict: "rep\\ = \"
huffman@35653: by (rule iso.abs_strict [OF swap])
huffman@35653:
huffman@35653: lemma abs_defin': "abs\x = \ \ x = \"
huffman@35653: proof -
huffman@35653: have "x = rep\(abs\x)" by simp
huffman@35653: also assume "abs\x = \"
huffman@35653: also note rep_strict
huffman@35653: finally show "x = \" .
huffman@35653: qed
huffman@35653:
huffman@35653: lemma rep_defin': "rep\z = \ \ z = \"
huffman@35653: by (rule iso.abs_defin' [OF swap])
huffman@35653:
huffman@35653: lemma abs_defined: "z \ \ \ abs\z \ \"
huffman@35653: by (erule contrapos_nn, erule abs_defin')
huffman@35653:
huffman@35653: lemma rep_defined: "z \ \ \ rep\z \ \"
huffman@35653: by (rule iso.abs_defined [OF iso.swap]) (rule iso_axioms)
huffman@35653:
huffman@40321: lemma abs_bottom_iff: "(abs\x = \) = (x = \)"
huffman@35653: by (auto elim: abs_defin' intro: abs_strict)
huffman@35653:
huffman@40321: lemma rep_bottom_iff: "(rep\x = \) = (x = \)"
huffman@40321: by (rule iso.abs_bottom_iff [OF iso.swap]) (rule iso_axioms)
huffman@35653:
huffman@35653: lemma casedist_rule: "rep\x = \ \ P \ x = \ \ P"
huffman@40321: by (simp add: rep_bottom_iff)
huffman@35653:
huffman@35653: lemma compact_abs_rev: "compact (abs\x) \ compact x"
huffman@35653: proof (unfold compact_def)
huffman@35653: assume "adm (\y. \ abs\x \ y)"
huffman@40327: with cont_Rep_cfun2
huffman@35653: have "adm (\y. \ abs\x \ abs\y)" by (rule adm_subst)
huffman@35653: then show "adm (\y. \ x \ y)" using abs_below by simp
huffman@35653: qed
huffman@35653:
huffman@35653: lemma compact_rep_rev: "compact (rep\x) \ compact x"
huffman@35653: by (rule iso.compact_abs_rev [OF iso.swap]) (rule iso_axioms)
huffman@35653:
huffman@35653: lemma compact_abs: "compact x \ compact (abs\x)"
huffman@35653: by (rule compact_rep_rev) simp
huffman@35653:
huffman@35653: lemma compact_rep: "compact x \ compact (rep\x)"
huffman@35653: by (rule iso.compact_abs [OF iso.swap]) (rule iso_axioms)
huffman@35653:
huffman@35653: lemma iso_swap: "(x = abs\y) = (rep\x = y)"
huffman@35653: proof
huffman@35653: assume "x = abs\y"
huffman@35653: then have "rep\x = rep\(abs\y)" by simp
huffman@35653: then show "rep\x = y" by simp
huffman@35653: next
huffman@35653: assume "rep\x = y"
huffman@35653: then have "abs\(rep\x) = abs\y" by simp
huffman@35653: then show "x = abs\y" by simp
huffman@35653: qed
huffman@35653:
huffman@35653: end
huffman@35653:
huffman@35653:
huffman@35652: subsection {* Proofs about take functions *}
huffman@35652:
huffman@35652: text {*
huffman@35652: This section contains lemmas that are used in a module that supports
huffman@35652: the domain isomorphism package; the module contains proofs related
huffman@35652: to take functions and the finiteness predicate.
huffman@35652: *}
huffman@35652:
huffman@35652: lemma deflation_abs_rep:
huffman@35652: fixes abs and rep and d
huffman@35652: assumes abs_iso: "\x. rep\(abs\x) = x"
huffman@35652: assumes rep_iso: "\y. abs\(rep\y) = y"
huffman@35652: shows "deflation d \ deflation (abs oo d oo rep)"
huffman@35652: by (rule ep_pair.deflation_e_d_p) (simp add: ep_pair.intro assms)
huffman@35652:
huffman@35652: lemma deflation_chain_min:
huffman@35652: assumes chain: "chain d"
huffman@35652: assumes defl: "\n. deflation (d n)"
huffman@35652: shows "d m\(d n\x) = d (min m n)\x"
huffman@35652: proof (rule linorder_le_cases)
huffman@35652: assume "m \ n"
huffman@35652: with chain have "d m \ d n" by (rule chain_mono)
huffman@35652: then have "d m\(d n\x) = d m\x"
huffman@35652: by (rule deflation_below_comp1 [OF defl defl])
huffman@35652: moreover from `m \ n` have "min m n = m" by simp
huffman@35652: ultimately show ?thesis by simp
huffman@35652: next
huffman@35652: assume "n \ m"
huffman@35652: with chain have "d n \ d m" by (rule chain_mono)
huffman@35652: then have "d m\(d n\x) = d n\x"
huffman@35652: by (rule deflation_below_comp2 [OF defl defl])
huffman@35652: moreover from `n \ m` have "min m n = n" by simp
huffman@35652: ultimately show ?thesis by simp
huffman@35652: qed
huffman@35652:
huffman@35653: lemma lub_ID_take_lemma:
huffman@35653: assumes "chain t" and "(\n. t n) = ID"
huffman@35653: assumes "\n. t n\x = t n\y" shows "x = y"
huffman@35653: proof -
huffman@35653: have "(\n. t n\x) = (\n. t n\y)"
huffman@35653: using assms(3) by simp
huffman@35653: then have "(\n. t n)\x = (\n. t n)\y"
huffman@35653: using assms(1) by (simp add: lub_distribs)
huffman@35653: then show "x = y"
huffman@35653: using assms(2) by simp
huffman@35653: qed
huffman@35653:
huffman@35653: lemma lub_ID_reach:
huffman@35653: assumes "chain t" and "(\n. t n) = ID"
huffman@35653: shows "(\n. t n\x) = x"
huffman@35653: using assms by (simp add: lub_distribs)
huffman@35653:
huffman@35655: lemma lub_ID_take_induct:
huffman@35655: assumes "chain t" and "(\n. t n) = ID"
huffman@35655: assumes "adm P" and "\n. P (t n\x)" shows "P x"
huffman@35655: proof -
huffman@35655: from `chain t` have "chain (\n. t n\x)" by simp
huffman@35655: from `adm P` this `\n. P (t n\x)` have "P (\n. t n\x)" by (rule admD)
huffman@35655: with `chain t` `(\n. t n) = ID` show "P x" by (simp add: lub_distribs)
huffman@35655: qed
huffman@35655:
huffman@35653:
huffman@35653: subsection {* Finiteness *}
huffman@35653:
huffman@35653: text {*
huffman@35653: Let a ``decisive'' function be a deflation that maps every input to
huffman@35653: either itself or bottom. Then if a domain's take functions are all
huffman@35653: decisive, then all values in the domain are finite.
huffman@35653: *}
huffman@35653:
huffman@35653: definition
huffman@35653: decisive :: "('a::pcpo \ 'a) \ bool"
huffman@35653: where
huffman@35653: "decisive d \ (\x. d\x = x \ d\x = \)"
huffman@35653:
huffman@35653: lemma decisiveI: "(\x. d\x = x \ d\x = \) \ decisive d"
huffman@35653: unfolding decisive_def by simp
huffman@35653:
huffman@35653: lemma decisive_cases:
huffman@35653: assumes "decisive d" obtains "d\x = x" | "d\x = \"
huffman@35653: using assms unfolding decisive_def by auto
huffman@35653:
huffman@35653: lemma decisive_bottom: "decisive \"
huffman@35653: unfolding decisive_def by simp
huffman@35653:
huffman@35653: lemma decisive_ID: "decisive ID"
huffman@35653: unfolding decisive_def by simp
huffman@35653:
huffman@35653: lemma decisive_ssum_map:
huffman@35653: assumes f: "decisive f"
huffman@35653: assumes g: "decisive g"
huffman@35653: shows "decisive (ssum_map\f\g)"
huffman@35653: apply (rule decisiveI, rename_tac s)
huffman@35653: apply (case_tac s, simp_all)
huffman@35653: apply (rule_tac x=x in decisive_cases [OF f], simp_all)
huffman@35653: apply (rule_tac x=y in decisive_cases [OF g], simp_all)
huffman@35653: done
huffman@35653:
huffman@35653: lemma decisive_sprod_map:
huffman@35653: assumes f: "decisive f"
huffman@35653: assumes g: "decisive g"
huffman@35653: shows "decisive (sprod_map\f\g)"
huffman@35653: apply (rule decisiveI, rename_tac s)
huffman@35653: apply (case_tac s, simp_all)
huffman@35653: apply (rule_tac x=x in decisive_cases [OF f], simp_all)
huffman@35653: apply (rule_tac x=y in decisive_cases [OF g], simp_all)
huffman@35653: done
huffman@35653:
huffman@35653: lemma decisive_abs_rep:
huffman@35653: fixes abs rep
huffman@35653: assumes iso: "iso abs rep"
huffman@35653: assumes d: "decisive d"
huffman@35653: shows "decisive (abs oo d oo rep)"
huffman@35653: apply (rule decisiveI)
huffman@35653: apply (rule_tac x="rep\x" in decisive_cases [OF d])
huffman@35653: apply (simp add: iso.rep_iso [OF iso])
huffman@35653: apply (simp add: iso.abs_strict [OF iso])
huffman@35653: done
huffman@35653:
huffman@35653: lemma lub_ID_finite:
huffman@35653: assumes chain: "chain d"
huffman@35653: assumes lub: "(\n. d n) = ID"
huffman@35653: assumes decisive: "\n. decisive (d n)"
huffman@35653: shows "\n. d n\x = x"
huffman@35653: proof -
huffman@35653: have 1: "chain (\n. d n\x)" using chain by simp
huffman@35653: have 2: "(\n. d n\x) = x" using chain lub by (rule lub_ID_reach)
huffman@35653: have "\n. d n\x = x \ d n\x = \"
huffman@35653: using decisive unfolding decisive_def by simp
huffman@35653: hence "range (\n. d n\x) \ {x, \}"
huffman@35653: by auto
huffman@35653: hence "finite (range (\n. d n\x))"
huffman@35653: by (rule finite_subset, simp)
huffman@35653: with 1 have "finite_chain (\n. d n\x)"
huffman@35653: by (rule finite_range_imp_finch)
huffman@35653: then have "\n. (\n. d n\x) = d n\x"
huffman@35653: unfolding finite_chain_def by (auto simp add: maxinch_is_thelub)
huffman@35653: with 2 show "\n. d n\x = x" by (auto elim: sym)
huffman@35653: qed
huffman@35653:
huffman@35655: lemma lub_ID_finite_take_induct:
huffman@35655: assumes "chain d" and "(\n. d n) = ID" and "\n. decisive (d n)"
huffman@35655: shows "(\n. P (d n\x)) \ P x"
huffman@35655: using lub_ID_finite [OF assms] by metis
huffman@35655:
huffman@35653: subsection {* ML setup *}
huffman@35653:
huffman@35652: use "Tools/Domain/domain_take_proofs.ML"
huffman@35652:
huffman@40216: setup Domain_Take_Proofs.setup
huffman@40216:
huffman@35652: end