src/HOL/Tools/metis_tools.ML
changeset 24494 dc387e3999ec
parent 24424 90500d3b5b5d
child 24500 5e135602f660
equal deleted inserted replaced
24493:d4380e9b287b 24494:dc387e3999ec
   241                 | NONE => error ("unexpected metis function: " ^ a)
   241                 | NONE => error ("unexpected metis function: " ^ a)
   242     in  case tm_to_tt fol_tm of Term t => t | _ => error "fol_tm_to_tt: Term expected"  end;
   242     in  case tm_to_tt fol_tm of Term t => t | _ => error "fol_tm_to_tt: Term expected"  end;
   243 
   243 
   244   fun fol_terms_to_hol ctxt fol_tms =
   244   fun fol_terms_to_hol ctxt fol_tms =
   245     let val ts = map (fol_term_to_hol_RAW ctxt) fol_tms
   245     let val ts = map (fol_term_to_hol_RAW ctxt) fol_tms
   246         val _ = Output.debug (fn () => "  calling infer_types:")
   246         val _ = Output.debug (fn () => "  calling type inference:")
   247         val _ = app (fn t => Output.debug (fn () => ProofContext.string_of_term ctxt t)) ts
   247         val _ = app (fn t => Output.debug (fn () => ProofContext.string_of_term ctxt t)) ts
   248         val ts' = ProofContext.infer_types_pats ctxt ts
   248         val ts' = Syntax.check_terms ctxt ts |> Variable.polymorphic ctxt;
   249                     (*DO NOT freeze TVars in the result*)
       
   250         val _ = app (fn t => Output.debug
   249         val _ = app (fn t => Output.debug
   251                       (fn () => "  final term: " ^ ProofContext.string_of_term ctxt t ^
   250                       (fn () => "  final term: " ^ ProofContext.string_of_term ctxt t ^
   252                                 "  of type  " ^ ProofContext.string_of_typ ctxt (type_of t)))
   251                                 "  of type  " ^ ProofContext.string_of_typ ctxt (type_of t)))
   253                     ts'
   252                     ts'
   254     in  ts'  end;
   253     in  ts'  end;
   307                   SOME _ => NONE          (*type instantiations are forbidden!*)
   306                   SOME _ => NONE          (*type instantiations are forbidden!*)
   308                 | NONE   => SOME (a,t)    (*internal Metis var?*)
   307                 | NONE   => SOME (a,t)    (*internal Metis var?*)
   309         val _ = Output.debug (fn () => "  isa th: " ^ string_of_thm i_th)
   308         val _ = Output.debug (fn () => "  isa th: " ^ string_of_thm i_th)
   310         val substs = List.mapPartial remove_typeinst (Metis.Subst.toList fsubst)
   309         val substs = List.mapPartial remove_typeinst (Metis.Subst.toList fsubst)
   311         val (vars,rawtms) = ListPair.unzip (List.mapPartial subst_translation substs)
   310         val (vars,rawtms) = ListPair.unzip (List.mapPartial subst_translation substs)
   312         val tms = ProofContext.infer_types_pats ctxt rawtms
   311         val tms = Syntax.check_terms ctxt rawtms |> Variable.polymorphic ctxt;
   313         val ctm_of = cterm_of thy o (map_types o Logic.incr_tvar) (1 + Thm.maxidx_of i_th)
   312         val ctm_of = cterm_of thy o (map_types o Logic.incr_tvar) (1 + Thm.maxidx_of i_th)
   314         val substs' = ListPair.zip (vars, map ctm_of tms)
   313         val substs' = ListPair.zip (vars, map ctm_of tms)
   315         val _ = Output.debug (fn() => "subst_translations:")
   314         val _ = Output.debug (fn() => "subst_translations:")
   316         val _ = app (fn (x,y) => Output.debug (fn () => string_of_cterm x ^ " |-> " ^
   315         val _ = app (fn (x,y) => Output.debug (fn () => string_of_cterm x ^ " |-> " ^
   317                                                         string_of_cterm y))
   316                                                         string_of_cterm y))