Utilities

The tptp2X Utility

The tptp2X utility is a multi-functional utility for reformatting, transforming, and generating TPTP problem files. In particular, it tptp2X is written in Prolog, and should run on most Prolog systems. It is known to run on current versions of
Eclipse, SICStus, SWI, and YAP Prolog. Before using tptp2X, it is necessary to install the code for the dialect of Prolog that is to be used. This and other installation issues are described next.

Installation

The tptp2X utility consists of the following files: Installation of the tptp2X utility requires simple changes in the tptp2X script and the files tptp2X.config and tptp2X.main. These changes can be made by running tptp2X_install, which will prompt for required information. Otherwise, to install tptp2X by hand, the following must be attended to:

Using tptp2X

The most convenient way of using the tptp2X utility is through the tptp2X script. The use of this script is:
tptp2X [-h][-q<Level>][-i][-s<Size>][-t<Transform>][-f<Format>] [-d<Directory>] -l<NamesFile>|<TPTPFiles>
The -h flag specifies that usage information should be output. The -q flag specifies the level of quietness at which the script should operate. There are three quietness levels; 0 is verbose mode, 1 suppresses informational output from the Prolog interpreter, and 2 suppresses all informational output except lines showing what files are produced. The default quietness level is 1. The -i flag specifies that the script should enter interactive mode after processing all other command line parameters. Interactive mode is described below. The other command line parameter values are:
A common first use of tptp2X is to convert TPTP problems to another format. To convert all TPTP problems to another format, the use is tptp2X -f<Format>, e.g., tptp2X -f otter. To limit the conversion to one or more domains, the domain names are specified after the <Format>, e.g., tptp2X -f leantap ALG GRP LDA. If you are a new TPTP user, these are probably the uses that you want to start with.

The tptp2X Output Files

The output files produced by tptp2X are named according to the input file name and the options used. The TPTP problem name (the input file name without the .p or .g) forms the basis of the output file names. For files created from TPTP generators, the size parameters are appended to the base name, separated from the base name by a ".". Then, for each transformation applied a suffix is appended. The suffixes for the transformations are:

Transformation Suffix

stdfof +stdfof
clausify:<Algorithm> +cls_<Algorithm>
simplify +simp
cnf:<Algorithm> +cnf_<Algorithm>
propify +prop
lr +lr
cr +cr
clr +clr
fr +fr
random +ran
er +er
ran_er +ran_er
rm_equality:<Remove> +rm_eq_<Remove>
add_equality +eq
to_equality +2eq
magic +nhms
shorten +short
none

Finally an extension to indicate the output format is appended to the file name. The suffixes for the output formats are:

Format Extension Format Extension

bliksem .blk carine .car
clin-s .clin_s code .code
dedam .dedam dfg .dfg
dimacs .dimacs eqp .eqp
finder .fin glides .glides
ilf .ilf kif .kif
leanTAP .leantap tap .3tap
meteor .me mgtp .mgtp
oscar .oscar otter .in
protein .tme pttp .pttp
satchmo .sat scott .sin
sem .sem setheo .lop
sprfn .sprfn thinker .thinker
tptp .tptp waldmeister .pr

To record how a tptp2X output file has been formed, the tptp2X parameters are given in a % Comments field entry of the output file.

Example

~/TPTP/TPTP2X> tptp2X -tlr,cr,clr -fpttp ../Problems/ALG/ALG001-1.p
---------------------------------------------------------------------
TPTP2X directory      = /home/2/tptp/TPTP/TPTP2X
TPTP directory        = /home/2/tptp/TPTP
Prolog interpreter    = /usr/local/bin/sicstus
Files to convert      = ../Problems/ALG/ALG001-1.p
Size                  =
Transformation        = lr,cr,clr
Format to convert to  = pttp
Output directory      = /home/tptp/TPTP/Problems/pttp
---------------------------------------------------------------------
Made the directory /home/tptp/TPTP/Problems/pttp/ALG
ALG001-1 -> /home/tptp/TPTP/Problems/pttp/ALG/ALG001-1+lr.pttp
ALG001-1 -> /home/tptp/TPTP/Problems/pttp/ALG/ALG001-1+cr.pttp
ALG001-1 -> /home/tptp/TPTP/Problems/pttp/ALG/ALG001-1+clr.pttp
~/TPTP/TPTP2X>
This run applies three separate transformations to the problem ALG001-1. The transformations are literal order reversal, clause order reversal, and reversal of both literal and clause order. The transformed problems are output in pttp format, in the directory pttp/ALG below the TPTP Problems directory. The file names are ALG001-1+lr.pttp, ALG001-1+cr.pttp, and ALG001-1+clr.pttp.

Example

