280 |
280 |
281 (* consts signature *) |
281 (* consts signature *) |
282 |
282 |
283 fun const_constraint thy c = |
283 fun const_constraint thy c = |
284 let val ((_, consts), constraints) = #consts (rep_sg thy) in |
284 let val ((_, consts), constraints) = #consts (rep_sg thy) in |
285 (case Symtab.lookup (constraints, c) of |
285 (case Symtab.curried_lookup constraints c of |
286 NONE => Option.map #1 (Symtab.lookup (consts, c)) |
286 NONE => Option.map #1 (Symtab.curried_lookup consts c) |
287 | some => some) |
287 | some => some) |
288 end; |
288 end; |
289 |
289 |
290 fun the_const_constraint thy c = |
290 fun the_const_constraint thy c = |
291 (case const_constraint thy c of SOME T => T |
291 (case const_constraint thy c of SOME T => T |
292 | NONE => raise TYPE ("Undeclared constant " ^ quote c, [], [])); |
292 | NONE => raise TYPE ("Undeclared constant " ^ quote c, [], [])); |
293 |
293 |
294 fun const_type thy c = Option.map #1 (Symtab.lookup (#2 (#1 (#consts (rep_sg thy))), c)); |
294 val const_type = Option.map #1 oo (Symtab.curried_lookup o #2 o #1 o #consts o rep_sg); |
295 |
295 |
296 fun the_const_type thy c = |
296 fun the_const_type thy c = |
297 (case const_type thy c of SOME T => T |
297 (case const_type thy c of SOME T => T |
298 | NONE => raise TYPE ("Undeclared constant " ^ quote c, [], [])); |
298 | NONE => raise TYPE ("Undeclared constant " ^ quote c, [], [])); |
299 |
299 |
512 |
512 |
513 (* type and constant names *) |
513 (* type and constant names *) |
514 |
514 |
515 fun read_tyname thy raw_c = |
515 fun read_tyname thy raw_c = |
516 let val c = intern_type thy raw_c in |
516 let val c = intern_type thy raw_c in |
517 (case Symtab.lookup (#2 (#types (Type.rep_tsig (tsig_of thy))), c) of |
517 (case Symtab.curried_lookup (#2 (#types (Type.rep_tsig (tsig_of thy)))) c of |
518 SOME (Type.LogicalType n, _) => Type (c, replicate n dummyT) |
518 SOME (Type.LogicalType n, _) => Type (c, replicate n dummyT) |
519 | _ => error ("Undeclared type constructor: " ^ quote c)) |
519 | _ => error ("Undeclared type constructor: " ^ quote c)) |
520 end; |
520 end; |
521 |
521 |
522 fun read_const thy raw_c = |
522 fun read_const thy raw_c = |
712 val c = int_const thy raw_c; |
712 val c = int_const thy raw_c; |
713 val T = Term.zero_var_indexesT (Term.no_dummyT (prep_typ thy raw_T)) |
713 val T = Term.zero_var_indexesT (Term.no_dummyT (prep_typ thy raw_T)) |
714 handle TYPE (msg, _, _) => error msg; |
714 handle TYPE (msg, _, _) => error msg; |
715 val _ = cert_term thy (Const (c, T)) |
715 val _ = cert_term thy (Const (c, T)) |
716 handle TYPE (msg, _, _) => error msg; |
716 handle TYPE (msg, _, _) => error msg; |
717 in thy |> map_consts (apsnd (curry Symtab.update (c, T))) end; |
717 in thy |> map_consts (apsnd (Symtab.curried_update (c, T))) end; |
718 |
718 |
719 val add_const_constraint = gen_add_constraint intern_const (read_typ o no_def_sort); |
719 val add_const_constraint = gen_add_constraint intern_const (read_typ o no_def_sort); |
720 val add_const_constraint_i = gen_add_constraint (K I) certify_typ; |
720 val add_const_constraint_i = gen_add_constraint (K I) certify_typ; |
721 |
721 |
722 |
722 |