equal
deleted
inserted
replaced
90 end; |
90 end; |
91 |
91 |
92 structure Ctr_Sugar_Util : CTR_SUGAR_UTIL = |
92 structure Ctr_Sugar_Util : CTR_SUGAR_UTIL = |
93 struct |
93 struct |
94 |
94 |
95 fun map_prod f g (x, y) = (f x, g y) |
95 fun match_entire_string pat s = |
|
96 let |
|
97 fun match [] [] = true |
|
98 | match [] _ = false |
|
99 | match (ps as #"*" :: ps') cs = |
|
100 match ps' cs orelse (not (null cs) andalso match ps (tl cs)) |
|
101 | match _ [] = false |
|
102 | match (p :: ps) (c :: cs) = p = c andalso match ps cs; |
|
103 in |
|
104 match (String.explode pat) (String.explode s) |
|
105 end; |
|
106 |
|
107 fun map_prod f g (x, y) = (f x, g y); |
96 |
108 |
97 fun map3 _ [] [] [] = [] |
109 fun map3 _ [] [] [] = [] |
98 | map3 f (x1::x1s) (x2::x2s) (x3::x3s) = f x1 x2 x3 :: map3 f x1s x2s x3s |
110 | map3 f (x1::x1s) (x2::x2s) (x3::x3s) = f x1 x2 x3 :: map3 f x1s x2s x3s |
99 | map3 _ _ _ _ = raise ListPair.UnequalLengths; |
111 | map3 _ _ _ _ = raise ListPair.UnequalLengths; |
100 |
112 |
270 val parse_opt_binding_colon = Scan.optional parse_binding_colon Binding.empty; |
282 val parse_opt_binding_colon = Scan.optional parse_binding_colon Binding.empty; |
271 |
283 |
272 val parse_plugins = |
284 val parse_plugins = |
273 Parse.reserved "plugins" |-- |
285 Parse.reserved "plugins" |-- |
274 ((Parse.reserved "only" >> K I || Parse.reserved "del" >> K not) --| @{keyword ":"} |
286 ((Parse.reserved "only" >> K I || Parse.reserved "del" >> K not) --| @{keyword ":"} |
275 -- Scan.repeat Parse.short_ident) >> (fn (modif, ss) => modif o member (op =) ss); |
287 -- Scan.repeat (Parse.short_ident || Parse.string)) |
|
288 >> (fn (modif, pats) => modif o member (uncurry match_entire_string o swap) pats); |
276 |
289 |
277 fun ss_only thms ctxt = clear_simpset (put_simpset HOL_basic_ss ctxt) addsimps thms; |
290 fun ss_only thms ctxt = clear_simpset (put_simpset HOL_basic_ss ctxt) addsimps thms; |
278 |
291 |
279 (*Tactical WRAP surrounds a static given tactic (core) with two deterministic chains of tactics*) |
292 (*Tactical WRAP surrounds a static given tactic (core) with two deterministic chains of tactics*) |
280 fun WRAP gen_before gen_after xs core_tac = |
293 fun WRAP gen_before gen_after xs core_tac = |
289 |
302 |
290 fun CONJ_WRAP_GEN' conj_tac gen_tac xs = |
303 fun CONJ_WRAP_GEN' conj_tac gen_tac xs = |
291 let val (butlast, last) = split_last xs; |
304 let val (butlast, last) = split_last xs; |
292 in WRAP' (fn thm => conj_tac THEN' gen_tac thm) (K (K all_tac)) butlast (gen_tac last) end; |
305 in WRAP' (fn thm => conj_tac THEN' gen_tac thm) (K (K all_tac)) butlast (gen_tac last) end; |
293 |
306 |
294 (*not eta-converted because of monotype restriction*) |
|
295 fun CONJ_WRAP gen_tac = CONJ_WRAP_GEN (rtac conjI 1) gen_tac; |
307 fun CONJ_WRAP gen_tac = CONJ_WRAP_GEN (rtac conjI 1) gen_tac; |
296 fun CONJ_WRAP' gen_tac = CONJ_WRAP_GEN' (rtac conjI) gen_tac; |
308 fun CONJ_WRAP' gen_tac = CONJ_WRAP_GEN' (rtac conjI) gen_tac; |
297 |
309 |
298 end; |
310 end; |