# HG changeset patch # User Andreas Lochbihler # Date 1532074199 -7200 # Node ID 96aae7c44bb2159ae0748039dc60f1531f6a71fe # Parent 4bee4828cfc318ad7c25487baa608e6bbe24e173 add lemmas about prod_filter diff -r 4bee4828cfc3 -r 96aae7c44bb2 src/HOL/Filter.thy --- a/src/HOL/Filter.thy Fri Jul 20 09:05:34 2018 +0200 +++ b/src/HOL/Filter.thy Fri Jul 20 10:09:59 2018 +0200 @@ -1104,6 +1104,34 @@ lemma prod_filter_INF2: "J \ {} \ A \\<^sub>F (\i\J. B i) = (\i\J. A \\<^sub>F B i)" using prod_filter_INF[of "{A}" J "\x. x" B] by simp +lemma prod_filtermap1: "prod_filter (filtermap f F) G = filtermap (apfst f) (prod_filter F G)" + apply(clarsimp simp add: filter_eq_iff eventually_filtermap eventually_prod_filter; safe) + subgoal by auto + subgoal for P Q R by(rule exI[where x="\y. \x. y = f x \ Q x"])(auto intro: eventually_mono) + done + +lemma prod_filtermap2: "prod_filter F (filtermap g G) = filtermap (apsnd g) (prod_filter F G)" + apply(clarsimp simp add: filter_eq_iff eventually_filtermap eventually_prod_filter; safe) + subgoal by auto + subgoal for P Q R by(auto intro: exI[where x="\y. \x. y = g x \ R x"] eventually_mono) + done + +lemma prod_filter_assoc: + "prod_filter (prod_filter F G) H = filtermap (\(x, y, z). ((x, y), z)) (prod_filter F (prod_filter G H))" + apply(clarsimp simp add: filter_eq_iff eventually_filtermap eventually_prod_filter; safe) + subgoal for P Q R S T by(auto 4 4 intro: exI[where x="\(a, b). T a \ S b"]) + subgoal for P Q R S T by(auto 4 3 intro: exI[where x="\(a, b). Q a \ S b"]) + done + +lemma prod_filter_principal_singleton: "prod_filter (principal {x}) F = filtermap (Pair x) F" + by(fastforce simp add: filter_eq_iff eventually_prod_filter eventually_principal eventually_filtermap elim: eventually_mono intro: exI[where x="\a. a = x"]) + +lemma prod_filter_principal_singleton2: "prod_filter F (principal {x}) = filtermap (\a. (a, x)) F" + by(fastforce simp add: filter_eq_iff eventually_prod_filter eventually_principal eventually_filtermap elim: eventually_mono intro: exI[where x="\a. a = x"]) + +lemma prod_filter_commute: "prod_filter F G = filtermap prod.swap (prod_filter G F)" + by(auto simp add: filter_eq_iff eventually_prod_filter eventually_filtermap) + subsection \Limits\ definition filterlim :: "('a \ 'b) \ 'b filter \ 'a filter \ bool" where @@ -1699,6 +1727,50 @@ end +lemma prod_filter_parametric [transfer_rule]: includes lifting_syntax shows + "(rel_filter R ===> rel_filter S ===> rel_filter (rel_prod R S)) prod_filter prod_filter" +proof(intro rel_funI; elim rel_filter.cases; hypsubst) + fix F G + assume F: "\\<^sub>F (x, y) in F. R x y" and G: "\\<^sub>F (x, y) in G. S x y" + show "rel_filter (rel_prod R S) + (map_filter_on {(x, y). R x y} fst F \\<^sub>F map_filter_on {(x, y). S x y} fst G) + (map_filter_on {(x, y). R x y} snd F \\<^sub>F map_filter_on {(x, y). S x y} snd G)" + (is "rel_filter ?RS ?F ?G") + proof + let ?Z = "filtermap (\((a, b), (a', b')). ((a, a'), (b, b'))) (prod_filter F G)" + show *: "\\<^sub>F (x, y) in ?Z. rel_prod R S x y" using F G + by(auto simp add: eventually_filtermap split_beta eventually_prod_filter) + show "map_filter_on {(x, y). ?RS x y} fst ?Z = ?F" + using F G + apply(clarsimp simp add: filter_eq_iff eventually_map_filter_on *) + apply(simp add: eventually_filtermap split_beta eventually_prod_filter) + apply(subst eventually_map_filter_on; simp)+ + apply(rule iffI; clarsimp) + subgoal for P P' P'' + apply(rule exI[where x="\a. \b. P' (a, b) \ R a b"]; rule conjI) + subgoal by(fastforce elim: eventually_rev_mp eventually_mono) + subgoal + by(rule exI[where x="\a. \b. P'' (a, b) \ S a b"])(fastforce elim: eventually_rev_mp eventually_mono) + done + subgoal by fastforce + done + show "map_filter_on {(x, y). ?RS x y} snd ?Z = ?G" + using F G + apply(clarsimp simp add: filter_eq_iff eventually_map_filter_on *) + apply(simp add: eventually_filtermap split_beta eventually_prod_filter) + apply(subst eventually_map_filter_on; simp)+ + apply(rule iffI; clarsimp) + subgoal for P P' P'' + apply(rule exI[where x="\b. \a. P' (a, b) \ R a b"]; rule conjI) + subgoal by(fastforce elim: eventually_rev_mp eventually_mono) + subgoal + by(rule exI[where x="\b. \a. P'' (a, b) \ S a b"])(fastforce elim: eventually_rev_mp eventually_mono) + done + subgoal by fastforce + done + qed +qed + text \Code generation for filters\ definition abstract_filter :: "(unit \ 'a filter) \ 'a filter"