1 (* Title: HOL/TPTP/TPTP_Interpret_Test.thy
2 Author: Nik Sultana, Cambridge University Computer Laboratory
4 Some tests for the TPTP interface. Some of the tests rely on the Isabelle
5 environment variable $TPTP, which should point to the TPTP-vX.Y.Z directory.
8 theory TPTP_Interpret_Test
9 imports TPTP_Test TPTP_Interpret
12 section "Interpreter tests"
14 text "Interpret a problem."
16 val (time, ((type_map, const_map, fmlas), thy)) =
18 (TPTP_Interpret.interpret_file
20 (Path.dir tptp_probs_dir)
21 (Path.append tptp_probs_dir (Path.explode "LCL/LCL825-1.p"))
28 text "... and display nicely."
30 List.app (Pretty.writeln o (Syntax.pretty_term @{context}) o #3) fmlas;
33 subsection "Multiple tests"
36 (*default timeout is 1 min*)
37 fun interpret timeout file thy =
38 TimeLimit.timeLimit (Time.fromSeconds (if timeout = 0 then 60 else timeout))
39 (TPTP_Interpret.interpret_file
41 (Path.dir tptp_probs_dir)
46 fun interpret_timed timeout file thy =
47 Timing.timing (interpret timeout file) thy
49 fun interpretation_test timeout ctxt =
51 (fn file => interpret timeout file (Proof_Context.theory_of ctxt))
55 fun interpretation_tests timeout ctxt probs =
57 (interpretation_test timeout ctxt)
58 (List.map situate probs)
103 "SYN/SYN001^4.001.p",
105 "SYN/SYN393^4.002.p",
108 "SYN/SYN393^4.003.p",
117 interpretation_tests (get_timeout @{context}) @{context}
118 (some_probs @ take_too_long @ timeouts @ more_probs)
122 parse_timed (situate "NUM/NUM923^4.p");
123 interpret_timed 0 (situate "NUM/NUM923^4.p") @{theory}
127 fun interp_gain timeout thy file =
129 val t1 = (parse_timed file |> fst)
130 val t2 = (interpret_timed timeout file thy |> fst)
131 handle exn => (*FIXME*)
132 if Exn.is_interrupt exn then reraise exn
134 (warning (" test: file " ^ Path.print file ^
135 " raised exception: " ^ ML_Compiler.exn_message exn);
136 {gc = Time.zeroTime, cpu = Time.zeroTime, elapsed = Time.zeroTime})
137 val to_real = Time.toReal
139 #elapsed t2 - #elapsed t1
141 val elapsed = to_real (#elapsed t2)
143 (Path.base file, diff_elapsed,
144 diff_elapsed / elapsed,
150 subsection "Test against whole TPTP"
152 text "Run interpretation over all problems. This works only for logics
153 for which interpretation is defined (in TPTP_Parser/tptp_interpret.ML)."
155 if test_all @{context} then
156 (report @{context} "Interpreting all problems";
157 S timed_test (interpretation_test (get_timeout @{context})) @{context})