| author | nipkow | 
| Mon, 17 Dec 2007 17:01:54 +0100 | |
| changeset 25665 | faabc08af882 | 
| parent 25404 | 1a58d1c9fe88 | 
| child 26050 | 88bb26089ef5 | 
| permissions | -rw-r--r-- | 
| 18060 | 1 | (* Title: Pure/consts.ML | 
| 2 | ID: $Id$ | |
| 3 | Author: Makarius | |
| 4 | ||
| 18935 | 5 | Polymorphic constants: declarations, abbreviations, additional type | 
| 6 | constraints. | |
| 18060 | 7 | *) | 
| 8 | ||
| 9 | signature CONSTS = | |
| 10 | sig | |
| 11 | type T | |
| 19027 | 12 | val eq_consts: T * T -> bool | 
| 19364 | 13 | val abbrevs_of: T -> string list -> (term * term) list | 
| 18935 | 14 | val dest: T -> | 
| 25404 | 15 |    {constants: (typ * term option) NameSpace.table,
 | 
| 18935 | 16 | constraints: typ NameSpace.table} | 
| 25048 | 17 | val the_type: T -> string -> typ (*exception TYPE*) | 
| 18 | val the_abbreviation: T -> string -> typ * term (*exception TYPE*) | |
| 19 | val type_scheme: T -> string -> typ (*exception TYPE*) | |
| 20 | val the_tags: T -> string -> Markup.property list (*exception TYPE*) | |
| 21 | val is_monomorphic: T -> string -> bool (*exception TYPE*) | |
| 22 | val the_constraint: T -> string -> typ (*exception TYPE*) | |
| 18965 | 23 | val space_of: T -> NameSpace.T | 
| 19364 | 24 | val intern: T -> xstring -> string | 
| 25 | val extern: T -> string -> xstring | |
| 26 | val extern_early: T -> string -> xstring | |
| 19657 | 27 | val syntax: T -> string * mixfix -> string * typ * mixfix | 
| 21181 | 28 | val syntax_name: T -> string -> string | 
| 18965 | 29 | val read_const: T -> string -> term | 
| 24673 
62b75508eb66
certify: do_expand as explicit argument, actually certify type of abstractions;
 wenzelm parents: 
23655diff
changeset | 30 | val certify: Pretty.pp -> Type.tsig -> bool -> T -> term -> term (*exception TYPE*) | 
| 18146 | 31 | val typargs: T -> string * typ -> typ list | 
| 18163 | 32 | val instance: T -> string * typ list -> typ | 
| 24772 | 33 | val declare: bool -> NameSpace.naming -> Markup.property list -> (bstring * typ) -> T -> T | 
| 19098 
fc736dbbe333
constrain: assert const declaration, optional type (i.e. may delete constraints);
 wenzelm parents: 
19027diff
changeset | 34 | val constrain: string * typ option -> T -> T | 
| 24772 | 35 | val abbreviate: Pretty.pp -> Type.tsig -> NameSpace.naming -> string -> Markup.property list -> | 
| 21794 | 36 | bstring * term -> T -> (term * term) * T | 
| 25048 | 37 | val revert_abbrev: string -> string -> T -> T | 
| 18060 | 38 | val hide: bool -> string -> T -> T | 
| 39 | val empty: T | |
| 40 | val merge: T * T -> T | |
| 19364 | 41 | end; | 
| 18060 | 42 | |
| 43 | structure Consts: CONSTS = | |
| 44 | struct | |
| 45 | ||
| 19364 | 46 | (** consts type **) | 
| 47 | ||
| 48 | (* datatype T *) | |
| 18060 | 49 | |
| 24909 | 50 | type decl = {T: typ, typargs: int list list, tags: Markup.property list, authentic: bool};
 | 
| 51 | type abbrev = {rhs: term, normal_rhs: term, force_expand: bool};
 | |
| 18935 | 52 | |
| 18060 | 53 | datatype T = Consts of | 
| 24909 | 54 |  {decls: ((decl * abbrev option) * serial) NameSpace.table,
 | 
| 19364 | 55 | constraints: typ Symtab.table, | 
| 24673 
62b75508eb66
certify: do_expand as explicit argument, actually certify type of abstractions;
 wenzelm parents: 
23655diff
changeset | 56 | rev_abbrevs: (term * term) list Symtab.table} * stamp; | 
| 19027 | 57 | |
| 58 | fun eq_consts (Consts (_, s1), Consts (_, s2)) = s1 = s2; | |
| 18060 | 59 | |
| 24673 
62b75508eb66
certify: do_expand as explicit argument, actually certify type of abstractions;
 wenzelm parents: 
