src/Pure/sign.ML
changeset 24142 6f6b698b9def
parent 23963 c2ee97a963db
child 24233 5bec1b4149e7
equal deleted inserted replaced
24141:73baca986087 24142:6f6b698b9def
   397 (* certify wrt. type signature *)
   397 (* certify wrt. type signature *)
   398 
   398 
   399 val arity_number = Type.arity_number o tsig_of;
   399 val arity_number = Type.arity_number o tsig_of;
   400 fun arity_sorts thy = Type.arity_sorts (pp thy) (tsig_of thy);
   400 fun arity_sorts thy = Type.arity_sorts (pp thy) (tsig_of thy);
   401 
   401 
   402 fun certify cert = cert o tsig_of o Context.check_thy;
   402 fun certify cert = cert o tsig_of;
   403 
   403 
   404 val certify_class      = certify Type.cert_class;
   404 val certify_class      = certify Type.cert_class;
   405 val certify_sort       = certify Type.cert_sort;
   405 val certify_sort       = certify Type.cert_sort;
   406 val certify_typ        = certify Type.cert_typ;
   406 val certify_typ        = certify Type.cert_typ;
   407 val certify_typ_syntax = certify Type.cert_typ_syntax;
   407 val certify_typ_syntax = certify Type.cert_typ_syntax;
   448 
   448 
   449 in
   449 in
   450 
   450 
   451 fun certify' normalize prop pp consts thy tm =
   451 fun certify' normalize prop pp consts thy tm =
   452   let
   452   let
   453     val _ = Context.check_thy thy;
       
   454     val _ = check_vars tm;
   453     val _ = check_vars tm;
   455     val tm' = Term.map_types (certify_typ thy) tm;
   454     val tm' = Term.map_types (certify_typ thy) tm;
   456     val T = type_check pp tm';
   455     val T = type_check pp tm';
   457     val _ = if prop andalso T <> propT then err "Term not of type prop" else ();
   456     val _ = if prop andalso T <> propT then err "Term not of type prop" else ();
   458     val tm'' = Consts.certify pp (tsig_of thy) consts tm';
   457     val tm'' = Consts.certify pp (tsig_of thy) consts tm';
   499   handle TYPE (msg, _, _) => error msg;
   498   handle TYPE (msg, _, _) => error msg;
   500 
   499 
   501 fun read_sort' syn ctxt str =
   500 fun read_sort' syn ctxt str =
   502   let
   501   let
   503     val thy = ProofContext.theory_of ctxt;
   502     val thy = ProofContext.theory_of ctxt;
   504     val _ = Context.check_thy thy;
       
   505     val S = Syntax.read_sort ctxt syn (intern_sort thy) str;
   503     val S = Syntax.read_sort ctxt syn (intern_sort thy) str;
   506   in certify_sort thy S handle TYPE (msg, _, _) => error msg end;
   504   in certify_sort thy S handle TYPE (msg, _, _) => error msg end;
   507 
   505 
   508 fun read_sort thy str = read_sort' (syn_of thy) (ProofContext.init thy) str;
   506 fun read_sort thy str = read_sort' (syn_of thy) (ProofContext.init thy) str;
   509 
   507 
   545 local
   543 local
   546 
   544 
   547 fun gen_read_typ' cert syn ctxt def_sort str =
   545 fun gen_read_typ' cert syn ctxt def_sort str =
   548   let
   546   let
   549     val thy = ProofContext.theory_of ctxt;
   547     val thy = ProofContext.theory_of ctxt;
   550     val _ = Context.check_thy thy;
       
   551     val T = intern_tycons thy
   548     val T = intern_tycons thy
   552       (Syntax.read_typ ctxt syn (get_sort thy def_sort) (intern_sort thy) str);
   549       (Syntax.read_typ ctxt syn (get_sort thy def_sort) (intern_sort thy) str);
   553   in cert thy T handle TYPE (msg, _, _) => error msg end
   550   in cert thy T handle TYPE (msg, _, _) => error msg end
   554   handle ERROR msg => cat_error msg ("The error(s) above occurred in type " ^ quote str);
   551   handle ERROR msg => cat_error msg ("The error(s) above occurred in type " ^ quote str);
   555 
   552