29 (*Insert definitions for the recursive sets, which |
29 (*Insert definitions for the recursive sets, which |
30 must *already* be declared as constants in parent theory!*) |
30 must *already* be declared as constants in parent theory!*) |
31 val add_inductive_i: bool -> term list * term -> |
31 val add_inductive_i: bool -> term list * term -> |
32 ((bstring * term) * theory attribute list) list -> |
32 ((bstring * term) * theory attribute list) list -> |
33 thm list * thm list * thm list * thm list -> theory -> theory * inductive_result |
33 thm list * thm list * thm list * thm list -> theory -> theory * inductive_result |
34 val add_inductive_x: string list * string -> ((bstring * string) * theory attribute list) list |
|
35 -> thm list * thm list * thm list * thm list -> theory -> theory * inductive_result |
|
36 val add_inductive: string list * string -> |
34 val add_inductive: string list * string -> |
37 ((bstring * string) * Attrib.src list) list -> |
35 ((bstring * string) * Attrib.src list) list -> |
38 (thmref * Attrib.src list) list * (thmref * Attrib.src list) list * |
36 (thmref * Attrib.src list) list * (thmref * Attrib.src list) list * |
39 (thmref * Attrib.src list) list * (thmref * Attrib.src list) list -> |
37 (thmref * Attrib.src list) list * (thmref * Attrib.src list) list -> |
40 theory -> theory * inductive_result |
38 theory -> theory * inductive_result |
561 mk_cases = mk_cases, |
559 mk_cases = mk_cases, |
562 induct = induct, |
560 induct = induct, |
563 mutual_induct = mutual_induct}) |
561 mutual_induct = mutual_induct}) |
564 end; |
562 end; |
565 |
563 |
566 |
|
567 (*external version, accepting strings*) |
|
568 fun add_inductive_x (srec_tms, sdom_sum) sintrs (monos, con_defs, type_intrs, type_elims) thy = |
|
569 let |
|
570 val read = Sign.simple_read_term (Theory.sign_of thy); |
|
571 val rec_tms = map (read Ind_Syntax.iT) srec_tms; |
|
572 val dom_sum = read Ind_Syntax.iT sdom_sum; |
|
573 val intr_tms = map (read propT o snd o fst) sintrs; |
|
574 val intr_specs = (map (fst o fst) sintrs ~~ intr_tms) ~~ map snd sintrs; |
|
575 in |
|
576 add_inductive_i true (rec_tms, dom_sum) intr_specs |
|
577 (monos, con_defs, type_intrs, type_elims) thy |
|
578 end |
|
579 |
|
580 |
|
581 (*source version*) |
564 (*source version*) |
582 fun add_inductive (srec_tms, sdom_sum) intr_srcs |
565 fun add_inductive (srec_tms, sdom_sum) intr_srcs |
583 (raw_monos, raw_con_defs, raw_type_intrs, raw_type_elims) thy = |
566 (raw_monos, raw_con_defs, raw_type_intrs, raw_type_elims) thy = |
584 let |
567 let |
585 val intr_atts = map (map (Attrib.global_attribute thy) o snd) intr_srcs; |
568 val intr_atts = map (map (Attrib.global_attribute thy) o snd) intr_srcs; |
|
569 val sintrs = map fst intr_srcs ~~ intr_atts; |
|
570 val read = Sign.simple_read_term thy; |
|
571 val rec_tms = map (read Ind_Syntax.iT) srec_tms; |
|
572 val dom_sum = read Ind_Syntax.iT sdom_sum; |
|
573 val intr_tms = map (read propT o snd o fst) sintrs; |
|
574 val intr_specs = (map (fst o fst) sintrs ~~ intr_tms) ~~ map snd sintrs; |
|
575 |
586 val (thy', (((monos, con_defs), type_intrs), type_elims)) = thy |
576 val (thy', (((monos, con_defs), type_intrs), type_elims)) = thy |
587 |> IsarThy.apply_theorems raw_monos |
577 |> IsarThy.apply_theorems raw_monos |
588 |>>> IsarThy.apply_theorems raw_con_defs |
578 |>>> IsarThy.apply_theorems raw_con_defs |
589 |>>> IsarThy.apply_theorems raw_type_intrs |
579 |>>> IsarThy.apply_theorems raw_type_intrs |
590 |>>> IsarThy.apply_theorems raw_type_elims; |
580 |>>> IsarThy.apply_theorems raw_type_elims; |
591 in |
581 in |
592 add_inductive_x (srec_tms, sdom_sum) (map fst intr_srcs ~~ intr_atts) |
582 add_inductive_i true (rec_tms, dom_sum) intr_specs |
593 (monos, con_defs, type_intrs, type_elims) thy' |
583 (monos, con_defs, type_intrs, type_elims) thy' |
594 end; |
584 end |
595 |
585 |
596 |
586 |
597 (* outer syntax *) |
587 (* outer syntax *) |
598 |
588 |
599 local structure P = OuterParse and K = OuterKeyword in |
589 local structure P = OuterParse and K = OuterKeyword in |