23655diff
changeset | 60 | fun make_consts (decls, constraints, rev_abbrevs) = | 
| 
62b75508eb66
certify: do_expand as explicit argument, actually certify type of abstractions;
 wenzelm parents: 
23655diff
changeset | 61 |   Consts ({decls = decls, constraints = constraints, rev_abbrevs = rev_abbrevs}, stamp ());
 | 
| 18060 | 62 | |
| 24673 
62b75508eb66
certify: do_expand as explicit argument, actually certify type of abstractions;
 wenzelm parents: 
23655diff
changeset | 63 | fun map_consts f (Consts ({decls, constraints, rev_abbrevs}, _)) =
 | 
| 
62b75508eb66
certify: do_expand as explicit argument, actually certify type of abstractions;
 wenzelm parents: 
23655diff
changeset | 64 | make_consts (f (decls, constraints, rev_abbrevs)); | 
| 19364 | 65 | |
| 66 | fun abbrevs_of (Consts ({rev_abbrevs, ...}, _)) modes =
 | |
| 19482 
9f11af8f7ef9
tuned basic list operators (flat, maps, map_filter);
 wenzelm parents: 
19433diff
changeset | 67 | maps (Symtab.lookup_list rev_abbrevs) modes; | 
| 19364 | 68 | |
| 18965 | 69 | |
| 19364 | 70 | (* dest consts *) | 
| 71 | ||
| 72 | fun dest (Consts ({decls = (space, decls), constraints, ...}, _)) =
 | |
