equal
deleted
inserted
replaced
18 val add_typecopy: bstring * string list -> typ -> (bstring * bstring) option |
18 val add_typecopy: bstring * string list -> typ -> (bstring * bstring) option |
19 -> theory -> (string * info) * theory |
19 -> theory -> (string * info) * theory |
20 val get_typecopies: theory -> string list |
20 val get_typecopies: theory -> string list |
21 val get_info: theory -> string -> info option |
21 val get_info: theory -> string -> info option |
22 val interpretation: (string -> theory -> theory) -> theory -> theory |
22 val interpretation: (string -> theory -> theory) -> theory -> theory |
23 val get_eq: theory -> string -> thm |
|
24 val print_typecopies: theory -> unit |
23 val print_typecopies: theory -> unit |
25 val setup: theory -> theory |
24 val setup: theory -> theory |
26 end; |
25 end; |
27 |
26 |
28 structure TypecopyPackage: TYPECOPY_PACKAGE = |
27 structure TypecopyPackage: TYPECOPY_PACKAGE = |
120 end; |
119 end; |
121 |
120 |
122 |
121 |
123 (* code generator setup *) |
122 (* code generator setup *) |
124 |
123 |
125 fun get_eq thy = #inject o the o get_info thy; |
|
126 |
|
127 fun add_typecopy_spec tyco thy = |
124 fun add_typecopy_spec tyco thy = |
128 let |
125 let |
129 val SOME { constr, proj_def, inject, ... } = get_info thy tyco; |
126 val SOME { constr, proj_def, inject, vs, ... } = get_info thy tyco; |
|
127 val sorts_eq = |
|
128 map (curry (Sorts.inter_sort (Sign.classes_of thy)) [HOLogic.class_eq] o snd) vs; |
130 val ty = Logic.unvarifyT (Sign.the_const_type thy constr); |
129 val ty = Logic.unvarifyT (Sign.the_const_type thy constr); |
131 in |
130 in |
132 thy |
131 thy |
133 |> Code.add_datatype [(constr, ty)] |
132 |> Code.add_datatype [(constr, ty)] |
134 |> Code.add_func proj_def |
133 |> Code.add_func proj_def |
|
134 |> Instance.instantiate ([tyco], sorts_eq, [HOLogic.class_eq]) (pair ()) |
|
135 ((K o K) (Class.intro_classes_tac [])) |
|
136 |> Code.add_func (CodeUnit.constrain_thm [HOLogic.class_eq] inject) |
135 end; |
137 end; |
136 |
138 |
137 val setup = |
139 val setup = |
138 TypecopyInterpretation.init |
140 TypecopyInterpretation.init |
139 #> interpretation add_typecopy_spec |
141 #> interpretation add_typecopy_spec |