# HG changeset patch # User haftmann # Date 1360759132 -3600 # Node ID 60e4b75fefe1cf090aa78697f40cae556eaaae01 # Parent 7ae79f2e3cc75f3e55d46af85c2b948c246624ff combinator List.those; simprule for case distinction on Option.map expression diff -r 7ae79f2e3cc7 -r 60e4b75fefe1 src/HOL/List.thy --- a/src/HOL/List.thy Wed Feb 13 13:38:52 2013 +0100 +++ b/src/HOL/List.thy Wed Feb 13 13:38:52 2013 +0100 @@ -162,6 +162,13 @@ hide_const (open) find +primrec those :: "'a option list \ 'a list option" +where +"those [] = Some []" | +"those (x # xs) = (case x of + None \ None +| Some y \ Option.map (Cons y) (those xs))" + primrec remove1 :: "'a \ 'a list \ 'a list" where "remove1 x [] = []" | "remove1 x (y # xs) = (if x = y then xs else y # remove1 x xs)" diff -r 7ae79f2e3cc7 -r 60e4b75fefe1 src/HOL/Option.thy --- a/src/HOL/Option.thy Wed Feb 13 13:38:52 2013 +0100 +++ b/src/HOL/Option.thy Wed Feb 13 13:38:52 2013 +0100 @@ -101,6 +101,10 @@ qed qed +lemma option_case_map [simp]: + "option_case g h (Option.map f x) = option_case g (h \ f) x" + by (cases x) simp_all + primrec bind :: "'a option \ ('a \ 'b option) \ 'b option" where bind_lzero: "bind None f = None" | bind_lunit: "bind (Some x) f = f x"