equal
deleted
inserted
replaced
276 val all_sorts_nonempty = is_some o universal_witness; |
276 val all_sorts_nonempty = is_some o universal_witness; |
277 val typ_instance = Type.typ_instance o tsig_of; |
277 val typ_instance = Type.typ_instance o tsig_of; |
278 fun typ_equiv thy (T, U) = typ_instance thy (T, U) andalso typ_instance thy (U, T); |
278 fun typ_equiv thy (T, U) = typ_instance thy (T, U) andalso typ_instance thy (U, T); |
279 val typ_match = Type.typ_match o tsig_of; |
279 val typ_match = Type.typ_match o tsig_of; |
280 val typ_unify = Type.unify o tsig_of; |
280 val typ_unify = Type.unify o tsig_of; |
281 fun is_logtype thy c = c mem_string Type.logical_types (tsig_of thy); |
281 val is_logtype = member (op =) o Type.logical_types o tsig_of; |
282 |
282 |
283 |
283 |
284 (* polymorphic constants *) |
284 (* polymorphic constants *) |
285 |
285 |
286 val consts_of = #consts o rep_sg; |
286 val consts_of = #consts o rep_sg; |
336 |
336 |
337 val add_consts = Term.fold_aterms (fn Const (c, _) => insert (op =) c | _ => I); |
337 val add_consts = Term.fold_aterms (fn Const (c, _) => insert (op =) c | _ => I); |
338 |
338 |
339 fun mapping add_names f t = |
339 fun mapping add_names f t = |
340 let |
340 let |
341 fun f' x = let val y = f x in if x = y then NONE else SOME (x, y) end; |
341 fun f' (x: string) = let val y = f x in if x = y then NONE else SOME (x, y) end; |
342 val tab = map_filter f' (add_names t []); |
342 val tab = map_filter f' (add_names t []); |
343 fun get x = the_default x (AList.lookup (op =) tab x); |
343 fun get x = the_default x (AList.lookup (op =) tab x); |
344 in get end; |
344 in get end; |
345 |
345 |
346 fun typ_mapping f g thy T = |
346 fun typ_mapping f g thy T = |
661 val tsig' = Type.add_types naming decls tsig; |
661 val tsig' = Type.add_types naming decls tsig; |
662 in (naming, syn', tsig', consts) end); |
662 in (naming, syn', tsig', consts) end); |
663 |
663 |
664 fun add_typedecls decls thy = |
664 fun add_typedecls decls thy = |
665 let |
665 let |
666 fun type_of (a, vs, mx) = |
666 fun type_of (a, vs: string list, mx) = |
667 if not (has_duplicates (op =) vs) then (a, length vs, mx) |
667 if not (has_duplicates (op =) vs) then (a, length vs, mx) |
668 else error ("Duplicate parameters in type declaration: " ^ quote a); |
668 else error ("Duplicate parameters in type declaration: " ^ quote a); |
669 in add_types (map type_of decls) thy end; |
669 in add_types (map type_of decls) thy end; |
670 |
670 |
671 |
671 |