equal
deleted
inserted
replaced
5 *) |
5 *) |
6 |
6 |
7 signature TYPEDECL = |
7 signature TYPEDECL = |
8 sig |
8 sig |
9 val read_constraint: Proof.context -> string option -> sort |
9 val read_constraint: Proof.context -> string option -> sort |
10 val predeclare_constraints: binding * (string * sort) list * mixfix -> |
10 val basic_typedecl: binding * int * mixfix -> local_theory -> string * local_theory |
11 local_theory -> string * local_theory |
|
12 val typedecl: binding * (string * sort) list * mixfix -> local_theory -> typ * local_theory |
11 val typedecl: binding * (string * sort) list * mixfix -> local_theory -> typ * local_theory |
13 val typedecl_global: binding * (string * sort) list * mixfix -> theory -> typ * theory |
12 val typedecl_global: binding * (string * sort) list * mixfix -> theory -> typ * theory |
14 end; |
13 end; |
15 |
14 |
16 structure Typedecl: TYPEDECL = |
15 structure Typedecl: TYPEDECL = |
17 struct |
16 struct |
|
17 |
|
18 (* constraints *) |
|
19 |
|
20 fun read_constraint _ NONE = dummyS |
|
21 | read_constraint ctxt (SOME s) = Syntax.read_sort ctxt s; |
|
22 |
18 |
23 |
19 (* primitives *) |
24 (* primitives *) |
20 |
25 |
21 fun object_logic_arity name thy = |
26 fun object_logic_arity name thy = |
22 (case Object_Logic.get_base_sort thy of |
27 (case Object_Logic.get_base_sort thy of |
31 |> Local_Theory.type_alias b name |
36 |> Local_Theory.type_alias b name |
32 |> pair name |
37 |> pair name |
33 end; |
38 end; |
34 |
39 |
35 |
40 |
36 (* syntactic version -- useful for internalizing additional types/terms beforehand *) |
41 (* regular typedecl -- without dependencies on type parameters of the context *) |
37 |
|
38 fun read_constraint _ NONE = dummyS |
|
39 | read_constraint ctxt (SOME s) = Syntax.read_sort ctxt s; |
|
40 |
|
41 fun predeclare_constraints (b, raw_args, mx) = |
|
42 basic_typedecl (b, length raw_args, mx) ##> |
|
43 fold (Variable.declare_constraints o Logic.mk_type o TFree) raw_args; |
|
44 |
|
45 |
|
46 (* regular version -- without dependencies on type parameters of the context *) |
|
47 |
42 |
48 fun typedecl (b, raw_args, mx) lthy = |
43 fun typedecl (b, raw_args, mx) lthy = |
49 let |
44 let |
50 fun err msg = error (msg ^ " in type declaration " ^ quote (Binding.str_of b)); |
45 fun err msg = error (msg ^ " in type declaration " ^ quote (Binding.str_of b)); |
51 |
46 |