equal
deleted
inserted
replaced
4875 list_all_iff [code_post]: "list_all P xs \<longleftrightarrow> (\<forall>x \<in> set xs. P x)" |
4875 list_all_iff [code_post]: "list_all P xs \<longleftrightarrow> (\<forall>x \<in> set xs. P x)" |
4876 |
4876 |
4877 definition list_ex :: "('a \<Rightarrow> bool) \<Rightarrow> 'a list \<Rightarrow> bool" where |
4877 definition list_ex :: "('a \<Rightarrow> bool) \<Rightarrow> 'a list \<Rightarrow> bool" where |
4878 list_ex_iff [code_post]: "list_ex P xs \<longleftrightarrow> (\<exists>x \<in> set xs. P x)" |
4878 list_ex_iff [code_post]: "list_ex P xs \<longleftrightarrow> (\<exists>x \<in> set xs. P x)" |
4879 |
4879 |
|
4880 definition list_ex1 |
|
4881 where |
|
4882 list_ex1_iff: "list_ex1 P xs \<longleftrightarrow> (\<exists>! x. x \<in> set xs \<and> P x)" |
|
4883 |
4880 text {* |
4884 text {* |
4881 Usually you should prefer @{text "\<forall>x\<in>set xs"} and @{text "\<exists>x\<in>set xs"} |
4885 Usually you should prefer @{text "\<forall>x\<in>set xs"} and @{text "\<exists>x\<in>set xs"} |
4882 over @{const list_all} and @{const list_ex} in specifications. |
4886 over @{const list_all} and @{const list_ex} in specifications. |
4883 *} |
4887 *} |
4884 |
4888 |
4889 |
4893 |
4890 lemma list_ex_simps [simp, code]: |
4894 lemma list_ex_simps [simp, code]: |
4891 "list_ex P (x # xs) \<longleftrightarrow> P x \<or> list_ex P xs" |
4895 "list_ex P (x # xs) \<longleftrightarrow> P x \<or> list_ex P xs" |
4892 "list_ex P [] \<longleftrightarrow> False" |
4896 "list_ex P [] \<longleftrightarrow> False" |
4893 by (simp_all add: list_ex_iff) |
4897 by (simp_all add: list_ex_iff) |
|
4898 |
|
4899 lemma list_ex1_simps [simp, code]: |
|
4900 "list_ex1 P [] = False" |
|
4901 "list_ex1 P (x # xs) = (if P x then list_all (\<lambda>y. \<not> P y \<or> x = y) xs else list_ex1 P xs)" |
|
4902 unfolding list_ex1_iff list_all_iff by auto |
4894 |
4903 |
4895 lemma Ball_set_list_all [code_unfold]: |
4904 lemma Ball_set_list_all [code_unfold]: |
4896 "Ball (set xs) P \<longleftrightarrow> list_all P xs" |
4905 "Ball (set xs) P \<longleftrightarrow> list_all P xs" |
4897 by (simp add: list_all_iff) |
4906 by (simp add: list_all_iff) |
4898 |
4907 |