~/TPTP/TPTP2X> tptp2X -q2 -s3..5 -fotter -d~tptp/tmp SYN001-1.g
SYN001-1 -> /home/tptp/tmp/SYN/SYN001-1.003+rm_eq_stfp.in
SYN001-1 -> /home/tptp/tmp/SYN/SYN001-1.004+rm_eq_stfp.in
SYN001-1 -> /home/tptp/tmp/SYN/SYN001-1.005+rm_eq_stfp.in
~/TPTP/TPTP2X>
This run generates three sizes of the generic problem SYN001-1. The sizes are 3, 4, and 5. The output files are formatted for Otter, to use its auto mode. The files are placed in \verb/~/tptp/tmp/SYN, and are named SYN001-1.003.lop, SYN001-1.004.lop, and SYN001-1.005.lop. The quietness level is set to 2, thus suppressing all informational output except the lines showing what files are produced. Note that the file SYN001-1.g is automatically found in the generators directory.

Example

~/TPTP/TPTP2X> tptp2X -tmagic+shorten - < ~tptp/TPTP/Problems/GRP/GRP001-1.p
---------------------------------------------------------------------
TPTP2X directory      = /home/tptp/TPTP/TPTP2X
TPTP directory        = /home/tptp/TPTP
Prolog interpreter    = /usr/local/bin/sicstus
Files to convert      = -
Size                  =
Transformation        = magic+shorten
Format to convert to  = tptp
Output directory      = -
---------------------------------------------------------------------
%--------------------------------------------------------------------------
% File     : Shortened file, so there is no header
%--------------------------------------------------------------------------
input_clause(clause_1,axiom,
    [++equal(X1,X1)]).

... Lots of output omitted here for brevity

input_clause(clause_41,theorem,
    [--p2(c8,c7,c9)]).
%--------------------------------------------------------------------------
~/TPTP/TPTP2X>
This run uses the tptp2X script as a filter, to apply the non-Horn magic set transformation and then the symbol shortening transformation to GRP001-1.p. GRP001-1.p is fed in from standard input, and the output is written to standard output (thus all informational output is suppressed).

The tptp2X Interactive Mode

