src/HOL/TPTP/lib/Tools/tptp_translate
author nipkow
Tue, 11 Nov 2025 09:19:46 +0100
changeset 83547 db80ee4abed1
parent 83354 ea5f530ccfc5
permissions -rwxr-xr-x
tuned
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
54433
b1721e5b8717 reintroduced (unimplemented) 'tptp_translate' tool
blanchet
parents:
diff changeset
     1
#!/usr/bin/env bash
b1721e5b8717 reintroduced (unimplemented) 'tptp_translate' tool
blanchet
parents:
diff changeset
     2
#
b1721e5b8717 reintroduced (unimplemented) 'tptp_translate' tool
blanchet
parents:
diff changeset
     3
# Author: Jasmin Blanchette
83354
ea5f530ccfc5 adapted tptp_translate to use new process_theory command
desharna
parents: 81527
diff changeset
     4
# Author: Martin Desharnais-Schäfer
54433
b1721e5b8717 reintroduced (unimplemented) 'tptp_translate' tool
blanchet
parents:
diff changeset
     5
#
b1721e5b8717 reintroduced (unimplemented) 'tptp_translate' tool
blanchet
parents:
diff changeset
     6
# DESCRIPTION: translate between TPTP formats
b1721e5b8717 reintroduced (unimplemented) 'tptp_translate' tool
blanchet
parents:
diff changeset
     7
b1721e5b8717 reintroduced (unimplemented) 'tptp_translate' tool
blanchet
parents:
diff changeset
     8
PRG="$(basename "$0")"
b1721e5b8717 reintroduced (unimplemented) 'tptp_translate' tool
blanchet
parents:
diff changeset
     9
b1721e5b8717 reintroduced (unimplemented) 'tptp_translate' tool
blanchet
parents:
diff changeset
    10
function usage() {
b1721e5b8717 reintroduced (unimplemented) 'tptp_translate' tool
blanchet
parents:
diff changeset
    11
  echo
54472
073f041d83ae send output of "tptp_translate" to standard output, to simplify Geoff Sutcliffe's life
blanchet
parents: 54434
diff changeset
    12
  echo "Usage: isabelle $PRG FORMAT FILE"
54433
b1721e5b8717 reintroduced (unimplemented) 'tptp_translate' tool
blanchet
parents:
diff changeset
    13
  echo
54547
c999e2533487 renamed TFF0/THF0 to three-letter acronyms, in keeping with new TPTP policy
blanchet
parents: 54472
diff changeset
    14
  echo "  Translates TPTP input file to the specified format (\"FOF\", \"TF0\", \"TH0\", or \"DFG\")."
54472
073f041d83ae send output of "tptp_translate" to standard output, to simplify Geoff Sutcliffe's life
blanchet
parents: 54434
diff changeset
    15
  echo "  Emits the result to standard output."
54433
b1721e5b8717 reintroduced (unimplemented) 'tptp_translate' tool
blanchet
parents:
diff changeset
    16
  echo
b1721e5b8717 reintroduced (unimplemented) 'tptp_translate' tool
blanchet
parents:
diff changeset
    17
  exit 1
b1721e5b8717 reintroduced (unimplemented) 'tptp_translate' tool
blanchet
parents:
diff changeset
    18
}
b1721e5b8717 reintroduced (unimplemented) 'tptp_translate' tool
blanchet
parents:
diff changeset
    19
54472
073f041d83ae send output of "tptp_translate" to standard output, to simplify Geoff Sutcliffe's life
blanchet
parents: 54434
diff changeset
    20
[ "$#" -ne 2 -o "$1" = "-?" ] && usage
54433
b1721e5b8717 reintroduced (unimplemented) 'tptp_translate' tool
blanchet
parents:
diff changeset
    21
b1721e5b8717 reintroduced (unimplemented) 'tptp_translate' tool
blanchet
parents:
diff changeset
    22
