4 |
4 |
5 Generic case-splitter, suitable for most logics. |
5 Generic case-splitter, suitable for most logics. |
6 Deals with equalities of the form ?P(f args) = ... |
6 Deals with equalities of the form ?P(f args) = ... |
7 where "f args" must be a first-order term without duplicate variables. |
7 where "f args" must be a first-order term without duplicate variables. |
8 *) |
8 *) |
9 |
|
10 infix 4 addsplits delsplits; |
|
11 |
9 |
12 signature SPLITTER_DATA = |
10 signature SPLITTER_DATA = |
13 sig |
11 sig |
14 val thy : theory |
12 val thy : theory |
15 val mk_eq : thm -> thm |
13 val mk_eq : thm -> thm |
32 (* first argument is a "cmap", returns a list of "split packs" *) |
30 (* first argument is a "cmap", returns a list of "split packs" *) |
33 (* the "real" interface, providing a number of tactics *) |
31 (* the "real" interface, providing a number of tactics *) |
34 val split_tac : thm list -> int -> tactic |
32 val split_tac : thm list -> int -> tactic |
35 val split_inside_tac: thm list -> int -> tactic |
33 val split_inside_tac: thm list -> int -> tactic |
36 val split_asm_tac : thm list -> int -> tactic |
34 val split_asm_tac : thm list -> int -> tactic |
37 val addsplits : simpset * thm list -> simpset |
35 val add_split: thm -> simpset -> simpset |
38 val delsplits : simpset * thm list -> simpset |
36 val del_split: thm -> simpset -> simpset |
39 val split_add: attribute |
37 val split_add: attribute |
40 val split_del: attribute |
38 val split_del: attribute |
41 val split_modifiers : Method.modifier parser list |
39 val split_modifiers : Method.modifier parser list |
42 val setup: theory -> theory |
40 val setup: theory -> theory |
43 end; |
41 end; |
417 end; |
415 end; |
418 |
416 |
419 |
417 |
420 (** declare split rules **) |
418 (** declare split rules **) |
421 |
419 |
422 (* addsplits / delsplits *) |
420 (* add_split / del_split *) |
423 |
421 |
424 fun string_of_typ (Type (s, Ts)) = |
422 fun string_of_typ (Type (s, Ts)) = |
425 (if null Ts then "" else enclose "(" ")" (commas (map string_of_typ Ts))) ^ s |
423 (if null Ts then "" else enclose "(" ")" (commas (map string_of_typ Ts))) ^ s |
426 | string_of_typ _ = "_"; |
424 | string_of_typ _ = "_"; |
427 |
425 |
428 fun split_name (name, T) asm = "split " ^ |
426 fun split_name (name, T) asm = "split " ^ |
429 (if asm then "asm " else "") ^ name ^ " :: " ^ string_of_typ T; |
427 (if asm then "asm " else "") ^ name ^ " :: " ^ string_of_typ T; |
430 |
428 |
431 fun ss addsplits splits = |
429 fun add_split split ss = |
432 let |
430 let |
433 fun addsplit split ss = |
431 val (name, asm) = split_thm_info split |
434 let |
432 val tac = (if asm then split_asm_tac else split_tac) [split] |
435 val (name, asm) = split_thm_info split |
433 in Simplifier.addloop (ss, (split_name name asm, tac)) end; |
436 val tac = (if asm then split_asm_tac else split_tac) [split] |
434 |
437 in Simplifier.addloop (ss, (split_name name asm, tac)) end |
435 fun del_split split ss = |
438 in fold addsplit splits ss end; |
436 let val (name, asm) = split_thm_info split |
439 |
437 in Simplifier.delloop (ss, split_name name asm) end; |
440 fun ss delsplits splits = |
|
441 let |
|
442 fun delsplit split ss = |
|
443 let val (name, asm) = split_thm_info split |
|
444 in Simplifier.delloop (ss, split_name name asm) end |
|
445 in fold delsplit splits ss end; |
|
446 |
438 |
447 |
439 |
448 (* attributes *) |
440 (* attributes *) |
449 |
441 |
450 val splitN = "split"; |
442 val splitN = "split"; |
451 |
443 |
452 val split_add = Simplifier.attrib (op addsplits); |
444 val split_add = Simplifier.attrib add_split; |
453 val split_del = Simplifier.attrib (op delsplits); |
445 val split_del = Simplifier.attrib del_split; |
454 |
446 |
455 |
447 |
456 (* methods *) |
448 (* methods *) |
457 |
449 |
458 val split_modifiers = |
450 val split_modifiers = |