988 by blast |
988 by blast |
989 |
989 |
990 lemma Times_Diff_distrib1: "(A - B) <*> C = (A <*> C) - (B <*> C)" |
990 lemma Times_Diff_distrib1: "(A - B) <*> C = (A <*> C) - (B <*> C)" |
991 by blast |
991 by blast |
992 |
992 |
|
993 lemma Times_empty[simp]: "A \<times> B = {} \<longleftrightarrow> A = {} \<or> B = {}" |
|
994 by auto |
|
995 |
|
996 lemma fst_image_times[simp]: "fst ` (A \<times> B) = (if B = {} then {} else A)" |
|
997 by (auto intro!: image_eqI) |
|
998 |
|
999 lemma snd_image_times[simp]: "snd ` (A \<times> B) = (if A = {} then {} else B)" |
|
1000 by (auto intro!: image_eqI) |
|
1001 |
993 lemma insert_times_insert[simp]: |
1002 lemma insert_times_insert[simp]: |
994 "insert a A \<times> insert b B = |
1003 "insert a A \<times> insert b B = |
995 insert (a,b) (A \<times> insert b B \<union> insert a A \<times> B)" |
1004 insert (a,b) (A \<times> insert b B \<union> insert a A \<times> B)" |
996 by blast |
1005 by blast |
997 |
1006 |
998 lemma vimage_Times: "f -` (A \<times> B) = ((fst \<circ> f) -` A) \<inter> ((snd \<circ> f) -` B)" |
1007 lemma vimage_Times: "f -` (A \<times> B) = ((fst \<circ> f) -` A) \<inter> ((snd \<circ> f) -` B)" |
999 by (auto, rule_tac p = "f x" in PairE, auto) |
1008 by (auto, rule_tac p = "f x" in PairE, auto) |
1000 |
1009 |
1001 lemma swap_inj_on: |
1010 lemma swap_inj_on: |
1002 "inj_on (%(i, j). (j, i)) (A \<times> B)" |
1011 "inj_on (\<lambda>(i, j). (j, i)) A" |
1003 by (unfold inj_on_def) fast |
1012 by (auto intro!: inj_onI) |
1004 |
1013 |
1005 lemma swap_product: |
1014 lemma swap_product: |
1006 "(%(i, j). (j, i)) ` (A \<times> B) = B \<times> A" |
1015 "(%(i, j). (j, i)) ` (A \<times> B) = B \<times> A" |
1007 by (simp add: split_def image_def) blast |
1016 by (simp add: split_def image_def) blast |
1008 |
1017 |
|
1018 lemma image_split_eq_Sigma: |
|
1019 "(\<lambda>x. (f x, g x)) ` A = Sigma (f ` A) (\<lambda>x. g ` (f -` {x} \<inter> A))" |
|
1020 proof (safe intro!: imageI vimageI) |
|
1021 fix a b assume *: "a \<in> A" "b \<in> A" and eq: "f a = f b" |
|
1022 show "(f b, g a) \<in> (\<lambda>x. (f x, g x)) ` A" |
|
1023 using * eq[symmetric] by auto |
|
1024 qed simp_all |
1009 |
1025 |
1010 subsubsection {* Code generator setup *} |
1026 subsubsection {* Code generator setup *} |
1011 |
1027 |
1012 lemma [code]: |
1028 lemma [code]: |
1013 "eq_class.eq (x1\<Colon>'a\<Colon>eq, y1\<Colon>'b\<Colon>eq) (x2, y2) \<longleftrightarrow> x1 = x2 \<and> y1 = y2" by (simp add: eq) |
1029 "eq_class.eq (x1\<Colon>'a\<Colon>eq, y1\<Colon>'b\<Colon>eq) (x2, y2) \<longleftrightarrow> x1 = x2 \<and> y1 = y2" by (simp add: eq) |