# HG changeset patch # User haftmann # Date 1441570491 -7200 # Node ID 76cd7f1ec257710b3ae0a3be26740dab380a09e4 # Parent e6b1236f9b3daae4e770411ee6a22c7888ec46b2 tuned notation, proofs, namespace diff -r e6b1236f9b3d -r 76cd7f1ec257 src/HOL/Product_Type.thy --- a/src/HOL/Product_Type.thy Sun Sep 06 22:14:51 2015 +0200 +++ b/src/HOL/Product_Type.thy Sun Sep 06 22:14:51 2015 +0200 @@ -363,23 +363,23 @@ lemma prod_eqI [intro?]: "fst p = fst q \ snd p = snd q \ p = q" by (simp add: prod_eq_iff) -lemma split_conv [simp, code]: "uncurry f (a, b) = f a b" +lemma split_conv [simp, code]: "(case (a, b) of (c, d) \ f c d) = f a b" by (fact prod.case) -lemma splitI: "f a b \ uncurry f (a, b)" +lemma splitI: "f a b \ case (a, b) of (c, d) \ f c d" by (rule split_conv [THEN iffD2]) -lemma splitD: "uncurry f (a, b) \ f a b" +lemma splitD: "(case (a, b) of (c, d) \ f c d) \ f a b" by (rule split_conv [THEN iffD1]) -lemma split_Pair [simp]: "(\(x, y). (x, y)) = id" +lemma split_Pair [simp]: "uncurry Pair = id" by (simp add: fun_eq_iff split: prod.split) lemma split_eta: "(\(x, y). f (x, y)) = f" -- \Subsumes the old @{text split_Pair} when @{term f} is the identity function.\ by (simp add: fun_eq_iff split: prod.split) -lemma split_comp: "uncurry (f \ g) x = f (g (fst x)) (snd x)" +lemma split_comp: "(case x of (a, b) \ (f \ g) a b) = f (g (fst x)) (snd x)" by (cases x) simp lemma split_twice: "uncurry f (uncurry g p) = uncurry (\x y. uncurry f (g x y)) p" @@ -535,24 +535,24 @@ \medskip These rules are for use with @{text blast}; could instead call @{text simp} using @{thm [source] prod.split} as rewrite.\ -lemma splitI2: "!!p. [| !!a b. p = (a, b) ==> c a b |] ==> uncurry c p" +lemma splitI2: "!!p. [| !!a b. p = (a, b) ==> c a b |] ==> case p of (a, b) \ c a b" apply (simp only: split_tupled_all) apply (simp (no_asm_simp)) done -lemma splitI2': "!!p. [| !!a b. (a, b) = p ==> c a b x |] ==> uncurry c p x" +lemma splitI2': "!!p. [| !!a b. (a, b) = p ==> c a b x |] ==> (case p of (a, b) \ c a b) x" apply (simp only: split_tupled_all) apply (simp (no_asm_simp)) done -lemma splitE: "uncurry c p ==> (!!x y. p = (x, y) ==> c x y ==> Q) ==> Q" +lemma splitE: "(case p of (a, b) \ c a b) ==> (!!x y. p = (x, y) ==> c x y ==> Q) ==> Q" by (induct p) auto -lemma splitE': "uncurry c p z ==> (!!x y. p = (x, y) ==> c x y z ==> Q) ==> Q" +lemma splitE': "(case p of (a, b) \ c a b) z ==> (!!x y. p = (x, y) ==> c x y z ==> Q) ==> Q" by (induct p) auto lemma splitE2: - "[| Q (uncurry P z); !!x y. [|z = (x, y); Q (P x y)|] ==> R |] ==> R" + "[| Q (case z of (a, b) \ P a b); !!x y. [|z = (x, y); Q (P x y)|] ==> R |] ==> R" proof - assume q: "Q (uncurry P z)" assume r: "!!x y. [|z = (x, y); Q (P x y)|] ==> R" @@ -562,14 +562,17 @@ done qed -lemma splitD': "uncurry R (a,b) c ==> R a b c" +lemma splitD': + "(case (a, b) of (c, d) \ R c d) c \ R a b c" by simp -lemma mem_splitI: "z: c a b ==> z: uncurry c (a, b)" +lemma mem_splitI: + "z \ c a b \ z \ (case (a, b) of (d, e) \ c d e)" by simp -lemma mem_splitI2: "!!p. [| !!a b. p = (a, b) ==> z: c a b |] ==> z: uncurry c p" -by (simp only: split_tupled_all, simp) +lemma mem_splitI2: + "\p. (\a b. p = (a, b) \ z \ c a b) \ z \ (case p of (a, b) \ c a b)" + by (simp only: split_tupled_all) simp lemma mem_splitE: assumes "z \ uncurry c p" @@ -1044,44 +1047,52 @@ by (blast elim: equalityE) lemma SetCompr_Sigma_eq: - "Collect (uncurry (%x y. P x & Q x y)) = (SIGMA x:Collect P. Collect (Q x))" + "{(x, y). P x \ Q x y} = (SIGMA x:Collect P. Collect (Q x))" by blast -lemma Collect_split [simp]: "{(a,b). P a & Q b} = Collect P <*> Collect Q" +lemma Collect_split [simp]: + "{(a, b). P a \ Q b} = Collect P \ Collect Q " by (fact SetCompr_Sigma_eq) lemma UN_Times_distrib: - "(UN (a,b):(A <*> B). E a <*> F b) = (UNION A E) <*> (UNION B F)" + "(\(a, b)\A \ B. E a \ F b) = UNION A E \ UNION B F" -- \Suggested by Pierre Chartier\ by blast lemma split_paired_Ball_Sigma [simp, no_atp]: - "(ALL z: Sigma A B. P z) = (ALL x:A. ALL y: B x. P(x,y))" + "(\z\Sigma A B. P z) \ (\x\A. \y\B x. P (x, y))" by blast lemma split_paired_Bex_Sigma [simp, no_atp]: - "(EX z: Sigma A B. P z) = (EX x:A. EX y: B x. P(x,y))" + "(\z\Sigma A B. P z) \ (\x\A. \y\B x. P (x, y))" + by blast + +lemma Sigma_Un_distrib1: + "Sigma (I \ J) C = Sigma I C \ Sigma J C" by blast -lemma Sigma_Un_distrib1: "(SIGMA i:I Un J. C(i)) = (SIGMA i:I. C(i)) Un (SIGMA j:J. C(j))" +lemma Sigma_Un_distrib2: + "(SIGMA i:I. A i \ B i) = Sigma I A \ Sigma I B" by blast -lemma Sigma_Un_distrib2: "(SIGMA i:I. A(i) Un B(i)) = (SIGMA i:I. A(i)) Un (SIGMA i:I. B(i))" +lemma Sigma_Int_distrib1: + "Sigma (I \ J) C = Sigma I C \ Sigma J C" by blast -lemma Sigma_Int_distrib1: "(SIGMA i:I Int J. C(i)) = (SIGMA i:I. C(i)) Int (SIGMA j:J. C(j))" - by blast - -lemma Sigma_Int_distrib2: "(SIGMA i:I. A(i) Int B(i)) = (SIGMA i:I. A(i)) Int (SIGMA i:I. B(i))" +lemma Sigma_Int_distrib2: + "(SIGMA i:I. A i \ B i) = Sigma I A \ Sigma I B" by blast -lemma Sigma_Diff_distrib1: "(SIGMA i:I - J. C(i)) = (SIGMA i:I. C(i)) - (SIGMA j:J. C(j))" +lemma Sigma_Diff_distrib1: + "Sigma (I - J) C = Sigma I C - Sigma J C" by blast -lemma Sigma_Diff_distrib2: "(SIGMA i:I. A(i) - B(i)) = (SIGMA i:I. A(i)) - (SIGMA i:I. B(i))" +lemma Sigma_Diff_distrib2: + "(SIGMA i:I. A i - B i) = Sigma I A - Sigma I B" by blast -lemma Sigma_Union: "Sigma (Union X) B = (UN A:X. Sigma A B)" +lemma Sigma_Union: + "Sigma (\X) B = (\A\X. Sigma A B)" by blast text \ @@ -1089,25 +1100,32 @@ matching, especially when the rules are re-oriented. \ -lemma Times_Un_distrib1: "(A Un B) <*> C = (A <*> C) Un (B <*> C)" +lemma Times_Un_distrib1: + "(A \ B) \ C = A \ C \ B \ C " by (fact Sigma_Un_distrib1) -lemma Times_Int_distrib1: "(A Int B) <*> C = (A <*> C) Int (B <*> C)" +lemma Times_Int_distrib1: + "(A \ B) \ C = A \ C \ B \ C " by (fact Sigma_Int_distrib1) -lemma Times_Diff_distrib1: "(A - B) <*> C = (A <*> C) - (B <*> C)" +lemma Times_Diff_distrib1: + "(A - B) \ C = A \ C - B \ C " by (fact Sigma_Diff_distrib1) -lemma Times_empty[simp]: "A \ B = {} \ A = {} \ B = {}" +lemma Times_empty [simp]: + "A \ B = {} \ A = {} \ B = {}" by auto -lemma times_eq_iff: "A \ B = C \ D \ A = C \ B = D \ ((A = {} \ B = {}) \ (C = {} \ D = {}))" +lemma times_eq_iff: + "A \ B = C \ D \ A = C \ B = D \ (A = {} \ B = {}) \ (C = {} \ D = {})" by auto -lemma fst_image_times[simp]: "fst ` (A \ B) = (if B = {} then {} else A)" +lemma fst_image_times [simp]: + "fst ` (A \ B) = (if B = {} then {} else A)" by force -lemma snd_image_times[simp]: "snd ` (A \ B) = (if A = {} then {} else B)" +lemma snd_image_times [simp]: + "snd ` (A \ B) = (if A = {} then {} else B)" by force lemma vimage_fst: @@ -1121,15 +1139,18 @@ lemma insert_times_insert[simp]: "insert a A \ insert b B = insert (a,b) (A \ insert b B \ insert a A \ B)" -by blast + by blast -lemma vimage_Times: "f -` (A \ B) = ((fst \ f) -` A) \ ((snd \ f) -` B)" - apply auto - apply (case_tac "f x") - apply auto - done +lemma vimage_Times: + "f -` (A \ B) = (fst \ f) -` A \ (snd \ f) -` B" +proof (rule set_eqI) + fix x + show "x \ f -` (A \ B) \ x \ (fst \ f) -` A \ (snd \ f) -` B" + by (cases "f x") (auto split: prod.split) +qed -lemma times_Int_times: "A \ B \ C \ D = (A \ C) \ (B \ D)" +lemma times_Int_times: + "A \ B \ C \ D = (A \ C) \ (B \ D)" by auto lemma product_swap: @@ -1160,15 +1181,18 @@ lemma inj_apsnd [simp]: "inj (apsnd f) \ inj f" using inj_on_apsnd[of f UNIV] by simp -definition product :: "'a set \ 'b set \ ('a \ 'b) set" where +context +begin + +qualified definition product :: "'a set \ 'b set \ ('a \ 'b) set" where [code_abbrev]: "product A B = A \ B" -hide_const (open) product - lemma member_product: "x \ Product_Type.product A B \ x \ A \ B" - by (simp add: product_def) + by (simp add: Product_Type.product_def) +end + text \The following @{const map_prod} lemmas are due to Joachim Breitner:\ lemma map_prod_inj_on: