src/HOL/TPTP/TPTP_Interpret.thy
changeset 57810 2479dc4ef90b
parent 57796 07521fed6071
child 57813 0a84dc31601f
equal deleted inserted replaced
57809:a7345fae237b 57810:2479dc4ef90b
    12 
    12 
    13 typedecl ind
    13 typedecl ind
    14 
    14 
    15 ML_file "TPTP_Parser/tptp_interpret.ML"
    15 ML_file "TPTP_Parser/tptp_interpret.ML"
    16 
    16 
       
    17 
       
    18 ML {*
       
    19 open ATP_Util
       
    20 open ATP_Problem
       
    21 open ATP_Proof
       
    22 open ATP_Problem_Generate
       
    23 open ATP_Systems
       
    24 
       
    25 fun exploded_absolute_path file_name =
       
    26   Path.explode file_name
       
    27   |> (fn path => path |> not (Path.is_absolute path) ? Path.append (Path.explode "$PWD"))
       
    28 
       
    29 fun read_tptp_file thy postproc file_name =
       
    30   let
       
    31     fun has_role role (_, role', _, _) = (role' = role)
       
    32     fun get_prop f (name, _, P, _) =
       
    33       let val P' = P |> f |> close_form in
       
    34         (name, P') |> postproc
       
    35       end
       
    36     val path = exploded_absolute_path file_name
       
    37     val ((_, _, problem), thy) =
       
    38       TPTP_Interpret.interpret_file true [Path.dir path, Path.explode "$TPTP"]
       
    39                                     path [] [] thy
       
    40     val (conjs, defs_and_nondefs) =
       
    41       problem |> List.partition (has_role TPTP_Syntax.Role_Conjecture)
       
    42               ||> List.partition (has_role TPTP_Syntax.Role_Definition)
       
    43   in
       
    44     (map (get_prop I) conjs,
       
    45      pairself (map (get_prop Logic.varify_global)) defs_and_nondefs,
       
    46      Proof_Context.init_global thy)
       
    47   end
       
    48 *}
       
    49 
       
    50 declare [[ML_exception_trace]]
       
    51 
       
    52 setup {*
       
    53 snd o Theory.specify_const ((@{binding c}, @{typ "'b * 'a"}), NoSyn)
       
    54 *}
       
    55 
       
    56 ML {* Sign.the_const_type @{theory} @{const_name c} *}
       
    57 
       
    58 declare [[ML_print_depth = 1000]]
       
    59 
       
    60 ML {*
       
    61 let
       
    62   val (conjs, (defs, nondefs), _) = read_tptp_file @{theory} snd (* "/Users/blanchet/tmp/e.tptp" *)
       
    63     "/Users/blanchet/.isabelle/prob_alt_ergo_1"
       
    64   val ts = conjs @ defs @ nondefs
       
    65     |> map (map_aterms (fn Const (s, T) =>
       
    66         if String.isPrefix "TPTP" s then
       
    67           Const (s |> Long_Name.base_name |> perhaps (try (unprefix "bnd_")), T)
       
    68         else
       
    69           Const (s, T)
       
    70       | t => t))
       
    71 in
       
    72   tracing (cat_lines (map (Syntax.string_of_term_global @{theory}) ts));
       
    73   tracing (cat_lines (map @{make_string} ts))
    17 end
    74 end
       
    75 *}
       
    76 
       
    77 end