src/HOL/Tools/metis_tools.ML
changeset 26561 394cd765643d
parent 26423 8408edac8f6b
child 26928 ca87aff1ad2d
equal deleted inserted replaced
26560:d2fc9a18ee8a 26561:394cd765643d
   293   fun assume_inf ctxt atm =
   293   fun assume_inf ctxt atm =
   294     inst_excluded_middle EXCLUDED_MIDDLE
   294     inst_excluded_middle EXCLUDED_MIDDLE
   295       (ProofContext.theory_of ctxt)
   295       (ProofContext.theory_of ctxt)
   296       (singleton (fol_terms_to_hol ctxt) (Metis.Term.Fn atm));
   296       (singleton (fol_terms_to_hol ctxt) (Metis.Term.Fn atm));
   297 
   297 
   298   (* INFERENCE RULE: INSTANTIATE. Type instantiations are ignored. Attempting to reconstruct
   298   (* INFERENCE RULE: INSTANTIATE (Subst). Type instantiations are ignored. Trying to reconstruct
   299      them admits new possibilities of errors, e.g. concerning sorts. Instead we try to arrange
   299      them admits new possibilities of errors, e.g. concerning sorts. Instead we try to arrange
   300      that new TVars are distinct and that types can be inferred from terms.*)
   300      that new TVars are distinct and that types can be inferred from terms.*)
   301   fun inst_inf ctxt thpairs fsubst th =
   301   fun inst_inf ctxt thpairs fsubst th =    
   302     let val thy = ProofContext.theory_of ctxt
   302     let val thy = ProofContext.theory_of ctxt
   303         val i_th   = lookth thpairs th
   303         val i_th   = lookth thpairs th
   304         val i_th_vars = term_vars (prop_of i_th)
   304         val i_th_vars = term_vars (prop_of i_th)
   305         fun find_var x = valOf (List.find (fn Term.Var((a,_),_) => a=x) i_th_vars)
   305         fun find_var x = valOf (List.find (fn Term.Var((a,_),_) => a=x) i_th_vars)
   306         fun subst_translation (x,y) =
   306         fun subst_translation (x,y) =
   307               let val v = find_var x
   307               let val v = find_var x
   308                   val t = fol_term_to_hol_RAW ctxt y
   308                   val t = fol_term_to_hol_RAW ctxt y (*we call infer_types below*)
   309               in  SOME (cterm_of thy v, t)  end
   309               in  SOME (cterm_of thy v, t)  end
   310               handle Option =>
   310               handle Option =>
   311                   (Output.debug (fn() => "List.find failed for the variable " ^ x ^
   311                   (Output.debug (fn() => "List.find failed for the variable " ^ x ^
   312                                          " in " ^ string_of_thm i_th);
   312                                          " in " ^ string_of_thm i_th);
   313                    NONE)
   313                    NONE)
   604                   else warning ("Unused theorems: " ^ commas (map #1 unused));
   604                   else warning ("Unused theorems: " ^ commas (map #1 unused));
   605                   case result of
   605                   case result of
   606                       (_,ith)::_ => (Output.debug (fn () => "success: " ^ string_of_thm ith); ith)
   606                       (_,ith)::_ => (Output.debug (fn () => "success: " ^ string_of_thm ith); ith)
   607                     | _ => error "METIS: no result"
   607                     | _ => error "METIS: no result"
   608               end
   608               end
   609           | Metis.Resolution.Satisfiable _ => error "Metis finds the theorem to be invalid"
   609           | Metis.Resolution.Satisfiable _ => error "Metis: No first-order proof with the lemmas supplied"
   610     end;
   610     end;
   611 
   611 
   612   fun metis_general_tac mode ctxt ths i st0 =
   612   fun metis_general_tac mode ctxt ths i st0 =
   613     let val _ = Output.debug (fn () =>
   613     let val _ = Output.debug (fn () =>
   614           "Metis called with theorems " ^ cat_lines (map string_of_thm ths))
   614           "Metis called with theorems " ^ cat_lines (map string_of_thm ths))