src/HOL/Tools/meson.ML
changeset 26928 ca87aff1ad2d
parent 26562 9d25ef112cf6
child 26931 aa226d8405a8
equal deleted inserted replaced
26927:8684b5240f11 26928:ca87aff1ad2d
   119   and the effect should be to instantiate ?P and ?Q with normalized versions of P' and Q'.*)
   119   and the effect should be to instantiate ?P and ?Q with normalized versions of P' and Q'.*)
   120 fun forward_res nf st =
   120 fun forward_res nf st =
   121   let fun forward_tacf [prem] = rtac (nf prem) 1
   121   let fun forward_tacf [prem] = rtac (nf prem) 1
   122         | forward_tacf prems =
   122         | forward_tacf prems =
   123             error ("Bad proof state in forward_res, please inform lcp@cl.cam.ac.uk:\n" ^
   123             error ("Bad proof state in forward_res, please inform lcp@cl.cam.ac.uk:\n" ^
   124                    string_of_thm st ^
   124                    Display.string_of_thm st ^
   125                    "\nPremises:\n" ^
   125                    "\nPremises:\n" ^
   126                    cat_lines (map string_of_thm prems))
   126                    cat_lines (map Display.string_of_thm prems))
   127   in
   127   in
   128     case Seq.pull (ALLGOALS (METAHYPS forward_tacf) st)
   128     case Seq.pull (ALLGOALS (METAHYPS forward_tacf) st)
   129     of SOME(th,_) => th
   129     of SOME(th,_) => th
   130      | NONE => raise THM("forward_res", 0, [st])
   130      | NONE => raise THM("forward_res", 0, [st])
   131   end;
   131   end;
   333               in  Seq.list_of (tac (th RS disj_forward)) @ ths  end
   333               in  Seq.list_of (tac (th RS disj_forward)) @ ths  end
   334           | _ => nodups th :: ths  (*no work to do*)
   334           | _ => nodups th :: ths  (*no work to do*)
   335       and cnf_nil th = cnf_aux (th,[])
   335       and cnf_nil th = cnf_aux (th,[])
   336       val cls = 
   336       val cls = 
   337 	    if too_many_clauses (SOME ctxt) (concl_of th)
   337 	    if too_many_clauses (SOME ctxt) (concl_of th)
   338 	    then (warning ("cnf is ignoring: " ^ string_of_thm th); ths)
   338 	    then (warning ("cnf is ignoring: " ^ Display.string_of_thm th); ths)
   339 	    else cnf_aux (th,ths)
   339 	    else cnf_aux (th,ths)
   340   in  (cls, !ctxtr)  end;
   340   in  (cls, !ctxtr)  end;
   341 
   341 
   342 fun make_cnf skoths th ctxt = cnf skoths ctxt (th, []);
   342 fun make_cnf skoths th ctxt = cnf skoths ctxt (th, []);
   343 
   343 
   533 
   533 
   534 fun skolemize_nnf_list [] = []
   534 fun skolemize_nnf_list [] = []
   535   | skolemize_nnf_list (th::ths) = 
   535   | skolemize_nnf_list (th::ths) = 
   536       skolemize (make_nnf th) :: skolemize_nnf_list ths
   536       skolemize (make_nnf th) :: skolemize_nnf_list ths
   537       handle THM _ => (*RS can fail if Unify.search_bound is too small*)
   537       handle THM _ => (*RS can fail if Unify.search_bound is too small*)
   538        (warning ("Failed to Skolemize " ^ string_of_thm th);
   538        (warning ("Failed to Skolemize " ^ Display.string_of_thm th);
   539         skolemize_nnf_list ths);
   539         skolemize_nnf_list ths);
   540 
   540 
   541 fun add_clauses (th,cls) =
   541 fun add_clauses (th,cls) =
   542   let val ctxt0 = Variable.thm_context th
   542   let val ctxt0 = Variable.thm_context th
   543       val (cnfs,ctxt) = make_cnf [] th ctxt0
   543       val (cnfs,ctxt) = make_cnf [] th ctxt0
   623            [] => no_tac  (*no goal clauses*)
   623            [] => no_tac  (*no goal clauses*)
   624          | goes =>
   624          | goes =>
   625              let val horns = make_horns (cls@ths)
   625              let val horns = make_horns (cls@ths)
   626                  val _ =
   626                  val _ =
   627                      Output.debug (fn () => ("meson method called:\n" ^
   627                      Output.debug (fn () => ("meson method called:\n" ^
   628                                   space_implode "\n" (map string_of_thm (cls@ths)) ^
   628                                   space_implode "\n" (map Display.string_of_thm (cls@ths)) ^
   629                                   "\nclauses:\n" ^
   629                                   "\nclauses:\n" ^
   630                                   space_implode "\n" (map string_of_thm horns)))
   630                                   space_implode "\n" (map Display.string_of_thm horns)))
   631              in THEN_ITER_DEEPEN (resolve_tac goes 1) (has_fewer_prems 1) (prolog_step_tac' horns)
   631              in THEN_ITER_DEEPEN (resolve_tac goes 1) (has_fewer_prems 1) (prolog_step_tac' horns)
   632              end
   632              end
   633  );
   633  );
   634 
   634 
   635 fun meson_claset_tac ths cs =
   635 fun meson_claset_tac ths cs =