src/HOL/Tools/Sledgehammer/metis_tactics.ML
changeset 38280 577f138af235
parent 38100 e458a0dd3dc1
child 38433 1e28e2e1c2fb
equal deleted inserted replaced
38279:7497c22bb185 38280:577f138af235
   572   | (_, Metis.Proof.Equality (f_lit, f_p, f_r)) =>
   572   | (_, Metis.Proof.Equality (f_lit, f_p, f_r)) =>
   573     equality_inf ctxt mode skolems f_lit f_p f_r
   573     equality_inf ctxt mode skolems f_lit f_p f_r
   574 
   574 
   575 fun real_literal (_, (c, _)) = not (String.isPrefix class_prefix c);
   575 fun real_literal (_, (c, _)) = not (String.isPrefix class_prefix c);
   576 
   576 
   577 (* FIXME: use "fold" instead *)
   577 fun translate_one ctxt mode skolems (fol_th, inf) thpairs =
   578 fun translate _ _ _ thpairs [] = thpairs
   578   let
   579   | translate ctxt mode skolems thpairs ((fol_th, inf) :: infpairs) =
   579     val _ = trace_msg (fn () => "=============================================")
   580       let val _ = trace_msg (fn () => "=============================================")
   580     val _ = trace_msg (fn () => "METIS THM: " ^ Metis.Thm.toString fol_th)
   581           val _ = trace_msg (fn () => "METIS THM: " ^ Metis.Thm.toString fol_th)
   581     val _ = trace_msg (fn () => "INFERENCE: " ^ Metis.Proof.inferenceToString inf)
   582           val _ = trace_msg (fn () => "INFERENCE: " ^ Metis.Proof.inferenceToString inf)
   582     val th = Meson.flexflex_first_order (step ctxt mode skolems
   583           val th = Meson.flexflex_first_order (step ctxt mode skolems
   583                                               thpairs (fol_th, inf))
   584                                                     thpairs (fol_th, inf))
   584     val _ = trace_msg (fn () => "ISABELLE THM: " ^ Display.string_of_thm ctxt th)
   585           val _ = trace_msg (fn () => "ISABELLE THM: " ^ Display.string_of_thm ctxt th)
   585     val _ = trace_msg (fn () => "=============================================")
   586           val _ = trace_msg (fn () => "=============================================")
   586     val n_metis_lits =
   587           val n_metis_lits =
   587       length (filter real_literal (Metis.LiteralSet.toList (Metis.Thm.clause fol_th)))
   588             length (filter real_literal (Metis.LiteralSet.toList (Metis.Thm.clause fol_th)))
   588     val _ =
   589       in
   589       if nprems_of th = n_metis_lits then ()
   590           if nprems_of th = n_metis_lits then ()
   590       else raise METIS ("translate", "Proof reconstruction has gone wrong.")
   591           else raise METIS ("translate", "Proof reconstruction has gone wrong.");
   591   in (fol_th, th) :: thpairs end
   592           translate ctxt mode skolems ((fol_th, th) :: thpairs) infpairs
       
   593       end;
       
   594 
   592 
   595 (*Determining which axiom clauses are actually used*)
   593 (*Determining which axiom clauses are actually used*)
   596 fun used_axioms axioms (th, Metis.Proof.Axiom _) = SOME (lookth axioms th)
   594 fun used_axioms axioms (th, Metis.Proof.Axiom _) = SOME (lookth axioms th)
   597   | used_axioms _ _ = NONE;
   595   | used_axioms _ _ = NONE;
   598 
   596 
   742             let val _ = trace_msg (fn () => "METIS RECONSTRUCTION START: " ^
   740             let val _ = trace_msg (fn () => "METIS RECONSTRUCTION START: " ^
   743                           Metis.Thm.toString mth)
   741                           Metis.Thm.toString mth)
   744                 val ctxt' = fold Variable.declare_constraints (map prop_of cls) ctxt
   742                 val ctxt' = fold Variable.declare_constraints (map prop_of cls) ctxt
   745                              (*add constraints arising from converting goal to clause form*)
   743                              (*add constraints arising from converting goal to clause form*)
   746                 val proof = Metis.Proof.proof mth
   744                 val proof = Metis.Proof.proof mth
   747                 val result = translate ctxt' mode skolems axioms proof
   745                 val result = fold (translate_one ctxt' mode skolems) proof axioms
   748                 and used = map_filter (used_axioms axioms) proof
   746                 and used = map_filter (used_axioms axioms) proof
   749                 val _ = trace_msg (fn () => "METIS COMPLETED...clauses actually used:")
   747                 val _ = trace_msg (fn () => "METIS COMPLETED...clauses actually used:")
   750                 val _ = app (fn th => trace_msg (fn () => Display.string_of_thm ctxt th)) used
   748                 val _ = app (fn th => trace_msg (fn () => Display.string_of_thm ctxt th)) used
   751                 val unused = th_cls_pairs |> map_filter (fn (name, cls) =>
   749                 val unused = th_cls_pairs |> map_filter (fn (name, cls) =>
   752                   if common_thm used cls then NONE else SOME name)
   750                   if common_thm used cls then NONE else SOME name)