src/HOL/Tools/ATP/atp_proof.ML
changeset 42603 a7dff503ffab
parent 42594 62398fdbb528
child 42605 8734eb0033b3
equal deleted inserted replaced
42602:a2db47fa015e 42603:a7dff503ffab
   315 val vampire_unknown_fact = "unknown"
   315 val vampire_unknown_fact = "unknown"
   316 val tofof_fact_prefix = "fof_"
   316 val tofof_fact_prefix = "fof_"
   317 
   317 
   318 (* Syntax: (cnf|fof|tff)\(<num>, <formula_role>, <formula> <extra_arguments>\).
   318 (* Syntax: (cnf|fof|tff)\(<num>, <formula_role>, <formula> <extra_arguments>\).
   319    The <num> could be an identifier, but we assume integers. *)
   319    The <num> could be an identifier, but we assume integers. *)
   320 val parse_tstp_line =
   320 fun parse_tstp_line x =
   321   ((Scan.this_string "cnf" || Scan.this_string "fof" || Scan.this_string "tff")
   321   (((Scan.this_string "cnf" || Scan.this_string "fof" || Scan.this_string "tff")
   322       -- $$ "(")
   322        -- $$ "(")
   323     |-- scan_general_id --| $$ "," -- Symbol.scan_id --| $$ ","
   323      |-- scan_general_id --| $$ "," -- Symbol.scan_id --| $$ ","
   324     -- parse_formula -- parse_tstp_extra_arguments --| $$ ")" --| $$ "."
   324      -- parse_formula -- parse_tstp_extra_arguments --| $$ ")" --| $$ "."
   325    >> (fn (((num, role), phi), deps) =>
   325     >> (fn (((num, role), phi), deps) =>
   326           let
   326            let
   327             val (name, deps) =
   327              val (name, deps) =
   328               case deps of
   328                case deps of
   329                 ["file", _, s] =>
   329                  ["file", _, s] =>
   330                 ((num,
   330                  ((num,
   331                   if s = vampire_unknown_fact then NONE
   331                    if s = vampire_unknown_fact then NONE
   332                   else SOME (s |> perhaps (try (unprefix tofof_fact_prefix)))),
   332                    else SOME (s |> perhaps (try (unprefix tofof_fact_prefix)))),
   333                  [])
   333                   [])
   334               | _ => ((num, NONE), deps)
   334                | _ => ((num, NONE), deps)
   335           in
   335            in
   336             case role of
   336              case role of
   337               "definition" =>
   337                "definition" =>
   338               (case phi of
   338                (case phi of
   339                  AConn (AIff, [phi1 as AAtom _, phi2]) =>
   339                   AConn (AIff, [phi1 as AAtom _, phi2]) =>
   340                  Definition (name, phi1, phi2)
   340                   Definition (name, phi1, phi2)
   341                | AAtom (ATerm ("c_equal", _)) =>
   341                 | AAtom (ATerm ("c_equal", _)) =>
   342                  (* Vampire's equality proxy axiom *)
   342                   (* Vampire's equality proxy axiom *)
   343                  Inference (name, phi, map (rpair NONE) deps)
   343                   Inference (name, phi, map (rpair NONE) deps)
   344                | _ => raise Fail "malformed definition")
   344                 | _ => raise Fail "malformed definition")
   345             | _ => Inference (name, phi, map (rpair NONE) deps)
   345              | _ => Inference (name, phi, map (rpair NONE) deps)
   346           end)
   346            end)) x
   347 
   347 
   348 (**** PARSING OF VAMPIRE OUTPUT ****)
   348 (**** PARSING OF VAMPIRE OUTPUT ****)
   349 
   349 
   350 val parse_vampire_braced_stuff =
   350 val parse_vampire_braced_stuff =
   351   $$ "{" -- Scan.repeat (scan_general_id --| Scan.option ($$ ",")) -- $$ "}"
   351   $$ "{" -- Scan.repeat (scan_general_id --| Scan.option ($$ ",")) -- $$ "}"
   352 val parse_vampire_parenthesized_detritus =
   352 val parse_vampire_parenthesized_detritus =
   353   $$ "(" |-- parse_vampire_detritus --| $$ ")"
   353   $$ "(" |-- parse_vampire_detritus --| $$ ")"
   354 
   354 
   355 (* Syntax: <num>. <formula> <annotation> *)
   355 (* Syntax: <num>. <formula> <annotation> *)
   356 val parse_vampire_line =
   356 fun parse_vampire_line x =
   357   scan_general_id --| $$ "." -- parse_formula
   357   (scan_general_id --| $$ "." -- parse_formula
   358     --| Scan.option parse_vampire_braced_stuff
   358      --| Scan.option parse_vampire_braced_stuff
   359     --| Scan.option parse_vampire_parenthesized_detritus
   359      --| Scan.option parse_vampire_parenthesized_detritus
   360     -- parse_annotation
   360      -- parse_annotation
   361   >> (fn ((num, phi), deps) =>
   361    >> (fn ((num, phi), deps) =>
   362          Inference ((num, NONE), phi, map (rpair NONE) deps))
   362           Inference ((num, NONE), phi, map (rpair NONE) deps))) x
   363 
   363 
   364 (**** PARSING OF SPASS OUTPUT ****)
   364 (**** PARSING OF SPASS OUTPUT ****)
   365 
   365 
   366 (* SPASS returns clause references of the form "x.y". We ignore "y", whose role
   366 (* SPASS returns clause references of the form "x.y". We ignore "y", whose role
   367    is not clear anyway. *)
   367    is not clear anyway. *)