author | haftmann |
Thu, 19 Feb 2015 11:53:36 +0100 | |
changeset 59557 | ebd8ecacfba6 |
parent 58959 | 1f195ed99941 |
child 59859 | f9d1442c70f3 |
permissions | -rw-r--r-- |
31723
f5cafe803b55
discontinued ancient tradition to suffix certain ML module names with "_package"
haftmann
parents:
30345
diff
changeset
|
1 |
(* Title: HOL/Tools/typedef.ML |
16458 | 2 |
Author: Markus Wenzel and Stefan Berghofer, TU Muenchen |
4866 | 3 |
|
21352 | 4 |
Gordon/HOL-style type definitions: create a new syntactic type |
35741 | 5 |
represented by a non-empty set. |
4866 | 6 |
*) |
7 |
||
31723
f5cafe803b55
discontinued ancient tradition to suffix certain ML module names with "_package"
haftmann
parents:
30345
diff
changeset
|
8 |
signature TYPEDEF = |
4866 | 9 |
sig |
19705 | 10 |
type info = |
36107 | 11 |
{rep_type: typ, abs_type: typ, Rep_name: string, Abs_name: string, axiom_name: string} * |
49833 | 12 |
{inhabited: thm, type_definition: thm, Rep: thm, Rep_inverse: thm, Abs_inverse: thm, |
13 |
Rep_inject: thm, Abs_inject: thm, Rep_cases: thm, Abs_cases: thm, |
|
29061
c67cc9402ba9
inhabitance goal is now stated in original form and result contracted --
wenzelm
parents:
29059
diff
changeset
|
14 |
Rep_induct: thm, Abs_induct: thm} |
35741 | 15 |
val transform_info: morphism -> info -> info |
16 |
val get_info: Proof.context -> string -> info list |
|
17 |
val get_info_global: theory -> string -> info list |
|
58662 | 18 |
val interpretation: (string -> local_theory -> local_theory) -> theory -> theory |
58239
1c5bc387bd4c
added flag to 'typedef' to allow concealed definitions
blanchet
parents:
56375
diff
changeset
|
19 |
val add_typedef: bool -> binding * (string * sort) list * mixfix -> |
58959 | 20 |
term -> (binding * binding) option -> (Proof.context -> tactic) -> local_theory -> |
21 |
(string * info) * local_theory |
|
58239
1c5bc387bd4c
added flag to 'typedef' to allow concealed definitions
blanchet
parents:
56375
diff
changeset
|
22 |
val add_typedef_global: bool -> binding * (string * sort) list * mixfix -> |
58959 | 23 |
term -> (binding * binding) option -> (Proof.context -> tactic) -> theory -> |
24 |
(string * info) * theory |
|
49835 | 25 |
val typedef: (binding * (string * sort) list * mixfix) * term * |
35741 | 26 |
(binding * binding) option -> local_theory -> Proof.state |
49835 | 27 |
val typedef_cmd: (binding * (string * string option) list * mixfix) * string * |
35741 | 28 |
(binding * binding) option -> local_theory -> Proof.state |
4866 | 29 |
end; |
30 |
||
31723
f5cafe803b55
discontinued ancient tradition to suffix certain ML module names with "_package"
haftmann
parents:
30345
diff
changeset
|
31 |
structure Typedef: TYPEDEF = |
4866 | 32 |
struct |
33 |
||
17922 | 34 |
(** type definitions **) |
35 |
||
36 |
(* theory data *) |
|
15259 | 37 |
|
19705 | 38 |
type info = |
35994
9cc3df9a606e
Typedef.info: separate global and local part, only the latter is transformed by morphisms;
wenzelm
parents:
35840
diff
changeset
|
39 |
(*global part*) |
36107 | 40 |
{rep_type: typ, abs_type: typ, Rep_name: string, Abs_name: string, axiom_name: string} * |
35741 | 41 |
(*local part*) |
49833 | 42 |
{inhabited: thm, type_definition: thm, Rep: thm, Rep_inverse: thm, Abs_inverse: thm, |
43 |
Rep_inject: thm, Abs_inject: thm, Rep_cases: thm, Abs_cases: thm, |
|
35994
9cc3df9a606e
Typedef.info: separate global and local part, only the latter is transformed by morphisms;
wenzelm
parents:
35840
diff
changeset
|
44 |
Rep_induct: thm, Abs_induct: thm}; |
19459 | 45 |
|
35741 | 46 |
fun transform_info phi (info: info) = |
47 |
let |
|
48 |
val thm = Morphism.thm phi; |
|
49833 | 49 |
val (global_info, {inhabited, type_definition, Rep, Rep_inverse, Abs_inverse, |
50 |
Rep_inject, Abs_inject, Rep_cases, Abs_cases, Rep_induct, Abs_induct}) = info; |
|
35741 | 51 |
in |
35994
9cc3df9a606e
Typedef.info: separate global and local part, only the latter is transformed by morphisms;
wenzelm
parents:
35840
diff
changeset
|
52 |
(global_info, |
9cc3df9a606e
Typedef.info: separate global and local part, only the latter is transformed by morphisms;
wenzelm
parents:
35840
diff
changeset
|
53 |
{inhabited = thm inhabited, type_definition = thm type_definition, |
49833 | 54 |
Rep = thm Rep, Rep_inverse = thm Rep_inverse, Abs_inverse = thm Abs_inverse, |
55 |
Rep_inject = thm Rep_inject, Abs_inject = thm Abs_inject, |
|
56 |
Rep_cases = thm Rep_cases, Abs_cases = thm Abs_cases, |
|
57 |
Rep_induct = thm Rep_induct, Abs_induct = thm Abs_induct}) |
|
35741 | 58 |
end; |
59 |
||
60 |
structure Data = Generic_Data |
|
22846 | 61 |
( |
35741 | 62 |
type T = info list Symtab.table; |
15259 | 63 |
val empty = Symtab.empty; |
16458 | 64 |
val extend = I; |
35741 | 65 |
fun merge data = Symtab.merge_list (K true) data; |
22846 | 66 |
); |
15259 | 67 |
|
35741 | 68 |
val get_info = Symtab.lookup_list o Data.get o Context.Proof; |
69 |
val get_info_global = Symtab.lookup_list o Data.get o Context.Theory; |
|
70 |
||
71 |
fun put_info name info = Data.map (Symtab.cons_list (name, info)); |
|
72 |
||
73 |
||
74 |
(* global interpretation *) |
|
75 |
||
58662 | 76 |
structure Typedef_Plugin = Plugin(type T = string); |
77 |
||
78 |
val typedef_plugin = Plugin_Name.declare_setup @{binding typedef}; |
|
56375
32e0da92c786
use same idiom as used for datatype 'size' function to name constants and theorems emerging from various type interpretations -- reduces the chances of name clashes on theory merges
blanchet
parents:
54883
diff
changeset
|
79 |
|
58662 | 80 |
fun interpretation f = |
81 |
Typedef_Plugin.interpretation typedef_plugin |
|
82 |
(fn name => fn lthy => |
|
83 |
lthy |
|
84 |
|> Local_Theory.map_naming |
|
85 |
(Name_Space.root_path #> Name_Space.add_path (Long_Name.qualifier name)) |
|
86 |
|> f name |
|
87 |
|> Local_Theory.restore_naming lthy); |
|
35741 | 88 |
|
89 |
||
90 |
(* primitive typedef axiomatization -- for fresh typedecl *) |
|
91 |
||
92 |
fun mk_inhabited A = |
|
93 |
let val T = HOLogic.dest_setT (Term.fastype_of A) |
|
94 |
in HOLogic.mk_Trueprop (HOLogic.exists_const T $ Abs ("x", T, HOLogic.mk_mem (Bound 0, A))) end; |
|
95 |
||
96 |
fun mk_typedef newT oldT RepC AbsC A = |
|
97 |
let |
|
98 |
val typedefC = |
|
99 |
Const (@{const_name type_definition}, |
|
100 |
(newT --> oldT) --> (oldT --> newT) --> HOLogic.mk_setT oldT --> HOLogic.boolT); |
|
101 |
in Logic.mk_implies (mk_inhabited A, HOLogic.mk_Trueprop (typedefC $ RepC $ AbsC $ A)) end; |
|
35134 | 102 |
|
42375
774df7c59508
report Name_Space.declare/define, relatively to context;
wenzelm
parents:
42361
diff
changeset
|
103 |
fun primitive_typedef typedef_name newT oldT Rep_name Abs_name A lthy = |
35741 | 104 |
let |
105 |
(* errors *) |
|
106 |
||
107 |
fun show_names pairs = commas_quote (map fst pairs); |
|
108 |
||
109 |
val lhs_tfrees = Term.add_tfreesT newT []; |
|
110 |
val rhs_tfrees = Term.add_tfreesT oldT []; |
|
111 |
val _ = |
|
112 |
(case fold (remove (op =)) lhs_tfrees rhs_tfrees of [] => () |
|
113 |
| extras => error ("Extra type variables in representing set: " ^ show_names extras)); |
|
114 |
||
115 |
val _ = |
|
116 |
(case Term.add_frees A [] of [] => [] |
|
117 |
| xs => error ("Illegal variables in representing set: " ^ show_names xs)); |
|
35134 | 118 |
|
35741 | 119 |
|
120 |
(* axiomatization *) |
|
121 |
||
42375
774df7c59508
report Name_Space.declare/define, relatively to context;
wenzelm
parents:
42361
diff
changeset
|
122 |
val ((RepC, AbsC), consts_lthy) = lthy |
774df7c59508
report Name_Space.declare/define, relatively to context;
wenzelm
parents:
42361
diff
changeset
|
123 |
|> Local_Theory.background_theory_result |
774df7c59508
report Name_Space.declare/define, relatively to context;
wenzelm
parents:
42361
diff
changeset
|
124 |
(Sign.declare_const lthy ((Rep_name, newT --> oldT), NoSyn) ##>> |
774df7c59508
report Name_Space.declare/define, relatively to context;
wenzelm
parents:
42361
diff
changeset
|
125 |
Sign.declare_const lthy ((Abs_name, oldT --> newT), NoSyn)); |
35741 | 126 |
|
127 |
val typedef_deps = Term.add_consts A []; |
|
128 |
||
42375
774df7c59508
report Name_Space.declare/define, relatively to context;
wenzelm
parents:
42361
diff
changeset
|
129 |
val ((axiom_name, axiom), axiom_lthy) = consts_lthy |
774df7c59508
report Name_Space.declare/define, relatively to context;
wenzelm
parents:
42361
diff
changeset
|
130 |
|> Local_Theory.background_theory_result |
774df7c59508
report Name_Space.declare/define, relatively to context;
wenzelm
parents:
42361
diff
changeset
|
131 |
(Thm.add_axiom consts_lthy (typedef_name, mk_typedef newT oldT RepC AbsC A) ##> |
774df7c59508
report Name_Space.declare/define, relatively to context;
wenzelm
parents:
42361
diff
changeset
|
132 |
Theory.add_deps consts_lthy "" (dest_Const RepC) typedef_deps ##> |
774df7c59508
report Name_Space.declare/define, relatively to context;
wenzelm
parents:
42361
diff
changeset
|
133 |
Theory.add_deps consts_lthy "" (dest_Const AbsC) typedef_deps); |
35741 | 134 |
|
42375
774df7c59508
report Name_Space.declare/define, relatively to context;
wenzelm
parents:
42361
diff
changeset
|
135 |
in ((RepC, AbsC, axiom_name, axiom), axiom_lthy) end; |
15259 | 136 |
|
137 |
||
6383 | 138 |
(* prepare_typedef *) |
139 |
||
58239
1c5bc387bd4c
added flag to 'typedef' to allow concealed definitions
blanchet
parents:
56375
diff
changeset
|
140 |
fun prepare_typedef conceal prep_term (name, raw_args, mx) raw_set opt_morphs lthy = |
4866 | 141 |
let |
58239
1c5bc387bd4c
added flag to 'typedef' to allow concealed definitions
blanchet
parents:
56375
diff
changeset
|
142 |
val concealed_name = name |> conceal ? Binding.conceal; |
30345 | 143 |
val bname = Binding.name_of name; |
4866 | 144 |
|
35741 | 145 |
|
146 |
(* rhs *) |
|
147 |
||
36153
1ac501e16a6a
replaced slightly odd Typedecl.predeclare_constraints by plain declaration of type arguments -- also avoid "recursive" declaration of type constructor, which can cause problems with sequential definitions B.foo = A.foo;
wenzelm
parents:
36107
diff
changeset
|
148 |
val tmp_ctxt = lthy |> fold (Variable.declare_typ o TFree) raw_args; |
1ac501e16a6a
replaced slightly odd Typedecl.predeclare_constraints by plain declaration of type arguments -- also avoid "recursive" declaration of type constructor, which can cause problems with sequential definitions B.foo = A.foo;
wenzelm
parents:
36107
diff
changeset
|
149 |
val set = prep_term tmp_ctxt raw_set; |
1ac501e16a6a
replaced slightly odd Typedecl.predeclare_constraints by plain declaration of type arguments -- also avoid "recursive" declaration of type constructor, which can cause problems with sequential definitions B.foo = A.foo;
wenzelm
parents:
36107
diff
changeset
|
150 |
val tmp_ctxt' = tmp_ctxt |> Variable.declare_term set; |
35836
9380fab5f4f7
eliminated slightly odd typedecl_wrt in favour of explicit predeclare_constraints;
wenzelm
parents:
35766
diff
changeset
|
151 |
|
21352 | 152 |
val setT = Term.fastype_of set; |
35741 | 153 |
val oldT = HOLogic.dest_setT setT handle TYPE _ => |
154 |
error ("Not a set type: " ^ quote (Syntax.string_of_typ lthy setT)); |
|
155 |
||
156 |
val goal = mk_inhabited set; |
|
42290
b1f544c84040
discontinued special treatment of structure Lexicon;
wenzelm
parents:
38757
diff
changeset
|
157 |
val goal_pat = mk_inhabited (Var (the_default (bname, 0) (Lexicon.read_variable bname), setT)); |
35741 | 158 |
|
159 |
||
160 |
(* lhs *) |
|
161 |
||
42361 | 162 |
val args = map (Proof_Context.check_tfree tmp_ctxt') raw_args; |
35741 | 163 |
val (newT, typedecl_lthy) = lthy |
49835 | 164 |
|> Typedecl.typedecl (name, args, mx) |
35741 | 165 |
||> Variable.declare_term set; |
166 |
||
56375
32e0da92c786
use same idiom as used for datatype 'size' function to name constants and theorems emerging from various type interpretations -- reduces the chances of name clashes on theory merges
blanchet
parents:
54883
diff
changeset
|
167 |
val Type (full_name, _) = newT; |
35741 | 168 |
|
169 |
||
170 |
(* axiomatization *) |
|
4866 | 171 |
|
30345 | 172 |
val (Rep_name, Abs_name) = |
173 |
(case opt_morphs of |
|
58239
1c5bc387bd4c
added flag to 'typedef' to allow concealed definitions
blanchet
parents:
56375
diff
changeset
|
174 |
NONE => (Binding.prefix_name "Rep_" concealed_name, |
1c5bc387bd4c
added flag to 'typedef' to allow concealed definitions
blanchet
parents:
56375
diff
changeset
|
175 |
Binding.prefix_name "Abs_" concealed_name) |
30345 | 176 |
| SOME morphs => morphs); |
10280 | 177 |
|
58239
1c5bc387bd4c
added flag to 'typedef' to allow concealed definitions
blanchet
parents:
56375
diff
changeset
|
178 |
val typedef_name = Binding.prefix_name "type_definition_" concealed_name; |
4866 | 179 |
|
49833 | 180 |
val ((RepC, AbsC, axiom_name, typedef), typedef_lthy) = typedecl_lthy |
181 |
|> primitive_typedef typedef_name newT oldT Rep_name Abs_name set; |
|
35741 | 182 |
|
183 |
val alias_lthy = typedef_lthy |
|
184 |
|> Local_Theory.const_alias Rep_name (#1 (Term.dest_Const RepC)) |
|
185 |
|> Local_Theory.const_alias Abs_name (#1 (Term.dest_Const AbsC)); |
|
6383 | 186 |
|
29056 | 187 |
|
35741 | 188 |
(* result *) |
4866 | 189 |
|
35741 | 190 |
fun note_qualify ((b, atts), th) = |
191 |
Local_Theory.note ((Binding.qualify false bname b, map (Attrib.internal o K) atts), [th]) |
|
192 |
#>> (fn (_, [th']) => th'); |
|
4866 | 193 |
|
35741 | 194 |
fun typedef_result inhabited lthy1 = |
195 |
let |
|
49833 | 196 |
val typedef' = inhabited RS typedef; |
54883
dd04a8b654fc
proper context for norm_hhf and derived operations;
wenzelm
parents:
49835
diff
changeset
|
197 |
fun make th = Goal.norm_result lthy1 (typedef' RS th); |
35741 | 198 |
val (((((((((((_, [type_definition]), Rep), Rep_inverse), Abs_inverse), Rep_inject), |
199 |
Abs_inject), Rep_cases), Abs_cases), Rep_induct), Abs_induct), lthy2) = lthy1 |
|
200 |
|> Local_Theory.note ((typedef_name, []), [typedef']) |
|
201 |
||>> note_qualify ((Rep_name, []), make @{thm type_definition.Rep}) |
|
202 |
||>> note_qualify ((Binding.suffix_name "_inverse" Rep_name, []), |
|
203 |
make @{thm type_definition.Rep_inverse}) |
|
204 |
||>> note_qualify ((Binding.suffix_name "_inverse" Abs_name, []), |
|
205 |
make @{thm type_definition.Abs_inverse}) |
|
206 |
||>> note_qualify ((Binding.suffix_name "_inject" Rep_name, []), |
|
207 |
make @{thm type_definition.Rep_inject}) |
|
208 |
||>> note_qualify ((Binding.suffix_name "_inject" Abs_name, []), |
|
209 |
make @{thm type_definition.Abs_inject}) |
|
210 |
||>> note_qualify ((Binding.suffix_name "_cases" Rep_name, |
|
211 |
[Rule_Cases.case_names [Binding.name_of Rep_name], Induct.cases_pred full_name]), |
|
212 |
make @{thm type_definition.Rep_cases}) |
|
213 |
||>> note_qualify ((Binding.suffix_name "_cases" Abs_name, |
|
49835 | 214 |
[Rule_Cases.case_names [Binding.name_of Abs_name], Induct.cases_type full_name]), |
35741 | 215 |
make @{thm type_definition.Abs_cases}) |
216 |
||>> note_qualify ((Binding.suffix_name "_induct" Rep_name, |
|
217 |
[Rule_Cases.case_names [Binding.name_of Rep_name], Induct.induct_pred full_name]), |
|
218 |
make @{thm type_definition.Rep_induct}) |
|
219 |
||>> note_qualify ((Binding.suffix_name "_induct" Abs_name, |
|
49835 | 220 |
[Rule_Cases.case_names [Binding.name_of Abs_name], Induct.induct_type full_name]), |
35741 | 221 |
make @{thm type_definition.Abs_induct}); |
4866 | 222 |
|
35994
9cc3df9a606e
Typedef.info: separate global and local part, only the latter is transformed by morphisms;
wenzelm
parents:
35840
diff
changeset
|
223 |
val info = |
36107 | 224 |
({rep_type = oldT, abs_type = newT, Rep_name = #1 (Term.dest_Const RepC), |
225 |
Abs_name = #1 (Term.dest_Const AbsC), axiom_name = axiom_name}, |
|
49833 | 226 |
{inhabited = inhabited, type_definition = type_definition, |
35741 | 227 |
Rep = Rep, Rep_inverse = Rep_inverse, Abs_inverse = Abs_inverse, |
228 |
Rep_inject = Rep_inject, Abs_inject = Abs_inject, Rep_cases = Rep_cases, |
|
35994
9cc3df9a606e
Typedef.info: separate global and local part, only the latter is transformed by morphisms;
wenzelm
parents:
35840
diff
changeset
|
229 |
Abs_cases = Abs_cases, Rep_induct = Rep_induct, Abs_induct = Abs_induct}); |
35741 | 230 |
in |
231 |
lthy2 |
|
45291
57cd50f98fdc
uniform Local_Theory.declaration with explicit params;
wenzelm
parents:
42381
diff
changeset
|
232 |
|> Local_Theory.declaration {syntax = false, pervasive = true} |
49835 | 233 |
(fn phi => put_info full_name (transform_info phi info)) |
58662 | 234 |
|> Typedef_Plugin.data Plugin_Name.default_filter full_name |
49835 | 235 |
|> pair (full_name, info) |
35741 | 236 |
end; |
11426
f280d4b29a2c
abtract non-emptiness statements (no longer use Eps);
wenzelm
parents:
10697
diff
changeset
|
237 |
|
35741 | 238 |
in ((goal, goal_pat, typedef_result), alias_lthy) end |
30345 | 239 |
handle ERROR msg => |
42381
309ec68442c6
added Binding.print convenience, which includes quote already;
wenzelm
parents:
42375
diff
changeset
|
240 |
cat_error msg ("The error(s) above occurred in typedef " ^ Binding.print name); |
4866 | 241 |
|
242 |
||
29056 | 243 |
(* add_typedef: tactic interface *) |
4866 | 244 |
|
58239
1c5bc387bd4c
added flag to 'typedef' to allow concealed definitions
blanchet
parents:
56375
diff
changeset
|
245 |
fun add_typedef conceal typ set opt_morphs tac lthy = |
6383 | 246 |
let |
35741 | 247 |
val ((goal, _, typedef_result), lthy') = |
58239
1c5bc387bd4c
added flag to 'typedef' to allow concealed definitions
blanchet
parents:
56375
diff
changeset
|
248 |
prepare_typedef conceal Syntax.check_term typ set opt_morphs lthy; |
35741 | 249 |
val inhabited = |
58959 | 250 |
Goal.prove lthy' [] [] goal (tac o #context) |
54883
dd04a8b654fc
proper context for norm_hhf and derived operations;
wenzelm
parents:
49835
diff
changeset
|
251 |
|> Goal.norm_result lthy' |> Thm.close_derivation; |
35741 | 252 |
in typedef_result inhabited lthy' end; |
253 |
||
58239
1c5bc387bd4c
added flag to 'typedef' to allow concealed definitions
blanchet
parents:
56375
diff
changeset
|
254 |
fun add_typedef_global conceal typ set opt_morphs tac = |
38388 | 255 |
Named_Target.theory_init |
58239
1c5bc387bd4c
added flag to 'typedef' to allow concealed definitions
blanchet
parents:
56375
diff
changeset
|
256 |
#> add_typedef conceal typ set opt_morphs tac |
35741 | 257 |
#> Local_Theory.exit_result_global (apsnd o transform_info); |
4866 | 258 |
|
17339 | 259 |
|
29056 | 260 |
(* typedef: proof interface *) |
6383 | 261 |
|
17339 | 262 |
local |
263 |
||
49835 | 264 |
fun gen_typedef prep_term prep_constraint ((b, raw_args, mx), set, opt_morphs) lthy = |
11822 | 265 |
let |
35840
01d7c4ba9050
allow sort constraints in HOL/typedef and related HOLCF variants;
wenzelm
parents:
35836
diff
changeset
|
266 |
val args = map (apsnd (prep_constraint lthy)) raw_args; |
35741 | 267 |
val ((goal, goal_pat, typedef_result), lthy') = |
58239
1c5bc387bd4c
added flag to 'typedef' to allow concealed definitions
blanchet
parents:
56375
diff
changeset
|
268 |
prepare_typedef false prep_term (b, args, mx) set opt_morphs lthy; |
35741 | 269 |
fun after_qed [[th]] = snd o typedef_result th; |
36323
655e2d74de3a
modernized naming conventions of main Isar proof elements;
wenzelm
parents:
36153
diff
changeset
|
270 |
in Proof.theorem NONE after_qed [[(goal, [goal_pat])]] lthy' end; |
17339 | 271 |
|
272 |
in |
|
6383 | 273 |
|
35840
01d7c4ba9050
allow sort constraints in HOL/typedef and related HOLCF variants;
wenzelm
parents:
35836
diff
changeset
|
274 |
val typedef = gen_typedef Syntax.check_term (K I); |
01d7c4ba9050
allow sort constraints in HOL/typedef and related HOLCF variants;
wenzelm
parents:
35836
diff
changeset
|
275 |
val typedef_cmd = gen_typedef Syntax.read_term Typedecl.read_constraint; |
17339 | 276 |
|
19705 | 277 |
end; |
15259 | 278 |
|
279 |
||
280 |
||
6383 | 281 |
(** outer syntax **) |
282 |
||
24867 | 283 |
val _ = |
46961
5c6955f487e5
outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents:
46949
diff
changeset
|
284 |
Outer_Syntax.local_theory_to_proof @{command_spec "typedef"} |
5c6955f487e5
outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents:
46949
diff
changeset
|
285 |
"HOL type definition (requires non-emptiness proof)" |
49835 | 286 |
(Parse.type_args_constrained -- Parse.binding -- Parse.opt_mixfix -- |
287 |
(@{keyword "="} |-- Parse.term) -- |
|
288 |
Scan.option (@{keyword "morphisms"} |-- Parse.!!! (Parse.binding -- Parse.binding)) |
|
289 |
>> (fn ((((vs, t), mx), A), morphs) => fn lthy => typedef_cmd ((t, vs, mx), A, morphs) lthy)); |
|
6357 | 290 |
|
29056 | 291 |
end; |
292 |