author | blanchet |
Thu, 07 Aug 2014 12:17:41 +0200 | |
changeset 57810 | 2479dc4ef90b |
parent 57796 | 07521fed6071 |
child 57813 | 0a84dc31601f |
permissions | -rw-r--r-- |
47509
6f215c2ebd72
split TPTP_Parser thy -- parser can rely on smaller image, whereas TPTP_Interpret requires HOL;
sultana
parents:
diff
changeset
|
1 |
(* Title: HOL/TPTP/TPTP_Interpret.thy |
6f215c2ebd72
split TPTP_Parser thy -- parser can rely on smaller image, whereas TPTP_Interpret requires HOL;
sultana
parents:
diff
changeset
|
2 |
Author: Nik Sultana, Cambridge University Computer Laboratory |
6f215c2ebd72
split TPTP_Parser thy -- parser can rely on smaller image, whereas TPTP_Interpret requires HOL;
sultana
parents:
diff
changeset
|
3 |
|
6f215c2ebd72
split TPTP_Parser thy -- parser can rely on smaller image, whereas TPTP_Interpret requires HOL;
sultana
parents:
diff
changeset
|
4 |
Importing TPTP files into Isabelle/HOL: parsing TPTP formulas and |
6f215c2ebd72
split TPTP_Parser thy -- parser can rely on smaller image, whereas TPTP_Interpret requires HOL;
sultana
parents:
diff
changeset
|
5 |
interpreting them as HOL terms (i.e. importing types and type-checking the terms) |
6f215c2ebd72
split TPTP_Parser thy -- parser can rely on smaller image, whereas TPTP_Interpret requires HOL;
sultana
parents:
diff
changeset
|
6 |
*) |
6f215c2ebd72
split TPTP_Parser thy -- parser can rely on smaller image, whereas TPTP_Interpret requires HOL;
sultana
parents:
diff
changeset
|
7 |
|
6f215c2ebd72
split TPTP_Parser thy -- parser can rely on smaller image, whereas TPTP_Interpret requires HOL;
sultana
parents:
diff
changeset
|
8 |
theory TPTP_Interpret |
57796 | 9 |
imports Complex_Main TPTP_Parser |
47509
6f215c2ebd72
split TPTP_Parser thy -- parser can rely on smaller image, whereas TPTP_Interpret requires HOL;
sultana
parents:
diff
changeset
|
10 |
keywords "import_tptp" :: thy_decl |
48891 | 11 |
begin |
12 |
||
57796 | 13 |
typedecl ind |
47509
6f215c2ebd72
split TPTP_Parser thy -- parser can rely on smaller image, whereas TPTP_Interpret requires HOL;
sultana
parents:
diff
changeset
|
14 |
|
57796 | 15 |
ML_file "TPTP_Parser/tptp_interpret.ML" |
48891 | 16 |
|
57810 | 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)) |
|
74 |
end |
|
75 |
*} |
|
76 |
||
47509
6f215c2ebd72
split TPTP_Parser thy -- parser can rely on smaller image, whereas TPTP_Interpret requires HOL;
sultana
parents:
diff
changeset
|
77 |
end |