author | paulson |
Mon, 21 Dec 2009 16:50:28 +0000 | |
changeset 34156 | 3a7937841585 |
parent 33941 | 40408e6b833b |
child 34272 | 95df5e6dd41c |
permissions | -rw-r--r-- |
256 | 1 |
(* Title: Pure/type.ML |
14790
0d984ee030a1
major cleanup of tsig datastructures and extend/merge operations; fixes old bugs in classes/arities code; proper treatment of nonterminals and syntax-only types;
wenzelm
parents:
13666
diff
changeset
|
2 |
Author: Tobias Nipkow, Lawrence C Paulson, and Markus Wenzel |
0 | 3 |
|
14790
0d984ee030a1
major cleanup of tsig datastructures and extend/merge operations; fixes old bugs in classes/arities code; proper treatment of nonterminals and syntax-only types;
wenzelm
parents:
13666
diff
changeset
|
4 |
Type signatures and certified types, special treatment of type vars, |
0d984ee030a1
major cleanup of tsig datastructures and extend/merge operations; fixes old bugs in classes/arities code; proper treatment of nonterminals and syntax-only types;
wenzelm
parents:
13666
diff
changeset
|
5 |
matching and unification of types, extend and merge type signatures. |
0 | 6 |
*) |
7 |
||
8 |
signature TYPE = |
|
2964 | 9 |
sig |
14790
0d984ee030a1
major cleanup of tsig datastructures and extend/merge operations; fixes old bugs in classes/arities code; proper treatment of nonterminals and syntax-only types;
wenzelm
parents:
13666
diff
changeset
|
10 |
(*type signatures and certified types*) |
0d984ee030a1
major cleanup of tsig datastructures and extend/merge operations; fixes old bugs in classes/arities code; proper treatment of nonterminals and syntax-only types;
wenzelm
parents:
13666
diff
changeset
|
11 |
datatype decl = |
0d984ee030a1
major cleanup of tsig datastructures and extend/merge operations; fixes old bugs in classes/arities code; proper treatment of nonterminals and syntax-only types;
wenzelm
parents:
13666
diff
changeset
|
12 |
LogicalType of int | |
14989 | 13 |
Abbreviation of string list * typ * bool | |
14790
0d984ee030a1
major cleanup of tsig datastructures and extend/merge operations; fixes old bugs in classes/arities code; proper treatment of nonterminals and syntax-only types;
wenzelm
parents:
13666
diff
changeset
|
14 |
Nonterminal |
0d984ee030a1
major cleanup of tsig datastructures and extend/merge operations; fixes old bugs in classes/arities code; proper treatment of nonterminals and syntax-only types;
wenzelm
parents:
13666
diff
changeset
|
15 |
type tsig |
0d984ee030a1
major cleanup of tsig datastructures and extend/merge operations; fixes old bugs in classes/arities code; proper treatment of nonterminals and syntax-only types;
wenzelm
parents:
13666
diff
changeset
|
16 |
val rep_tsig: tsig -> |
33095
bbd52d2f8696
renamed NameSpace to Name_Space -- also to emphasize its subtle change in semantics;
wenzelm
parents:
33094
diff
changeset
|
17 |
{classes: Name_Space.T * Sorts.algebra, |
14790
0d984ee030a1
major cleanup of tsig datastructures and extend/merge operations; fixes old bugs in classes/arities code; proper treatment of nonterminals and syntax-only types;
wenzelm
parents:
13666
diff
changeset
|
18 |
default: sort, |
33173
b8ca12f6681a
eliminated obsolete tags for types/consts -- now handled via name space, in strongly typed fashion;
wenzelm
parents:
33097
diff
changeset
|
19 |
types: decl Name_Space.table, |
26641 | 20 |
log_types: string list} |
14790
0d984ee030a1
major cleanup of tsig datastructures and extend/merge operations; fixes old bugs in classes/arities code; proper treatment of nonterminals and syntax-only types;
wenzelm
parents:
13666
diff
changeset
|
21 |
val empty_tsig: tsig |
33941 | 22 |
val build_tsig: (Name_Space.T * Sorts.algebra) * sort * decl Name_Space.table -> tsig |
14790
0d984ee030a1
major cleanup of tsig datastructures and extend/merge operations; fixes old bugs in classes/arities code; proper treatment of nonterminals and syntax-only types;
wenzelm
parents:
13666
diff
changeset
|
23 |
val defaultS: tsig -> sort |
0d984ee030a1
major cleanup of tsig datastructures and extend/merge operations; fixes old bugs in classes/arities code; proper treatment of nonterminals and syntax-only types;
wenzelm
parents:
13666
diff
changeset
|
24 |
val logical_types: tsig -> string list |
0d984ee030a1
major cleanup of tsig datastructures and extend/merge operations; fixes old bugs in classes/arities code; proper treatment of nonterminals and syntax-only types;
wenzelm
parents:
13666
diff
changeset
|
25 |
val eq_sort: tsig -> sort * sort -> bool |
0d984ee030a1
major cleanup of tsig datastructures and extend/merge operations; fixes old bugs in classes/arities code; proper treatment of nonterminals and syntax-only types;
wenzelm
parents:
13666
diff
changeset
|
26 |
val subsort: tsig -> sort * sort -> bool |
0d984ee030a1
major cleanup of tsig datastructures and extend/merge operations; fixes old bugs in classes/arities code; proper treatment of nonterminals and syntax-only types;
wenzelm
parents:
13666
diff
changeset
|
27 |
val of_sort: tsig -> typ * sort -> bool |
19464 | 28 |
val inter_sort: tsig -> sort * sort -> sort |
14790
0d984ee030a1
major cleanup of tsig datastructures and extend/merge operations; fixes old bugs in classes/arities code; proper treatment of nonterminals and syntax-only types;
wenzelm
parents:
13666
diff
changeset
|
29 |
val cert_class: tsig -> class -> class |
0d984ee030a1
major cleanup of tsig datastructures and extend/merge operations; fixes old bugs in classes/arities code; proper treatment of nonterminals and syntax-only types;
wenzelm
parents:
13666
diff
changeset
|
30 |
val cert_sort: tsig -> sort -> sort |
31946
99ac0321cd47
witness_sorts: proper type witnesses for hyps, not invented "'hyp" variables;
wenzelm
parents:
30343
diff
changeset
|
31 |
val witness_sorts: tsig -> (typ * sort) list -> sort list -> (typ * sort) list |
24274
cb9236269af1
type mode: models certification mode (default, syntax, abbrev);
wenzelm
parents:
23655
diff
changeset
|
32 |
type mode |
cb9236269af1
type mode: models certification mode (default, syntax, abbrev);
wenzelm
parents:
23655
diff
changeset
|
33 |
val mode_default: mode |
cb9236269af1
type mode: models certification mode (default, syntax, abbrev);
wenzelm
parents:
23655
diff
changeset
|
34 |
val mode_syntax: mode |
cb9236269af1
type mode: models certification mode (default, syntax, abbrev);
wenzelm
parents:
23655
diff
changeset
|
35 |
val mode_abbrev: mode |
24484 | 36 |
val get_mode: Proof.context -> mode |
37 |
val set_mode: mode -> Proof.context -> Proof.context |
|
38 |
val restore_mode: Proof.context -> Proof.context -> Proof.context |
|
24274
cb9236269af1
type mode: models certification mode (default, syntax, abbrev);
wenzelm
parents:
23655
diff
changeset
|
39 |
val cert_typ_mode: mode -> tsig -> typ -> typ |
14993 | 40 |
val cert_typ: tsig -> typ -> typ |
19464 | 41 |
val arity_number: tsig -> string -> int |
42 |
val arity_sorts: Pretty.pp -> tsig -> string -> sort -> sort list |
|
14790
0d984ee030a1
major cleanup of tsig datastructures and extend/merge operations; fixes old bugs in classes/arities code; proper treatment of nonterminals and syntax-only types;
wenzelm
parents:
13666
diff
changeset
|
43 |
|
0d984ee030a1
major cleanup of tsig datastructures and extend/merge operations; fixes old bugs in classes/arities code; proper treatment of nonterminals and syntax-only types;
wenzelm
parents:
13666
diff
changeset
|
44 |
(*special treatment of type vars*) |
0d984ee030a1
major cleanup of tsig datastructures and extend/merge operations; fixes old bugs in classes/arities code; proper treatment of nonterminals and syntax-only types;
wenzelm
parents:
13666
diff
changeset
|
45 |
val strip_sorts: typ -> typ |
621 | 46 |
val no_tvars: typ -> typ |
21116 | 47 |
val varify: (string * sort) list -> term -> ((string * sort) * indexname) list * term |
33832 | 48 |
val legacy_freeze_thaw_type: typ -> typ * (typ -> typ) |
49 |
val legacy_freeze_type: typ -> typ |
|
50 |
val legacy_freeze_thaw: term -> term * (term -> term) |
|
51 |
val legacy_freeze: term -> term |
|
2964 | 52 |
|
14790
0d984ee030a1
major cleanup of tsig datastructures and extend/merge operations; fixes old bugs in classes/arities code; proper treatment of nonterminals and syntax-only types;
wenzelm
parents:
13666
diff
changeset
|
53 |
(*matching and unification*) |
2964 | 54 |
exception TYPE_MATCH |
25324 | 55 |
type tyenv = (sort * typ) Vartab.table |
26327 | 56 |
val lookup: tyenv -> indexname * sort -> typ option |
32648
143e0b0a6b33
Correct chasing of type variable instantiations during type unification.
paulson
parents:
32030
diff
changeset
|
57 |
val devar: tyenv -> typ -> typ |
16946 | 58 |
val typ_match: tsig -> typ * typ -> tyenv -> tyenv |
14790
0d984ee030a1
major cleanup of tsig datastructures and extend/merge operations; fixes old bugs in classes/arities code; proper treatment of nonterminals and syntax-only types;
wenzelm
parents:
13666
diff
changeset
|
59 |
val typ_instance: tsig -> typ * typ -> bool |
16946 | 60 |
val raw_match: typ * typ -> tyenv -> tyenv |
19694 | 61 |
val raw_matches: typ list * typ list -> tyenv -> tyenv |
16946 | 62 |
val raw_instance: typ * typ -> bool |
2964 | 63 |
exception TUNIFY |
16946 | 64 |
val unify: tsig -> typ * typ -> tyenv * int -> tyenv * int |
65 |
val raw_unify: typ * typ -> tyenv -> tyenv |
|
19696 | 66 |
val raw_unifys: typ list * typ list -> tyenv -> tyenv |
17804 | 67 |
val could_unify: typ * typ -> bool |
19696 | 68 |
val could_unifys: typ list * typ list -> bool |
16650 | 69 |
val eq_type: tyenv -> typ * typ -> bool |
0 | 70 |
|
14790
0d984ee030a1
major cleanup of tsig datastructures and extend/merge operations; fixes old bugs in classes/arities code; proper treatment of nonterminals and syntax-only types;
wenzelm
parents:
13666
diff
changeset
|
71 |
(*extend and merge type signatures*) |
33095
bbd52d2f8696
renamed NameSpace to Name_Space -- also to emphasize its subtle change in semantics;
wenzelm
parents:
33094
diff
changeset
|
72 |
val add_class: Pretty.pp -> Name_Space.naming -> binding * class list -> tsig -> tsig |
26669 | 73 |
val hide_class: bool -> string -> tsig -> tsig |
14790
0d984ee030a1
major cleanup of tsig datastructures and extend/merge operations; fixes old bugs in classes/arities code; proper treatment of nonterminals and syntax-only types;
wenzelm
parents:
13666
diff
changeset
|
74 |
val set_defsort: sort -> tsig -> tsig |
33173
b8ca12f6681a
eliminated obsolete tags for types/consts -- now handled via name space, in strongly typed fashion;
wenzelm
parents:
33097
diff
changeset
|
75 |
val add_type: Name_Space.naming -> binding * int -> tsig -> tsig |
b8ca12f6681a
eliminated obsolete tags for types/consts -- now handled via name space, in strongly typed fashion;
wenzelm
parents:
33097
diff
changeset
|
76 |
val add_abbrev: Name_Space.naming -> binding * string list * typ -> tsig -> tsig |
b8ca12f6681a
eliminated obsolete tags for types/consts -- now handled via name space, in strongly typed fashion;
wenzelm
parents:
33097
diff
changeset
|
77 |
val add_nonterminal: Name_Space.naming -> binding -> tsig -> tsig |
26669 | 78 |
val hide_type: bool -> string -> tsig -> tsig |
19515
9f650083da65
build classes/arities: refer to operations in sorts.ML;
wenzelm
parents:
19464
diff
changeset
|
79 |
val add_arity: Pretty.pp -> arity -> tsig -> tsig |
9f650083da65
build classes/arities: refer to operations in sorts.ML;
wenzelm
parents:
19464
diff
changeset
|
80 |
val add_classrel: Pretty.pp -> class * class -> tsig -> tsig |
14830
faa4865ba1ce
removed norm_typ; improved output; refer to Pretty.pp;
wenzelm
parents:
14790
diff
changeset
|
81 |
val merge_tsigs: Pretty.pp -> tsig * tsig -> tsig |
2964 | 82 |
end; |
83 |
||
84 |
structure Type: TYPE = |
|
0 | 85 |
struct |
86 |
||
14790
0d984ee030a1
major cleanup of tsig datastructures and extend/merge operations; fixes old bugs in classes/arities code; proper treatment of nonterminals and syntax-only types;
wenzelm
parents:
13666
diff
changeset
|
87 |
(** type signatures and certified types **) |
2964 | 88 |
|
14790
0d984ee030a1
major cleanup of tsig datastructures and extend/merge operations; fixes old bugs in classes/arities code; proper treatment of nonterminals and syntax-only types;
wenzelm
parents:
13666
diff
changeset
|
89 |
(* type declarations *) |
0d984ee030a1
major cleanup of tsig datastructures and extend/merge operations; fixes old bugs in classes/arities code; proper treatment of nonterminals and syntax-only types;
wenzelm
parents:
13666
diff
changeset
|
90 |
|
0d984ee030a1
major cleanup of tsig datastructures and extend/merge operations; fixes old bugs in classes/arities code; proper treatment of nonterminals and syntax-only types;
wenzelm
parents:
13666
diff
changeset
|
91 |
datatype decl = |
0d984ee030a1
major cleanup of tsig datastructures and extend/merge operations; fixes old bugs in classes/arities code; proper treatment of nonterminals and syntax-only types;
wenzelm
parents:
13666
diff
changeset
|
92 |
LogicalType of int | |
14989 | 93 |
Abbreviation of string list * typ * bool | |
14790
0d984ee030a1
major cleanup of tsig datastructures and extend/merge operations; fixes old bugs in classes/arities code; proper treatment of nonterminals and syntax-only types;
wenzelm
parents:
13666
diff
changeset
|
94 |
Nonterminal; |
0d984ee030a1
major cleanup of tsig datastructures and extend/merge operations; fixes old bugs in classes/arities code; proper treatment of nonterminals and syntax-only types;
wenzelm
parents:
13666
diff
changeset
|
95 |
|
0d984ee030a1
major cleanup of tsig datastructures and extend/merge operations; fixes old bugs in classes/arities code; proper treatment of nonterminals and syntax-only types;
wenzelm
parents:
13666
diff
changeset
|
96 |
|
0d984ee030a1
major cleanup of tsig datastructures and extend/merge operations; fixes old bugs in classes/arities code; proper treatment of nonterminals and syntax-only types;
wenzelm
parents:
13666
diff
changeset
|
97 |
(* type tsig *) |
0d984ee030a1
major cleanup of tsig datastructures and extend/merge operations; fixes old bugs in classes/arities code; proper treatment of nonterminals and syntax-only types;
wenzelm
parents:
13666
diff
changeset
|
98 |
|
0d984ee030a1
major cleanup of tsig datastructures and extend/merge operations; fixes old bugs in classes/arities code; proper treatment of nonterminals and syntax-only types;
wenzelm
parents:
13666
diff
changeset
|
99 |
datatype tsig = |
0d984ee030a1
major cleanup of tsig datastructures and extend/merge operations; fixes old bugs in classes/arities code; proper treatment of nonterminals and syntax-only types;
wenzelm
parents:
13666
diff
changeset
|
100 |
TSig of { |
33095
bbd52d2f8696
renamed NameSpace to Name_Space -- also to emphasize its subtle change in semantics;
wenzelm
parents:
33094
diff
changeset
|
101 |
classes: Name_Space.T * Sorts.algebra, (*order-sorted algebra of type classes*) |
16370
033d890fe91f
name space of classes and types maintained in tsig;
wenzelm
parents:
16340
diff
changeset
|
102 |
default: sort, (*default sort on input*) |
33173
b8ca12f6681a
eliminated obsolete tags for types/consts -- now handled via name space, in strongly typed fashion;
wenzelm
parents:
33097
diff
changeset
|
103 |
types: decl Name_Space.table, (*declared types*) |
26641 | 104 |
log_types: string list}; (*logical types sorted by number of arguments*) |
14790
0d984ee030a1
major cleanup of tsig datastructures and extend/merge operations; fixes old bugs in classes/arities code; proper treatment of nonterminals and syntax-only types;
wenzelm
parents:
13666
diff
changeset
|
105 |
|
0d984ee030a1
major cleanup of tsig datastructures and extend/merge operations; fixes old bugs in classes/arities code; proper treatment of nonterminals and syntax-only types;
wenzelm
parents:
13666
diff
changeset
|
106 |
fun rep_tsig (TSig comps) = comps; |
0d984ee030a1
major cleanup of tsig datastructures and extend/merge operations; fixes old bugs in classes/arities code; proper treatment of nonterminals and syntax-only types;
wenzelm
parents:
13666
diff
changeset
|
107 |
|
26641 | 108 |
fun make_tsig (classes, default, types, log_types) = |
109 |
TSig {classes = classes, default = default, types = types, log_types = log_types}; |
|
14790
0d984ee030a1
major cleanup of tsig datastructures and extend/merge operations; fixes old bugs in classes/arities code; proper treatment of nonterminals and syntax-only types;
wenzelm
parents:
13666
diff
changeset
|
110 |
|
33094
ef0d77b1e687
eliminated separate stamp -- NameSpace.define/merge etc. ensure uniqueness already;
wenzelm
parents:
32784
diff
changeset
|
111 |
fun build_tsig (classes, default, types) = |
14790
0d984ee030a1
major cleanup of tsig datastructures and extend/merge operations; fixes old bugs in classes/arities code; proper treatment of nonterminals and syntax-only types;
wenzelm
parents:
13666
diff
changeset
|
112 |
let |
0d984ee030a1
major cleanup of tsig datastructures and extend/merge operations; fixes old bugs in classes/arities code; proper treatment of nonterminals and syntax-only types;
wenzelm
parents:
13666
diff
changeset
|
113 |
val log_types = |
33173
b8ca12f6681a
eliminated obsolete tags for types/consts -- now handled via name space, in strongly typed fashion;
wenzelm
parents:
33097
diff
changeset
|
114 |
Symtab.fold (fn (c, LogicalType n) => cons (c, n) | _ => I) (snd types) [] |
33094
ef0d77b1e687
eliminated separate stamp -- NameSpace.define/merge etc. ensure uniqueness already;
wenzelm
parents:
32784
diff
changeset
|
115 |
|> Library.sort (int_ord o pairself snd) |> map fst; |
ef0d77b1e687
eliminated separate stamp -- NameSpace.define/merge etc. ensure uniqueness already;
wenzelm
parents:
32784
diff
changeset
|
116 |
in make_tsig (classes, default, types, log_types) end; |
14790
0d984ee030a1
major cleanup of tsig datastructures and extend/merge operations; fixes old bugs in classes/arities code; proper treatment of nonterminals and syntax-only types;
wenzelm
parents:
13666
diff
changeset
|
117 |
|
26641 | 118 |
fun map_tsig f (TSig {classes, default, types, log_types = _}) = |
19642 | 119 |
build_tsig (f (classes, default, types)); |
14790
0d984ee030a1
major cleanup of tsig datastructures and extend/merge operations; fixes old bugs in classes/arities code; proper treatment of nonterminals and syntax-only types;
wenzelm
parents:
13666
diff
changeset
|
120 |
|
16370
033d890fe91f
name space of classes and types maintained in tsig;
wenzelm
parents:
16340
diff
changeset
|
121 |
val empty_tsig = |
33096 | 122 |
build_tsig ((Name_Space.empty "class", Sorts.empty_algebra), [], Name_Space.empty_table "type"); |
14790
0d984ee030a1
major cleanup of tsig datastructures and extend/merge operations; fixes old bugs in classes/arities code; proper treatment of nonterminals and syntax-only types;
wenzelm
parents:
13666
diff
changeset
|
123 |
|
0d984ee030a1
major cleanup of tsig datastructures and extend/merge operations; fixes old bugs in classes/arities code; proper treatment of nonterminals and syntax-only types;
wenzelm
parents:
13666
diff
changeset
|
124 |
|
0d984ee030a1
major cleanup of tsig datastructures and extend/merge operations; fixes old bugs in classes/arities code; proper treatment of nonterminals and syntax-only types;
wenzelm
parents:
13666
diff
changeset
|
125 |
(* classes and sorts *) |
0d984ee030a1
major cleanup of tsig datastructures and extend/merge operations; fixes old bugs in classes/arities code; proper treatment of nonterminals and syntax-only types;
wenzelm
parents:
13666
diff
changeset
|
126 |
|
0d984ee030a1
major cleanup of tsig datastructures and extend/merge operations; fixes old bugs in classes/arities code; proper treatment of nonterminals and syntax-only types;
wenzelm
parents:
13666
diff
changeset
|
127 |
fun defaultS (TSig {default, ...}) = default; |
0d984ee030a1
major cleanup of tsig datastructures and extend/merge operations; fixes old bugs in classes/arities code; proper treatment of nonterminals and syntax-only types;
wenzelm
parents:
13666
diff
changeset
|
128 |
fun logical_types (TSig {log_types, ...}) = log_types; |
0d984ee030a1
major cleanup of tsig datastructures and extend/merge operations; fixes old bugs in classes/arities code; proper treatment of nonterminals and syntax-only types;
wenzelm
parents:
13666
diff
changeset
|
129 |
|
16370
033d890fe91f
name space of classes and types maintained in tsig;
wenzelm
parents:
16340
diff
changeset
|
130 |
fun eq_sort (TSig {classes, ...}) = Sorts.sort_eq (#2 classes); |
033d890fe91f
name space of classes and types maintained in tsig;
wenzelm
parents:
16340
diff
changeset
|
131 |
fun subsort (TSig {classes, ...}) = Sorts.sort_le (#2 classes); |
19642 | 132 |
fun of_sort (TSig {classes, ...}) = Sorts.of_sort (#2 classes); |
19464 | 133 |
fun inter_sort (TSig {classes, ...}) = Sorts.inter_sort (#2 classes); |
14790
0d984ee030a1
major cleanup of tsig datastructures and extend/merge operations; fixes old bugs in classes/arities code; proper treatment of nonterminals and syntax-only types;
wenzelm
parents:
13666
diff
changeset
|
134 |
|
19642 | 135 |
fun cert_class (TSig {classes, ...}) = Sorts.certify_class (#2 classes); |
136 |
fun cert_sort (TSig {classes, ...}) = Sorts.certify_sort (#2 classes); |
|
19515
9f650083da65
build classes/arities: refer to operations in sorts.ML;
wenzelm
parents:
19464
diff
changeset
|
137 |
|
32784 | 138 |
fun witness_sorts (TSig {classes, log_types, ...}) = |
19642 | 139 |
Sorts.witness_sorts (#2 classes) log_types; |
14790
0d984ee030a1
major cleanup of tsig datastructures and extend/merge operations; fixes old bugs in classes/arities code; proper treatment of nonterminals and syntax-only types;
wenzelm
parents:
13666
diff
changeset
|
140 |
|
0d984ee030a1
major cleanup of tsig datastructures and extend/merge operations; fixes old bugs in classes/arities code; proper treatment of nonterminals and syntax-only types;
wenzelm
parents:
13666
diff
changeset
|
141 |
|
24274
cb9236269af1
type mode: models certification mode (default, syntax, abbrev);
wenzelm
parents:
23655
diff
changeset
|
142 |
(* certification mode *) |
cb9236269af1
type mode: models certification mode (default, syntax, abbrev);
wenzelm
parents:
23655
diff
changeset
|
143 |
|
cb9236269af1
type mode: models certification mode (default, syntax, abbrev);
wenzelm
parents:
23655
diff
changeset
|
144 |
datatype mode = Mode of {normalize: bool, logical: bool}; |
cb9236269af1
type mode: models certification mode (default, syntax, abbrev);
wenzelm
parents:
23655
diff
changeset
|
145 |
|
cb9236269af1
type mode: models certification mode (default, syntax, abbrev);
wenzelm
parents:
23655
diff
changeset
|
146 |
val mode_default = Mode {normalize = true, logical = true}; |
cb9236269af1
type mode: models certification mode (default, syntax, abbrev);
wenzelm
parents:
23655
diff
changeset
|
147 |
val mode_syntax = Mode {normalize = true, logical = false}; |
cb9236269af1
type mode: models certification mode (default, syntax, abbrev);
wenzelm
parents:
23655
diff
changeset
|
148 |
val mode_abbrev = Mode {normalize = false, logical = false}; |
cb9236269af1
type mode: models certification mode (default, syntax, abbrev);
wenzelm
parents:
23655
diff
changeset
|
149 |
|
33519 | 150 |
structure Mode = Proof_Data |
24484 | 151 |
( |
152 |
type T = mode; |
|
153 |
fun init _ = mode_default; |
|
154 |
); |
|
155 |
||
156 |
val get_mode = Mode.get; |
|
157 |
fun set_mode mode = Mode.map (K mode); |
|
158 |
fun restore_mode ctxt = set_mode (get_mode ctxt); |
|
159 |
||
24274
cb9236269af1
type mode: models certification mode (default, syntax, abbrev);
wenzelm
parents:
23655
diff
changeset
|
160 |
|
27313 | 161 |
(* lookup types *) |
162 |
||
163 |
fun undecl_type c = "Undeclared type constructor: " ^ quote c; |
|
164 |
||
33094
ef0d77b1e687
eliminated separate stamp -- NameSpace.define/merge etc. ensure uniqueness already;
wenzelm
parents:
32784
diff
changeset
|
165 |
fun lookup_type (TSig {types = (_, types), ...}) = Symtab.lookup types; |
27313 | 166 |
|
167 |
||
14790
0d984ee030a1
major cleanup of tsig datastructures and extend/merge operations; fixes old bugs in classes/arities code; proper treatment of nonterminals and syntax-only types;
wenzelm
parents:
13666
diff
changeset
|
168 |
(* certified types *) |
0d984ee030a1
major cleanup of tsig datastructures and extend/merge operations; fixes old bugs in classes/arities code; proper treatment of nonterminals and syntax-only types;
wenzelm
parents:
13666
diff
changeset
|
169 |
|
0d984ee030a1
major cleanup of tsig datastructures and extend/merge operations; fixes old bugs in classes/arities code; proper treatment of nonterminals and syntax-only types;
wenzelm
parents:
13666
diff
changeset
|
170 |
fun bad_nargs t = "Bad number of arguments for type constructor: " ^ quote t; |
14830
faa4865ba1ce
removed norm_typ; improved output; refer to Pretty.pp;
wenzelm
parents:
14790
diff
changeset
|
171 |
|
14998 | 172 |
local |
173 |
||
174 |
fun inst_typ env (Type (c, Ts)) = Type (c, map (inst_typ env) Ts) |
|
18957 | 175 |
| inst_typ env (T as TFree (x, _)) = the_default T (AList.lookup (op =) env x) |
14998 | 176 |
| inst_typ _ T = T; |
177 |
||
24274
cb9236269af1
type mode: models certification mode (default, syntax, abbrev);
wenzelm
parents:
23655
diff
changeset
|
178 |
in |
cb9236269af1
type mode: models certification mode (default, syntax, abbrev);
wenzelm
parents:
23655
diff
changeset
|
179 |
|
cb9236269af1
type mode: models certification mode (default, syntax, abbrev);
wenzelm
parents:
23655
diff
changeset
|
180 |
fun cert_typ_mode (Mode {normalize, logical}) tsig ty = |
14790
0d984ee030a1
major cleanup of tsig datastructures and extend/merge operations; fixes old bugs in classes/arities code; proper treatment of nonterminals and syntax-only types;
wenzelm
parents:
13666
diff
changeset
|
181 |
let |
0d984ee030a1
major cleanup of tsig datastructures and extend/merge operations; fixes old bugs in classes/arities code; proper treatment of nonterminals and syntax-only types;
wenzelm
parents:
13666
diff
changeset
|
182 |
fun err msg = raise TYPE (msg, [ty], []); |
0d984ee030a1
major cleanup of tsig datastructures and extend/merge operations; fixes old bugs in classes/arities code; proper treatment of nonterminals and syntax-only types;
wenzelm
parents:
13666
diff
changeset
|
183 |
|
24274
cb9236269af1
type mode: models certification mode (default, syntax, abbrev);
wenzelm
parents:
23655
diff
changeset
|
184 |
val check_logical = |
cb9236269af1
type mode: models certification mode (default, syntax, abbrev);
wenzelm
parents:
23655
diff
changeset
|
185 |
if logical then fn c => err ("Illegal occurrence of syntactic type: " ^ quote c) |
cb9236269af1
type mode: models certification mode (default, syntax, abbrev);
wenzelm
parents:
23655
diff
changeset
|
186 |
else fn _ => (); |
14989 | 187 |
|
188 |
fun cert (T as Type (c, Ts)) = |
|
189 |
let |
|
190 |
val Ts' = map cert Ts; |
|
191 |
fun nargs n = if length Ts <> n then err (bad_nargs c) else (); |
|
192 |
in |
|
27302 | 193 |
(case lookup_type tsig c of |
33173
b8ca12f6681a
eliminated obsolete tags for types/consts -- now handled via name space, in strongly typed fashion;
wenzelm
parents:
33097
diff
changeset
|
194 |
SOME (LogicalType n) => (nargs n; Type (c, Ts')) |
b8ca12f6681a
eliminated obsolete tags for types/consts -- now handled via name space, in strongly typed fashion;
wenzelm
parents:
33097
diff
changeset
|
195 |
| SOME (Abbreviation (vs, U, syn)) => |
24274
cb9236269af1
type mode: models certification mode (default, syntax, abbrev);
wenzelm
parents:
23655
diff
changeset
|
196 |
(nargs (length vs); |
cb9236269af1
type mode: models certification mode (default, syntax, abbrev);
wenzelm
parents:
23655
diff
changeset
|
197 |
if syn then check_logical c else (); |
14993 | 198 |
if normalize then inst_typ (vs ~~ Ts') U |
14989 | 199 |
else Type (c, Ts')) |
33173
b8ca12f6681a
eliminated obsolete tags for types/consts -- now handled via name space, in strongly typed fashion;
wenzelm
parents:
33097
diff
changeset
|
200 |
| SOME Nonterminal => (nargs 0; check_logical c; T) |
15531 | 201 |
| NONE => err (undecl_type c)) |
14790
0d984ee030a1
major cleanup of tsig datastructures and extend/merge operations; fixes old bugs in classes/arities code; proper treatment of nonterminals and syntax-only types;
wenzelm
parents:
13666
diff
changeset
|
202 |
end |
19515
9f650083da65
build classes/arities: refer to operations in sorts.ML;
wenzelm
parents:
19464
diff
changeset
|
203 |
| cert (TFree (x, S)) = TFree (x, cert_sort tsig S) |
14989 | 204 |
| cert (TVar (xi as (_, i), S)) = |
14993 | 205 |
if i < 0 then |
206 |
err ("Malformed type variable: " ^ quote (Term.string_of_vname xi)) |
|
19515
9f650083da65
build classes/arities: refer to operations in sorts.ML;
wenzelm
parents:
19464
diff
changeset
|
207 |
else TVar (xi, cert_sort tsig S); |
14790
0d984ee030a1
major cleanup of tsig datastructures and extend/merge operations; fixes old bugs in classes/arities code; proper treatment of nonterminals and syntax-only types;
wenzelm
parents:
13666
diff
changeset
|
208 |
|
14989 | 209 |
val ty' = cert ty; |
14993 | 210 |
in if ty = ty' then ty else ty' end; (*avoid copying of already normal type*) |
14830
faa4865ba1ce
removed norm_typ; improved output; refer to Pretty.pp;
wenzelm
parents:
14790
diff
changeset
|
211 |
|
24274
cb9236269af1
type mode: models certification mode (default, syntax, abbrev);
wenzelm
parents:
23655
diff
changeset
|
212 |
val cert_typ = cert_typ_mode mode_default; |
14790
0d984ee030a1
major cleanup of tsig datastructures and extend/merge operations; fixes old bugs in classes/arities code; proper treatment of nonterminals and syntax-only types;
wenzelm
parents:
13666
diff
changeset
|
213 |
|
14998 | 214 |
end; |
215 |
||
14790
0d984ee030a1
major cleanup of tsig datastructures and extend/merge operations; fixes old bugs in classes/arities code; proper treatment of nonterminals and syntax-only types;
wenzelm
parents:
13666
diff
changeset
|
216 |
|
19464 | 217 |
(* type arities *) |
218 |
||
27302 | 219 |
fun arity_number tsig a = |
220 |
(case lookup_type tsig a of |
|
33173
b8ca12f6681a
eliminated obsolete tags for types/consts -- now handled via name space, in strongly typed fashion;
wenzelm
parents:
33097
diff
changeset
|
221 |
SOME (LogicalType n) => n |
19464 | 222 |
| _ => error (undecl_type a)); |
223 |
||
224 |
fun arity_sorts _ tsig a [] = replicate (arity_number tsig a) [] |
|
19642 | 225 |
| arity_sorts pp (TSig {classes, ...}) a S = Sorts.mg_domain (#2 classes) a S |
26641 | 226 |
handle Sorts.CLASS_ERROR err => error (Sorts.class_error pp err); |
19464 | 227 |
|
228 |
||
14790
0d984ee030a1
major cleanup of tsig datastructures and extend/merge operations; fixes old bugs in classes/arities code; proper treatment of nonterminals and syntax-only types;
wenzelm
parents:
13666
diff
changeset
|
229 |
|
0d984ee030a1
major cleanup of tsig datastructures and extend/merge operations; fixes old bugs in classes/arities code; proper treatment of nonterminals and syntax-only types;
wenzelm
parents:
13666
diff
changeset
|
230 |
(** special treatment of type vars **) |
0d984ee030a1
major cleanup of tsig datastructures and extend/merge operations; fixes old bugs in classes/arities code; proper treatment of nonterminals and syntax-only types;
wenzelm
parents:
13666
diff
changeset
|
231 |
|
0d984ee030a1
major cleanup of tsig datastructures and extend/merge operations; fixes old bugs in classes/arities code; proper treatment of nonterminals and syntax-only types;
wenzelm
parents:
13666
diff
changeset
|
232 |
(* strip_sorts *) |
0d984ee030a1
major cleanup of tsig datastructures and extend/merge operations; fixes old bugs in classes/arities code; proper treatment of nonterminals and syntax-only types;
wenzelm
parents:
13666
diff
changeset
|
233 |
|
0d984ee030a1
major cleanup of tsig datastructures and extend/merge operations; fixes old bugs in classes/arities code; proper treatment of nonterminals and syntax-only types;
wenzelm
parents:
13666
diff
changeset
|
234 |
fun strip_sorts (Type (a, Ts)) = Type (a, map strip_sorts Ts) |
0d984ee030a1
major cleanup of tsig datastructures and extend/merge operations; fixes old bugs in classes/arities code; proper treatment of nonterminals and syntax-only types;
wenzelm
parents:
13666
diff
changeset
|
235 |
| strip_sorts (TFree (x, _)) = TFree (x, []) |
0d984ee030a1
major cleanup of tsig datastructures and extend/merge operations; fixes old bugs in classes/arities code; proper treatment of nonterminals and syntax-only types;
wenzelm
parents:
13666
diff
changeset
|
236 |
| strip_sorts (TVar (xi, _)) = TVar (xi, []); |
0d984ee030a1
major cleanup of tsig datastructures and extend/merge operations; fixes old bugs in classes/arities code; proper treatment of nonterminals and syntax-only types;
wenzelm
parents:
13666
diff
changeset
|
237 |
|
0d984ee030a1
major cleanup of tsig datastructures and extend/merge operations; fixes old bugs in classes/arities code; proper treatment of nonterminals and syntax-only types;
wenzelm
parents:
13666
diff
changeset
|
238 |
|
0d984ee030a1
major cleanup of tsig datastructures and extend/merge operations; fixes old bugs in classes/arities code; proper treatment of nonterminals and syntax-only types;
wenzelm
parents:
13666
diff
changeset
|
239 |
(* no_tvars *) |
621 | 240 |
|
241 |
fun no_tvars T = |
|
29275
9fa69e3858d6
moved old add_type_XXX, add_term_XXX etc. to structure OldTerm;
wenzelm
parents:
29269
diff
changeset
|
242 |
(case Term.add_tvarsT T [] of [] => T |
12501 | 243 |
| vs => raise TYPE ("Illegal schematic type variable(s): " ^ |
29275
9fa69e3858d6
moved old add_type_XXX, add_term_XXX etc. to structure OldTerm;
wenzelm
parents:
29269
diff
changeset
|
244 |
commas_quote (map (Term.string_of_vname o #1) (rev vs)), [T], [])); |
621 | 245 |
|
7641 | 246 |
|
19806 | 247 |
(* varify *) |
621 | 248 |
|
21116 | 249 |
fun varify fixed t = |
621 | 250 |
let |
19305 | 251 |
val fs = Term.fold_types (Term.fold_atyps |
252 |
(fn TFree v => if member (op =) fixed v then I else insert (op =) v | _ => I)) t []; |
|
29260 | 253 |
val used = Name.context |
254 |
|> fold_types (fold_atyps (fn TVar ((a, _), _) => Name.declare a | _ => I)) t; |
|
255 |
val fmap = fs ~~ map (rpair 0) (#1 (Name.variants (map fst fs) used)); |
|
32784 | 256 |
fun thaw (f as (_, S)) = |
17184 | 257 |
(case AList.lookup (op =) fmap f of |
15531 | 258 |
NONE => TFree f |
16946 | 259 |
| SOME xi => TVar (xi, S)); |
21116 | 260 |
in (fmap, map_types (map_type_tfree thaw) t) end; |
2964 | 261 |
|
262 |
||
7641 | 263 |
(* freeze_thaw: freeze TVars in a term; return the "thaw" inverse *) |
3411
163f8f4a42d7
Removal of freeze_vars and thaw_vars. New freeze_thaw
paulson
parents:
3175
diff
changeset
|
264 |
|
7641 | 265 |
local |
266 |
||
16289 | 267 |
fun new_name (ix, (pairs, used)) = |
20071
8f3e1ddb50e6
replaced Term.variant(list) by Name.variant(_list);
wenzelm
parents:
19806
diff
changeset
|
268 |
let val v = Name.variant used (string_of_indexname ix) |
16289 | 269 |
in ((ix, v) :: pairs, v :: used) end; |
621 | 270 |
|
16289 | 271 |
fun freeze_one alist (ix, sort) = |
17184 | 272 |
TFree (the (AList.lookup (op =) alist ix), sort) |
15531 | 273 |
handle Option => |
3790 | 274 |
raise TYPE ("Failure during freezing of ?" ^ string_of_indexname ix, [], []); |
2964 | 275 |
|
17184 | 276 |
fun thaw_one alist (a, sort) = TVar (the (AList.lookup (op =) alist a), sort) |
16289 | 277 |
handle Option => TFree (a, sort); |
416 | 278 |
|
10495 | 279 |
in |
280 |
||
33832 | 281 |
fun legacy_freeze_thaw_type T = |
7641 | 282 |
let |
29275
9fa69e3858d6
moved old add_type_XXX, add_term_XXX etc. to structure OldTerm;
wenzelm
parents:
29269
diff
changeset
|
283 |
val used = OldTerm.add_typ_tfree_names (T, []) |
9fa69e3858d6
moved old add_type_XXX, add_term_XXX etc. to structure OldTerm;
wenzelm
parents:
29269
diff
changeset
|
284 |
and tvars = map #1 (OldTerm.add_typ_tvars (T, [])); |
23178 | 285 |
val (alist, _) = List.foldr new_name ([], used) tvars; |
7641 | 286 |
in (map_type_tvar (freeze_one alist) T, map_type_tfree (thaw_one (map swap alist))) end; |
287 |
||
33832 | 288 |
val legacy_freeze_type = #1 o legacy_freeze_thaw_type; |
16289 | 289 |
|
33832 | 290 |
fun legacy_freeze_thaw t = |
7641 | 291 |
let |
29275
9fa69e3858d6
moved old add_type_XXX, add_term_XXX etc. to structure OldTerm;
wenzelm
parents:
29269
diff
changeset
|
292 |
val used = OldTerm.it_term_types OldTerm.add_typ_tfree_names (t, []) |
9fa69e3858d6
moved old add_type_XXX, add_term_XXX etc. to structure OldTerm;
wenzelm
parents:
29269
diff
changeset
|
293 |
and tvars = map #1 (OldTerm.it_term_types OldTerm.add_typ_tvars (t, [])); |
23178 | 294 |
val (alist, _) = List.foldr new_name ([], used) tvars; |
7641 | 295 |
in |
296 |
(case alist of |
|
297 |
[] => (t, fn x => x) (*nothing to do!*) |
|
20548
8ef25fe585a8
renamed Term.map_term_types to Term.map_types (cf. Term.fold_types);
wenzelm
parents:
20071
diff
changeset
|
298 |
| _ => (map_types (map_type_tvar (freeze_one alist)) t, |
8ef25fe585a8
renamed Term.map_term_types to Term.map_types (cf. Term.fold_types);
wenzelm
parents:
20071
diff
changeset
|
299 |
map_types (map_type_tfree (thaw_one (map swap alist))))) |
7641 | 300 |
end; |
301 |
||
33832 | 302 |
val legacy_freeze = #1 o legacy_freeze_thaw; |
16289 | 303 |
|
7641 | 304 |
end; |
305 |
||
256 | 306 |
|
307 |
||
14790
0d984ee030a1
major cleanup of tsig datastructures and extend/merge operations; fixes old bugs in classes/arities code; proper treatment of nonterminals and syntax-only types;
wenzelm
parents:
13666
diff
changeset
|
308 |
(** matching and unification of types **) |
8899 | 309 |
|
15797 | 310 |
type tyenv = (sort * typ) Vartab.table; |
256 | 311 |
|
15797 | 312 |
fun tvar_clash ixn S S' = raise TYPE ("Type variable " ^ |
313 |
quote (Term.string_of_vname ixn) ^ " has two distinct sorts", |
|
314 |
[TVar (ixn, S), TVar (ixn, S')], []); |
|
0 | 315 |
|
26327 | 316 |
fun lookup tye (ixn, S) = |
17412 | 317 |
(case Vartab.lookup tye ixn of |
15797 | 318 |
NONE => NONE |
16289 | 319 |
| SOME (S', T) => if S = S' then SOME T else tvar_clash ixn S S'); |
320 |
||
0 | 321 |
|
14790
0d984ee030a1
major cleanup of tsig datastructures and extend/merge operations; fixes old bugs in classes/arities code; proper treatment of nonterminals and syntax-only types;
wenzelm
parents:
13666
diff
changeset
|
322 |
(* matching *) |
0 | 323 |
|
2964 | 324 |
exception TYPE_MATCH; |
0 | 325 |
|
16946 | 326 |
fun typ_match tsig = |
2964 | 327 |
let |
16340 | 328 |
fun match (TVar (v, S), T) subs = |
26327 | 329 |
(case lookup subs (v, S) of |
15531 | 330 |
NONE => |
17412 | 331 |
if of_sort tsig (T, S) then Vartab.update_new (v, (S, T)) subs |
14993 | 332 |
else raise TYPE_MATCH |
15531 | 333 |
| SOME U => if U = T then subs else raise TYPE_MATCH) |
16340 | 334 |
| match (Type (a, Ts), Type (b, Us)) subs = |
2964 | 335 |
if a <> b then raise TYPE_MATCH |
16885 | 336 |
else matches (Ts, Us) subs |
16340 | 337 |
| match (TFree x, TFree y) subs = |
2964 | 338 |
if x = y then subs else raise TYPE_MATCH |
16885 | 339 |
| match _ _ = raise TYPE_MATCH |
340 |
and matches (T :: Ts, U :: Us) subs = matches (Ts, Us) (match (T, U) subs) |
|
341 |
| matches _ subs = subs; |
|
16946 | 342 |
in match end; |
0 | 343 |
|
14790
0d984ee030a1
major cleanup of tsig datastructures and extend/merge operations; fixes old bugs in classes/arities code; proper treatment of nonterminals and syntax-only types;
wenzelm
parents:
13666
diff
changeset
|
344 |
fun typ_instance tsig (T, U) = |
16946 | 345 |
(typ_match tsig (U, T) Vartab.empty; true) handle TYPE_MATCH => false; |
346 |
||
347 |
(*purely structural matching*) |
|
348 |
fun raw_match (TVar (v, S), T) subs = |
|
26327 | 349 |
(case lookup subs (v, S) of |
17412 | 350 |
NONE => Vartab.update_new (v, (S, T)) subs |
16946 | 351 |
| SOME U => if U = T then subs else raise TYPE_MATCH) |
352 |
| raw_match (Type (a, Ts), Type (b, Us)) subs = |
|
353 |
if a <> b then raise TYPE_MATCH |
|
354 |
else raw_matches (Ts, Us) subs |
|
355 |
| raw_match (TFree x, TFree y) subs = |
|
356 |
if x = y then subs else raise TYPE_MATCH |
|
357 |
| raw_match _ _ = raise TYPE_MATCH |
|
358 |
and raw_matches (T :: Ts, U :: Us) subs = raw_matches (Ts, Us) (raw_match (T, U) subs) |
|
19694 | 359 |
| raw_matches ([], []) subs = subs |
360 |
| raw_matches _ _ = raise TYPE_MATCH; |
|
16946 | 361 |
|
362 |
fun raw_instance (T, U) = |
|
363 |
(raw_match (U, T) Vartab.empty; true) handle TYPE_MATCH => false; |
|
2964 | 364 |
|
0 | 365 |
|
14790
0d984ee030a1
major cleanup of tsig datastructures and extend/merge operations; fixes old bugs in classes/arities code; proper treatment of nonterminals and syntax-only types;
wenzelm
parents:
13666
diff
changeset
|
366 |
(* unification *) |
2964 | 367 |
|
0 | 368 |
exception TUNIFY; |
369 |
||
26641 | 370 |
(*occurs check*) |
2964 | 371 |
fun occurs v tye = |
372 |
let |
|
373 |
fun occ (Type (_, Ts)) = exists occ Ts |
|
374 |
| occ (TFree _) = false |
|
15797 | 375 |
| occ (TVar (w, S)) = |
29269
5c25a2012975
moved term order operations to structure TermOrd (cf. Pure/term_ord.ML);
wenzelm
parents:
29260
diff
changeset
|
376 |
Term.eq_ix (v, w) orelse |
26327 | 377 |
(case lookup tye (w, S) of |
15531 | 378 |
NONE => false |
379 |
| SOME U => occ U); |
|
0 | 380 |
in occ end; |
381 |
||
14790
0d984ee030a1
major cleanup of tsig datastructures and extend/merge operations; fixes old bugs in classes/arities code; proper treatment of nonterminals and syntax-only types;
wenzelm
parents:
13666
diff
changeset
|
382 |
(*chase variable assignments; if devar returns a type var then it must be unassigned*) |
16885 | 383 |
fun devar tye (T as TVar v) = |
26327 | 384 |
(case lookup tye v of |
16885 | 385 |
SOME U => devar tye U |
15531 | 386 |
| NONE => T) |
32784 | 387 |
| devar _ T = T; |
0 | 388 |
|
17804 | 389 |
(*order-sorted unification*) |
32784 | 390 |
fun unify (TSig {classes = (_, classes), ...}) TU (tyenv, maxidx) = |
2964 | 391 |
let |
32738 | 392 |
val tyvar_count = Unsynchronized.ref maxidx; |
393 |
fun gen_tyvar S = TVar ((Name.aT, Unsynchronized.inc tyvar_count), S); |
|
2964 | 394 |
|
19642 | 395 |
fun mg_domain a S = Sorts.mg_domain classes a S |
396 |
handle Sorts.CLASS_ERROR _ => raise TUNIFY; |
|
2964 | 397 |
|
16885 | 398 |
fun meet (_, []) tye = tye |
399 |
| meet (TVar (xi, S'), S) tye = |
|
14790
0d984ee030a1
major cleanup of tsig datastructures and extend/merge operations; fixes old bugs in classes/arities code; proper treatment of nonterminals and syntax-only types;
wenzelm
parents:
13666
diff
changeset
|
400 |
if Sorts.sort_le classes (S', S) then tye |
17412 | 401 |
else Vartab.update_new |
17221 | 402 |
(xi, (S', gen_tyvar (Sorts.inter_sort classes (S', S)))) tye |
16885 | 403 |
| meet (TFree (_, S'), S) tye = |
14790
0d984ee030a1
major cleanup of tsig datastructures and extend/merge operations; fixes old bugs in classes/arities code; proper treatment of nonterminals and syntax-only types;
wenzelm
parents:
13666
diff
changeset
|
404 |
if Sorts.sort_le classes (S', S) then tye |
2964 | 405 |
else raise TUNIFY |
16885 | 406 |
| meet (Type (a, Ts), S) tye = meets (Ts, mg_domain a S) tye |
407 |
and meets (T :: Ts, S :: Ss) tye = meets (Ts, Ss) (meet (devar tye T, S) tye) |
|
408 |
| meets _ tye = tye; |
|
2964 | 409 |
|
16885 | 410 |
fun unif (ty1, ty2) tye = |
411 |
(case (devar tye ty1, devar tye ty2) of |
|
2964 | 412 |
(T as TVar (v, S1), U as TVar (w, S2)) => |
29269
5c25a2012975
moved term order operations to structure TermOrd (cf. Pure/term_ord.ML);
wenzelm
parents:
29260
diff
changeset
|
413 |
if Term.eq_ix (v, w) then |
15797 | 414 |
if S1 = S2 then tye else tvar_clash v S1 S2 |
14790
0d984ee030a1
major cleanup of tsig datastructures and extend/merge operations; fixes old bugs in classes/arities code; proper treatment of nonterminals and syntax-only types;
wenzelm
parents:
13666
diff
changeset
|
415 |
else if Sorts.sort_le classes (S1, S2) then |
17412 | 416 |
Vartab.update_new (w, (S2, T)) tye |
14790
0d984ee030a1
major cleanup of tsig datastructures and extend/merge operations; fixes old bugs in classes/arities code; proper treatment of nonterminals and syntax-only types;
wenzelm
parents:
13666
diff
changeset
|
417 |
else if Sorts.sort_le classes (S2, S1) then |
17412 | 418 |
Vartab.update_new (v, (S1, U)) tye |
2964 | 419 |
else |
14790
0d984ee030a1
major cleanup of tsig datastructures and extend/merge operations; fixes old bugs in classes/arities code; proper treatment of nonterminals and syntax-only types;
wenzelm
parents:
13666
diff
changeset
|
420 |
let val S = gen_tyvar (Sorts.inter_sort classes (S1, S2)) in |
17412 | 421 |
Vartab.update_new (v, (S1, S)) (Vartab.update_new (w, (S2, S)) tye) |
2964 | 422 |
end |
423 |
| (TVar (v, S), T) => |
|
424 |
if occurs v tye T then raise TUNIFY |
|
17412 | 425 |
else meet (T, S) (Vartab.update_new (v, (S, T)) tye) |
2964 | 426 |
| (T, TVar (v, S)) => |
427 |
if occurs v tye T then raise TUNIFY |
|
17412 | 428 |
else meet (T, S) (Vartab.update_new (v, (S, T)) tye) |
2964 | 429 |
| (Type (a, Ts), Type (b, Us)) => |
430 |
if a <> b then raise TUNIFY |
|
16885 | 431 |
else unifs (Ts, Us) tye |
432 |
| (T, U) => if T = U then tye else raise TUNIFY) |
|
433 |
and unifs (T :: Ts, U :: Us) tye = unifs (Ts, Us) (unif (T, U) tye) |
|
434 |
| unifs _ tye = tye; |
|
435 |
in (unif TU tyenv, ! tyvar_count) end; |
|
0 | 436 |
|
16946 | 437 |
(*purely structural unification*) |
438 |
fun raw_unify (ty1, ty2) tye = |
|
439 |
(case (devar tye ty1, devar tye ty2) of |
|
32784 | 440 |
(T as TVar (v, S1), TVar (w, S2)) => |
29269
5c25a2012975
moved term order operations to structure TermOrd (cf. Pure/term_ord.ML);
wenzelm
parents:
29260
diff
changeset
|
441 |
if Term.eq_ix (v, w) then |
16946 | 442 |
if S1 = S2 then tye else tvar_clash v S1 S2 |
17412 | 443 |
else Vartab.update_new (w, (S2, T)) tye |
16946 | 444 |
| (TVar (v, S), T) => |
445 |
if occurs v tye T then raise TUNIFY |
|
17412 | 446 |
else Vartab.update_new (v, (S, T)) tye |
16946 | 447 |
| (T, TVar (v, S)) => |
448 |
if occurs v tye T then raise TUNIFY |
|
17412 | 449 |
else Vartab.update_new (v, (S, T)) tye |
16946 | 450 |
| (Type (a, Ts), Type (b, Us)) => |
451 |
if a <> b then raise TUNIFY |
|
452 |
else raw_unifys (Ts, Us) tye |
|
453 |
| (T, U) => if T = U then tye else raise TUNIFY) |
|
454 |
and raw_unifys (T :: Ts, U :: Us) tye = raw_unifys (Ts, Us) (raw_unify (T, U) tye) |
|
19696 | 455 |
| raw_unifys ([], []) tye = tye |
456 |
| raw_unifys _ _ = raise TUNIFY; |
|
16946 | 457 |
|
17804 | 458 |
(*fast unification filter*) |
459 |
fun could_unify (Type (a, Ts), Type (b, Us)) = a = b andalso could_unifys (Ts, Us) |
|
460 |
| could_unify (TFree (a, _), TFree (b, _)) = a = b |
|
461 |
| could_unify (TVar _, _) = true |
|
462 |
| could_unify (_, TVar _) = true |
|
463 |
| could_unify _ = false |
|
464 |
and could_unifys (T :: Ts, U :: Us) = could_unify (T, U) andalso could_unifys (Ts, Us) |
|
19696 | 465 |
| could_unifys ([], []) = true |
466 |
| could_unifys _ = false; |
|
450 | 467 |
|
17804 | 468 |
|
469 |
(*equality with respect to a type environment*) |
|
32030 | 470 |
fun equal_type tye (T, T') = |
16885 | 471 |
(case (devar tye T, devar tye T') of |
16650 | 472 |
(Type (s, Ts), Type (s', Ts')) => |
32030 | 473 |
s = s' andalso ListPair.all (equal_type tye) (Ts, Ts') |
16650 | 474 |
| (U, U') => U = U'); |
475 |
||
32030 | 476 |
fun eq_type tye = |
477 |
if Vartab.is_empty tye then op = else equal_type tye; |
|
478 |
||
450 | 479 |
|
0 | 480 |
|
14790
0d984ee030a1
major cleanup of tsig datastructures and extend/merge operations; fixes old bugs in classes/arities code; proper treatment of nonterminals and syntax-only types;
wenzelm
parents:
13666
diff
changeset
|
481 |
(** extend and merge type signatures **) |
0d984ee030a1
major cleanup of tsig datastructures and extend/merge operations; fixes old bugs in classes/arities code; proper treatment of nonterminals and syntax-only types;
wenzelm
parents:
13666
diff
changeset
|
482 |
|
0d984ee030a1
major cleanup of tsig datastructures and extend/merge operations; fixes old bugs in classes/arities code; proper treatment of nonterminals and syntax-only types;
wenzelm
parents:
13666
diff
changeset
|
483 |
(* classes *) |
0d984ee030a1
major cleanup of tsig datastructures and extend/merge operations; fixes old bugs in classes/arities code; proper treatment of nonterminals and syntax-only types;
wenzelm
parents:
13666
diff
changeset
|
484 |
|
16370
033d890fe91f
name space of classes and types maintained in tsig;
wenzelm
parents:
16340
diff
changeset
|
485 |
fun add_class pp naming (c, cs) tsig = |
19642 | 486 |
tsig |> map_tsig (fn ((space, classes), default, types) => |
16370
033d890fe91f
name space of classes and types maintained in tsig;
wenzelm
parents:
16340
diff
changeset
|
487 |
let |
033d890fe91f
name space of classes and types maintained in tsig;
wenzelm
parents:
16340
diff
changeset
|
488 |
val cs' = map (cert_class tsig) cs |
033d890fe91f
name space of classes and types maintained in tsig;
wenzelm
parents:
16340
diff
changeset
|
489 |
handle TYPE (msg, _, _) => error msg; |
33095
bbd52d2f8696
renamed NameSpace to Name_Space -- also to emphasize its subtle change in semantics;
wenzelm
parents:
33094
diff
changeset
|
490 |
val (c', space') = space |> Name_Space.declare true naming c; |
19515
9f650083da65
build classes/arities: refer to operations in sorts.ML;
wenzelm
parents:
19464
diff
changeset
|
491 |
val classes' = classes |> Sorts.add_class pp (c', cs'); |
19642 | 492 |
in ((space', classes'), default, types) end); |
14790
0d984ee030a1
major cleanup of tsig datastructures and extend/merge operations; fixes old bugs in classes/arities code; proper treatment of nonterminals and syntax-only types;
wenzelm
parents:
13666
diff
changeset
|
493 |
|
26669 | 494 |
fun hide_class fully c = map_tsig (fn ((space, classes), default, types) => |
33095
bbd52d2f8696
renamed NameSpace to Name_Space -- also to emphasize its subtle change in semantics;
wenzelm
parents:
33094
diff
changeset
|
495 |
((Name_Space.hide fully c space, classes), default, types)); |
16370
033d890fe91f
name space of classes and types maintained in tsig;
wenzelm
parents:
16340
diff
changeset
|
496 |
|
14790
0d984ee030a1
major cleanup of tsig datastructures and extend/merge operations; fixes old bugs in classes/arities code; proper treatment of nonterminals and syntax-only types;
wenzelm
parents:
13666
diff
changeset
|
497 |
|
19515
9f650083da65
build classes/arities: refer to operations in sorts.ML;
wenzelm
parents:
19464
diff
changeset
|
498 |
(* arities *) |
9f650083da65
build classes/arities: refer to operations in sorts.ML;
wenzelm
parents:
19464
diff
changeset
|
499 |
|
19642 | 500 |
fun add_arity pp (t, Ss, S) tsig = tsig |> map_tsig (fn ((space, classes), default, types) => |
19515
9f650083da65
build classes/arities: refer to operations in sorts.ML;
wenzelm
parents:
19464
diff
changeset
|
501 |
let |
9f650083da65
build classes/arities: refer to operations in sorts.ML;
wenzelm
parents:
19464
diff
changeset
|
502 |
val _ = |
27302 | 503 |
(case lookup_type tsig t of |
33173
b8ca12f6681a
eliminated obsolete tags for types/consts -- now handled via name space, in strongly typed fashion;
wenzelm
parents:
33097
diff
changeset
|
504 |
SOME (LogicalType n) => if length Ss <> n then error (bad_nargs t) else () |
33094
ef0d77b1e687
eliminated separate stamp -- NameSpace.define/merge etc. ensure uniqueness already;
wenzelm
parents:
32784
diff
changeset
|
505 |
| SOME _ => error ("Logical type constructor expected: " ^ quote t) |
19515
9f650083da65
build classes/arities: refer to operations in sorts.ML;
wenzelm
parents:
19464
diff
changeset
|
506 |
| NONE => error (undecl_type t)); |
9f650083da65
build classes/arities: refer to operations in sorts.ML;
wenzelm
parents:
19464
diff
changeset
|
507 |
val (Ss', S') = (map (cert_sort tsig) Ss, cert_sort tsig S) |
9f650083da65
build classes/arities: refer to operations in sorts.ML;
wenzelm
parents:
19464
diff
changeset
|
508 |
handle TYPE (msg, _, _) => error msg; |
19642 | 509 |
val classes' = classes |> Sorts.add_arities pp ((t, map (fn c' => (c', Ss')) S')); |
510 |
in ((space, classes'), default, types) end); |
|
19515
9f650083da65
build classes/arities: refer to operations in sorts.ML;
wenzelm
parents:
19464
diff
changeset
|
511 |
|
9f650083da65
build classes/arities: refer to operations in sorts.ML;
wenzelm
parents:
19464
diff
changeset
|
512 |
|
9f650083da65
build classes/arities: refer to operations in sorts.ML;
wenzelm
parents:
19464
diff
changeset
|
513 |
(* classrel *) |
9f650083da65
build classes/arities: refer to operations in sorts.ML;
wenzelm
parents:
19464
diff
changeset
|
514 |
|
9f650083da65
build classes/arities: refer to operations in sorts.ML;
wenzelm
parents:
19464
diff
changeset
|
515 |
fun add_classrel pp rel tsig = |
19642 | 516 |
tsig |> map_tsig (fn ((space, classes), default, types) => |
19515
9f650083da65
build classes/arities: refer to operations in sorts.ML;
wenzelm
parents:
19464
diff
changeset
|
517 |
let |
9f650083da65
build classes/arities: refer to operations in sorts.ML;
wenzelm
parents:
19464
diff
changeset
|
518 |
val rel' = pairself (cert_class tsig) rel |
9f650083da65
build classes/arities: refer to operations in sorts.ML;
wenzelm
parents:
19464
diff
changeset
|
519 |
handle TYPE (msg, _, _) => error msg; |
32784 | 520 |
val classes' = classes |> Sorts.add_classrel pp rel'; |
19642 | 521 |
in ((space, classes'), default, types) end); |
19515
9f650083da65
build classes/arities: refer to operations in sorts.ML;
wenzelm
parents:
19464
diff
changeset
|
522 |
|
9f650083da65
build classes/arities: refer to operations in sorts.ML;
wenzelm
parents:
19464
diff
changeset
|
523 |
|
14790
0d984ee030a1
major cleanup of tsig datastructures and extend/merge operations; fixes old bugs in classes/arities code; proper treatment of nonterminals and syntax-only types;
wenzelm
parents:
13666
diff
changeset
|
524 |
(* default sort *) |
0d984ee030a1
major cleanup of tsig datastructures and extend/merge operations; fixes old bugs in classes/arities code; proper treatment of nonterminals and syntax-only types;
wenzelm
parents:
13666
diff
changeset
|
525 |
|
19642 | 526 |
fun set_defsort S tsig = tsig |> map_tsig (fn (classes, _, types) => |
527 |
(classes, cert_sort tsig S handle TYPE (msg, _, _) => error msg, types)); |
|
0 | 528 |
|
529 |
||
14790
0d984ee030a1
major cleanup of tsig datastructures and extend/merge operations; fixes old bugs in classes/arities code; proper treatment of nonterminals and syntax-only types;
wenzelm
parents:
13666
diff
changeset
|
530 |
(* types *) |
0d984ee030a1
major cleanup of tsig datastructures and extend/merge operations; fixes old bugs in classes/arities code; proper treatment of nonterminals and syntax-only types;
wenzelm
parents:
13666
diff
changeset
|
531 |
|
0d984ee030a1
major cleanup of tsig datastructures and extend/merge operations; fixes old bugs in classes/arities code; proper treatment of nonterminals and syntax-only types;
wenzelm
parents:
13666
diff
changeset
|
532 |
local |
0d984ee030a1
major cleanup of tsig datastructures and extend/merge operations; fixes old bugs in classes/arities code; proper treatment of nonterminals and syntax-only types;
wenzelm
parents:
13666
diff
changeset
|
533 |
|
33173
b8ca12f6681a
eliminated obsolete tags for types/consts -- now handled via name space, in strongly typed fashion;
wenzelm
parents:
33097
diff
changeset
|
534 |
fun new_decl naming (c, decl) types = |
b8ca12f6681a
eliminated obsolete tags for types/consts -- now handled via name space, in strongly typed fashion;
wenzelm
parents:
33097
diff
changeset
|
535 |
#2 (Name_Space.define true naming (c, decl) types); |
14790
0d984ee030a1
major cleanup of tsig datastructures and extend/merge operations; fixes old bugs in classes/arities code; proper treatment of nonterminals and syntax-only types;
wenzelm
parents:
13666
diff
changeset
|
536 |
|
19642 | 537 |
fun map_types f = map_tsig (fn (classes, default, types) => |
19579
b802d1804b77
replaced Sorts.DOMAIN by general Sorts.CLASS_ERROR;
wenzelm
parents:
19530
diff
changeset
|
538 |
let |
b802d1804b77
replaced Sorts.DOMAIN by general Sorts.CLASS_ERROR;
wenzelm
parents:
19530
diff
changeset
|
539 |
val (space', tab') = f types; |
33095
bbd52d2f8696
renamed NameSpace to Name_Space -- also to emphasize its subtle change in semantics;
wenzelm
parents:
33094
diff
changeset
|
540 |
val _ = Name_Space.intern space' "dummy" = "dummy" orelse |
21858
05f57309170c
avoid conflict with Alice keywords: renamed pack -> implode, unpack -> explode, any -> many, avoided assert;
wenzelm
parents:
21116
diff
changeset
|
541 |
error "Illegal declaration of dummy type"; |
19642 | 542 |
in (classes, default, (space', tab')) end); |
2964 | 543 |
|
14989 | 544 |
fun syntactic types (Type (c, Ts)) = |
33173
b8ca12f6681a
eliminated obsolete tags for types/consts -- now handled via name space, in strongly typed fashion;
wenzelm
parents:
33097
diff
changeset
|
545 |
(case Symtab.lookup types c of SOME Nonterminal => true | _ => false) |
14989 | 546 |
orelse exists (syntactic types) Ts |
547 |
| syntactic _ _ = false; |
|
548 |
||
27302 | 549 |
in |
550 |
||
33173
b8ca12f6681a
eliminated obsolete tags for types/consts -- now handled via name space, in strongly typed fashion;
wenzelm
parents:
33097
diff
changeset
|
551 |
fun add_type naming (c, n) = |
33094
ef0d77b1e687
eliminated separate stamp -- NameSpace.define/merge etc. ensure uniqueness already;
wenzelm
parents:
32784
diff
changeset
|
552 |
if n < 0 then error ("Bad type constructor declaration " ^ quote (Binding.str_of c)) |
33173
b8ca12f6681a
eliminated obsolete tags for types/consts -- now handled via name space, in strongly typed fashion;
wenzelm
parents:
33097
diff
changeset
|
553 |
else map_types (new_decl naming (c, LogicalType n)); |
27302 | 554 |
|
33173
b8ca12f6681a
eliminated obsolete tags for types/consts -- now handled via name space, in strongly typed fashion;
wenzelm
parents:
33097
diff
changeset
|
555 |
fun add_abbrev naming (a, vs, rhs) tsig = tsig |> map_types (fn types => |
14790
0d984ee030a1
major cleanup of tsig datastructures and extend/merge operations; fixes old bugs in classes/arities code; proper treatment of nonterminals and syntax-only types;
wenzelm
parents:
13666
diff
changeset
|
556 |
let |
30343
79f022df8527
replace old bstring by binding for logical primitives: class, type, const etc.;
wenzelm
parents:
29275
diff
changeset
|
557 |
fun err msg = |
33173
b8ca12f6681a
eliminated obsolete tags for types/consts -- now handled via name space, in strongly typed fashion;
wenzelm
parents:
33097
diff
changeset
|
558 |
cat_error msg ("The error(s) above occurred in type abbreviation " ^ |
b8ca12f6681a
eliminated obsolete tags for types/consts -- now handled via name space, in strongly typed fashion;
wenzelm
parents:
33097
diff
changeset
|
559 |
quote (Binding.str_of a)); |
24274
cb9236269af1
type mode: models certification mode (default, syntax, abbrev);
wenzelm
parents:
23655
diff
changeset
|
560 |
val rhs' = strip_sorts (no_tvars (cert_typ_mode mode_syntax tsig rhs)) |
14790
0d984ee030a1
major cleanup of tsig datastructures and extend/merge operations; fixes old bugs in classes/arities code; proper treatment of nonterminals and syntax-only types;
wenzelm
parents:
13666
diff
changeset
|
561 |
handle TYPE (msg, _, _) => err msg; |
33094
ef0d77b1e687
eliminated separate stamp -- NameSpace.define/merge etc. ensure uniqueness already;
wenzelm
parents:
32784
diff
changeset
|
562 |
val _ = |
ef0d77b1e687
eliminated separate stamp -- NameSpace.define/merge etc. ensure uniqueness already;
wenzelm
parents:
32784
diff
changeset
|
563 |
(case duplicates (op =) vs of |
ef0d77b1e687
eliminated separate stamp -- NameSpace.define/merge etc. ensure uniqueness already;
wenzelm
parents:
32784
diff
changeset
|
564 |
[] => [] |
ef0d77b1e687
eliminated separate stamp -- NameSpace.define/merge etc. ensure uniqueness already;
wenzelm
parents:
32784
diff
changeset
|
565 |
| dups => err ("Duplicate variables on lhs: " ^ commas_quote dups)); |
ef0d77b1e687
eliminated separate stamp -- NameSpace.define/merge etc. ensure uniqueness already;
wenzelm
parents:
32784
diff
changeset
|
566 |
val _ = |
ef0d77b1e687
eliminated separate stamp -- NameSpace.define/merge etc. ensure uniqueness already;
wenzelm
parents:
32784
diff
changeset
|
567 |
(case subtract (op =) vs (map #1 (Term.add_tfreesT rhs' [])) of |
ef0d77b1e687
eliminated separate stamp -- NameSpace.define/merge etc. ensure uniqueness already;
wenzelm
parents:
32784
diff
changeset
|
568 |
[] => [] |
ef0d77b1e687
eliminated separate stamp -- NameSpace.define/merge etc. ensure uniqueness already;
wenzelm
parents:
32784
diff
changeset
|
569 |
| extras => err ("Extra variables on rhs: " ^ commas_quote extras)); |
33173
b8ca12f6681a
eliminated obsolete tags for types/consts -- now handled via name space, in strongly typed fashion;
wenzelm
parents:
33097
diff
changeset
|
570 |
in types |> new_decl naming (a, Abbreviation (vs, rhs', syntactic (#2 types) rhs')) end); |
0 | 571 |
|
33173
b8ca12f6681a
eliminated obsolete tags for types/consts -- now handled via name space, in strongly typed fashion;
wenzelm
parents:
33097
diff
changeset
|
572 |
fun add_nonterminal naming = map_types o new_decl naming o rpair Nonterminal; |
14790
0d984ee030a1
major cleanup of tsig datastructures and extend/merge operations; fixes old bugs in classes/arities code; proper treatment of nonterminals and syntax-only types;
wenzelm
parents:
13666
diff
changeset
|
573 |
|
0d984ee030a1
major cleanup of tsig datastructures and extend/merge operations; fixes old bugs in classes/arities code; proper treatment of nonterminals and syntax-only types;
wenzelm
parents:
13666
diff
changeset
|
574 |
end; |
0 | 575 |
|
26669 | 576 |
fun hide_type fully c = map_tsig (fn (classes, default, (space, types)) => |
33095
bbd52d2f8696
renamed NameSpace to Name_Space -- also to emphasize its subtle change in semantics;
wenzelm
parents:
33094
diff
changeset
|
577 |
(classes, default, (Name_Space.hide fully c space, types))); |
16370
033d890fe91f
name space of classes and types maintained in tsig;
wenzelm
parents:
16340
diff
changeset
|
578 |
|
3790 | 579 |
|
14790
0d984ee030a1
major cleanup of tsig datastructures and extend/merge operations; fixes old bugs in classes/arities code; proper treatment of nonterminals and syntax-only types;
wenzelm
parents:
13666
diff
changeset
|
580 |
(* merge type signatures *) |
0d984ee030a1
major cleanup of tsig datastructures and extend/merge operations; fixes old bugs in classes/arities code; proper treatment of nonterminals and syntax-only types;
wenzelm
parents:
13666
diff
changeset
|
581 |
|
14830
faa4865ba1ce
removed norm_typ; improved output; refer to Pretty.pp;
wenzelm
parents:
14790
diff
changeset
|
582 |
fun merge_tsigs pp (tsig1, tsig2) = |
14790
0d984ee030a1
major cleanup of tsig datastructures and extend/merge operations; fixes old bugs in classes/arities code; proper treatment of nonterminals and syntax-only types;
wenzelm
parents:
13666
diff
changeset
|
583 |
let |
19515
9f650083da65
build classes/arities: refer to operations in sorts.ML;
wenzelm
parents:
19464
diff
changeset
|
584 |
val (TSig {classes = (space1, classes1), default = default1, types = types1, |
26641 | 585 |
log_types = _}) = tsig1; |
19515
9f650083da65
build classes/arities: refer to operations in sorts.ML;
wenzelm
parents:
19464
diff
changeset
|
586 |
val (TSig {classes = (space2, classes2), default = default2, types = types2, |
26641 | 587 |
log_types = _}) = tsig2; |
14790
0d984ee030a1
major cleanup of tsig datastructures and extend/merge operations; fixes old bugs in classes/arities code; proper treatment of nonterminals and syntax-only types;
wenzelm
parents:
13666
diff
changeset
|
588 |
|
33095
bbd52d2f8696
renamed NameSpace to Name_Space -- also to emphasize its subtle change in semantics;
wenzelm
parents:
33094
diff
changeset
|
589 |
val space' = Name_Space.merge (space1, space2); |
19642 | 590 |
val classes' = Sorts.merge_algebra pp (classes1, classes2); |
19515
9f650083da65
build classes/arities: refer to operations in sorts.ML;
wenzelm
parents:
19464
diff
changeset
|
591 |
val default' = Sorts.inter_sort classes' (default1, default2); |
33095
bbd52d2f8696
renamed NameSpace to Name_Space -- also to emphasize its subtle change in semantics;
wenzelm
parents:
33094
diff
changeset
|
592 |
val types' = Name_Space.merge_tables (types1, types2); |
19642 | 593 |
in build_tsig ((space', classes'), default', types') end; |
14790
0d984ee030a1
major cleanup of tsig datastructures and extend/merge operations; fixes old bugs in classes/arities code; proper treatment of nonterminals and syntax-only types;
wenzelm
parents:
13666
diff
changeset
|
594 |
|
0 | 595 |
end; |