BeHOLd.TPTP (behold v1.0.0)

View Source

Contains utility to parse files from the TPTP problem library (https://tptp.org/TPTP/) as well as custom files in TPTP's TH0 syntax. Also contains utility to generate TH0 string representation of terms, types and declarations. This module only works with files in TH0 syntax. For reference, the TH0 language is defined in https://doi.org/10.1007/s10817-017-9407-7.

Note that there is no functionality of generating a full TPTP file from a given term which would include definitions and user type declarations.

Summary

From TPTP Representation

Parses a TPTP file in TH0 syntax at the proveded path into a Problem structure. Returns {:error, reason} if a problem occured when reading the file.

Parses a string representing a problem file in TPTP's TH0 syntax into a Problem structure.

To TPTP Representation

Converts a given term or variable/constant declaration to TPTP's TH0 syntax. Tries to reconstruct the syntactic sugar (e.g., the XOR operator "<~>") present in the TH0 language and eta-reduces the terms.

Converts a type given as HOL.Data.type() or atom to TPTP's TH0 string representation. Does not introduce declarations as required for handling user types when creating a TPTP file.

From TPTP Representation

parse_file(problem, is_tptp \\ true)

@spec parse_file(String.t(), boolean()) ::
  {:ok, BeHOLd.Data.Problem.t()} | {:error, String.t()}

Parses a TPTP file in TH0 syntax at the proveded path into a Problem structure. Returns {:error, reason} if a problem occured when reading the file.

This function serves two purposes: parsing a file from the TPTP problem library (https://tptp.org/TPTP/) or a custom problem file given by the user.

The default is to parse a file from the TPTP problem library. In that case, the flag is_tptp should be set to true. This also requires an environment variable TPTP_ROOT which points to the unpacked root folder of the TPTP problem library. Setting this environment variable may require a system restart before Elixir recognizes it.

When parsing a custom problem file, the flag is_tptp should be set to false. problem should contain the absolute path to the problem file. Note that imports of custom files are not supported. Only axioms from the TPTP problem library can be imported (this also requires the TPTP_ROOT environment variable to be set).

parse_string(content, path \\ "memory")

@spec parse_string(String.t(), String.t()) ::
  {:ok, BeHOLd.Data.Problem.t()} | {:error, String.t()}

Parses a string representing a problem file in TPTP's TH0 syntax into a Problem structure.

The parsing of content only supports including files from the TPTP problem library. If such includes are present, make sure that the TPTP_ROOT environment variable is set.

The path does not need to be specified when calling this method. It is purely for keeping track of the file name from a call to parse_file/2.

To TPTP Representation

term_to_tptp(term_or_declaration)

@spec term_to_tptp(HOL.Data.hol_term() | HOL.Data.declaration()) :: String.t()

Converts a given term or variable/constant declaration to TPTP's TH0 syntax. Tries to reconstruct the syntactic sugar (e.g., the XOR operator "<~>") present in the TH0 language and eta-reduces the terms.

As bound variables are named using deBrujn indices, they are prefixed with "BV". Skolem constants, which are internally named by prefixing them with "__sk" followed by an identifying number, are prefixed by "skolem", removing the double underscore before the name. To ensure TH0's variable encoding scheme (variables start with uppercase letters), variables are prefixed with "VAR".

type_to_tptp(type_or_atom)

@spec type_to_tptp(HOL.Data.type() | atom()) :: String.t()

Converts a type given as HOL.Data.type() or atom to TPTP's TH0 string representation. Does not introduce declarations as required for handling user types when creating a TPTP file.