SCRATCH="Scratch_${PRG}_$$_${RANDOM}"
83354
ea5f530ccfc5 adapted tptp_translate to use new process_theory command
desharna
parents: 81527
diff changeset
    23
SCRATCH_FILE=/tmp/${SCRATCH}.thy
54433
b1721e5b8717 reintroduced (unimplemented) 'tptp_translate' tool
blanchet
parents:
diff changeset
    24
b1721e5b8717 reintroduced (unimplemented) 'tptp_translate' tool
blanchet
parents:
diff changeset
    25
args=("$@")
b1721e5b8717 reintroduced (unimplemented) 'tptp_translate' tool
blanchet
parents:
diff changeset
    26
83354
ea5f530ccfc5 adapted tptp_translate to use new process_theory command
desharna
parents: 81527
diff changeset
    27
echo "theory ${SCRATCH} imports \"HOL-TPTP.ATP_Problem_Import\" begin \
ea5f530ccfc5 adapted tptp_translate to use new process_theory command
desharna
parents: 81527
diff changeset
    28
ML \<open> ATP_Problem_Import.translate_tptp_file @{theory} \"${args[0]}\" \"${args[1]}\" \<close> end" \
ea5f530ccfc5 adapted tptp_translate to use new process_theory command
desharna
parents: 81527
diff changeset
    29
    > "${SCRATCH_FILE}"
60546
dcb0b9b42fcb automatically build image
blanchet
parents: 60545
diff changeset
    30
83354
ea5f530ccfc5 adapted tptp_translate to use new process_theory command
desharna
parents: 81527
diff changeset
    31
isabelle process_theories -O -U -l HOL-TPTP -f "${SCRATCH_FILE}" "${SCRATCH}" \
ea5f530ccfc5 adapted tptp_translate to use new process_theory command
desharna
parents: 81527
diff changeset
    32
    | grep --line-buffered -vE \
ea5f530ccfc5 adapted tptp_translate to use new process_theory command
desharna
parents: 81527
diff changeset
    33
        -e '^Running Draft ...$' \
ea5f530ccfc5 adapted tptp_translate to use new process_theory command
desharna
parents: 81527
diff changeset
    34
        -e '^[[:space:]]*$' \
ea5f530ccfc5 adapted tptp_translate to use new process_theory command
desharna
parents: 81527
diff changeset
    35
        -e '^Output \(line [[:digit:]]+ of ".*"):$' \
ea5f530ccfc5 adapted tptp_translate to use new process_theory command
desharna
parents: 81527
diff changeset
    36
        -e '^val it = \(\): unit$' \
ea5f530ccfc5 adapted tptp_translate to use new process_theory command
desharna
parents: 81527
diff changeset
    37
        -e '^Finished Draft \([0-9:]+ elapsed time(, [0-9:]+ cpu time, factor [0-9.]+)?\)$' \
ea5f530ccfc5 adapted tptp_translate to use new process_theory command
desharna
parents: 81527
diff changeset
    38
        -e '^PROOF FAILED for depth' \
ea5f530ccfc5 adapted tptp_translate to use new process_theory command
desharna
parents: 81527
diff changeset
    39
        -e '^Failure node' \
ea5f530ccfc5 adapted tptp_translate to use new process_theory command
desharna
parents: 81527
diff changeset
    40
        -e 'inferences so far.  Searching to depth' \
ea5f530ccfc5 adapted tptp_translate to use new process_theory command
desharna
parents: 81527
diff changeset
    41
        -e '^val ' \
ea5f530ccfc5 adapted tptp_translate to use new process_theory command
desharna
parents: 81527
diff changeset
    42
        -e 'Loading theory' \
ea5f530ccfc5 adapted tptp_translate to use new process_theory command
desharna
parents: 81527
diff changeset
    43
        -e '^poly.*warning: The type of' \
ea5f530ccfc5 adapted tptp_translate to use new process_theory command
desharna
parents: 81527
diff changeset
    44
        -e '^   monotype.$'