src/HOL/TPTP/TPTP_Interpret_Test.thy
author sultana
Tue, 17 Apr 2012 16:14:07 +0100
changeset 47518 b2f209258621
parent 47516 9c29589c9b31
child 47547 1a5dc8377b5c
permissions -rw-r--r--
more cleaning of tptp tests;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
47512
b381d428a725 reorganised tptp testing thys
sultana
parents:
diff changeset
     1
(*  Title:      HOL/TPTP/TPTP_Interpret_Test.thy
b381d428a725 reorganised tptp testing thys
sultana
parents:
diff changeset
     2
    Author:     Nik Sultana, Cambridge University Computer Laboratory
b381d428a725 reorganised tptp testing thys
sultana
parents:
diff changeset
     3
b381d428a725 reorganised tptp testing thys
sultana
parents:
diff changeset
     4
Some tests for the TPTP interface. Some of the tests rely on the Isabelle
b381d428a725 reorganised tptp testing thys
sultana
parents:
diff changeset
     5
environment variable TPTP_PROBLEMS_PATH, which should point to the
b381d428a725 reorganised tptp testing thys
sultana
parents:
diff changeset
     6
TPTP-vX.Y.Z/Problems directory.
b381d428a725 reorganised tptp testing thys
sultana
parents:
diff changeset
     7
*)
b381d428a725 reorganised tptp testing thys
sultana
parents:
diff changeset
     8
b381d428a725 reorganised tptp testing thys
sultana
parents:
diff changeset
     9
theory TPTP_Interpret_Test
b381d428a725 reorganised tptp testing thys
sultana
parents:
diff changeset
    10
imports TPTP_Test TPTP_Interpret
b381d428a725 reorganised tptp testing thys
sultana
parents:
diff changeset
    11
begin
b381d428a725 reorganised tptp testing thys
sultana
parents:
diff changeset
    12
b381d428a725 reorganised tptp testing thys
sultana
parents:
diff changeset
    13
section "Interpreter tests"
47518
b2f209258621 more cleaning of tptp tests;
sultana
parents: 47516
diff changeset
    14
47512
b381d428a725 reorganised tptp testing thys
sultana
parents:
diff changeset
    15
text "Interpret a problem."
b381d428a725 reorganised tptp testing thys
sultana
parents:
diff changeset
    16
ML {*
b381d428a725 reorganised tptp testing thys
sultana
parents:
diff changeset
    17
  val (time, ((type_map, const_map, fmlas), thy)) =
b381d428a725 reorganised tptp testing thys
sultana
parents:
diff changeset
    18
    Timing.timing
b381d428a725 reorganised tptp testing thys
sultana
parents:
diff changeset
    19
      (TPTP_Interpret.interpret_file
b381d428a725 reorganised tptp testing thys
sultana
parents:
diff changeset
    20
       false
b381d428a725 reorganised tptp testing thys
sultana
parents:
diff changeset
    21
       (Path.dir tptp_probs_dir)
b381d428a725 reorganised tptp testing thys
sultana
parents:
diff changeset
    22
      (Path.append tptp_probs_dir (Path.explode "LCL/LCL825-1.p"))
b381d428a725 reorganised tptp testing thys
sultana
parents:
diff changeset
    23
       []
b381d428a725 reorganised tptp testing thys
sultana
parents:
diff changeset
    24
       [])
b381d428a725 reorganised tptp testing thys
sultana
parents:
diff changeset
    25
      @{theory}
b381d428a725 reorganised tptp testing thys
sultana
parents:
diff changeset
    26
*}
b381d428a725 reorganised tptp testing thys
sultana
parents:
diff changeset
    27
b381d428a725 reorganised tptp testing thys
sultana
parents:
diff changeset
    28
text "... and display nicely."
b381d428a725 reorganised tptp testing thys
sultana
parents:
diff changeset
    29
