src/Pure/sign.ML
changeset 16494 6961e8ab33e1
parent 16442 1171ecf7fb7e
child 16536 c5744af6b28a
equal deleted inserted replaced
16493:d0f6c33b2300 16494:6961e8ab33e1
   131   val certify_sort: theory -> sort -> sort
   131   val certify_sort: theory -> sort -> sort
   132   val certify_typ: theory -> typ -> typ
   132   val certify_typ: theory -> typ -> typ
   133   val certify_typ_syntax: theory -> typ -> typ
   133   val certify_typ_syntax: theory -> typ -> typ
   134   val certify_typ_abbrev: theory -> typ -> typ
   134   val certify_typ_abbrev: theory -> typ -> typ
   135   val certify_term: Pretty.pp -> theory -> term -> term * typ * int
   135   val certify_term: Pretty.pp -> theory -> term -> term * typ * int
       
   136   val certify_prop: Pretty.pp -> theory -> term -> term * typ * int
       
   137   val cert_term: theory -> term -> term
       
   138   val cert_prop: theory -> term -> term
   136   val read_sort': Syntax.syntax -> theory -> string -> sort
   139   val read_sort': Syntax.syntax -> theory -> string -> sort
   137   val read_sort: theory -> string -> sort
   140   val read_sort: theory -> string -> sort
   138   val read_typ': Syntax.syntax -> theory * (indexname -> sort option) -> string -> typ
   141   val read_typ': Syntax.syntax -> theory * (indexname -> sort option) -> string -> typ
   139   val read_typ_syntax': Syntax.syntax -> theory * (indexname -> sort option) -> string -> typ
   142   val read_typ_syntax': Syntax.syntax -> theory * (indexname -> sort option) -> string -> typ
   140   val read_typ_abbrev': Syntax.syntax -> theory * (indexname -> sort option) -> string -> typ
   143   val read_typ_abbrev': Syntax.syntax -> theory * (indexname -> sort option) -> string -> typ
   154     string list -> bool -> (string * typ) list -> term list * (indexname * typ) list
   157     string list -> bool -> (string * typ) list -> term list * (indexname * typ) list
   155   val read_def_terms:
   158   val read_def_terms:
   156     theory * (indexname -> typ option) * (indexname -> sort option) ->
   159     theory * (indexname -> typ option) * (indexname -> sort option) ->
   157     string list -> bool -> (string * typ) list -> term list * (indexname * typ) list
   160     string list -> bool -> (string * typ) list -> term list * (indexname * typ) list
   158   val simple_read_term: theory -> typ -> string -> term
   161   val simple_read_term: theory -> typ -> string -> term
       
   162   val read_term: theory -> string -> term
       
   163   val read_prop: theory -> string -> term
   159   val const_of_class: class -> string
   164   val const_of_class: class -> string
   160   val class_of_const: string -> class
   165   val class_of_const: string -> class
   161   include SIGN_THEORY
   166   include SIGN_THEORY
   162 end
   167 end
   163 
   168 
   461     check_atoms tm';
   466     check_atoms tm';
   462     (tm', type_check pp tm', maxidx_of_term tm')
   467     (tm', type_check pp tm', maxidx_of_term tm')
   463   end;
   468   end;
   464 
   469 
   465 end;
   470 end;
       
   471 
       
   472 fun certify_prop pp thy tm =
       
   473   let val res as (tm', T, _) = certify_term pp thy tm
       
   474   in if T <> propT then raise TYPE ("Term not of type prop", [T], [tm']) else res end;
       
   475 
       
   476 fun cert_term thy tm = #1 (certify_term (pp thy) thy tm);
       
   477 fun cert_prop thy tm = #1 (certify_prop (pp thy) thy tm);
   466 
   478 
   467 
   479 
   468 
   480 
   469 (** read and certify entities **)    (*exception ERROR*)
   481 (** read and certify entities **)    (*exception ERROR*)
   470 
   482 
   573 
   585 
   574 fun infer_types pp thy def_type def_sort used freeze tsT =
   586 fun infer_types pp thy def_type def_sort used freeze tsT =
   575   apfst hd (infer_types_simult pp thy def_type def_sort used freeze [tsT]);
   587   apfst hd (infer_types_simult pp thy def_type def_sort used freeze [tsT]);
   576 
   588 
   577 
   589 
   578 
   590 (* read_def_terms -- read terms and infer types *)    (*exception ERROR*)
   579 (** read_def_terms -- read terms and infer types **)    (*exception ERROR*)
       
   580 
   591 
   581 fun read_def_terms' pp is_logtype syn (thy, types, sorts) used freeze sTs =
   592 fun read_def_terms' pp is_logtype syn (thy, types, sorts) used freeze sTs =
   582   let
   593   let
   583     fun read (s, T) =
   594     fun read (s, T) =
   584       let val T' = certify_typ thy T handle TYPE (msg, _, _) => error msg
   595       let val T' = certify_typ thy T handle TYPE (msg, _, _) => error msg
   590 
   601 
   591 fun simple_read_term thy T s =
   602 fun simple_read_term thy T s =
   592   let val ([t], _) = read_def_terms (thy, K NONE, K NONE) [] true [(s, T)]
   603   let val ([t], _) = read_def_terms (thy, K NONE, K NONE) [] true [(s, T)]
   593   in t end
   604   in t end
   594   handle ERROR => error ("The error(s) above occurred for term " ^ s);
   605   handle ERROR => error ("The error(s) above occurred for term " ^ s);
       
   606 
       
   607 fun read_term thy = simple_read_term thy TypeInfer.logicT;
       
   608 fun read_prop thy = simple_read_term thy propT;
   595 
   609 
   596 
   610 
   597 
   611 
   598 (** signature extension functions **)  (*exception ERROR/TYPE*)
   612 (** signature extension functions **)  (*exception ERROR/TYPE*)
   599 
   613