src/HOL/Tools/Ctr_Sugar/ctr_sugar_util.ML
changeset 58659 6c9821c32dd5
parent 58634 9f10d82e8188
child 59271 c448752e8b9d
equal deleted inserted replaced
58658:9002fe021e2f 58659:6c9821c32dd5
    69   val substitute_noted_thm: (string * thm list) list -> morphism
    69   val substitute_noted_thm: (string * thm list) list -> morphism
    70 
    70 
    71   val standard_binding: binding
    71   val standard_binding: binding
    72   val parse_binding_colon: binding parser
    72   val parse_binding_colon: binding parser
    73   val parse_opt_binding_colon: binding parser
    73   val parse_opt_binding_colon: binding parser
    74   val parse_plugins: (string -> bool) parser
       
    75 
    74 
    76   val ss_only: thm list -> Proof.context -> Proof.context
    75   val ss_only: thm list -> Proof.context -> Proof.context
    77 
    76 
    78   val WRAP: ('a -> tactic) -> ('a -> tactic) -> 'a list -> tactic -> tactic
    77   val WRAP: ('a -> tactic) -> ('a -> tactic) -> 'a list -> tactic -> tactic
    79   val WRAP': ('a -> int -> tactic) -> ('a -> int -> tactic) -> 'a list -> (int -> tactic) -> int ->
    78   val WRAP': ('a -> int -> tactic) -> ('a -> int -> tactic) -> 'a list -> (int -> tactic) -> int ->
    84   val CONJ_WRAP': ('a -> int -> tactic) -> 'a list -> int -> tactic
    83   val CONJ_WRAP': ('a -> int -> tactic) -> 'a list -> int -> tactic
    85 end;
    84 end;
    86 
    85 
    87 structure Ctr_Sugar_Util : CTR_SUGAR_UTIL =
    86 structure Ctr_Sugar_Util : CTR_SUGAR_UTIL =
    88 struct
    87 struct
    89 
       
    90 fun match_entire_string pat s =
       
    91   let
       
    92     fun match [] [] = true
       
    93       | match [] _ = false
       
    94       | match (ps as #"*" :: ps') cs =
       
    95         match ps' cs orelse (not (null cs) andalso match ps (tl cs))
       
    96       | match _ [] = false
       
    97       | match (p :: ps) (c :: cs) = p = c andalso match ps cs;
       
    98   in
       
    99     match (String.explode pat) (String.explode s)
       
   100   end;
       
   101 
    88 
   102 fun map_prod f g (x, y) = (f x, g y);
    89 fun map_prod f g (x, y) = (f x, g y);
   103 
    90 
   104 fun seq_conds f n k xs =
    91 fun seq_conds f n k xs =
   105   if k = n then
    92   if k = n then
   260 val standard_binding = @{binding _};
   247 val standard_binding = @{binding _};
   261 
   248 
   262 val parse_binding_colon = Parse.binding --| @{keyword ":"};
   249 val parse_binding_colon = Parse.binding --| @{keyword ":"};
   263 val parse_opt_binding_colon = Scan.optional parse_binding_colon Binding.empty;
   250 val parse_opt_binding_colon = Scan.optional parse_binding_colon Binding.empty;
   264 
   251 
   265 val parse_plugins =
       
   266   Parse.reserved "plugins" |--
       
   267     ((Parse.reserved "only" >> K I || Parse.reserved "del" >> K not) --| @{keyword ":"}
       
   268      -- Scan.repeat (Parse.short_ident || Parse.string))
       
   269   >> (fn (modif, pats) => modif o member (uncurry match_entire_string o swap) pats);
       
   270 
       
   271 fun ss_only thms ctxt = clear_simpset (put_simpset HOL_basic_ss ctxt) addsimps thms;
   252 fun ss_only thms ctxt = clear_simpset (put_simpset HOL_basic_ss ctxt) addsimps thms;
   272 
   253 
   273 (*Tactical WRAP surrounds a static given tactic (core) with two deterministic chains of tactics*)
   254 (*Tactical WRAP surrounds a static given tactic (core) with two deterministic chains of tactics*)
   274 fun WRAP gen_before gen_after xs core_tac =
   255 fun WRAP gen_before gen_after xs core_tac =
   275   fold_rev (fn x => fn tac => gen_before x THEN tac THEN gen_after x) xs core_tac;
   256   fold_rev (fn x => fn tac => gen_before x THEN tac THEN gen_after x) xs core_tac;