# HG changeset patch # User haftmann # Date 1325152075 -3600 # Node ID 51b2f3412a03123fd826d053e3aa5d2448041393 # Parent 4a19e3d147c30d354c57f9baa5736788f74442e6 attribute code_abbrev superseedes code_unfold_post; tuned text diff -r 4a19e3d147c3 -r 51b2f3412a03 src/HOL/List.thy --- a/src/HOL/List.thy Thu Dec 29 10:47:55 2011 +0100 +++ b/src/HOL/List.thy Thu Dec 29 10:47:55 2011 +0100 @@ -5017,10 +5017,10 @@ subsubsection {* Counterparts for set-related operations *} definition member :: "'a list \ 'a \ bool" where - [code_post]: "member xs x \ x \ set xs" + [code_abbrev]: "member xs x \ x \ set xs" text {* - Only use @{text member} for generating executable code. Otherwise use + Use @{text member} only for generating executable code. Otherwise use @{prop "x \ set xs"} instead --- it is much easier to reason about. *} @@ -5029,7 +5029,7 @@ "member [] y \ False" by (auto simp add: member_def) -lemma in_set_member [code_unfold]: +lemma in_set_member (* FIXME delete candidate *): "x \ set xs \ member xs x" by (simp add: member_def) @@ -5039,18 +5039,18 @@ declare set_map [symmetric, code_unfold] definition list_all :: "('a \ bool) \ 'a list \ bool" where - list_all_iff [code_post]: "list_all P xs \ (\x \ set xs. P x)" + list_all_iff [code_abbrev]: "list_all P xs \ Ball (set xs) P" definition list_ex :: "('a \ bool) \ 'a list \ bool" where - list_ex_iff [code_post]: "list_ex P xs \ (\x \ set xs. P x)" - -definition list_ex1 -where - list_ex1_iff: "list_ex1 P xs \ (\! x. x \ set xs \ P x)" + list_ex_iff [code_abbrev]: "list_ex P xs \ Bex (set xs) P" + +definition list_ex1 :: "('a \ bool) \ 'a list \ bool" where + list_ex1_iff [code_abbrev]: "list_ex1 P xs \ (\! x. x \ set xs \ P x)" text {* - Usually you should prefer @{text "\x\set xs"} and @{text "\x\set xs"} - over @{const list_all} and @{const list_ex} in specifications. + Usually you should prefer @{text "\x\set xs"}, @{text "\x\set xs"} + and @{text "\!x. x\set xs \ _"} over @{const list_all}, @{const list_ex} + and @{const list_ex1} in specifications. *} lemma list_all_simps [simp, code]: @@ -5066,13 +5066,13 @@ lemma list_ex1_simps [simp, code]: "list_ex1 P [] = False" "list_ex1 P (x # xs) = (if P x then list_all (\y. \ P y \ x = y) xs else list_ex1 P xs)" -unfolding list_ex1_iff list_all_iff by auto - -lemma Ball_set_list_all [code_unfold]: + by (auto simp add: list_ex1_iff list_all_iff) + +lemma Ball_set_list_all: (* FIXME delete candidate *) "Ball (set xs) P \ list_all P xs" by (simp add: list_all_iff) -lemma Bex_set_list_ex [code_unfold]: +lemma Bex_set_list_ex: (* FIXME delete candidate *) "Bex (set xs) P \ list_ex P xs" by (simp add: list_ex_iff) @@ -5176,7 +5176,7 @@ subsubsection {* Optimizing by rewriting *} definition null :: "'a list \ bool" where - [code_post]: "null xs \ xs = []" + [code_abbrev]: "null xs \ xs = []" text {* Efficient emptyness check is implemented by @{const null}. @@ -5187,7 +5187,7 @@ "null [] \ True" by (simp_all add: null_def) -lemma eq_Nil_null [code_unfold]: +lemma eq_Nil_null: (* FIXME delete candidate *) "xs = [] \ null xs" by (simp add: null_def) @@ -5196,7 +5196,7 @@ by (simp add: equal eq_Nil_null) definition maps :: "('a \ 'b list) \ 'a list \ 'b list" where - [code_post]: "maps f xs = concat (map f xs)" + [code_abbrev]: "maps f xs = concat (map f xs)" definition map_filter :: "('a \ 'b option) \ 'a list \ 'b list" where [code_post]: "map_filter f xs = map (the \ f) (filter (\x. f x \ None) xs)" @@ -5216,7 +5216,7 @@ "map_filter f [] = []" by (simp_all add: map_filter_def split: option.split) -lemma concat_map_maps [code_unfold]: +lemma concat_map_maps: (* FIXME delete candidate *) "concat (map f xs) = maps f xs" by (simp add: maps_def)