src/HOL/Set.thy
changeset 14208 144f45277d5a
parent 14098 54f130df1136
child 14302 6c24235e8d5d
equal deleted inserted replaced
14207:f20fbb141673 14208:144f45277d5a
   777   by blast
   777   by blast
   778 
   778 
   779 lemma subset_image_iff: "(B \<subseteq> f`A) = (EX AA. AA \<subseteq> A & B = f`AA)"
   779 lemma subset_image_iff: "(B \<subseteq> f`A) = (EX AA. AA \<subseteq> A & B = f`AA)"
   780   apply safe
   780   apply safe
   781    prefer 2 apply fast
   781    prefer 2 apply fast
   782   apply (rule_tac x = "{a. a : A & f a : B}" in exI)
   782   apply (rule_tac x = "{a. a : A & f a : B}" in exI, fast)
   783   apply fast
       
   784   done
   783   done
   785 
   784 
   786 lemma image_subsetI: "(!!x. x \<in> A ==> f x \<in> B) ==> f`A \<subseteq> B"
   785 lemma image_subsetI: "(!!x. x \<in> A ==> f x \<in> B) ==> f`A \<subseteq> B"
   787   -- {* Replaces the three steps @{text subsetI}, @{text imageE},
   786   -- {* Replaces the three steps @{text subsetI}, @{text imageE},
   788     @{text hypsubst}, but breaks too many existing proofs. *}
   787     @{text hypsubst}, but breaks too many existing proofs. *}
  1042 lemma insert_subset [simp]: "(insert x A \<subseteq> B) = (x \<in> B & A \<subseteq> B)"
  1041 lemma insert_subset [simp]: "(insert x A \<subseteq> B) = (x \<in> B & A \<subseteq> B)"
  1043   by blast
  1042   by blast
  1044 
  1043 
  1045 lemma mk_disjoint_insert: "a \<in> A ==> \<exists>B. A = insert a B & a \<notin> B"
  1044 lemma mk_disjoint_insert: "a \<in> A ==> \<exists>B. A = insert a B & a \<notin> B"
  1046   -- {* use new @{text B} rather than @{text "A - {a}"} to avoid infinite unfolding *}
  1045   -- {* use new @{text B} rather than @{text "A - {a}"} to avoid infinite unfolding *}
  1047   apply (rule_tac x = "A - {a}" in exI)
  1046   apply (rule_tac x = "A - {a}" in exI, blast)
  1048   apply blast
       
  1049   done
  1047   done
  1050 
  1048 
  1051 lemma insert_Collect: "insert a (Collect P) = {u. u \<noteq> a --> P u}"
  1049 lemma insert_Collect: "insert a (Collect P) = {u. u \<noteq> a --> P u}"
  1052   by auto
  1050   by auto
  1053 
  1051 
  1101 
  1099 
  1102 lemma full_SetCompr_eq: "{u. \<exists>x. u = f x} = range f"
  1100 lemma full_SetCompr_eq: "{u. \<exists>x. u = f x} = range f"
  1103   by auto
  1101   by auto
  1104 
  1102 
  1105 lemma range_composition [simp]: "range (\<lambda>x. f (g x)) = f`range g"
  1103 lemma range_composition [simp]: "range (\<lambda>x. f (g x)) = f`range g"
  1106   apply (subst image_image)
  1104 by (subst image_image, simp)
  1107   apply simp
       
  1108   done
       
  1109 
  1105 
  1110 
  1106 
  1111 text {* \medskip @{text Int} *}
  1107 text {* \medskip @{text Int} *}
  1112 
  1108 
  1113 lemma Int_absorb [simp]: "A \<inter> A = A"
  1109 lemma Int_absorb [simp]: "A \<inter> A = A"
  1343   by blast
  1339   by blast
  1344 
  1340 
  1345 lemma Inter_UNIV_conv [iff]:
  1341 lemma Inter_UNIV_conv [iff]:
  1346   "(\<Inter>A = UNIV) = (\<forall>x\<in>A. x = UNIV)"
  1342   "(\<Inter>A = UNIV) = (\<forall>x\<in>A. x = UNIV)"
  1347   "(UNIV = \<Inter>A) = (\<forall>x\<in>A. x = UNIV)"
  1343   "(UNIV = \<Inter>A) = (\<forall>x\<in>A. x = UNIV)"
  1348   by(blast)+
  1344   by blast+
  1349 
  1345 
  1350 
  1346 
  1351 text {*
  1347 text {*
  1352   \medskip @{text UN} and @{text INT}.
  1348   \medskip @{text UN} and @{text INT}.
  1353 
  1349 
  1576 
  1572 
  1577 text {* \medskip Quantification over type @{typ bool}. *}
  1573 text {* \medskip Quantification over type @{typ bool}. *}
  1578 
  1574 
  1579 lemma all_bool_eq: "(\<forall>b::bool. P b) = (P True & P False)"
  1575 lemma all_bool_eq: "(\<forall>b::bool. P b) = (P True & P False)"
  1580   apply auto
  1576   apply auto
  1581   apply (tactic {* case_tac "b" 1 *})
  1577   apply (tactic {* case_tac "b" 1 *}, auto)
  1582    apply auto
       
  1583   done
  1578   done
  1584 
  1579 
  1585 lemma bool_induct: "P True \<Longrightarrow> P False \<Longrightarrow> P x"
  1580 lemma bool_induct: "P True \<Longrightarrow> P False \<Longrightarrow> P x"
  1586   by (rule conjI [THEN all_bool_eq [THEN iffD2], THEN spec])
  1581   by (rule conjI [THEN all_bool_eq [THEN iffD2], THEN spec])
  1587 
  1582 
  1588 lemma ex_bool_eq: "(\<exists>b::bool. P b) = (P True | P False)"
  1583 lemma ex_bool_eq: "(\<exists>b::bool. P b) = (P True | P False)"
  1589   apply auto
  1584   apply auto
  1590   apply (tactic {* case_tac "b" 1 *})
  1585   apply (tactic {* case_tac "b" 1 *}, auto)
  1591    apply auto
       
  1592   done
  1586   done
  1593 
  1587 
  1594 lemma Un_eq_UN: "A \<union> B = (\<Union>b. if b then A else B)"
  1588 lemma Un_eq_UN: "A \<union> B = (\<Union>b. if b then A else B)"
  1595   by (auto simp add: split_if_mem2)
  1589   by (auto simp add: split_if_mem2)
  1596 
  1590 
  1597 lemma UN_bool_eq: "(\<Union>b::bool. A b) = (A True \<union> A False)"
  1591 lemma UN_bool_eq: "(\<Union>b::bool. A b) = (A True \<union> A False)"
  1598   apply auto
  1592   apply auto
  1599   apply (tactic {* case_tac "b" 1 *})
  1593   apply (tactic {* case_tac "b" 1 *}, auto)
  1600    apply auto
       
  1601   done
  1594   done
  1602 
  1595 
  1603 lemma INT_bool_eq: "(\<Inter>b::bool. A b) = (A True \<inter> A False)"
  1596 lemma INT_bool_eq: "(\<Inter>b::bool. A b) = (A True \<inter> A False)"
  1604   apply auto
  1597   apply auto
  1605   apply (tactic {* case_tac "b" 1 *})
  1598   apply (tactic {* case_tac "b" 1 *}, auto)
  1606   apply auto
       
  1607   done
  1599   done
  1608 
  1600 
  1609 
  1601 
  1610 text {* \medskip @{text Pow} *}
  1602 text {* \medskip @{text Pow} *}
  1611 
  1603 
  1798 
  1790 
  1799 text {* \medskip Monotonicity of implications. *}
  1791 text {* \medskip Monotonicity of implications. *}
  1800 
  1792 
  1801 lemma in_mono: "A \<subseteq> B ==> x \<in> A --> x \<in> B"
  1793 lemma in_mono: "A \<subseteq> B ==> x \<in> A --> x \<in> B"
  1802   apply (rule impI)
  1794   apply (rule impI)
  1803   apply (erule subsetD)
  1795   apply (erule subsetD, assumption)
  1804   apply assumption
       
  1805   done
  1796   done
  1806 
  1797 
  1807 lemma conj_mono: "P1 --> Q1 ==> P2 --> Q2 ==> (P1 & P2) --> (Q1 & Q2)"
  1798 lemma conj_mono: "P1 --> Q1 ==> P2 --> Q2 ==> (P1 & P2) --> (Q1 & Q2)"
  1808   by rules
  1799   by rules
  1809 
  1800 
  1841 lemma Least_mono:
  1832 lemma Least_mono:
  1842   "mono (f::'a::order => 'b::order) ==> EX x:S. ALL y:S. x <= y
  1833   "mono (f::'a::order => 'b::order) ==> EX x:S. ALL y:S. x <= y
  1843     ==> (LEAST y. y : f ` S) = f (LEAST x. x : S)"
  1834     ==> (LEAST y. y : f ` S) = f (LEAST x. x : S)"
  1844     -- {* Courtesy of Stephan Merz *}
  1835     -- {* Courtesy of Stephan Merz *}
  1845   apply clarify
  1836   apply clarify
  1846   apply (erule_tac P = "%x. x : S" in LeastI2)
  1837   apply (erule_tac P = "%x. x : S" in LeastI2, fast)
  1847    apply fast
       
  1848   apply (rule LeastI2)
  1838   apply (rule LeastI2)
  1849   apply (auto elim: monoD intro!: order_antisym)
  1839   apply (auto elim: monoD intro!: order_antisym)
  1850   done
  1840   done
  1851 
  1841 
  1852 
  1842