equal
deleted
inserted
replaced
36 val Collect_False_empty = @{thm empty_def [THEN sym, THEN eq_reflection]}; |
36 val Collect_False_empty = @{thm empty_def [THEN sym, THEN eq_reflection]}; |
37 val empty_iff = @{thm empty_iff}; |
37 val empty_iff = @{thm empty_iff}; |
38 |
38 |
39 open NominalAtoms; |
39 open NominalAtoms; |
40 |
40 |
41 (** FIXME: Datatype should export this function **) |
|
42 |
|
43 local |
|
44 |
|
45 fun dt_recs (Datatype_Aux.DtTFree _) = [] |
|
46 | dt_recs (Datatype_Aux.DtType (_, dts)) = maps dt_recs dts |
|
47 | dt_recs (Datatype_Aux.DtRec i) = [i]; |
|
48 |
|
49 fun dt_cases (descr: Datatype_Aux.descr) (_, args, constrs) = |
|
50 let |
|
51 fun the_bname i = Long_Name.base_name (#1 (the (AList.lookup (op =) descr i))); |
|
52 val bnames = map the_bname (distinct op = (maps dt_recs args)); |
|
53 in map (fn (c, _) => space_implode "_" (Long_Name.base_name c :: bnames)) constrs end; |
|
54 |
|
55 |
|
56 fun induct_cases descr = |
|
57 Datatype_Prop.indexify_names (maps (dt_cases descr) (map #2 descr)); |
|
58 |
|
59 fun exhaust_cases descr i = dt_cases descr (the (AList.lookup (op =) descr i)); |
|
60 |
|
61 in |
|
62 |
|
63 fun mk_case_names_induct descr = Rule_Cases.case_names (induct_cases descr); |
|
64 |
|
65 fun mk_case_names_exhausts descr new = |
|
66 map (Rule_Cases.case_names o exhaust_cases descr o #1) |
|
67 (filter (fn ((_, (name, _, _))) => member (op =) new name) descr); |
|
68 |
|
69 end; |
|
70 |
41 |
71 (* theory data *) |
42 (* theory data *) |
72 |
43 |
73 type descr = |
44 type descr = |
74 (int * (string * Datatype_Aux.dtyp list * |
45 (int * (string * Datatype_Aux.dtyp list * |
1072 [REPEAT (eresolve_tac Abs_inverse_thms' 1), |
1043 [REPEAT (eresolve_tac Abs_inverse_thms' 1), |
1073 simp_tac (HOL_basic_ss addsimps [Thm.symmetric r]) 1, |
1044 simp_tac (HOL_basic_ss addsimps [Thm.symmetric r]) 1, |
1074 DEPTH_SOLVE_1 (ares_tac [prem] 1 ORELSE etac allE 1)])) |
1045 DEPTH_SOLVE_1 (ares_tac [prem] 1 ORELSE etac allE 1)])) |
1075 (prems ~~ constr_defs))]); |
1046 (prems ~~ constr_defs))]); |
1076 |
1047 |
1077 val case_names_induct = mk_case_names_induct descr''; |
1048 val case_names_induct = Datatype_Data.mk_case_names_induct descr''; |
1078 |
1049 |
1079 (**** prove that new datatypes have finite support ****) |
1050 (**** prove that new datatypes have finite support ****) |
1080 |
1051 |
1081 val _ = warning "proving finite support for the new datatype"; |
1052 val _ = warning "proving finite support for the new datatype"; |
1082 |
1053 |