src/HOL/Tools/metis_tools.ML
changeset 28528 0cf2749e8ef7
parent 28262 aa7ca36d67fd
child 28700 fb92b1d1b285
equal deleted inserted replaced
28527:82b36daff4c1 28528:0cf2749e8ef7
   325         val substs' = ListPair.zip (vars, map ctm_of tms)
   325         val substs' = ListPair.zip (vars, map ctm_of tms)
   326         val _ = Output.debug (fn() => "subst_translations:")
   326         val _ = Output.debug (fn() => "subst_translations:")
   327         val _ = app (fn (x,y) => Output.debug (fn () => Display.string_of_cterm x ^ " |-> " ^
   327         val _ = app (fn (x,y) => Output.debug (fn () => Display.string_of_cterm x ^ " |-> " ^
   328                                                         Display.string_of_cterm y))
   328                                                         Display.string_of_cterm y))
   329                   substs'
   329                   substs'
   330     in  cterm_instantiate substs' i_th  end;
   330     in  cterm_instantiate substs' i_th  
       
   331         handle THM (msg, _, _) => error ("metis error (inst_inf): " ^ msg)
       
   332     end;
   331 
   333 
   332   (* INFERENCE RULE: RESOLVE *)
   334   (* INFERENCE RULE: RESOLVE *)
   333 
   335 
   334   (*Like RSN, but we rename apart only the type variables. Vars here typically have an index
   336   (*Like RSN, but we rename apart only the type variables. Vars here typically have an index
   335     of 1, and the use of RSN would increase this typically to 3. Instantiations of those Vars
   337     of 1, and the use of RSN would increase this typically to 3. Instantiations of those Vars
   428         val _ = Output.debug (fn () => "subst' " ^ Display.string_of_thm subst')
   430         val _ = Output.debug (fn () => "subst' " ^ Display.string_of_thm subst')
   429         val eq_terms = map (pairself (cterm_of thy))
   431         val eq_terms = map (pairself (cterm_of thy))
   430                            (ListPair.zip (term_vars (prop_of subst'), [tm_abs, tm_subst, i_tm]))
   432                            (ListPair.zip (term_vars (prop_of subst'), [tm_abs, tm_subst, i_tm]))
   431     in  cterm_instantiate eq_terms subst'  end;
   433     in  cterm_instantiate eq_terms subst'  end;
   432 
   434 
       
   435   val factor = Seq.hd o distinct_subgoals_tac;
       
   436 
   433   fun step ctxt isFO thpairs (fol_th, Metis.Proof.Axiom _)                        =
   437   fun step ctxt isFO thpairs (fol_th, Metis.Proof.Axiom _)                        =
   434         axiom_inf ctxt thpairs fol_th
   438         factor (axiom_inf ctxt thpairs fol_th)
   435     | step ctxt isFO thpairs (_, Metis.Proof.Assume f_atm)                        =
   439     | step ctxt isFO thpairs (_, Metis.Proof.Assume f_atm)                        =
   436         assume_inf ctxt f_atm
   440         assume_inf ctxt f_atm
   437     | step ctxt isFO thpairs (_, Metis.Proof.Subst(f_subst, f_th1))                =
   441     | step ctxt isFO thpairs (_, Metis.Proof.Subst(f_subst, f_th1))               =
   438         inst_inf ctxt thpairs f_subst f_th1
   442         factor (inst_inf ctxt thpairs f_subst f_th1)
   439     | step ctxt isFO thpairs (_, Metis.Proof.Resolve(f_atm, f_th1, f_th2))        =
   443     | step ctxt isFO thpairs (_, Metis.Proof.Resolve(f_atm, f_th1, f_th2))        =
   440         resolve_inf ctxt thpairs f_atm f_th1 f_th2
   444         factor (resolve_inf ctxt thpairs f_atm f_th1 f_th2)
   441     | step ctxt isFO thpairs (_, Metis.Proof.Refl f_tm)                           =
   445     | step ctxt isFO thpairs (_, Metis.Proof.Refl f_tm)                           =
   442         refl_inf ctxt f_tm
   446         refl_inf ctxt f_tm
   443     | step ctxt isFO thpairs (_, Metis.Proof.Equality(f_lit, f_p, f_r)) =
   447     | step ctxt isFO thpairs (_, Metis.Proof.Equality(f_lit, f_p, f_r)) =
   444         equality_inf ctxt isFO thpairs f_lit f_p f_r;
   448         equality_inf ctxt isFO thpairs f_lit f_p f_r;
   445 
       
   446   val factor = Seq.hd o distinct_subgoals_tac;
       
   447 
   449 
   448   fun real_literal (b, (c, _)) = not (String.isPrefix ResClause.class_prefix c);
   450   fun real_literal (b, (c, _)) = not (String.isPrefix ResClause.class_prefix c);
   449 
   451 
   450   fun translate isFO _    thpairs [] = thpairs
   452   fun translate isFO _    thpairs [] = thpairs
   451     | translate isFO ctxt thpairs ((fol_th, inf) :: infpairs) =
   453     | translate isFO ctxt thpairs ((fol_th, inf) :: infpairs) =
   452         let val _ = Output.debug (fn () => "=============================================")
   454         let val _ = Output.debug (fn () => "=============================================")
   453             val _ = Output.debug (fn () => "METIS THM: " ^ Metis.Thm.toString fol_th)
   455             val _ = Output.debug (fn () => "METIS THM: " ^ Metis.Thm.toString fol_th)
   454             val _ = Output.debug (fn () => "INFERENCE: " ^ Metis.Proof.inferenceToString inf)
   456             val _ = Output.debug (fn () => "INFERENCE: " ^ Metis.Proof.inferenceToString inf)
   455             val th = Meson.flexflex_first_order (factor (step ctxt isFO thpairs (fol_th, inf)))
   457             val th = Meson.flexflex_first_order (step ctxt isFO thpairs (fol_th, inf))
   456             val _ = Output.debug (fn () => "ISABELLE THM: " ^ Display.string_of_thm th)
   458             val _ = Output.debug (fn () => "ISABELLE THM: " ^ Display.string_of_thm th)
   457             val _ = Output.debug (fn () => "=============================================")
   459             val _ = Output.debug (fn () => "=============================================")
   458             val n_metis_lits = length (filter real_literal (Metis.LiteralSet.toList (Metis.Thm.clause fol_th)))
   460             val n_metis_lits = length (filter real_literal (Metis.LiteralSet.toList (Metis.Thm.clause fol_th)))
   459         in
   461         in
   460             if nprems_of th = n_metis_lits then ()
   462             if nprems_of th = n_metis_lits then ()