add option_fold
authorkuncar
Mon, 26 Nov 2012 14:15:48 +0100
changeset 50225 f478f4ca7f19
parent 50224 aacd6da09825
child 50226 536ab2e82ead
add option_fold
src/HOL/Tools/Lifting/lifting_util.ML
--- a/src/HOL/Tools/Lifting/lifting_util.ML	Mon Nov 26 14:11:31 2012 +0100
+++ b/src/HOL/Tools/Lifting/lifting_util.ML	Mon Nov 26 14:15:48 2012 +0100
@@ -8,6 +8,7 @@
 sig
   val MRSL: thm list * thm -> thm
   val Trueprop_conv: conv -> conv
+  val option_fold: 'b -> ('a -> 'b) -> 'a option -> 'b
   val dest_Quotient: term -> term * term * term * term
 
   val quot_thm_rel: thm -> term
@@ -29,6 +30,9 @@
     Const (@{const_name Trueprop}, _) $ _ => Conv.arg_conv cv ct
   | _ => raise CTERM ("Trueprop_conv", [ct]))
 
+fun option_fold a _ NONE = a
+  | option_fold _ f (SOME x) = f x
+
 fun dest_Quotient (Const (@{const_name Quotient}, _) $ rel $ abs $ rep $ cr)
       = (rel, abs, rep, cr)
   | dest_Quotient t = raise TERM ("dest_Quotient", [t])