src/Pure/sign.ML
changeset 24761 d762ab297a07
parent 24732 08c2dd5378c7
child 24776 38afb780f622
equal deleted inserted replaced
24760:3f9aa1e13d16 24761:d762ab297a07
    87   val typ_instance: theory -> typ * typ -> bool
    87   val typ_instance: theory -> typ * typ -> bool
    88   val typ_equiv: theory -> typ * typ -> bool
    88   val typ_equiv: theory -> typ * typ -> bool
    89   val typ_match: theory -> typ * typ -> Type.tyenv -> Type.tyenv
    89   val typ_match: theory -> typ * typ -> Type.tyenv -> Type.tyenv
    90   val typ_unify: theory -> typ * typ -> Type.tyenv * int -> Type.tyenv * int
    90   val typ_unify: theory -> typ * typ -> Type.tyenv * int -> Type.tyenv * int
    91   val consts_of: theory -> Consts.T
    91   val consts_of: theory -> Consts.T
    92   val const_constraint: theory -> string -> typ option
       
    93   val the_const_constraint: theory -> string -> typ
    92   val the_const_constraint: theory -> string -> typ
    94   val const_type: theory -> string -> typ option
    93   val const_type: theory -> string -> typ option
    95   val the_const_type: theory -> string -> typ
    94   val the_const_type: theory -> string -> typ
    96   val declared_tyname: theory -> string -> bool
    95   val declared_tyname: theory -> string -> bool
    97   val declared_const: theory -> string -> bool
    96   val declared_const: theory -> string -> bool
   164   val read_prop: theory -> string -> term
   163   val read_prop: theory -> string -> term
   165   val add_consts_authentic: (bstring * typ * mixfix) list -> theory -> theory
   164   val add_consts_authentic: (bstring * typ * mixfix) list -> theory -> theory
   166   val add_notation: Syntax.mode -> (term * mixfix) list -> theory -> theory
   165   val add_notation: Syntax.mode -> (term * mixfix) list -> theory -> theory
   167   val add_abbrev: string -> bstring * term -> theory -> (term * term) * theory
   166   val add_abbrev: string -> bstring * term -> theory -> (term * term) * theory
   168   include SIGN_THEORY
   167   include SIGN_THEORY
   169   val add_const_constraint: xstring * string option -> theory -> theory
   168   val add_const_constraint: string * typ option -> theory -> theory
   170   val add_const_constraint_i: string * typ option -> theory -> theory
       
   171   val primitive_class: string * class list -> theory -> theory
   169   val primitive_class: string * class list -> theory -> theory
   172   val primitive_classrel: class * class -> theory -> theory
   170   val primitive_classrel: class * class -> theory -> theory
   173   val primitive_arity: arity -> theory -> theory
   171   val primitive_arity: arity -> theory -> theory
   174   val hide_classes: bool -> xstring list -> theory -> theory
   172   val hide_classes: bool -> xstring list -> theory -> theory
   175   val hide_classes_i: bool -> string list -> theory -> theory
   173   val hide_classes_i: bool -> string list -> theory -> theory
   269 
   267 
   270 (* polymorphic constants *)
   268 (* polymorphic constants *)
   271 
   269 
   272 val consts_of = #consts o rep_sg;
   270 val consts_of = #consts o rep_sg;
   273 val the_const_constraint = Consts.the_constraint o consts_of;
   271 val the_const_constraint = Consts.the_constraint o consts_of;
   274 val const_constraint = try o the_const_constraint;
       
   275 val the_const_type = Consts.the_declaration o consts_of;
   272 val the_const_type = Consts.the_declaration o consts_of;
   276 val const_type = try o the_const_type;
   273 val const_type = try o the_const_type;
   277 val const_monomorphic = Consts.is_monomorphic o consts_of;
   274 val const_monomorphic = Consts.is_monomorphic o consts_of;
   278 val const_syntax_name = Consts.syntax_name o consts_of;
   275 val const_syntax_name = Consts.syntax_name o consts_of;
   279 val const_typargs = Consts.typargs o consts_of;
   276 val const_typargs = Consts.typargs o consts_of;
   280 val const_instance = Consts.instance o consts_of;
   277 val const_instance = Consts.instance o consts_of;
   281 
   278 
   282 val declared_tyname = Symtab.defined o #2 o #types o Type.rep_tsig o tsig_of;
   279 val declared_tyname = Symtab.defined o #2 o #types o Type.rep_tsig o tsig_of;
   283 val declared_const = is_some oo const_constraint;
   280 val declared_const = can o the_const_constraint;
   284 
   281 
   285 
   282 
   286 
   283 
   287 (** intern / extern names **)
   284 (** intern / extern names **)
   288 
   285 
   575     val thy = ProofContext.theory_of ctxt;
   572     val thy = ProofContext.theory_of ctxt;
   576     fun check_typs Ts = map (certify_typ thy) Ts
   573     fun check_typs Ts = map (certify_typ thy) Ts
   577       handle TYPE (msg, _, _) => error msg;
   574       handle TYPE (msg, _, _) => error msg;
   578 
   575 
   579     fun infer args = TypeInfer.infer_types pp (tsig_of thy) check_typs
   576     fun infer args = TypeInfer.infer_types pp (tsig_of thy) check_typs
   580         (try (Consts.the_constraint consts)) def_type used freeze args |>> map fst
   577         (try (Consts.the_constraint consts)) def_type used ~1 (SOME freeze) args |>> map fst
   581       handle TYPE (msg, _, _) => error msg;
   578       handle TYPE (msg, _, _) => error msg;
   582 
   579 
   583     fun check T t = Exn.Result (singleton (fst o infer) (t, T))
   580     fun check T t = Exn.Result (singleton (fst o infer) (t, T))
   584       handle ERROR msg => Exn.Exn (ERROR msg);
   581       handle ERROR msg => Exn.Exn (ERROR msg);
   585     val map_const = try (#1 o Term.dest_Const o Consts.read_const consts);
   582     val map_const = try (#1 o Term.dest_Const o Consts.read_const consts);
   738   in (res, thy |> map_consts (K consts')) end;
   735   in (res, thy |> map_consts (K consts')) end;
   739 
   736 
   740 
   737 
   741 (* add constraints *)
   738 (* add constraints *)
   742 
   739 
   743 fun gen_add_constraint int_const prep_typ (raw_c, opt_T) thy =
   740 fun add_const_constraint (c, opt_T) thy =
   744   let
   741   let
   745     val c = int_const thy raw_c;
       
   746     fun prepT raw_T =
   742     fun prepT raw_T =
   747       let val T = Logic.varifyT (Type.no_tvars (Term.no_dummyT (prep_typ thy raw_T)))
   743       let val T = Logic.varifyT (Type.no_tvars (Term.no_dummyT (certify_typ thy raw_T)))
   748       in cert_term thy (Const (c, T)); T end
   744       in cert_term thy (Const (c, T)); T end
   749       handle TYPE (msg, _, _) => error msg;
   745       handle TYPE (msg, _, _) => error msg;
   750   in thy |> map_consts (Consts.constrain (c, Option.map prepT opt_T)) end;
   746   in thy |> map_consts (Consts.constrain (c, Option.map prepT opt_T)) end;
   751 
       
   752 val add_const_constraint = gen_add_constraint intern_const read_typ;
       
   753 val add_const_constraint_i = gen_add_constraint (K I) certify_typ;
       
   754 
   747 
   755 
   748 
   756 (* primitive classes and arities *)
   749 (* primitive classes and arities *)
   757 
   750 
   758 fun primitive_class (bclass, classes) thy =
   751 fun primitive_class (bclass, classes) thy =