| 73 |  {constants = (space,
 | |
| 24909 | 74 |     Symtab.fold (fn (c, (({T, ...}, abbr), _)) =>
 | 
| 25404 | 75 | Symtab.update (c, (T, Option.map #rhs abbr))) decls Symtab.empty), | 
| 18060 | 76 | constraints = (space, constraints)}; | 
| 77 | ||
| 78 | ||
| 79 | (* lookup consts *) | |
| 80 | ||
| 19027 | 81 | fun the_const (Consts ({decls = (_, tab), ...}, _)) c =
 | 
| 19364 | 82 | (case Symtab.lookup tab c of | 
| 24772 | 83 | SOME (decl, _) => decl | 
| 25041 | 84 |   | NONE => raise TYPE ("Unknown constant: " ^ quote c, [], []));
 | 
| 18935 | 85 | |
| 25041 | 86 | fun the_type consts c = | 
| 24772 | 87 | (case the_const consts c of | 
| 24909 | 88 |     ({T, ...}, NONE) => T
 | 
| 21720 
059e6b8cee8e
abbreviate: always authentic, force expansion of internal abbreviations;
 wenzelm parents: 
21694diff
changeset | 89 |   | _ => raise TYPE ("Not a logical constant: " ^ quote c, [], []));
 | 
| 18060 | 90 | |
| 21720 
059e6b8cee8e
abbreviate: always authentic, force expansion of internal abbreviations;
 wenzelm parents: 
21694diff
changeset | 91 | fun the_abbreviation consts c = | 
| 24772 | 92 | (case the_const consts c of | 
| 25048 | 93 |     ({T, ...}, SOME {rhs, ...}) => (T, rhs)
 | 
| 21720 
059e6b8cee8e
abbreviate: always authentic, force expansion of internal abbreviations;
 wenzelm parents: 
21694diff
changeset | 94 |   | _ => raise TYPE ("Not an abbreviated constant: " ^ quote c, [], []));
 | 
| 
059e6b8cee8e
abbreviate: always authentic, force expansion of internal abbreviations;
 wenzelm parents: 
21694diff
changeset | 95 | |
| 25041 | 96 | val the_decl = #1 oo the_const; | 
| 97 | val type_scheme = #T oo the_decl; | |
| 98 | val type_arguments = #typargs oo the_decl; | |
| 99 | val the_tags = #tags oo the_decl; | |
| 100 | ||
| 21720 
059e6b8cee8e
abbreviate: always authentic, force expansion of internal abbreviations;
 wenzelm parents: 
21694diff
changeset | 101 | val is_monomorphic = null oo type_arguments; | 
| 18935 | 102 | |
| 21720 
059e6b8cee8e
abbreviate: always authentic, force expansion of internal abbreviations;
 wenzelm parents: 
21694diff
changeset | 103 | fun the_constraint (consts as Consts ({constraints, ...}, _)) c =
 | 
| 18060 | 104 | (case Symtab.lookup constraints c of | 
| 105 | SOME T => T | |
| 25041 | 106 | | NONE => type_scheme consts c); | 
| 18935 | 107 | |
| 108 | ||
| 19657 | 109 | (* name space and syntax *) | 
| 19364 | 110 | |
| 111 | fun space_of (Consts ({decls = (space, _), ...}, _)) = space;
 | |
| 112 | ||
| 113 | val intern = NameSpace.intern o space_of; | |
| 114 | val extern = NameSpace.extern o space_of; | |
| 115 | ||
| 116 | fun extern_early consts c = | |
| 117 | (case try (the_const consts) c of | |
| 24909 | 118 |     SOME ({authentic = true, ...}, _) => Syntax.constN ^ c
 | 
| 19576 
179ad0076f75
extern_early: improved handling of undeclared constants;
 wenzelm parents: 
19502diff
changeset | 119 | | _ => extern consts c); | 
| 19364 | 120 | |
| 19657 | 121 | fun syntax consts (c, mx) = | 
| 122 | let | |
| 24909 | 123 |     val ({T, authentic, ...}, _) = the_const consts c handle TYPE (msg, _, _) => error msg;
 | 
| 19677 | 124 | val c' = if authentic then Syntax.constN ^ c else NameSpace.base c; | 
| 19657 | 125 | in (c', T, mx) end; | 
| 126 | ||
| 21181 | 127 | fun syntax_name consts c = #1 (syntax consts (c, NoSyn)); | 
| 128 | ||
| 18060 | 129 | |
| 19364 | 130 | (* read_const *) | 
| 131 | ||
| 132 | fun read_const consts raw_c = | |
| 133 | let | |
| 134 | val c = intern consts raw_c; | |
| 25041 | 135 | val T = type_scheme consts c handle TYPE (msg, _, _) => error msg; | 
| 21205 | 136 | in Const (c, T) end; | 
| 19364 | 137 | |
| 138 | ||
| 139 | (* certify *) | |
| 140 | ||
| 24673 
62b75508eb66
certify: do_expand as explicit argument, actually certify type of abstractions;
 wenzelm parents: 
23655diff
changeset | 141 | fun certify pp tsig do_expand consts = | 
| 18965 | 142 | let | 
| 143 | fun err msg (c, T) = | |
| 144 | raise TYPE (msg ^ " " ^ quote c ^ " :: " ^ Pretty.string_of_typ pp T, [], []); | |
| 24673 
62b75508eb66
certify: do_expand as explicit argument, actually certify type of abstractions;
 wenzelm parents: 
23655diff
changeset | 145 | val certT = Type.cert_typ tsig; | 
| 18965 | 146 | fun cert tm = | 
| 147 | let | |
| 148 | val (head, args) = Term.strip_comb tm; | |
| 21694 | 149 | val args' = map cert args; | 
| 150 | fun comb head' = Term.list_comb (head', args'); | |
| 18965 | 151 | in | 
| 152 | (case head of | |
| 24673 
62b75508eb66
certify: do_expand as explicit argument, actually certify type of abstractions;
 wenzelm parents: 
23655diff
changeset | 153 | Abs (x, T, t) => comb (Abs (x, certT T, cert t)) | 
| 19364 | 154 | | Const (c, T) => | 
| 155 | let | |
| 24673 
62b75508eb66
certify: do_expand as explicit argument, actually certify type of abstractions;
 wenzelm parents: 
23655diff
changeset | 156 | val T' = certT T; | 
| 24909 | 157 |               val ({T = U, ...}, abbr) = the_const consts c;
 | 
| 25048 | 158 | fun expand u = | 
| 159 | Term.betapplys (Envir.expand_atom T' (U, u) handle TYPE _ => | |
| 160 | err "Illegal type for abbreviation" (c, T), args'); | |
| 19364 | 161 | in | 
| 19433 
c7a2b7a8c4cb
certify: ignore sort constraints of declarations (MAJOR CHANGE);
 wenzelm parents: 
19364diff
changeset | 162 | if not (Type.raw_instance (T', U)) then | 
| 19364 | 163 | err "Illegal type for constant" (c, T) | 
| 164 | else | |
| 24909 | 165 | (case abbr of | 
| 25048 | 166 |                   SOME {rhs, normal_rhs, force_expand} =>
 | 
| 167 | if do_expand then expand normal_rhs | |
| 168 | else if force_expand then expand rhs | |
| 21720 
059e6b8cee8e
abbreviate: always authentic, force expansion of internal abbreviations;
 wenzelm parents: 
21694diff
changeset | 169 | else comb head | 
| 19364 | 170 | | _ => comb head) | 
| 171 | end | |
| 172 | | _ => comb head) | |
| 18965 | 173 | end; | 
| 174 | in cert end; | |
| 175 | ||
| 176 | ||
| 18060 | 177 | (* typargs -- view actual const type as instance of declaration *) | 
| 178 | ||
| 24909 | 179 | local | 
| 180 | ||
| 181 | fun args_of (Type (_, Ts)) pos = args_of_list Ts 0 pos | |
| 182 | | args_of (TVar v) pos = insert (eq_fst op =) (v, rev pos) | |
| 183 | | args_of (TFree _) _ = I | |
| 184 | and args_of_list (T :: Ts) i is = args_of T (i :: is) #> args_of_list Ts (i + 1) is | |
| 185 | | args_of_list [] _ _ = I; | |
| 186 | ||
| 19364 | 187 | fun subscript (Type (_, Ts)) (i :: is) = subscript (nth Ts i) is | 
| 188 | | subscript T [] = T | |
| 189 | | subscript T _ = raise Subscript; | |
| 18060 | 190 | |
| 24909 | 191 | in | 
| 192 | ||
| 193 | fun typargs_of T = map #2 (rev (args_of T [] [])); | |
| 194 | ||
| 19364 | 195 | fun typargs consts (c, T) = map (subscript T) (type_arguments consts c); | 
| 18060 | 196 | |
| 24909 | 197 | end; | 
| 198 | ||
| 18163 | 199 | fun instance consts (c, Ts) = | 
| 200 | let | |
| 25041 | 201 | val declT = type_scheme consts c; | 
| 18163 | 202 | val vars = map Term.dest_TVar (typargs consts (c, declT)); | 
| 24673 
62b75508eb66
certify: do_expand as explicit argument, actually certify type of abstractions;
 wenzelm parents: 
23655diff
changeset | 203 | val inst = vars ~~ Ts handle UnequalLengths => | 
| 
62b75508eb66
certify: do_expand as explicit argument, actually certify type of abstractions;
 wenzelm parents: 
23655diff
changeset | 204 |       raise TYPE ("Consts.instance", Ts, [Const (c, dummyT)]);
 | 
| 
62b75508eb66
certify: do_expand as explicit argument, actually certify type of abstractions;
 wenzelm parents: 
23655diff
changeset | 205 | in declT |> TermSubst.instantiateT inst end; | 
| 18163 | 206 | |
| 18060 | 207 | |
| 208 | ||
| 19364 | 209 | (** build consts **) | 
| 18060 | 210 | |
| 23655 
d2d1138e0ddc
replaced exception TableFun/GraphFun.DUPS by TableFun/GraphFun.DUP;
 wenzelm parents: 
23086diff
changeset | 211 | fun err_dup_const c = | 
| 
d2d1138e0ddc
replaced exception TableFun/GraphFun.DUPS by TableFun/GraphFun.DUP;
 wenzelm parents: 
23086diff
changeset | 212 |   error ("Duplicate declaration of constant " ^ quote c);
 | 
| 18060 | 213 | |
| 23086 | 214 | fun extend_decls naming decl tab = NameSpace.extend_table naming [decl] tab | 
| 23655 
d2d1138e0ddc
replaced exception TableFun/GraphFun.DUPS by TableFun/GraphFun.DUP;
 wenzelm parents: 
23086diff
changeset | 215 | handle Symtab.DUP c => err_dup_const c; | 
| 18060 | 216 | |
| 18935 | 217 | |
| 218 | (* name space *) | |
| 18060 | 219 | |
| 24673 
62b75508eb66
certify: do_expand as explicit argument, actually certify type of abstractions;
 wenzelm parents: 
23655diff
changeset | 220 | fun hide fully c = map_consts (fn (decls, constraints, rev_abbrevs) => | 
| 
62b75508eb66
certify: do_expand as explicit argument, actually certify type of abstractions;
 wenzelm parents: 
23655diff
changeset | 221 | (apfst (NameSpace.hide fully c) decls, constraints, rev_abbrevs)); | 
| 18935 | 222 | |
| 223 | ||
| 224 | (* declarations *) | |
| 225 | ||
| 24772 | 226 | fun declare authentic naming tags (c, declT) = map_consts (fn (decls, constraints, rev_abbrevs) => | 
| 18060 | 227 | let | 
| 24909 | 228 |     val decl = {T = declT, typargs = typargs_of declT, tags = tags, authentic = authentic};
 | 
| 229 | val decls' = decls |> extend_decls naming (c, ((decl, NONE), serial ())); | |
| 24772 | 230 | in (decls', constraints, rev_abbrevs) end); | 
| 19364 | 231 | |
| 232 | ||
| 233 | (* constraints *) | |
| 234 | ||
| 235 | fun constrain (c, C) consts = | |
| 24673 
62b75508eb66
certify: do_expand as explicit argument, actually certify type of abstractions;
 wenzelm parents: 
23655diff
changeset | 236 | consts |> map_consts (fn (decls, constraints, rev_abbrevs) => | 
| 19364 | 237 | (the_const consts c handle TYPE (msg, _, _) => error msg; | 
| 238 | (decls, | |
| 239 | constraints |> (case C of SOME T => Symtab.update (c, T) | NONE => Symtab.delete_safe c), | |
| 24673 
62b75508eb66
certify: do_expand as explicit argument, actually certify type of abstractions;
 wenzelm parents: 
23655diff
changeset | 240 | rev_abbrevs))); | 
| 18060 | 241 | |
| 18935 | 242 | |
| 243 | (* abbreviations *) | |
| 244 | ||
| 19027 | 245 | local | 
| 246 | ||
| 19364 | 247 | fun strip_abss tm = ([], tm) :: | 
| 248 | (case tm of | |
| 249 | Abs (a, T, t) => | |
| 250 | if Term.loose_bvar1 (t, 0) then | |
| 251 | strip_abss t |> map (fn (xs, b) => ((a, T) :: xs, b)) | |
| 252 | else [] | |
| 253 | | _ => []); | |
| 19027 | 254 | |
| 21720 
059e6b8cee8e
abbreviate: always authentic, force expansion of internal abbreviations;
 wenzelm parents: 
21694diff
changeset | 255 | fun rev_abbrev lhs rhs = | 
| 18060 | 256 | let | 
| 19027 | 257 | fun abbrev (xs, body) = | 
| 258 | let val vars = fold (fn (x, T) => cons (Var ((x, 0), T))) (Term.rename_wrt_term body xs) [] | |
| 21720 
059e6b8cee8e
abbreviate: always authentic, force expansion of internal abbreviations;
 wenzelm parents: 
21694diff
changeset | 259 | in (Term.subst_bounds (rev vars, body), Term.list_comb (lhs, vars)) end; | 
| 19502 | 260 | in map abbrev (strip_abss (Envir.beta_eta_contract rhs)) end; | 
| 19027 | 261 | |
| 262 | in | |
| 18965 | 263 | |
| 24772 | 264 | fun abbreviate pp tsig naming mode tags (c, raw_rhs) consts = | 
| 18965 | 265 | let | 
| 24673 
62b75508eb66
certify: do_expand as explicit argument, actually certify type of abstractions;
 wenzelm parents: 
23655diff
changeset | 266 | val cert_term = certify pp tsig false consts; | 
| 
62b75508eb66
certify: do_expand as explicit argument, actually certify type of abstractions;
 wenzelm parents: 
23655diff
changeset | 267 | val expand_term = certify pp tsig true consts; | 
| 25116 | 268 | val force_expand = mode = PrintMode.internal; | 
| 21720 
059e6b8cee8e
abbreviate: always authentic, force expansion of internal abbreviations;
 wenzelm parents: 
21694diff
changeset | 269 | |
| 19364 | 270 | val rhs = raw_rhs | 
| 20548 
8ef25fe585a8
renamed Term.map_term_types to Term.map_types (cf. Term.fold_types);
 wenzelm parents: 
20509diff
changeset | 271 | |> Term.map_types (Type.cert_typ tsig) | 
| 21720 
059e6b8cee8e
abbreviate: always authentic, force expansion of internal abbreviations;
 wenzelm parents: 
21694diff
changeset | 272 | |> cert_term; | 
| 25404 | 273 | val normal_rhs = expand_term rhs; | 
| 21794 | 274 | val T = Term.fastype_of rhs; | 
| 275 | val lhs = Const (NameSpace.full naming c, T); | |
| 21720 
059e6b8cee8e
abbreviate: always authentic, force expansion of internal abbreviations;
 wenzelm parents: 
21694diff
changeset | 276 | |
| 21680 
5d2230ad1261
abbreviate: improved error handling, return result;
 wenzelm parents: 
21205diff
changeset | 277 | fun err msg = error (msg ^ " on rhs of abbreviation:\n" ^ | 
| 21720 
059e6b8cee8e
abbreviate: always authentic, force expansion of internal abbreviations;
 wenzelm parents: 
21694diff
changeset | 278 | Pretty.string_of_term pp (Logic.mk_equals (lhs, rhs))); | 
| 25048 | 279 | val _ = Term.exists_subterm Term.is_Var rhs andalso err "Illegal schematic variables"; | 
| 280 | val _ = null (Term.hidden_polymorphism rhs) orelse err "Extra type variables"; | |
| 19364 | 281 | in | 
| 24673 
62b75508eb66
certify: do_expand as explicit argument, actually certify type of abstractions;
 wenzelm parents: 
23655diff
changeset | 282 | consts |> map_consts (fn (decls, constraints, rev_abbrevs) => | 
| 19364 | 283 | let | 
| 24909 | 284 |         val decl = {T = T, typargs = typargs_of T, tags = tags, authentic = true};
 | 
| 25404 | 285 |         val abbr = {rhs = rhs, normal_rhs = normal_rhs, force_expand = force_expand};
 | 
| 24772 | 286 | val decls' = decls | 
| 24909 | 287 | |> extend_decls naming (c, ((decl, SOME abbr), serial ())); | 
| 19364 | 288 | val rev_abbrevs' = rev_abbrevs | 
| 25389 | 289 | |> fold (curry Symtab.cons_list mode) (rev_abbrev lhs rhs); | 
| 24673 
62b75508eb66
certify: do_expand as explicit argument, actually certify type of abstractions;
 wenzelm parents: 
23655diff
changeset | 290 | in (decls', constraints, rev_abbrevs') end) | 
| 21794 | 291 | |> pair (lhs, rhs) | 
| 19364 | 292 | end; | 
| 18935 | 293 | |
| 25048 | 294 | fun revert_abbrev mode c consts = consts |> map_consts (fn (decls, constraints, rev_abbrevs) => | 
| 295 | let | |
| 296 | val (T, rhs) = the_abbreviation consts c; | |
| 297 | val rev_abbrevs' = rev_abbrevs | |
| 25389 | 298 | |> fold (curry Symtab.cons_list mode) (rev_abbrev (Const (c, T)) rhs); | 
| 25048 | 299 | in (decls, constraints, rev_abbrevs') end); | 
| 300 | ||
| 19027 | 301 | end; | 
| 302 | ||
| 18060 | 303 | |
| 304 | (* empty and merge *) | |
| 305 | ||
| 24673 
62b75508eb66
certify: do_expand as explicit argument, actually certify type of abstractions;
 wenzelm parents: 
23655diff
changeset | 306 | val empty = make_consts (NameSpace.empty_table, Symtab.empty, Symtab.empty); | 
| 18060 | 307 | |
| 308 | fun merge | |
| 24673 
62b75508eb66
certify: do_expand as explicit argument, actually certify type of abstractions;
 wenzelm parents: 
23655diff
changeset | 309 |    (Consts ({decls = decls1, constraints = constraints1, rev_abbrevs = rev_abbrevs1}, _),
 | 
| 
62b75508eb66
certify: do_expand as explicit argument, actually certify type of abstractions;
 wenzelm parents: 
23655diff
changeset | 310 |     Consts ({decls = decls2, constraints = constraints2, rev_abbrevs = rev_abbrevs2}, _)) =
 | 
| 18060 | 311 | let | 
| 18935 | 312 | val decls' = NameSpace.merge_tables (eq_snd (op =)) (decls1, decls2) | 
| 23655 
d2d1138e0ddc
replaced exception TableFun/GraphFun.DUPS by TableFun/GraphFun.DUP;
 wenzelm parents: 
23086diff
changeset | 313 | handle Symtab.DUP c => err_dup_const c; | 
| 25037 | 314 | val constraints' = Symtab.join (K fst) (constraints1, constraints2); | 
| 19364 | 315 | val rev_abbrevs' = (rev_abbrevs1, rev_abbrevs2) |> Symtab.join | 
| 316 | (K (Library.merge (fn ((t, u), (t', u')) => t aconv t' andalso u aconv u'))); | |
| 24673 
62b75508eb66
certify: do_expand as explicit argument, actually certify type of abstractions;
 wenzelm parents: 
23655diff
changeset | 317 | in make_consts (decls', constraints', rev_abbrevs') end; | 
| 18060 | 318 | |
| 319 | end; |