29 case_thms : thm list list, |
29 case_thms : thm list list, |
30 split_thms : (thm * thm) list, |
30 split_thms : (thm * thm) list, |
31 induction : thm, |
31 induction : thm, |
32 size : thm list, |
32 size : thm list, |
33 simps : thm list} |
33 simps : thm list} |
34 val add_rep_datatype : string list option -> thm list list -> |
34 val rep_datatype : string list option -> xstring list list -> |
|
35 xstring list list -> xstring -> theory -> theory * |
|
36 {distinct : thm list list, |
|
37 inject : thm list list, |
|
38 exhaustion : thm list, |
|
39 rec_thms : thm list, |
|
40 case_thms : thm list list, |
|
41 split_thms : (thm * thm) list, |
|
42 induction : thm, |
|
43 size : thm list, |
|
44 simps : thm list} |
|
45 val rep_datatype_i : string list option -> thm list list -> |
35 thm list list -> thm -> theory -> theory * |
46 thm list list -> thm -> theory -> theory * |
36 {distinct : thm list list, |
47 {distinct : thm list list, |
37 inject : thm list list, |
48 inject : thm list list, |
38 exhaustion : thm list, |
49 exhaustion : thm list, |
39 rec_thms : thm list, |
50 rec_thms : thm list, |
470 end; |
481 end; |
471 |
482 |
472 |
483 |
473 (*********************** declare non-datatype as datatype *********************) |
484 (*********************** declare non-datatype as datatype *********************) |
474 |
485 |
475 fun add_rep_datatype alt_names distinct inject induction thy = |
486 fun gen_rep_datatype get get' alt_names distinct_names inject_names induction_name thy = |
476 let |
487 let |
477 val sign = sign_of thy; |
488 val sign = sign_of thy; |
|
489 |
|
490 val distinct = map (get thy) distinct_names; |
|
491 val inject = map (get thy) inject_names; |
|
492 val induction = get' thy induction_name; |
478 |
493 |
479 val induction' = freezeT induction; |
494 val induction' = freezeT induction; |
480 |
495 |
481 fun err t = error ("Ill-formed predicate in induction rule: " ^ |
496 fun err t = error ("Ill-formed predicate in induction rule: " ^ |
482 Sign.string_of_term sign t); |
497 Sign.string_of_term sign t); |
554 induction = induction, |
569 induction = induction, |
555 size = size_thms, |
570 size = size_thms, |
556 simps = simps}) |
571 simps = simps}) |
557 end; |
572 end; |
558 |
573 |
|
574 val rep_datatype = gen_rep_datatype |
|
575 (fn thy => map Attribute.thm_of o PureThy.get_tthmss thy) get_thm; |
|
576 val rep_datatype_i = gen_rep_datatype (K I) (K I); |
559 |
577 |
560 (******************************** add datatype ********************************) |
578 (******************************** add datatype ********************************) |
561 |
579 |
562 fun gen_add_datatype prep_typ flat_names new_type_names dts thy = |
580 fun gen_add_datatype prep_typ flat_names new_type_names dts thy = |
563 let |
581 let |