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