src/Pure/thm.ML
changeset 67697 58f951ce71c8
parent 67649 1e1782c1aedf
child 67721 5348bea4accd
equal deleted inserted replaced
67696:3d8d4f6d1d64 67697:58f951ce71c8
    73   val cprem_of: thm -> int -> cterm
    73   val cprem_of: thm -> int -> cterm
    74   val chyps_of: thm -> cterm list
    74   val chyps_of: thm -> cterm list
    75   exception CONTEXT of string * ctyp list * cterm list * thm list * Context.generic option
    75   exception CONTEXT of string * ctyp list * cterm list * thm list * Context.generic option
    76   val theory_of_cterm: cterm -> theory
    76   val theory_of_cterm: cterm -> theory
    77   val theory_of_thm: thm -> theory
    77   val theory_of_thm: thm -> theory
       
    78   val trim_context_ctyp: ctyp -> ctyp
    78   val trim_context_cterm: cterm -> cterm
    79   val trim_context_cterm: cterm -> cterm
    79   val trim_context: thm -> thm
    80   val trim_context: thm -> thm
    80   val transfer_cterm: theory -> cterm -> cterm
    81   val transfer_cterm: theory -> cterm -> cterm
    81   val transfer: theory -> thm -> thm
    82   val transfer: theory -> thm -> thm
    82   val transfer': Proof.context -> thm -> thm
    83   val transfer': Proof.context -> thm -> thm
   116   val combination: thm -> thm -> thm
   117   val combination: thm -> thm -> thm
   117   val equal_intr: thm -> thm -> thm
   118   val equal_intr: thm -> thm -> thm
   118   val equal_elim: thm -> thm -> thm
   119   val equal_elim: thm -> thm -> thm
   119   val flexflex_rule: Proof.context option -> thm -> thm Seq.seq
   120   val flexflex_rule: Proof.context option -> thm -> thm Seq.seq
   120   val generalize: string list * string list -> int -> thm -> thm
   121   val generalize: string list * string list -> int -> thm -> thm
       
   122   val generalize_cterm: string list * string list -> int -> cterm -> cterm
       
   123   val generalize_ctyp: string list -> int -> ctyp -> ctyp
   121   val instantiate: ((indexname * sort) * ctyp) list * ((indexname * typ) * cterm) list ->
   124   val instantiate: ((indexname * sort) * ctyp) list * ((indexname * typ) * cterm) list ->
   122     thm -> thm
   125     thm -> thm
   123   val instantiate_cterm: ((indexname * sort) * ctyp) list * ((indexname * typ) * cterm) list ->
   126   val instantiate_cterm: ((indexname * sort) * ctyp) list * ((indexname * typ) * cterm) list ->
   124     cterm -> cterm
   127     cterm -> cterm
   125   val trivial: cterm -> thm
   128   val trivial: cterm -> thm
   408 
   411 
   409 fun theory_of_thm th =
   412 fun theory_of_thm th =
   410   Context.certificate_theory (cert_of th)
   413   Context.certificate_theory (cert_of th)
   411     handle ERROR msg => raise CONTEXT (msg, [], [], [th], NONE);
   414     handle ERROR msg => raise CONTEXT (msg, [], [], [th], NONE);
   412 
   415 
       
   416 fun trim_context_ctyp cT =
       
   417   (case cT of
       
   418     Ctyp {cert = Context.Certificate_Id _, ...} => cT
       
   419   | Ctyp {cert = Context.Certificate thy, T, maxidx, sorts} =>
       
   420       Ctyp {cert = Context.Certificate_Id (Context.theory_id thy),
       
   421         T = T, maxidx = maxidx, sorts = sorts});
       
   422 
   413 fun trim_context_cterm ct =
   423 fun trim_context_cterm ct =
   414   (case ct of
   424   (case ct of
   415     Cterm {cert = Context.Certificate_Id _, ...} => ct
   425     Cterm {cert = Context.Certificate_Id _, ...} => ct
   416   | Cterm {cert = Context.Certificate thy, t, T, maxidx, sorts} =>
   426   | Cterm {cert = Context.Certificate thy, t, T, maxidx, sorts} =>
   417       Cterm {cert = Context.Certificate_Id (Context.theory_id thy),
   427       Cterm {cert = Context.Certificate_Id (Context.theory_id thy),
  1149           shyps = shyps,
  1159           shyps = shyps,
  1150           hyps = hyps,
  1160           hyps = hyps,
  1151           tpairs = tpairs',
  1161           tpairs = tpairs',
  1152           prop = prop'})
  1162           prop = prop'})
  1153       end;
  1163       end;
       
  1164 
       
  1165 fun generalize_cterm ([], []) _ ct = ct
       
  1166   | generalize_cterm (tfrees, frees) idx (ct as Cterm {cert, t, T, maxidx, sorts}) =
       
  1167       if idx <= maxidx then raise CTERM ("generalize_cterm: bad index", [ct])
       
  1168       else
       
  1169         Cterm {cert = cert, sorts = sorts,
       
  1170           T = Term_Subst.generalizeT tfrees idx T,
       
  1171           t = Term_Subst.generalize (tfrees, frees) idx t,
       
  1172           maxidx = Int.max (maxidx, idx)};
       
  1173 
       
  1174 fun generalize_ctyp [] _ cT = cT
       
  1175   | generalize_ctyp tfrees idx (Ctyp {cert, T, maxidx, sorts}) =
       
  1176       if idx <= maxidx then raise CTERM ("generalize_ctyp: bad index", [])
       
  1177       else
       
  1178         Ctyp {cert = cert, sorts = sorts,
       
  1179           T = Term_Subst.generalizeT tfrees idx T,
       
  1180           maxidx = Int.max (maxidx, idx)};
  1154 
  1181 
  1155 
  1182 
  1156 (*Instantiation of schematic variables
  1183 (*Instantiation of schematic variables
  1157            A
  1184            A
  1158   --------------------
  1185   --------------------