src/HOL/Tools/ATP/atp_proof.ML
changeset 48539 0debf65972c7
parent 48316 252f45c04042
child 48700 d06138bfeb45
equal deleted inserted replaced
48538:726590131ca1 48539:0debf65972c7
    50   val extract_tstplike_proof_and_outcome :
    50   val extract_tstplike_proof_and_outcome :
    51     bool -> bool -> (string * string) list -> (failure * string) list -> string
    51     bool -> bool -> (string * string) list -> (failure * string) list -> string
    52     -> string * failure option
    52     -> string * failure option
    53   val is_same_atp_step : step_name -> step_name -> bool
    53   val is_same_atp_step : step_name -> step_name -> bool
    54   val scan_general_id : string list -> string * string list
    54   val scan_general_id : string list -> string * string list
    55   val satallax_unsat_coreN : string
    55   val satallax_coreN : string
       
    56   val z3_tptp_coreN : string
    56   val parse_formula :
    57   val parse_formula :
    57     string list
    58     string list
    58     -> (string, 'a, (string, 'a) ho_term, string) formula * string list
    59     -> (string, 'a, (string, 'a) ho_term, string) formula * string list
    59   val atp_proof_from_tstplike_proof : string problem -> string -> string proof
    60   val atp_proof_from_tstplike_proof : string problem -> string -> string proof
    60   val clean_up_atp_proof_dependencies : string proof -> string proof
    61   val clean_up_atp_proof_dependencies : string proof -> string proof
   152      else ":\n" ^ string)
   153      else ":\n" ^ string)
   153 
   154 
   154 fun extract_delimited (begin_delim, end_delim) output =
   155 fun extract_delimited (begin_delim, end_delim) output =
   155   output |> first_field begin_delim |> the |> snd
   156   output |> first_field begin_delim |> the |> snd
   156          |> first_field end_delim |> the |> fst
   157          |> first_field end_delim |> the |> fst
   157          |> first_field "\n" |> the |> snd
   158          |> perhaps (try (first_field "\n" #> the #> snd))
   158   handle Option.Option => ""
   159   handle Option.Option => ""
   159 
   160 
   160 val tstp_important_message_delims =
   161 val tstp_important_message_delims =
   161   ("% SZS start RequiredInformation", "% SZS end RequiredInformation")
   162   ("% SZS start RequiredInformation", "% SZS end RequiredInformation")
   162 
   163 
   459      -- Scan.option (Scan.this_string "derived from formulae "
   460      -- Scan.option (Scan.this_string "derived from formulae "
   460                      |-- Scan.repeat (scan_general_id --| Scan.option ($$ " ")))
   461                      |-- Scan.repeat (scan_general_id --| Scan.option ($$ " ")))
   461    >> (fn ((((num, rule), deps), u), names) =>
   462    >> (fn ((((num, rule), deps), u), names) =>
   462           Inference_Step ((num, these names), u, rule, map (rpair []) deps))) x
   463           Inference_Step ((num, these names), u, rule, map (rpair []) deps))) x
   463 
   464 
   464 val satallax_unsat_coreN = "__satallax_unsat_core" (* arbitrary *)
   465 val satallax_coreN = "__satallax_core" (* arbitrary *)
       
   466 val z3_tptp_coreN = "__z3_tptp_core" (* arbitrary *)
       
   467 
       
   468 (* Syntax: core(<name>,[<name>,...,<name>]). *)
       
   469 fun parse_z3_tptp_line x =
       
   470   (scan_general_id --| $$ "," --| $$ "[" -- parse_dependencies --| $$ "]"
       
   471    >> (fn (name, names) =>
       
   472           Inference_Step (("", name :: names), dummy_phi, z3_tptp_coreN, []))) x
   465 
   473 
   466 (* Syntax: <name> *)
   474 (* Syntax: <name> *)
   467 fun parse_satallax_line x =
   475 fun parse_satallax_line x =
   468   (scan_general_id --| Scan.option ($$ " ")
   476   (scan_general_id --| Scan.option ($$ " ")
   469    >> (fn s => Inference_Step ((s, [s]), dummy_phi, satallax_unsat_coreN, [])))
   477    >> (fn s => Inference_Step ((s, [s]), dummy_phi, satallax_coreN, []))) x
   470       x
       
   471 
   478 
   472 fun parse_line problem =
   479 fun parse_line problem =
   473   parse_tstp_line problem || parse_spass_line || parse_satallax_line
   480   parse_tstp_line problem || parse_spass_line || parse_z3_tptp_line
       
   481   || parse_satallax_line
   474 fun parse_proof problem tstp =
   482 fun parse_proof problem tstp =
   475   tstp |> strip_spaces_except_between_idents
   483   tstp |> strip_spaces_except_between_idents
   476        |> raw_explode
   484        |> raw_explode
   477        |> Scan.finite Symbol.stopper
   485        |> Scan.finite Symbol.stopper
   478               (Scan.error (!! (fn _ => raise UNRECOGNIZED_ATP_PROOF ())
   486               (Scan.error (!! (fn _ => raise UNRECOGNIZED_ATP_PROOF ())