185 |
185 |
186 defs (overloaded) |
186 defs (overloaded) |
187 subset_def: "A <= B == ALL x:A. x:B" |
187 subset_def: "A <= B == ALL x:A. x:B" |
188 psubset_def: "A < B == (A::'a set) <= B & ~ A=B" |
188 psubset_def: "A < B == (A::'a set) <= B & ~ A=B" |
189 Compl_def: "- A == {x. ~x:A}" |
189 Compl_def: "- A == {x. ~x:A}" |
|
190 set_diff_def: "A - B == {x. x:A & ~x:B}" |
190 |
191 |
191 defs |
192 defs |
192 Un_def: "A Un B == {x. x:A | x:B}" |
193 Un_def: "A Un B == {x. x:A | x:B}" |
193 Int_def: "A Int B == {x. x:A & x:B}" |
194 Int_def: "A Int B == {x. x:A & x:B}" |
194 set_diff_def: "A - B == {x. x:A & ~x:B}" |
|
195 INTER_def: "INTER A B == {y. ALL x:A. y: B(x)}" |
195 INTER_def: "INTER A B == {y. ALL x:A. y: B(x)}" |
196 UNION_def: "UNION A B == {y. EX x:A. y: B(x)}" |
196 UNION_def: "UNION A B == {y. EX x:A. y: B(x)}" |
197 Inter_def: "Inter S == (INT x:S. x)" |
197 Inter_def: "Inter S == (INT x:S. x)" |
198 Union_def: "Union S == (UN x:S. x)" |
198 Union_def: "Union S == (UN x:S. x)" |
199 Pow_def: "Pow A == {B. B <= A}" |
199 Pow_def: "Pow A == {B. B <= A}" |
205 |
205 |
206 subsection {* Lemmas and proof tool setup *} |
206 subsection {* Lemmas and proof tool setup *} |
207 |
207 |
208 subsubsection {* Relating predicates and sets *} |
208 subsubsection {* Relating predicates and sets *} |
209 |
209 |
210 lemma CollectI [intro!]: "P(a) ==> a : {x. P(x)}" |
210 lemma CollectI: "P(a) ==> a : {x. P(x)}" |
211 by simp |
211 by simp |
212 |
212 |
213 lemma CollectD: "a : {x. P(x)} ==> P(a)" |
213 lemma CollectD: "a : {x. P(x)} ==> P(a)" |
214 by simp |
214 by simp |
215 |
215 |
216 lemma set_ext: "(!!x. (x:A) = (x:B)) ==> A = B" |
216 lemma set_ext: (assumes prem: "(!!x. (x:A) = (x:B))") "A = B" |
217 proof - |
217 apply (rule prem [THEN ext, THEN arg_cong, THEN box_equals]) |
218 case rule_context |
218 apply (rule Collect_mem_eq) |
219 show ?thesis |
219 apply (rule Collect_mem_eq) |
220 apply (rule prems [THEN ext, THEN arg_cong, THEN box_equals]) |
220 done |
221 apply (rule Collect_mem_eq) |
|
222 apply (rule Collect_mem_eq) |
|
223 done |
|
224 qed |
|
225 |
221 |
226 lemma Collect_cong: "(!!x. P x = Q x) ==> {x. P(x)} = {x. Q(x)}" |
222 lemma Collect_cong: "(!!x. P x = Q x) ==> {x. P(x)} = {x. Q(x)}" |
227 by simp |
223 by simp |
228 |
224 |
229 lemmas CollectE [elim!] = CollectD [elim_format] |
225 lemmas CollectE = CollectD [elim_format] |
230 |
226 |
231 |
227 |
232 subsubsection {* Bounded quantifiers *} |
228 subsubsection {* Bounded quantifiers *} |
233 |
229 |
234 lemma ballI [intro!]: "(!!x. x:A ==> P x) ==> ALL x:A. P x" |
230 lemma ballI [intro!]: "(!!x. x:A ==> P x) ==> ALL x:A. P x" |
901 apply (erule_tac P = "%x. x : S" in LeastI2) |
897 apply (erule_tac P = "%x. x : S" in LeastI2) |
902 apply fast |
898 apply fast |
903 apply (rule LeastI2) |
899 apply (rule LeastI2) |
904 apply (auto elim: monoD intro!: order_antisym) |
900 apply (auto elim: monoD intro!: order_antisym) |
905 done |
901 done |
|
902 |
|
903 |
|
904 subsection {* Inverse image of a function *} |
|
905 |
|
906 constdefs |
|
907 vimage :: "('a => 'b) => 'b set => 'a set" (infixr "-`" 90) |
|
908 "f -` B == {x. f x : B}" |
|
909 |
|
910 |
|
911 subsubsection {* Basic rules *} |
|
912 |
|
913 lemma vimage_eq [simp]: "(a : f -` B) = (f a : B)" |
|
914 by (unfold vimage_def) blast |
|
915 |
|
916 lemma vimage_singleton_eq: "(a : f -` {b}) = (f a = b)" |
|
917 by simp |
|
918 |
|
919 lemma vimageI [intro]: "f a = b ==> b:B ==> a : f -` B" |
|
920 by (unfold vimage_def) blast |
|
921 |
|
922 lemma vimageI2: "f a : A ==> a : f -` A" |
|
923 by (unfold vimage_def) fast |
|
924 |
|
925 lemma vimageE [elim!]: "a: f -` B ==> (!!x. f a = x ==> x:B ==> P) ==> P" |
|
926 by (unfold vimage_def) blast |
|
927 |
|
928 lemma vimageD: "a : f -` A ==> f a : A" |
|
929 by (unfold vimage_def) fast |
|
930 |
|
931 |
|
932 subsubsection {* Equations *} |
|
933 |
|
934 lemma vimage_empty [simp]: "f -` {} = {}" |
|
935 by blast |
|
936 |
|
937 lemma vimage_Compl: "f -` (-A) = -(f -` A)" |
|
938 by blast |
|
939 |
|
940 lemma vimage_Un [simp]: "f -` (A Un B) = (f -` A) Un (f -` B)" |
|
941 by blast |
|
942 |
|
943 lemma vimage_Int [simp]: "f -` (A Int B) = (f -` A) Int (f -` B)" |
|
944 by fast |
|
945 |
|
946 lemma vimage_Union: "f -` (Union A) = (UN X:A. f -` X)" |
|
947 by blast |
|
948 |
|
949 lemma vimage_UN: "f-`(UN x:A. B x) = (UN x:A. f -` B x)" |
|
950 by blast |
|
951 |
|
952 lemma vimage_INT: "f-`(INT x:A. B x) = (INT x:A. f -` B x)" |
|
953 by blast |
|
954 |
|
955 lemma vimage_Collect_eq [simp]: "f -` Collect P = {y. P (f y)}" |
|
956 by blast |
|
957 |
|
958 lemma vimage_Collect: "(!!x. P (f x) = Q x) ==> f -` (Collect P) = Collect Q" |
|
959 by blast |
|
960 |
|
961 lemma vimage_insert: "f-`(insert a B) = (f-`{a}) Un (f-`B)" |
|
962 -- {* NOT suitable for rewriting because of the recurrence of @{term "{a}"}. *} |
|
963 by blast |
|
964 |
|
965 lemma vimage_Diff: "f -` (A - B) = (f -` A) - (f -` B)" |
|
966 by blast |
|
967 |
|
968 lemma vimage_UNIV [simp]: "f -` UNIV = UNIV" |
|
969 by blast |
|
970 |
|
971 lemma vimage_eq_UN: "f-`B = (UN y: B. f-`{y})" |
|
972 -- {* NOT suitable for rewriting *} |
|
973 by blast |
|
974 |
|
975 lemma vimage_mono: "A <= B ==> f -` A <= f -` B" |
|
976 -- {* monotonicity *} |
|
977 by blast |
906 |
978 |
907 |
979 |
908 subsection {* Transitivity rules for calculational reasoning *} |
980 subsection {* Transitivity rules for calculational reasoning *} |
909 |
981 |
910 lemma forw_subst: "a = b ==> P b ==> P a" |
982 lemma forw_subst: "a = b ==> P b ==> P a" |