src/HOL/Tools/Metis/metis_reconstruct.ML
changeset 43300 854f667df3d6
parent 43298 82d4874757df
child 43301 8d7fc4a5b502
equal deleted inserted replaced
43299:f78d5f0818a0 43300:854f667df3d6
    31 open ATP_Translate
    31 open ATP_Translate
    32 open ATP_Reconstruct
    32 open ATP_Reconstruct
    33 open Metis_Translate
    33 open Metis_Translate
    34 
    34 
    35 exception METIS of string * string
    35 exception METIS of string * string
    36 
       
    37 datatype term_or_type = SomeTerm of term | SomeType of typ
       
    38 
       
    39 fun terms_of [] = []
       
    40   | terms_of (SomeTerm t :: tts) = t :: terms_of tts
       
    41   | terms_of (SomeType _ :: tts) = terms_of tts;
       
    42 
       
    43 fun types_of [] = []
       
    44   | types_of (SomeTerm (Var ((a, idx), _)) :: tts) =
       
    45     types_of tts
       
    46     |> (if String.isPrefix metis_generated_var_prefix a then
       
    47           (* Variable generated by Metis, which might have been a type
       
    48              variable. *)
       
    49           cons (TVar (("'" ^ a, idx), HOLogic.typeS))
       
    50         else
       
    51           I)
       
    52   | types_of (SomeTerm _ :: tts) = types_of tts
       
    53   | types_of (SomeType T :: tts) = T :: types_of tts
       
    54 
    36 
    55 fun atp_name_from_metis s =
    37 fun atp_name_from_metis s =
    56   case find_first (fn (_, (s', _)) => s' = s) metis_name_table of
    38   case find_first (fn (_, (s', _)) => s' = s) metis_name_table of
    57     SOME ((s, _), (_, swap)) => (s, swap)
    39     SOME ((s, _), (_, swap)) => (s, swap)
    58   | _ => (s, false)
    40   | _ => (s, false)
   186 
   168 
   187 (* INFERENCE RULE: RESOLVE *)
   169 (* INFERENCE RULE: RESOLVE *)
   188 
   170 
   189 (* Like RSN, but we rename apart only the type variables. Vars here typically
   171 (* Like RSN, but we rename apart only the type variables. Vars here typically
   190    have an index of 1, and the use of RSN would increase this typically to 3.
   172    have an index of 1, and the use of RSN would increase this typically to 3.
   191    Instantiations of those Vars could then fail. See comment on "make_var". *)
   173    Instantiations of those Vars could then fail. *)
   192 fun resolve_inc_tyvars thy tha i thb =
   174 fun resolve_inc_tyvars thy tha i thb =
   193   let
   175   let
   194     val tha = Drule.incr_type_indexes (1 + Thm.maxidx_of thb) tha
   176     val tha = Drule.incr_type_indexes (1 + Thm.maxidx_of thb) tha
   195     fun aux tha thb =
   177     fun aux tha thb =
   196       case Thm.bicompose false (false, tha, nprems_of tha) i thb
   178       case Thm.bicompose false (false, tha, nprems_of tha) i thb