8 - induction theorem |
8 - induction theorem |
9 *) |
9 *) |
10 |
10 |
11 signature DATATYPE_REP_PROOFS = |
11 signature DATATYPE_REP_PROOFS = |
12 sig |
12 sig |
13 include DATATYPE_COMMON |
13 val add_datatype : DatatypeAux.config -> string list -> (string list * binding * mixfix * |
14 val add_datatype : config -> string list -> (string list * binding * mixfix * |
|
15 (binding * typ list * mixfix) list) list -> theory -> string list * theory |
14 (binding * typ list * mixfix) list) list -> theory -> string list * theory |
16 val datatype_cmd : string list -> (string list * binding * mixfix * |
15 val datatype_cmd : string list -> (string list * binding * mixfix * |
17 (binding * string list * mixfix) list) list -> theory -> theory |
16 (binding * string list * mixfix) list) list -> theory -> theory |
18 end; |
17 end; |
19 |
18 |
48 val In0_eq = @{thm In0_eq}; |
47 val In0_eq = @{thm In0_eq}; |
49 val In1_eq = @{thm In1_eq}; |
48 val In1_eq = @{thm In1_eq}; |
50 val In0_not_In1 = @{thm In0_not_In1}; |
49 val In0_not_In1 = @{thm In0_not_In1}; |
51 val In1_not_In0 = @{thm In1_not_In0}; |
50 val In1_not_In0 = @{thm In1_not_In0}; |
52 val Lim_inject = @{thm Lim_inject}; |
51 val Lim_inject = @{thm Lim_inject}; |
|
52 val Inl_inject = @{thm Inl_inject}; |
|
53 val Inr_inject = @{thm Inr_inject}; |
53 val Suml_inject = @{thm Suml_inject}; |
54 val Suml_inject = @{thm Suml_inject}; |
54 val Sumr_inject = @{thm Sumr_inject}; |
55 val Sumr_inject = @{thm Sumr_inject}; |
55 |
56 |
56 |
57 |
57 |
58 |
695 end; |
696 end; |
696 |
697 |
697 val (dts', constr_syntax, sorts', i) = |
698 val (dts', constr_syntax, sorts', i) = |
698 fold2 prep_dt_spec dts new_type_names ([], [], [], 0); |
699 fold2 prep_dt_spec dts new_type_names ([], [], [], 0); |
699 val sorts = sorts' @ map (rpair (Sign.defaultS tmp_thy)) (subtract (op =) (map fst sorts') tyvars); |
700 val sorts = sorts' @ map (rpair (Sign.defaultS tmp_thy)) (subtract (op =) (map fst sorts') tyvars); |
700 val dt_info = Datatype.get_all thy; |
701 val dt_info = Datatype_Data.get_all thy; |
701 val (descr, _) = unfold_datatypes tmp_thy dts' sorts dt_info dts' i; |
702 val (descr, _) = unfold_datatypes tmp_thy dts' sorts dt_info dts' i; |
702 val _ = check_nonempty descr handle (exn as Datatype_Empty s) => |
703 val _ = check_nonempty descr handle (exn as Datatype_Empty s) => |
703 if #strict config then error ("Nonemptiness check failed for datatype " ^ s) |
704 if #strict config then error ("Nonemptiness check failed for datatype " ^ s) |
704 else raise exn; |
705 else raise exn; |
705 |
706 |
706 val _ = message config ("Constructing datatype(s) " ^ commas_quote new_type_names); |
707 val _ = message config ("Constructing datatype(s) " ^ commas_quote new_type_names); |
707 |
708 |
708 in |
709 in |
709 thy |
710 thy |
710 |> representation_proofs config dt_info new_type_names descr sorts |
711 |> representation_proofs config dt_info new_type_names descr sorts |
711 types_syntax constr_syntax (Datatype.mk_case_names_induct (flat descr)) |
712 types_syntax constr_syntax (Datatype_Data.mk_case_names_induct (flat descr)) |
712 |-> (fn (inject, distinct, induct) => Datatype.derive_datatype_props |
713 |-> (fn (inject, distinct, induct) => Datatype_Data.derive_datatype_props |
713 config dt_names (SOME new_type_names) descr sorts |
714 config dt_names (SOME new_type_names) descr sorts |
714 induct inject distinct) |
715 induct inject distinct) |
715 end; |
716 end; |
716 |
717 |
717 val add_datatype = gen_add_datatype Datatype.cert_typ; |
718 val add_datatype = gen_add_datatype Datatype_Data.cert_typ; |
718 val datatype_cmd = snd ooo gen_add_datatype Datatype.read_typ default_config; |
719 val datatype_cmd = snd ooo gen_add_datatype Datatype_Data.read_typ default_config; |
719 |
720 |
720 local |
721 local |
721 |
722 |
722 structure P = OuterParse and K = OuterKeyword |
723 structure P = OuterParse and K = OuterKeyword |
723 |
724 |