If the -i flag is set, the tptp2X script enters interactive mode after processing all other command line parameters. In interactive mode the user can change the value of any of the command line parameters. The user is prompted for the <TPTPFiles>, the <Size>, the <Transform>, the <Format>, and the <Directory>. In each prompt the current value is given. The user may respond by specifying a new value or by entering <cr> to accept the current value. The prompt-respond loop continues for each parameter until the user accepts the value for the parameter. Example
~/TPTP/TPTP2X> tptp2X -q0 -d~tptp/tmp -i
---- Interactive mode -----------------------------------------------
Files to convert      [Problems/*/*.p] : ../Problems/GRP/GRP001-1.p
Files to convert      [../Problems/GRP/GRP001-1.p] :
Size                  [] :
Transformation        [none] : lr+rm_equality:stfp
Transformation        [lr+rm_equality:stfp] :
Format to convert to  [tptp] : setheo
Format to convert to  [setheo] :
Output directory      [/home/tptp/tmp] :
---- End of Interactive mode ----------------------------------------
---------------------------------------------------------------------
TPTP2X directory      = /home/2/tptp/TPTP/TPTP2X
TPTP directory        = /home/2/tptp/TPTP
Prolog interpreter    = /usr/local/bin/sicstus
Files to convert      = ../Problems/GRP/GRP001-1.p
Size                  =
Transformation        = lr+rm_equality:stfp
Format to convert to  = setheo:sign
Output directory      = /home/tptp/tmp
---------------------------------------------------------------------
Made the directory /home/tptp/tmp/GRP
SICStus 3  #6: Mon Nov 3 18:32:08 MET 1997

... Lots of informational output omitted here for brevity

{/home/2/tptp/TPTP/TPTP2X/tptp2X.main compiled, 12080 msec 785600 bytes}

yes

yes
GRP001-1 -> /home/tptp/tmp/GRP/GRP001-1+lr+rm_eq_stfp.lop
~/TPTP/TPTP2X>
This run converts the problem GRP001-1 to a SETHEO format file. The literals are reversed and all equality clauses except reflexivity are removed. The top level output directory is specified as \verb/~/tptp/tmp, below which the subdirectory GRP is made. The output file is named GRP001-1+lr+eq_stfp.lop. Verbose mode is used, so all informational output is given.

The following subsections are only of interest to real Prolog users. If you do not want to use Prolog directly, skip to the next section.

Running tptp2X from within Prolog

The tptp2X utility may also be run from within a Prolog interpreter. The tptp2X.main file has to be loaded, and the entry point is then tptp2X/5, in the form:

?-tptp2X(<TPTPFile>,<Size>,<Transform>,<Format>,<Directory>).

The parameters are similar to the tptp2X script command line parameters. A summary, highlighting differences with "(!)", is given here. See Section Using tptp2X for parameter options.

Example
~/TPTP/TPTP2X> sicstus
SICStus 3  #6: Mon Nov 3 18:32:08 MET 1997
| ?- ['tptp2X.main'].
{consulting /home/2/tptp/TPTP/TPTP2X/tptp2X.main...}

... Lots of informational output omitted here for brevity

{/home/tptp/TPTP/TPTP2X/tptp2X.main consulted, 10750 msec 773088 bytes}

yes
| ?- tptp2X('Generators/SYN010-1.g',3:[2,4],[lr,cr]+magic,kif,'.').
{compiling /home/tptp/TPTP/Generators/SYN010-1.g...}
{/home/tptp/TPTP/Generators/SYN010-1.g compiled, 90 msec 4288 bytes}
SYN010-1 -> ./SYN010-1.003:002+lr+nhms.kif
SYN010-1 -> ./SYN010-1.003:002+cr+nhms.kif
SYN010-1 -> ./SYN010-1.003:004+lr+nhms.kif
SYN010-1 -> ./SYN010-1.003:004+cr+nhms.kif

yes
| ?- ^D
~/TPTP/TPTP2X>
This run generates two sizes of the generic problem SYN010-1, and does two transformation sequences on each of the two sets of clauses, to produce four output files. The sizes are 3:2 and 3:4. The first transformation sequence is literal order reversal followed by the non-Horn magic set transformation, and the second transformation sequence is clause order reversal followed by the non-Horn magic set transformation. The files are output in KIF format in the current directory. The file names are
SYN010-1.003:002+lr+nhms.kif, SYN010-1.003:002+cr+nhms.kif,
SYN010-1.003:004+lr+nhms.kif, and SYN010-1.003:004+cr+nhms.kif.

Note that the TPTP file name is quoted in the query, to form a Prolog atom.

Writing your own Transformations and Output Formats

The transformations and output formatting are implemented in Prolog, in the files transform.<TRAN> and format.<ATP>, respectively. It is simple to add new transformations and output formats to the tptp2X utility, by creating new transformation and format files. New files should follow the structure of the existing files. Typically, a new file can be created by modifying a copy of one of the existing files.

The entry point in a transformation file is <Transform>/6. The first three arguments are inputs: a list of the problem's formulae, the variable dictionary (a bit complicated), and the transformation specification. The next three arguments are outputs: the transformed formulae, the transformed variable dictionary (typically the same as the input dictionary), and the transformation suffix. As well as the <Transform>/6 entry point, a <Transform>_file_information/2 fact must be provided. The two arguments of the <Transform>_file_information/2 fact are the atom transform and a description of the possible transformation specifications (as used in the third argument of <Transform>/6). See the existing transform.<TRAN> files for examples.

The entry point in a format file is <Format>/3. The three arguments are inputs: the format specification, a list of the problem's formulae, and the file header information. (It is not necessary to output a file header here; this information is available only for producing supplementary documentation.) As well as the <Format>/3 entry point, a <Format>_format_information/2 fact and a <Format>_file_information/2 fact must be provided. The two arguments of the <Format>_format_information/2 fact are a character that can be used to start a comment in the output file and the format extension, both as Prolog atoms. The two arguments of the <Format>_file_information/2 fact are the atom format and a description of the possible format specifications. See the existing format.<ATP> files for examples.

New transformation and format files must be compiled in with the other tptp2X files. This is done by adding a compile query in the tptp2X.main file, alongside the queries that compile in the existing files.

If you need help, please contact Geoff Sutcliffe.

Writing your own Problem Generators

The TPTP generators are implemented in Prolog. It is simple to write new generators. New files should follow the structure of the existing files.

The entry point in a generator file is <Problem name>/3, where <Problem name> is the file name without the .g suffix. The first argument is an input: the size parameter for generation. The second and third arguments are outputs: the formulae generated and the % Status of the formulae. The formulae must be a Prolog list of formulae in TPTP format. A <Problem name>_file_information/3 fact must also be provided. The three arguments of the fact are the atom generator, a description of the possible size parameters, and the TPTP size for this problem (this is hard to determine!). See the existing generator files for examples.

If you need help, please contact Geoff Sutcliffe.

The tptp1T Script

The tptp1T script selects lines from either the FOFProblemStatistics file or the CNFProblemStatistics file, by problem characteristics.

The tptp1T script is written in perl.

Installation

Installation of the tptp1T utility requires simple changes in the tptp1T script. These changes can be made by running tptp1T_install, which will prompt for required information. Otherwise, to install tptp1T by hand, in the tptp1T script file $TPTPDirectory must be set to the absolute path name of the TPTP directory.

Using tptp1T

The use of this script is:

tptp1T CNF|FOF [-f <ProblemFile>] {[-]<Constraint>}

The CNF or FOF argument indicates which statistics file to select lines from. The optional -f <ProblemFile> argument specifies the name of a file containing TPTP problem names. tptp1T will select statistics file lines for only those problems whose names appear in the <ProblemFile>. The problem names (without the .p extension) must appear one per line in the <ProblemFile>, and lines that start with # are ignored. The <Constraint>s specify required problem characteristics, all of which must be satisfied for the statistics file line to be selected. A - may be prepended to negate the meaning of any <Constraint>. The possible <Constraint>s are: