equal
deleted
inserted
replaced
439 fun prep (b, raw_T, mx) = |
439 fun prep (b, raw_T, mx) = |
440 let |
440 let |
441 val c = full_name thy b; |
441 val c = full_name thy b; |
442 val T = (prepT raw_T handle TYPE (msg, _, _) => error msg) handle ERROR msg => |
442 val T = (prepT raw_T handle TYPE (msg, _, _) => error msg) handle ERROR msg => |
443 cat_error msg ("in declaration of constant " ^ quote (Binding.str_of b)); |
443 cat_error msg ("in declaration of constant " ^ quote (Binding.str_of b)); |
444 val T' = Logic.varifyT T; |
444 val T' = Logic.varifyT_global T; |
445 in ((b, T'), (Syntax.mark_const c, T', mx), Const (c, T)) end; |
445 in ((b, T'), (Syntax.mark_const c, T', mx), Const (c, T)) end; |
446 val args = map prep raw_args; |
446 val args = map prep raw_args; |
447 in |
447 in |
448 thy |
448 thy |
449 |> map_consts (fold (Consts.declare (naming_of thy) o #1) args) |
449 |> map_consts (fold (Consts.declare (naming_of thy) o #1) args) |
484 (* add constraints *) |
484 (* add constraints *) |
485 |
485 |
486 fun add_const_constraint (c, opt_T) thy = |
486 fun add_const_constraint (c, opt_T) thy = |
487 let |
487 let |
488 fun prepT raw_T = |
488 fun prepT raw_T = |
489 let val T = Logic.varifyT (Type.no_tvars (Term.no_dummyT (certify_typ thy raw_T))) |
489 let val T = Logic.varifyT_global (Type.no_tvars (Term.no_dummyT (certify_typ thy raw_T))) |
490 in cert_term thy (Const (c, T)); T end |
490 in cert_term thy (Const (c, T)); T end |
491 handle TYPE (msg, _, _) => error msg; |
491 handle TYPE (msg, _, _) => error msg; |
492 in thy |> map_consts (Consts.constrain (c, Option.map prepT opt_T)) end; |
492 in thy |> map_consts (Consts.constrain (c, Option.map prepT opt_T)) end; |
493 |
493 |
494 |
494 |