ML {*
47518
b2f209258621 more cleaning of tptp tests;
sultana
parents: 47516
diff changeset
    30
  List.app (Pretty.writeln o (Syntax.pretty_term @{context}) o #4) fmlas;
b2f209258621 more cleaning of tptp tests;
sultana
parents: 47516
diff changeset
    31
47512
b381d428a725 reorganised tptp testing thys
sultana
parents:
diff changeset
    32
  (*Don't use TPTP_Syntax.string_of_tptp_formula, it's just for testing*)
b381d428a725 reorganised tptp testing thys
sultana
parents:
diff changeset
    33
  List.app (writeln o TPTP_Syntax.string_of_tptp_formula o #3) fmlas
b381d428a725 reorganised tptp testing thys
sultana
parents:
diff changeset
    34
*}
b381d428a725 reorganised tptp testing thys
sultana
parents:
diff changeset
    35
b381d428a725 reorganised tptp testing thys
sultana
parents:
diff changeset
    36
subsection "Multiple tests"
b381d428a725 reorganised tptp testing thys
sultana
parents:
diff changeset
    37
b381d428a725 reorganised tptp testing thys
sultana
parents:
diff changeset
    38
ML {*
47518
b2f209258621 more cleaning of tptp tests;
sultana
parents: 47516
diff changeset
    39
  (*default timeout is 1 min*)
47516
9c29589c9b31 improved tptp interpretation test thy
sultana
parents: 47512
diff changeset
    40
  fun interpret timeout file thy =
47518
b2f209258621 more cleaning of tptp tests;
sultana
parents: 47516
diff changeset
    41
    TimeLimit.timeLimit (Time.fromSeconds (if timeout = 0 then 60 else timeout))
47516
9c29589c9b31 improved tptp interpretation test thy
sultana
parents: 47512
diff changeset
    42
     (TPTP_Interpret.interpret_file
9c29589c9b31 improved tptp interpretation test thy
sultana
parents: 47512
diff changeset
    43
       false
9c29589c9b31 improved tptp interpretation test thy
sultana
parents: 47512
diff changeset
    44
       (Path.dir tptp_probs_dir)
9c29589c9b31 improved tptp interpretation test thy
sultana
parents: 47512
diff changeset
    45
       file
9c29589c9b31 improved tptp interpretation test thy
sultana
parents: 47512
diff changeset
    46
       []
9c29589c9b31 improved tptp interpretation test thy
sultana
parents: 47512
diff changeset
    47
       []) thy
9c29589c9b31 improved tptp interpretation test thy
sultana
parents: 47512
diff changeset
    48
9c29589c9b31 improved tptp interpretation test thy
sultana
parents: 47512
diff changeset
    49
  fun interpret_timed timeout file thy =
9c29589c9b31 improved tptp interpretation test thy
sultana
parents: 47512
diff changeset
    50
    Timing.timing (interpret timeout file) thy
9c29589c9b31 improved tptp interpretation test thy
sultana
parents: 47512
diff changeset
    51
47512
b381d428a725 reorganised tptp testing thys
sultana
parents:
diff changeset
    52
  fun interpretation_test timeout ctxt =
b381d428a725 reorganised tptp testing thys
sultana
parents:
diff changeset
    53
    test_fn ctxt
47518
b2f209258621 more cleaning of tptp tests;
sultana
parents: 47516
diff changeset
    54
     (fn file => interpret timeout file (Proof_Context.theory_of ctxt))
47512
b381d428a725 reorganised tptp testing thys
sultana
parents:
diff changeset
    55
     "interpreter"
b381d428a725 reorganised tptp testing thys
sultana
parents:
diff changeset
    56
     ()
b381d428a725 reorganised tptp testing thys
sultana
parents:
diff changeset
    57
b381d428a725 reorganised tptp testing thys
sultana
parents:
diff changeset
    58
  fun interpretation_tests timeout ctxt probs =
b381d428a725 reorganised tptp testing thys
sultana
parents:
diff changeset
    59
    List.app
b381d428a725 reorganised tptp testing thys
sultana
parents:
diff changeset
    60
     (interpretation_test timeout ctxt)
b381d428a725 reorganised tptp testing thys
sultana
parents:
diff changeset
    61
     (List.map situate probs)
b381d428a725 reorganised tptp testing thys
sultana
parents:
diff changeset
    62
*}
b381d428a725 reorganised tptp testing thys
sultana
parents:
diff changeset
    63
b381d428a725 reorganised tptp testing thys
sultana
parents:
diff changeset
    64
ML {*
b381d428a725 reorganised tptp testing thys
sultana
parents:
diff changeset
    65
  val some_probs =
b381d428a725 reorganised tptp testing thys
sultana
parents:
diff changeset
    66
    ["LCL/LCL825-1.p",
b381d428a725 reorganised tptp testing thys
sultana
parents:
diff changeset
    67
     "ALG/ALG001^5.p",
b381d428a725 reorganised tptp testing thys
sultana
parents:
diff changeset
    68
     "COM/COM003+2.p",
b381d428a725 reorganised tptp testing thys
sultana
parents:
diff changeset
    69
     "COM/COM003-1.p",
b381d428a725 reorganised tptp testing thys
sultana
parents:
diff changeset
    70
     "COM/COM024^5.p",
b381d428a725 reorganised tptp testing thys
sultana
parents:
diff changeset
    71
     "DAT/DAT017=1.p",
b381d428a725 reorganised tptp testing thys
sultana
parents:
diff changeset
    72
     "NUM/NUM021^1.p",
b381d428a725 reorganised tptp testing thys
sultana
parents:
diff changeset
    73
     "NUM/NUM858=1.p",
b381d428a725 reorganised tptp testing thys
sultana
parents:
diff changeset
    74
     "SYN/SYN000^2.p"]
b381d428a725 reorganised tptp testing thys
sultana
parents:
diff changeset
    75
b381d428a725 reorganised tptp testing thys
sultana
parents:
diff changeset
    76
  val take_too_long =
b381d428a725 reorganised tptp testing thys
sultana
parents:
diff changeset
    77
    ["NLP/NLP562+1.p",
b381d428a725 reorganised tptp testing thys
sultana
parents:
diff changeset
    78
     "SWV/SWV546-1.010.p",
b381d428a725 reorganised tptp testing thys
sultana
parents:
diff changeset
    79
     "SWV/SWV567-1.015.p",
b381d428a725 reorganised tptp testing thys
sultana
parents:
diff changeset
    80
     "LCL/LCL680+1.020.p"]
b381d428a725 reorganised tptp testing thys
sultana
parents:
diff changeset
    81
47516
9c29589c9b31 improved tptp interpretation test thy
sultana
parents: 47512
diff changeset
    82
  val timeouts =
9c29589c9b31 improved tptp interpretation test thy
sultana
parents: 47512
diff changeset
    83
    ["NUM/NUM923^4.p",
9c29589c9b31 improved tptp interpretation test thy
sultana
parents: 47512
diff changeset
    84
    "NUM/NUM926^4.p",
9c29589c9b31 improved tptp interpretation test thy
sultana
parents: 47512
diff changeset
    85
    "NUM/NUM925^4.p",
9c29589c9b31 improved tptp interpretation test thy
sultana
parents: 47512
diff changeset
    86
    "NUM/NUM924^4.p",
9c29589c9b31 improved tptp interpretation test thy
sultana
parents: 47512
diff changeset
    87
    "CSR/CSR153^3.p",
9c29589c9b31 improved tptp interpretation test thy
sultana
parents: 47512
diff changeset
    88
    "CSR/CSR151^3.p",
9c29589c9b31 improved tptp interpretation test thy
sultana
parents: 47512
diff changeset
    89
    "CSR/CSR148^3.p",
9c29589c9b31 improved tptp interpretation test thy
sultana
parents: 47512
diff changeset
    90
    "CSR/CSR120^3.p",
9c29589c9b31 improved tptp interpretation test thy
sultana
parents: 47512
diff changeset
    91
    "CSR/CSR150^3.p",
9c29589c9b31 improved tptp interpretation test thy
sultana
parents: 47512
diff changeset
    92
    "CSR/CSR119^3.p",
9c29589c9b31 improved tptp interpretation test thy
sultana
parents: 47512
diff changeset
    93
    "CSR/CSR149^3.p"]
9c29589c9b31 improved tptp interpretation test thy
sultana
parents: 47512
diff changeset
    94
47512
b381d428a725 reorganised tptp testing thys
sultana
parents:
diff changeset
    95
  val more_probs =
b381d428a725 reorganised tptp testing thys
sultana
parents:
diff changeset
    96
    ["GEG/GEG014^1.p",
b381d428a725 reorganised tptp testing thys
sultana
parents:
diff changeset
    97
     "GEG/GEG009^1.p",
b381d428a725 reorganised tptp testing thys
sultana
parents:
diff changeset
    98
     "GEG/GEG004^1.p",
b381d428a725 reorganised tptp testing thys
sultana
parents:
diff changeset
    99
     "GEG/GEG007^1.p",
b381d428a725 reorganised tptp testing thys
sultana
parents:
diff changeset
   100
     "GEG/GEG016^1.p",
b381d428a725 reorganised tptp testing thys
sultana
parents:
diff changeset
   101
     "GEG/GEG024=1.p",
b381d428a725 reorganised tptp testing thys
sultana
parents:
diff changeset
   102
     "GEG/GEG010^1.p",
b381d428a725 reorganised tptp testing thys
sultana
parents:
diff changeset
   103
     "GEG/GEG003^1.p",
b381d428a725 reorganised tptp testing thys
sultana
parents:
diff changeset
   104
     "GEG/GEG018^1.p",
b381d428a725 reorganised tptp testing thys
sultana
parents:
diff changeset
   105
     "SYN/SYN045^4.p",
b381d428a725 reorganised tptp testing thys
sultana
parents:
diff changeset
   106
     "SYN/SYN001^4.001.p",
b381d428a725 reorganised tptp testing thys
sultana
parents:
diff changeset
   107
     "SYN/SYN000^2.p",
b381d428a725 reorganised tptp testing thys
sultana
parents:
diff changeset
   108
     "SYN/SYN387^4.p",
b381d428a725 reorganised tptp testing thys
sultana
parents:
diff changeset
   109
     "SYN/SYN393^4.002.p",
b381d428a725 reorganised tptp testing thys
sultana
parents:
diff changeset
   110
     "SYN/SYN978^4.p",
b381d428a725 reorganised tptp testing thys
sultana
parents:
diff changeset
   111
     "SYN/SYN044^4.p",
b381d428a725 reorganised tptp testing thys
sultana
parents:
diff changeset
   112
     "SYN/SYN393^4.003.p",
b381d428a725 reorganised tptp testing thys
sultana
parents:
diff changeset
   113
     "SYN/SYN389^4.p"]
b381d428a725 reorganised tptp testing thys
sultana
parents:
diff changeset
   114
*}
b381d428a725 reorganised tptp testing thys
sultana
parents:
diff changeset
   115
b381d428a725 reorganised tptp testing thys
sultana
parents:
diff changeset
   116
ML {*
47516
9c29589c9b31 improved tptp interpretation test thy
sultana
parents: 47512
diff changeset
   117
  interpret_timed 0 (situate "NUM/NUM923^4.p") @{theory}
47512
b381d428a725 reorganised tptp testing thys
sultana
parents:
diff changeset
   118
*}
b381d428a725 reorganised tptp testing thys
sultana
parents:
diff changeset
   119
47516
9c29589c9b31 improved tptp interpretation test thy
sultana
parents: 47512
diff changeset
   120
ML {*
47518
b2f209258621 more cleaning of tptp tests;
sultana
parents: 47516
diff changeset
   121
 interpretation_tests (get_timeout @{context}) @{context}
47516
9c29589c9b31 improved tptp interpretation test thy
sultana
parents: 47512
diff changeset
   122
   (some_probs @ take_too_long @ timeouts @ more_probs)
9c29589c9b31 improved tptp interpretation test thy
sultana
parents: 47512
diff changeset
   123
*}
9c29589c9b31 improved tptp interpretation test thy
sultana
parents: 47512
diff changeset
   124
47512
b381d428a725 reorganised tptp testing thys
sultana
parents:
diff changeset
   125
b381d428a725 reorganised tptp testing thys
sultana
parents:
diff changeset
   126
subsection "Test against whole TPTP"
b381d428a725 reorganised tptp testing thys
sultana
parents:
diff changeset
   127
b381d428a725 reorganised tptp testing thys
sultana
parents:
diff changeset
   128
text "Run interpretation over all problems. This works only for logics
b381d428a725 reorganised tptp testing thys
sultana
parents:
diff changeset
   129
 for which interpretation is defined (in TPTP_Parser/tptp_interpret.ML)."
b381d428a725 reorganised tptp testing thys
sultana
parents:
diff changeset
   130
ML {*
47518
b2f209258621 more cleaning of tptp tests;
sultana
parents: 47516
diff changeset
   131
  if test_all @{context} then
b2f209258621 more cleaning of tptp tests;
sultana
parents: 47516
diff changeset
   132
    (report @{context} "Interpreting all problems";
b2f209258621 more cleaning of tptp tests;
sultana
parents: 47516
diff changeset
   133
     S timed_test (interpretation_test (get_timeout @{context})) @{context})
b2f209258621 more cleaning of tptp tests;
sultana
parents: 47516
diff changeset
   134
  else ()
47512
b381d428a725 reorganised tptp testing thys
sultana
parents:
diff changeset
   135
*}
b381d428a725 reorganised tptp testing thys
sultana
parents:
diff changeset
   136
47518
b2f209258621 more cleaning of tptp tests;
sultana
parents: 47516
diff changeset
   137
end