equal
deleted
inserted
replaced
445 |
445 |
446 lemma bind_map_pmf: "bind_pmf (map_pmf f M) g = bind_pmf M (\<lambda>x. g (f x))" |
446 lemma bind_map_pmf: "bind_pmf (map_pmf f M) g = bind_pmf M (\<lambda>x. g (f x))" |
447 by (simp add: map_pmf_def bind_assoc_pmf bind_return_pmf) |
447 by (simp add: map_pmf_def bind_assoc_pmf bind_return_pmf) |
448 |
448 |
449 lemma map_pmf_transfer[transfer_rule]: |
449 lemma map_pmf_transfer[transfer_rule]: |
450 "rel_fun op = (rel_fun cr_pmf cr_pmf) (\<lambda>f M. distr M (count_space UNIV) f) map_pmf" |
450 "rel_fun (=) (rel_fun cr_pmf cr_pmf) (\<lambda>f M. distr M (count_space UNIV) f) map_pmf" |
451 proof - |
451 proof - |
452 have "rel_fun op = (rel_fun pmf_as_measure.cr_pmf pmf_as_measure.cr_pmf) |
452 have "rel_fun (=) (rel_fun pmf_as_measure.cr_pmf pmf_as_measure.cr_pmf) |
453 (\<lambda>f M. M \<bind> (return (count_space UNIV) o f)) map_pmf" |
453 (\<lambda>f M. M \<bind> (return (count_space UNIV) o f)) map_pmf" |
454 unfolding map_pmf_def[abs_def] comp_def by transfer_prover |
454 unfolding map_pmf_def[abs_def] comp_def by transfer_prover |
455 then show ?thesis |
455 then show ?thesis |
456 by (force simp: rel_fun_def cr_pmf_def bind_return_distr) |
456 by (force simp: rel_fun_def cr_pmf_def bind_return_distr) |
457 qed |
457 qed |
474 using map_pmf_compose[of f g] by (simp add: comp_def) |
474 using map_pmf_compose[of f g] by (simp add: comp_def) |
475 |
475 |
476 lemma map_pmf_cong: "p = q \<Longrightarrow> (\<And>x. x \<in> set_pmf q \<Longrightarrow> f x = g x) \<Longrightarrow> map_pmf f p = map_pmf g q" |
476 lemma map_pmf_cong: "p = q \<Longrightarrow> (\<And>x. x \<in> set_pmf q \<Longrightarrow> f x = g x) \<Longrightarrow> map_pmf f p = map_pmf g q" |
477 unfolding map_pmf_def by (rule bind_pmf_cong) auto |
477 unfolding map_pmf_def by (rule bind_pmf_cong) auto |
478 |
478 |
479 lemma pmf_set_map: "set_pmf \<circ> map_pmf f = op ` f \<circ> set_pmf" |
479 lemma pmf_set_map: "set_pmf \<circ> map_pmf f = (`) f \<circ> set_pmf" |
480 by (auto simp add: comp_def fun_eq_iff map_pmf_def) |
480 by (auto simp add: comp_def fun_eq_iff map_pmf_def) |
481 |
481 |
482 lemma set_map_pmf[simp]: "set_pmf (map_pmf f M) = f`set_pmf M" |
482 lemma set_map_pmf[simp]: "set_pmf (map_pmf f M) = f`set_pmf M" |
483 using pmf_set_map[of f] by (auto simp: comp_def fun_eq_iff) |
483 using pmf_set_map[of f] by (auto simp: comp_def fun_eq_iff) |
484 |
484 |
1324 show "map_pmf id = id" by (rule map_pmf_id) |
1324 show "map_pmf id = id" by (rule map_pmf_id) |
1325 show "\<And>f g. map_pmf (f \<circ> g) = map_pmf f \<circ> map_pmf g" by (rule map_pmf_compose) |
1325 show "\<And>f g. map_pmf (f \<circ> g) = map_pmf f \<circ> map_pmf g" by (rule map_pmf_compose) |
1326 show "\<And>f g::'a \<Rightarrow> 'b. \<And>p. (\<And>x. x \<in> set_pmf p \<Longrightarrow> f x = g x) \<Longrightarrow> map_pmf f p = map_pmf g p" |
1326 show "\<And>f g::'a \<Rightarrow> 'b. \<And>p. (\<And>x. x \<in> set_pmf p \<Longrightarrow> f x = g x) \<Longrightarrow> map_pmf f p = map_pmf g p" |
1327 by (intro map_pmf_cong refl) |
1327 by (intro map_pmf_cong refl) |
1328 |
1328 |
1329 show "\<And>f::'a \<Rightarrow> 'b. set_pmf \<circ> map_pmf f = op ` f \<circ> set_pmf" |
1329 show "\<And>f::'a \<Rightarrow> 'b. set_pmf \<circ> map_pmf f = (`) f \<circ> set_pmf" |
1330 by (rule pmf_set_map) |
1330 by (rule pmf_set_map) |
1331 |
1331 |
1332 show "(card_of (set_pmf p), natLeq) \<in> ordLeq" for p :: "'s pmf" |
1332 show "(card_of (set_pmf p), natLeq) \<in> ordLeq" for p :: "'s pmf" |
1333 proof - |
1333 proof - |
1334 have "(card_of (set_pmf p), card_of (UNIV :: nat set)) \<in> ordLeq" |
1334 have "(card_of (set_pmf p), card_of (UNIV :: nat set)) \<in> ordLeq" |
1628 assumes 2: "rel_pmf R q p" |
1628 assumes 2: "rel_pmf R q p" |
1629 and refl: "reflp R" and trans: "transp R" and antisym: "antisymp R" |
1629 and refl: "reflp R" and trans: "transp R" and antisym: "antisymp R" |
1630 shows "p = q" |
1630 shows "p = q" |
1631 proof - |
1631 proof - |
1632 from 1 2 refl trans have "rel_pmf (inf R R\<inverse>\<inverse>) p q" by(rule rel_pmf_inf) |
1632 from 1 2 refl trans have "rel_pmf (inf R R\<inverse>\<inverse>) p q" by(rule rel_pmf_inf) |
1633 also have "inf R R\<inverse>\<inverse> = op =" |
1633 also have "inf R R\<inverse>\<inverse> = (=)" |
1634 using refl antisym by (auto intro!: ext simp add: reflpD dest: antisympD) |
1634 using refl antisym by (auto intro!: ext simp add: reflpD dest: antisympD) |
1635 finally show ?thesis unfolding pmf.rel_eq . |
1635 finally show ?thesis unfolding pmf.rel_eq . |
1636 qed |
1636 qed |
1637 |
1637 |
1638 lemma reflp_rel_pmf: "reflp R \<Longrightarrow> reflp (rel_pmf R)" |
1638 lemma reflp_rel_pmf: "reflp R \<Longrightarrow> reflp (rel_pmf R)" |