author | haftmann |
Fri, 23 Feb 2007 08:39:28 +0100 | |
changeset 22355 | f9d35783d28d |
parent 21934 | ba683b0b2456 |
child 23178 | 07ba6b58b3d2 |
permissions | -rw-r--r-- |
256 | 1 |
(* Title: Pure/type.ML |
0 | 2 |
ID: $Id$ |
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
|
3 |
Author: Tobias Nipkow, Lawrence C Paulson, and Markus Wenzel |
0 | 4 |
|
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
|
5 |
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
|
6 |
matching and unification of types, extend and merge type signatures. |
0 | 7 |
*) |
8 |
||
9 |
signature TYPE = |
|
2964 | 10 |
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
|
11 |
(*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
|
12 |
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
|
13 |
LogicalType of int | |
14989 | 14 |
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
|
15 |
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
|
16 |
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
|
17 |
val rep_tsig: tsig -> |
19642 | 18 |
{classes: NameSpace.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
|
19 |
default: sort, |
20674 | 20 |
types: (decl * serial) NameSpace.table, |
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 |
log_types: 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
|
22 |
witness: (typ * sort) option} |
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 empty_tsig: 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
|
24 |
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
|
25 |
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
|
26 |
val universal_witness: tsig -> (typ * sort) option |
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 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
|
28 |
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
|
29 |
val of_sort: tsig -> typ * sort -> bool |
19464 | 30 |
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
|
31 |
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
|
32 |
val cert_sort: tsig -> sort -> 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
|
33 |
val witness_sorts: tsig -> sort list -> sort list -> (typ * sort) list |
14993 | 34 |
val cert_typ: tsig -> typ -> typ |
35 |
val cert_typ_syntax: tsig -> typ -> typ |
|
16340 | 36 |
val cert_typ_abbrev: tsig -> typ -> typ |
19464 | 37 |
val arity_number: tsig -> string -> int |
38 |
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
|
39 |
|
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
|
40 |
(*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
|
41 |
val strip_sorts: typ -> typ |
621 | 42 |
val no_tvars: typ -> typ |
21116 | 43 |
val varify: (string * sort) list -> term -> ((string * sort) * indexname) list * term |
16289 | 44 |
val freeze_thaw_type: typ -> typ * (typ -> typ) |
45 |
val freeze_type: typ -> typ |
|
46 |
val freeze_thaw: term -> term * (term -> term) |
|
47 |
val freeze: term -> term |
|
2964 | 48 |
|
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
|
49 |
(*matching and unification*) |
2964 | 50 |
exception TYPE_MATCH |
15797 | 51 |
type tyenv |
52 |
val lookup: tyenv * (indexname * sort) -> typ option |
|
16946 | 53 |
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
|
54 |
val typ_instance: tsig -> typ * typ -> bool |
16946 | 55 |
val raw_match: typ * typ -> tyenv -> tyenv |
19694 | 56 |
val raw_matches: typ list * typ list -> tyenv -> tyenv |
16946 | 57 |
val raw_instance: typ * typ -> bool |
2964 | 58 |
exception TUNIFY |
16946 | 59 |
val unify: tsig -> typ * typ -> tyenv * int -> tyenv * int |
60 |
val raw_unify: typ * typ -> tyenv -> tyenv |
|
19696 | 61 |
val raw_unifys: typ list * typ list -> tyenv -> tyenv |
17804 | 62 |
val could_unify: typ * typ -> bool |
19696 | 63 |
val could_unifys: typ list * typ list -> bool |
16650 | 64 |
val eq_type: tyenv -> typ * typ -> bool |
0 | 65 |
|
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
|
66 |
(*extend and merge type signatures*) |
19515
9f650083da65
build classes/arities: refer to operations in sorts.ML;
wenzelm
parents:
19464
diff
changeset
|
67 |
val add_class: Pretty.pp -> NameSpace.naming -> bstring * class list -> tsig -> tsig |
16370
033d890fe91f
name space of classes and types maintained in tsig;
wenzelm
parents:
16340
diff
changeset
|
68 |
val hide_classes: bool -> string list -> 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
|
69 |
val set_defsort: sort -> tsig -> tsig |
16370
033d890fe91f
name space of classes and types maintained in tsig;
wenzelm
parents:
16340
diff
changeset
|
70 |
val add_types: NameSpace.naming -> (bstring * int) list -> tsig -> tsig |
033d890fe91f
name space of classes and types maintained in tsig;
wenzelm
parents:
16340
diff
changeset
|
71 |
val add_abbrevs: NameSpace.naming -> (string * string list * typ) list -> tsig -> tsig |
033d890fe91f
name space of classes and types maintained in tsig;
wenzelm
parents:
16340
diff
changeset
|
72 |
val add_nonterminals: NameSpace.naming -> string list -> tsig -> tsig |
033d890fe91f
name space of classes and types maintained in tsig;
wenzelm
parents:
16340
diff
changeset
|
73 |
val hide_types: bool -> string list -> tsig -> tsig |
19515
9f650083da65
build classes/arities: refer to operations in sorts.ML;
wenzelm
parents:
19464
diff
changeset
|
74 |
val add_arity: Pretty.pp -> arity -> tsig -> tsig |
9f650083da65
build classes/arities: refer to operations in sorts.ML;
wenzelm
parents:
19464
diff
changeset
|
75 |
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
|
76 |
val merge_tsigs: Pretty.pp -> tsig * tsig -> tsig |
2964 | 77 |
end; |
78 |
||
79 |
structure Type: TYPE = |
|
0 | 80 |
struct |
81 |
||
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
|
82 |
(** type signatures and certified types **) |
2964 | 83 |
|
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
|
84 |
(* 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
|
85 |
|
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
|
86 |
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
|
87 |
LogicalType of int | |
14989 | 88 |
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
|
89 |
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
|
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 |
fun str_of_decl (LogicalType _) = "logical type constructor" |
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 |
| str_of_decl (Abbreviation _) = "type abbreviation" |
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
|
93 |
| str_of_decl Nonterminal = "syntactic type"; |
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 |
|
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 |
(* 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
|
97 |
|
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 |
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
|
99 |
TSig of { |
19642 | 100 |
classes: NameSpace.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
|
101 |
default: sort, (*default sort on input*) |
20674 | 102 |
types: (decl * serial) NameSpace.table, (*declared types*) |
16370
033d890fe91f
name space of classes and types maintained in tsig;
wenzelm
parents:
16340
diff
changeset
|
103 |
log_types: string list, (*logical types sorted by number of arguments*) |
033d890fe91f
name space of classes and types maintained in tsig;
wenzelm
parents:
16340
diff
changeset
|
104 |
witness: (typ * sort) option}; (*witness for non-emptiness of strictest 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
|
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 |
|
19642 | 108 |
fun make_tsig (classes, default, types, log_types, witness) = |
109 |
TSig {classes = classes, default = default, types = 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 |
log_types = log_types, witness = witness}; |
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
|
111 |
|
19642 | 112 |
fun build_tsig ((space, 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
|
113 |
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
|
114 |
val log_types = |
17756 | 115 |
Symtab.fold (fn (c, (LogicalType n, _)) => cons (c, n) | _ => I) (snd types) [] |
116 |
|> Library.sort (Library.int_ord o pairself snd) |> map fst; |
|
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 |
val witness = |
21934 | 118 |
(case Sorts.witness_sorts classes log_types [] [Sorts.minimal_classes classes] of |
15531 | 119 |
[w] => SOME w | _ => NONE); |
19642 | 120 |
in make_tsig ((space, classes), default, types, log_types, witness) 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
|
121 |
|
19642 | 122 |
fun map_tsig f (TSig {classes, default, types, log_types = _, witness = _}) = |
123 |
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
|
124 |
|
16370
033d890fe91f
name space of classes and types maintained in tsig;
wenzelm
parents:
16340
diff
changeset
|
125 |
val empty_tsig = |
19642 | 126 |
build_tsig ((NameSpace.empty, Sorts.empty_algebra), [], NameSpace.empty_table); |
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
|
127 |
|
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 |
|
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 |
(* 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
|
130 |
|
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
|
131 |
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
|
132 |
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
|
133 |
fun universal_witness (TSig {witness, ...}) = witness; |
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 |
|
16370
033d890fe91f
name space of classes and types maintained in tsig;
wenzelm
parents:
16340
diff
changeset
|
135 |
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
|
136 |
fun subsort (TSig {classes, ...}) = Sorts.sort_le (#2 classes); |
19642 | 137 |
fun of_sort (TSig {classes, ...}) = Sorts.of_sort (#2 classes); |
19464 | 138 |
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
|
139 |
|
19642 | 140 |
fun cert_class (TSig {classes, ...}) = Sorts.certify_class (#2 classes); |
141 |
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
|
142 |
|
19642 | 143 |
fun witness_sorts (tsig as TSig {classes, log_types, ...}) = |
144 |
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
|
145 |
|
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
|
146 |
|
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
|
147 |
(* 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
|
148 |
|
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
|
149 |
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
|
150 |
fun undecl_type c = "Undeclared type constructor: " ^ quote c; |
faa4865ba1ce
removed norm_typ; improved output; refer to Pretty.pp;
wenzelm
parents:
14790
diff
changeset
|
151 |
|
14998 | 152 |
local |
153 |
||
154 |
fun inst_typ env (Type (c, Ts)) = Type (c, map (inst_typ env) Ts) |
|
18957 | 155 |
| inst_typ env (T as TFree (x, _)) = the_default T (AList.lookup (op =) env x) |
14998 | 156 |
| inst_typ _ T = T; |
157 |
||
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
|
158 |
fun certify_typ normalize syntax tsig 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
|
159 |
let |
19515
9f650083da65
build classes/arities: refer to operations in sorts.ML;
wenzelm
parents:
19464
diff
changeset
|
160 |
val TSig {types = (_, types), ...} = 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
|
161 |
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
|
162 |
|
14989 | 163 |
val check_syntax = |
164 |
if syntax then K () |
|
165 |
else fn c => err ("Illegal occurrence of syntactic type: " ^ quote c); |
|
166 |
||
167 |
fun cert (T as Type (c, Ts)) = |
|
168 |
let |
|
169 |
val Ts' = map cert Ts; |
|
170 |
fun nargs n = if length Ts <> n then err (bad_nargs c) else (); |
|
171 |
in |
|
17412 | 172 |
(case Symtab.lookup types c of |
15531 | 173 |
SOME (LogicalType n, _) => (nargs n; Type (c, Ts')) |
174 |
| SOME (Abbreviation (vs, U, syn), _) => (nargs (length vs); |
|
14989 | 175 |
if syn then check_syntax c else (); |
14993 | 176 |
if normalize then inst_typ (vs ~~ Ts') U |
14989 | 177 |
else Type (c, Ts')) |
15531 | 178 |
| SOME (Nonterminal, _) => (nargs 0; check_syntax c; T) |
179 |
| 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
|
180 |
end |
19515
9f650083da65
build classes/arities: refer to operations in sorts.ML;
wenzelm
parents:
19464
diff
changeset
|
181 |
| cert (TFree (x, S)) = TFree (x, cert_sort tsig S) |
14989 | 182 |
| cert (TVar (xi as (_, i), S)) = |
14993 | 183 |
if i < 0 then |
184 |
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
|
185 |
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
|
186 |
|
14989 | 187 |
val ty' = cert ty; |
14993 | 188 |
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
|
189 |
|
14998 | 190 |
in |
191 |
||
16340 | 192 |
val cert_typ = certify_typ true false; |
193 |
val cert_typ_syntax = certify_typ true true; |
|
194 |
val cert_typ_abbrev = certify_typ false true; |
|
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
|
195 |
|
14998 | 196 |
end; |
197 |
||
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
|
198 |
|
19464 | 199 |
(* type arities *) |
200 |
||
201 |
fun arity_number (TSig {types = (_, types), ...}) a = |
|
202 |
(case Symtab.lookup types a of |
|
203 |
SOME (LogicalType n, _) => n |
|
204 |
| _ => error (undecl_type a)); |
|
205 |
||
206 |
fun arity_sorts _ tsig a [] = replicate (arity_number tsig a) [] |
|
19642 | 207 |
| arity_sorts pp (TSig {classes, ...}) a S = Sorts.mg_domain (#2 classes) a S |
208 |
handle Sorts.CLASS_ERROR err => Sorts.class_error pp err; |
|
19464 | 209 |
|
210 |
||
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
|
211 |
|
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
|
212 |
(** 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
|
213 |
|
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
|
214 |
(* 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
|
215 |
|
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 |
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
|
217 |
| 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
|
218 |
| 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
|
219 |
|
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
|
220 |
|
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
|
221 |
(* no_tvars *) |
621 | 222 |
|
223 |
fun no_tvars T = |
|
12501 | 224 |
(case typ_tvars T of [] => T |
225 |
| vs => raise TYPE ("Illegal schematic type variable(s): " ^ |
|
14830
faa4865ba1ce
removed norm_typ; improved output; refer to Pretty.pp;
wenzelm
parents:
14790
diff
changeset
|
226 |
commas_quote (map (Term.string_of_vname o #1) vs), [T], [])); |
621 | 227 |
|
7641 | 228 |
|
19806 | 229 |
(* varify *) |
621 | 230 |
|
21116 | 231 |
fun varify fixed t = |
621 | 232 |
let |
19305 | 233 |
val fs = Term.fold_types (Term.fold_atyps |
234 |
(fn TFree v => if member (op =) fixed v then I else insert (op =) v | _ => I)) t []; |
|
621 | 235 |
val ixns = add_term_tvar_ixns (t, []); |
20071
8f3e1ddb50e6
replaced Term.variant(list) by Name.variant(_list);
wenzelm
parents:
19806
diff
changeset
|
236 |
val fmap = fs ~~ map (rpair 0) (Name.variant_list (map #1 ixns) (map fst fs)) |
2964 | 237 |
fun thaw (f as (a, S)) = |
17184 | 238 |
(case AList.lookup (op =) fmap f of |
15531 | 239 |
NONE => TFree f |
16946 | 240 |
| SOME xi => TVar (xi, S)); |
21116 | 241 |
in (fmap, map_types (map_type_tfree thaw) t) end; |
2964 | 242 |
|
243 |
||
7641 | 244 |
(* 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
|
245 |
|
7641 | 246 |
local |
247 |
||
16289 | 248 |
fun new_name (ix, (pairs, used)) = |
20071
8f3e1ddb50e6
replaced Term.variant(list) by Name.variant(_list);
wenzelm
parents:
19806
diff
changeset
|
249 |
let val v = Name.variant used (string_of_indexname ix) |
16289 | 250 |
in ((ix, v) :: pairs, v :: used) end; |
621 | 251 |
|
16289 | 252 |
fun freeze_one alist (ix, sort) = |
17184 | 253 |
TFree (the (AList.lookup (op =) alist ix), sort) |
15531 | 254 |
handle Option => |
3790 | 255 |
raise TYPE ("Failure during freezing of ?" ^ string_of_indexname ix, [], []); |
2964 | 256 |
|
17184 | 257 |
fun thaw_one alist (a, sort) = TVar (the (AList.lookup (op =) alist a), sort) |
16289 | 258 |
handle Option => TFree (a, sort); |
416 | 259 |
|
10495 | 260 |
in |
261 |
||
262 |
(*this sort of code could replace unvarifyT*) |
|
7641 | 263 |
fun freeze_thaw_type T = |
264 |
let |
|
265 |
val used = add_typ_tfree_names (T, []) |
|
266 |
and tvars = map #1 (add_typ_tvars (T, [])); |
|
15574
b1d1b5bfc464
Removed practically all references to Library.foldr.
skalberg
parents:
15570
diff
changeset
|
267 |
val (alist, _) = foldr new_name ([], used) tvars; |
7641 | 268 |
in (map_type_tvar (freeze_one alist) T, map_type_tfree (thaw_one (map swap alist))) end; |
269 |
||
16289 | 270 |
val freeze_type = #1 o freeze_thaw_type; |
271 |
||
3411
163f8f4a42d7
Removal of freeze_vars and thaw_vars. New freeze_thaw
paulson
parents:
3175
diff
changeset
|
272 |
fun freeze_thaw t = |
7641 | 273 |
let |
274 |
val used = it_term_types add_typ_tfree_names (t, []) |
|
275 |
and tvars = map #1 (it_term_types add_typ_tvars (t, [])); |
|
15574
b1d1b5bfc464
Removed practically all references to Library.foldr.
skalberg
parents:
15570
diff
changeset
|
276 |
val (alist, _) = foldr new_name ([], used) tvars; |
7641 | 277 |
in |
278 |
(case alist of |
|
279 |
[] => (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
|
280 |
| _ => (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
|
281 |
map_types (map_type_tfree (thaw_one (map swap alist))))) |
7641 | 282 |
end; |
283 |
||
16289 | 284 |
val freeze = #1 o freeze_thaw; |
285 |
||
7641 | 286 |
end; |
287 |
||
256 | 288 |
|
289 |
||
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
|
290 |
(** matching and unification of types **) |
8899 | 291 |
|
15797 | 292 |
type tyenv = (sort * typ) Vartab.table; |
256 | 293 |
|
15797 | 294 |
fun tvar_clash ixn S S' = raise TYPE ("Type variable " ^ |
295 |
quote (Term.string_of_vname ixn) ^ " has two distinct sorts", |
|
296 |
[TVar (ixn, S), TVar (ixn, S')], []); |
|
0 | 297 |
|
16289 | 298 |
fun lookup (tye, (ixn, S)) = |
17412 | 299 |
(case Vartab.lookup tye ixn of |
15797 | 300 |
NONE => NONE |
16289 | 301 |
| SOME (S', T) => if S = S' then SOME T else tvar_clash ixn S S'); |
302 |
||
0 | 303 |
|
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
|
304 |
(* matching *) |
0 | 305 |
|
2964 | 306 |
exception TYPE_MATCH; |
0 | 307 |
|
16946 | 308 |
fun typ_match tsig = |
2964 | 309 |
let |
16340 | 310 |
fun match (TVar (v, S), T) subs = |
15797 | 311 |
(case lookup (subs, (v, S)) of |
15531 | 312 |
NONE => |
17412 | 313 |
if of_sort tsig (T, S) then Vartab.update_new (v, (S, T)) subs |
14993 | 314 |
else raise TYPE_MATCH |
15531 | 315 |
| SOME U => if U = T then subs else raise TYPE_MATCH) |
16340 | 316 |
| match (Type (a, Ts), Type (b, Us)) subs = |
2964 | 317 |
if a <> b then raise TYPE_MATCH |
16885 | 318 |
else matches (Ts, Us) subs |
16340 | 319 |
| match (TFree x, TFree y) subs = |
2964 | 320 |
if x = y then subs else raise TYPE_MATCH |
16885 | 321 |
| match _ _ = raise TYPE_MATCH |
322 |
and matches (T :: Ts, U :: Us) subs = matches (Ts, Us) (match (T, U) subs) |
|
323 |
| matches _ subs = subs; |
|
16946 | 324 |
in match end; |
0 | 325 |
|
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
|
326 |
fun typ_instance tsig (T, U) = |
16946 | 327 |
(typ_match tsig (U, T) Vartab.empty; true) handle TYPE_MATCH => false; |
328 |
||
329 |
(*purely structural matching*) |
|
330 |
fun raw_match (TVar (v, S), T) subs = |
|
331 |
(case lookup (subs, (v, S)) of |
|
17412 | 332 |
NONE => Vartab.update_new (v, (S, T)) subs |
16946 | 333 |
| SOME U => if U = T then subs else raise TYPE_MATCH) |
334 |
| raw_match (Type (a, Ts), Type (b, Us)) subs = |
|
335 |
if a <> b then raise TYPE_MATCH |
|
336 |
else raw_matches (Ts, Us) subs |
|
337 |
| raw_match (TFree x, TFree y) subs = |
|
338 |
if x = y then subs else raise TYPE_MATCH |
|
339 |
| raw_match _ _ = raise TYPE_MATCH |
|
340 |
and raw_matches (T :: Ts, U :: Us) subs = raw_matches (Ts, Us) (raw_match (T, U) subs) |
|
19694 | 341 |
| raw_matches ([], []) subs = subs |
342 |
| raw_matches _ _ = raise TYPE_MATCH; |
|
16946 | 343 |
|
344 |
fun raw_instance (T, U) = |
|
345 |
(raw_match (U, T) Vartab.empty; true) handle TYPE_MATCH => false; |
|
2964 | 346 |
|
0 | 347 |
|
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
|
348 |
(* unification *) |
2964 | 349 |
|
0 | 350 |
exception TUNIFY; |
351 |
||
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
|
352 |
(*occurs_check*) |
2964 | 353 |
fun occurs v tye = |
354 |
let |
|
355 |
fun occ (Type (_, Ts)) = exists occ Ts |
|
356 |
| occ (TFree _) = false |
|
15797 | 357 |
| occ (TVar (w, S)) = |
2964 | 358 |
eq_ix (v, w) orelse |
15797 | 359 |
(case lookup (tye, (w, S)) of |
15531 | 360 |
NONE => false |
361 |
| SOME U => occ U); |
|
0 | 362 |
in occ end; |
363 |
||
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
|
364 |
(*chase variable assignments; if devar returns a type var then it must be unassigned*) |
16885 | 365 |
fun devar tye (T as TVar v) = |
366 |
(case lookup (tye, v) of |
|
367 |
SOME U => devar tye U |
|
15531 | 368 |
| NONE => T) |
16885 | 369 |
| devar tye T = T; |
0 | 370 |
|
17804 | 371 |
(*order-sorted unification*) |
19642 | 372 |
fun unify (tsig as TSig {classes = (_, classes), ...}) TU (tyenv, maxidx) = |
2964 | 373 |
let |
374 |
val tyvar_count = ref maxidx; |
|
375 |
fun gen_tyvar S = TVar (("'a", inc tyvar_count), S); |
|
376 |
||
19642 | 377 |
fun mg_domain a S = Sorts.mg_domain classes a S |
378 |
handle Sorts.CLASS_ERROR _ => raise TUNIFY; |
|
2964 | 379 |
|
16885 | 380 |
fun meet (_, []) tye = tye |
381 |
| 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
|
382 |
if Sorts.sort_le classes (S', S) then tye |
17412 | 383 |
else Vartab.update_new |
17221 | 384 |
(xi, (S', gen_tyvar (Sorts.inter_sort classes (S', S)))) tye |
16885 | 385 |
| 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
|
386 |
if Sorts.sort_le classes (S', S) then tye |
2964 | 387 |
else raise TUNIFY |
16885 | 388 |
| meet (Type (a, Ts), S) tye = meets (Ts, mg_domain a S) tye |
389 |
and meets (T :: Ts, S :: Ss) tye = meets (Ts, Ss) (meet (devar tye T, S) tye) |
|
390 |
| meets _ tye = tye; |
|
2964 | 391 |
|
16885 | 392 |
fun unif (ty1, ty2) tye = |
393 |
(case (devar tye ty1, devar tye ty2) of |
|
2964 | 394 |
(T as TVar (v, S1), U as TVar (w, S2)) => |
15797 | 395 |
if eq_ix (v, w) then |
396 |
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
|
397 |
else if Sorts.sort_le classes (S1, S2) then |
17412 | 398 |
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
|
399 |
else if Sorts.sort_le classes (S2, S1) then |
17412 | 400 |
Vartab.update_new (v, (S1, U)) tye |
2964 | 401 |
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
|
402 |
let val S = gen_tyvar (Sorts.inter_sort classes (S1, S2)) in |
17412 | 403 |
Vartab.update_new (v, (S1, S)) (Vartab.update_new (w, (S2, S)) tye) |
2964 | 404 |
end |
405 |
| (TVar (v, S), T) => |
|
406 |
if occurs v tye T then raise TUNIFY |
|
17412 | 407 |
else meet (T, S) (Vartab.update_new (v, (S, T)) tye) |
2964 | 408 |
| (T, TVar (v, S)) => |
409 |
if occurs v tye T then raise TUNIFY |
|
17412 | 410 |
else meet (T, S) (Vartab.update_new (v, (S, T)) tye) |
2964 | 411 |
| (Type (a, Ts), Type (b, Us)) => |
412 |
if a <> b then raise TUNIFY |
|
16885 | 413 |
else unifs (Ts, Us) tye |
414 |
| (T, U) => if T = U then tye else raise TUNIFY) |
|
415 |
and unifs (T :: Ts, U :: Us) tye = unifs (Ts, Us) (unif (T, U) tye) |
|
416 |
| unifs _ tye = tye; |
|
417 |
in (unif TU tyenv, ! tyvar_count) end; |
|
0 | 418 |
|
16946 | 419 |
(*purely structural unification*) |
420 |
fun raw_unify (ty1, ty2) tye = |
|
421 |
(case (devar tye ty1, devar tye ty2) of |
|
422 |
(T as TVar (v, S1), U as TVar (w, S2)) => |
|
423 |
if eq_ix (v, w) then |
|
424 |
if S1 = S2 then tye else tvar_clash v S1 S2 |
|
17412 | 425 |
else Vartab.update_new (w, (S2, T)) tye |
16946 | 426 |
| (TVar (v, S), T) => |
427 |
if occurs v tye T then raise TUNIFY |
|
17412 | 428 |
else Vartab.update_new (v, (S, T)) tye |
16946 | 429 |
| (T, TVar (v, S)) => |
430 |
if occurs v tye T then raise TUNIFY |
|
17412 | 431 |
else Vartab.update_new (v, (S, T)) tye |
16946 | 432 |
| (Type (a, Ts), Type (b, Us)) => |
433 |
if a <> b then raise TUNIFY |
|
434 |
else raw_unifys (Ts, Us) tye |
|
435 |
| (T, U) => if T = U then tye else raise TUNIFY) |
|
436 |
and raw_unifys (T :: Ts, U :: Us) tye = raw_unifys (Ts, Us) (raw_unify (T, U) tye) |
|
19696 | 437 |
| raw_unifys ([], []) tye = tye |
438 |
| raw_unifys _ _ = raise TUNIFY; |
|
16946 | 439 |
|
17804 | 440 |
(*fast unification filter*) |
441 |
fun could_unify (Type (a, Ts), Type (b, Us)) = a = b andalso could_unifys (Ts, Us) |
|
442 |
| could_unify (TFree (a, _), TFree (b, _)) = a = b |
|
443 |
| could_unify (TVar _, _) = true |
|
444 |
| could_unify (_, TVar _) = true |
|
445 |
| could_unify _ = false |
|
446 |
and could_unifys (T :: Ts, U :: Us) = could_unify (T, U) andalso could_unifys (Ts, Us) |
|
19696 | 447 |
| could_unifys ([], []) = true |
448 |
| could_unifys _ = false; |
|
450 | 449 |
|
17804 | 450 |
|
451 |
(*equality with respect to a type environment*) |
|
16650 | 452 |
fun eq_type tye (T, T') = |
16885 | 453 |
(case (devar tye T, devar tye T') of |
16650 | 454 |
(Type (s, Ts), Type (s', Ts')) => |
455 |
s = s' andalso ListPair.all (eq_type tye) (Ts, Ts') |
|
456 |
| (U, U') => U = U'); |
|
457 |
||
450 | 458 |
|
0 | 459 |
|
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
|
460 |
(** 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
|
461 |
|
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
|
462 |
(* 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
|
463 |
|
16370
033d890fe91f
name space of classes and types maintained in tsig;
wenzelm
parents:
16340
diff
changeset
|
464 |
fun add_class pp naming (c, cs) tsig = |
19642 | 465 |
tsig |> map_tsig (fn ((space, classes), default, types) => |
16370
033d890fe91f
name space of classes and types maintained in tsig;
wenzelm
parents:
16340
diff
changeset
|
466 |
let |
033d890fe91f
name space of classes and types maintained in tsig;
wenzelm
parents:
16340
diff
changeset
|
467 |
val c' = NameSpace.full naming c; |
033d890fe91f
name space of classes and types maintained in tsig;
wenzelm
parents:
16340
diff
changeset
|
468 |
val cs' = map (cert_class tsig) cs |
033d890fe91f
name space of classes and types maintained in tsig;
wenzelm
parents:
16340
diff
changeset
|
469 |
handle TYPE (msg, _, _) => error msg; |
033d890fe91f
name space of classes and types maintained in tsig;
wenzelm
parents:
16340
diff
changeset
|
470 |
val space' = space |> NameSpace.declare naming c'; |
19515
9f650083da65
build classes/arities: refer to operations in sorts.ML;
wenzelm
parents:
19464
diff
changeset
|
471 |
val classes' = classes |> Sorts.add_class pp (c', cs'); |
19642 | 472 |
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
|
473 |
|
19642 | 474 |
fun hide_classes fully cs = map_tsig (fn ((space, classes), default, types) => |
475 |
((fold (NameSpace.hide fully) cs space, classes), default, types)); |
|
16370
033d890fe91f
name space of classes and types maintained in tsig;
wenzelm
parents:
16340
diff
changeset
|
476 |
|
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
|
477 |
|
19515
9f650083da65
build classes/arities: refer to operations in sorts.ML;
wenzelm
parents:
19464
diff
changeset
|
478 |
(* arities *) |
9f650083da65
build classes/arities: refer to operations in sorts.ML;
wenzelm
parents:
19464
diff
changeset
|
479 |
|
19642 | 480 |
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
|
481 |
let |
9f650083da65
build classes/arities: refer to operations in sorts.ML;
wenzelm
parents:
19464
diff
changeset
|
482 |
val _ = |
9f650083da65
build classes/arities: refer to operations in sorts.ML;
wenzelm
parents:
19464
diff
changeset
|
483 |
(case Symtab.lookup (#2 types) t of |
9f650083da65
build classes/arities: refer to operations in sorts.ML;
wenzelm
parents:
19464
diff
changeset
|
484 |
SOME (LogicalType n, _) => if length Ss <> n then error (bad_nargs t) else () |
9f650083da65
build classes/arities: refer to operations in sorts.ML;
wenzelm
parents:
19464
diff
changeset
|
485 |
| SOME (decl, _) => error ("Illegal " ^ str_of_decl decl ^ ": " ^ quote t) |
9f650083da65
build classes/arities: refer to operations in sorts.ML;
wenzelm
parents:
19464
diff
changeset
|
486 |
| NONE => error (undecl_type t)); |
9f650083da65
build classes/arities: refer to operations in sorts.ML;
wenzelm
parents:
19464
diff
changeset
|
487 |
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
|
488 |
handle TYPE (msg, _, _) => error msg; |
19642 | 489 |
val classes' = classes |> Sorts.add_arities pp ((t, map (fn c' => (c', Ss')) S')); |
490 |
in ((space, classes'), default, types) end); |
|
19515
9f650083da65
build classes/arities: refer to operations in sorts.ML;
wenzelm
parents:
19464
diff
changeset
|
491 |
|
9f650083da65
build classes/arities: refer to operations in sorts.ML;
wenzelm
parents:
19464
diff
changeset
|
492 |
|
9f650083da65
build classes/arities: refer to operations in sorts.ML;
wenzelm
parents:
19464
diff
changeset
|
493 |
(* classrel *) |
9f650083da65
build classes/arities: refer to operations in sorts.ML;
wenzelm
parents:
19464
diff
changeset
|
494 |
|
9f650083da65
build classes/arities: refer to operations in sorts.ML;
wenzelm
parents:
19464
diff
changeset
|
495 |
fun add_classrel pp rel tsig = |
19642 | 496 |
tsig |> map_tsig (fn ((space, classes), default, types) => |
19515
9f650083da65
build classes/arities: refer to operations in sorts.ML;
wenzelm
parents:
19464
diff
changeset
|
497 |
let |
9f650083da65
build classes/arities: refer to operations in sorts.ML;
wenzelm
parents:
19464
diff
changeset
|
498 |
val rel' = pairself (cert_class tsig) rel |
9f650083da65
build classes/arities: refer to operations in sorts.ML;
wenzelm
parents:
19464
diff
changeset
|
499 |
handle TYPE (msg, _, _) => error msg; |
9f650083da65
build classes/arities: refer to operations in sorts.ML;
wenzelm
parents:
19464
diff
changeset
|
500 |
val classes' = classes |> Sorts.add_classrel pp rel; |
19642 | 501 |
in ((space, classes'), default, types) end); |
19515
9f650083da65
build classes/arities: refer to operations in sorts.ML;
wenzelm
parents:
19464
diff
changeset
|
502 |
|
9f650083da65
build classes/arities: refer to operations in sorts.ML;
wenzelm
parents:
19464
diff
changeset
|
503 |
|
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
|
504 |
(* 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
|
505 |
|
19642 | 506 |
fun set_defsort S tsig = tsig |> map_tsig (fn (classes, _, types) => |
507 |
(classes, cert_sort tsig S handle TYPE (msg, _, _) => error msg, types)); |
|
0 | 508 |
|
509 |
||
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
|
510 |
(* 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
|
511 |
|
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
|
512 |
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
|
513 |
|
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
|
514 |
fun err_neg_args c = |
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
|
515 |
error ("Negative number of arguments in type constructor declaration: " ^ quote c); |
949
83c588d6fee9
Changed treatment of during type inference internally generated type
nipkow
parents:
621
diff
changeset
|
516 |
|
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
|
517 |
fun err_in_decls c decl decl' = |
14906 | 518 |
let val s = str_of_decl decl and s' = str_of_decl decl' in |
519 |
if s = s' then error ("Duplicate declaration of " ^ s ^ ": " ^ quote c) |
|
14830
faa4865ba1ce
removed norm_typ; improved output; refer to Pretty.pp;
wenzelm
parents:
14790
diff
changeset
|
520 |
else error ("Conflict of " ^ s ^ " with " ^ s' ^ ": " ^ quote 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
|
521 |
end; |
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
|
522 |
|
16370
033d890fe91f
name space of classes and types maintained in tsig;
wenzelm
parents:
16340
diff
changeset
|
523 |
fun new_decl naming (c, decl) (space, types) = |
033d890fe91f
name space of classes and types maintained in tsig;
wenzelm
parents:
16340
diff
changeset
|
524 |
let |
033d890fe91f
name space of classes and types maintained in tsig;
wenzelm
parents:
16340
diff
changeset
|
525 |
val c' = NameSpace.full naming c; |
033d890fe91f
name space of classes and types maintained in tsig;
wenzelm
parents:
16340
diff
changeset
|
526 |
val space' = NameSpace.declare naming c' space; |
033d890fe91f
name space of classes and types maintained in tsig;
wenzelm
parents:
16340
diff
changeset
|
527 |
val types' = |
17412 | 528 |
(case Symtab.lookup types c' of |
16370
033d890fe91f
name space of classes and types maintained in tsig;
wenzelm
parents:
16340
diff
changeset
|
529 |
SOME (decl', _) => err_in_decls c' decl decl' |
20674 | 530 |
| NONE => Symtab.update (c', (decl, serial ())) types); |
16370
033d890fe91f
name space of classes and types maintained in tsig;
wenzelm
parents:
16340
diff
changeset
|
531 |
in (space', 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
|
532 |
|
17412 | 533 |
fun the_decl (_, types) = fst o the o Symtab.lookup 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
|
534 |
|
19642 | 535 |
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
|
536 |
let |
b802d1804b77
replaced Sorts.DOMAIN by general Sorts.CLASS_ERROR;
wenzelm
parents:
19530
diff
changeset
|
537 |
val (space', tab') = f types; |
21858
05f57309170c
avoid conflict with Alice keywords: renamed pack -> implode, unpack -> explode, any -> many, avoided assert;
wenzelm
parents:
21116
diff
changeset
|
538 |
val _ = NameSpace.intern space' "dummy" = "dummy" orelse |
05f57309170c
avoid conflict with Alice keywords: renamed pack -> implode, unpack -> explode, any -> many, avoided assert;
wenzelm
parents:
21116
diff
changeset
|
539 |
error "Illegal declaration of dummy type"; |
19642 | 540 |
in (classes, default, (space', tab')) end); |
2964 | 541 |
|
14989 | 542 |
fun syntactic types (Type (c, Ts)) = |
17412 | 543 |
(case Symtab.lookup types c of SOME (Nonterminal, _) => true | _ => false) |
14989 | 544 |
orelse exists (syntactic types) Ts |
545 |
| syntactic _ _ = false; |
|
546 |
||
19579
b802d1804b77
replaced Sorts.DOMAIN by general Sorts.CLASS_ERROR;
wenzelm
parents:
19530
diff
changeset
|
547 |
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
|
548 |
let |
19250 | 549 |
fun err msg = cat_error msg ("The error(s) above occurred in type abbreviation: " ^ quote a); |
16946 | 550 |
val rhs' = strip_sorts (no_tvars (cert_typ_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
|
551 |
handle TYPE (msg, _, _) => err msg; |
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
|
552 |
in |
18964 | 553 |
(case duplicates (op =) vs of |
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
|
554 |
[] => [] |
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
|
555 |
| dups => err ("Duplicate variables on lhs: " ^ commas_quote dups)); |
20951
868120282837
gen_rem(s) abandoned in favour of remove / subtract
haftmann
parents:
20674
diff
changeset
|
556 |
(case subtract (op =) vs (map (#1 o #1) (typ_tvars rhs')) of |
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
|
557 |
[] => [] |
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
|
558 |
| extras => err ("Extra variables on rhs: " ^ commas_quote extras)); |
16370
033d890fe91f
name space of classes and types maintained in tsig;
wenzelm
parents:
16340
diff
changeset
|
559 |
types |> new_decl naming (a, Abbreviation (vs, rhs', syntactic (#2 types) 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
|
560 |
end); |
0 | 561 |
|
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
|
562 |
in |
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
|
563 |
|
19579
b802d1804b77
replaced Sorts.DOMAIN by general Sorts.CLASS_ERROR;
wenzelm
parents:
19530
diff
changeset
|
564 |
fun add_types naming ps = map_types (fold (new_decl naming) (ps |> map (fn (c, n) => |
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
|
565 |
if n < 0 then err_neg_args c else (c, LogicalType n)))); |
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
|
566 |
|
16370
033d890fe91f
name space of classes and types maintained in tsig;
wenzelm
parents:
16340
diff
changeset
|
567 |
val add_abbrevs = fold o add_abbrev; |
033d890fe91f
name space of classes and types maintained in tsig;
wenzelm
parents:
16340
diff
changeset
|
568 |
|
19579
b802d1804b77
replaced Sorts.DOMAIN by general Sorts.CLASS_ERROR;
wenzelm
parents:
19530
diff
changeset
|
569 |
fun add_nonterminals naming = map_types o fold (new_decl naming) o map (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
|
570 |
|
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
|
571 |
fun merge_types (types1, types2) = |
20674 | 572 |
NameSpace.merge_tables (Library.eq_snd (op = : serial * serial -> bool)) (types1, types2) |
573 |
handle Symtab.DUPS (d :: _) => err_in_decls d (the_decl types1 d) (the_decl types2 d); |
|
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
|
574 |
|
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
|
575 |
end; |
0 | 576 |
|
19642 | 577 |
fun hide_types fully cs = map_tsig (fn (classes, default, (space, types)) => |
578 |
(classes, default, (fold (NameSpace.hide fully) cs space, types))); |
|
16370
033d890fe91f
name space of classes and types maintained in tsig;
wenzelm
parents:
16340
diff
changeset
|
579 |
|
3790 | 580 |
|
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
|
581 |
(* 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
|
582 |
|
14830
faa4865ba1ce
removed norm_typ; improved output; refer to Pretty.pp;
wenzelm
parents:
14790
diff
changeset
|
583 |
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
|
584 |
let |
19515
9f650083da65
build classes/arities: refer to operations in sorts.ML;
wenzelm
parents:
19464
diff
changeset
|
585 |
val (TSig {classes = (space1, classes1), default = default1, types = types1, |
19642 | 586 |
log_types = _, witness = _}) = tsig1; |
19515
9f650083da65
build classes/arities: refer to operations in sorts.ML;
wenzelm
parents:
19464
diff
changeset
|
587 |
val (TSig {classes = (space2, classes2), default = default2, types = types2, |
19642 | 588 |
log_types = _, witness = _}) = 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
|
589 |
|
19515
9f650083da65
build classes/arities: refer to operations in sorts.ML;
wenzelm
parents:
19464
diff
changeset
|
590 |
val space' = NameSpace.merge (space1, space2); |
19642 | 591 |
val classes' = Sorts.merge_algebra pp (classes1, classes2); |
19515
9f650083da65
build classes/arities: refer to operations in sorts.ML;
wenzelm
parents:
19464
diff
changeset
|
592 |
val default' = Sorts.inter_sort classes' (default1, default2); |
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
|
593 |
val types' = merge_types (types1, types2); |
19642 | 594 |
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
|
595 |
|
0 | 596 |
end; |