ShotDs (shot_ds v1.0.4)

Copy Markdown View Source

This module collects the most important functions from the library. These include parsing functions as well as simple term construction.

Summary

Functions

Applies a term to a single argument term or list of argument terms.

Pretty-prints the given HOL object taking the ETS cache into accout for recursively traversing term DAGs. This is implemented for singular types, declarations, terms and substitutions.

Pretty-prints the given HOL object taking the ETS cache into accout for recursively traversing term DAGs. This is implemented for singular types, declarations, terms and substitutions. Type annotations may be displayed by setting the second field to false.

Constructs a lambda abstraction over a list of variable types. Temporary fresh free variables will be generated corresponding to the types. Passes the generated variable term IDs to the provided body_fn. The arity of body_fn must correspond to the number of given variables.

Basic construction of a constant with the corresponding name and type and returns the ID for its term representation. While unique constants can be created by giving an Erlang reference as name, it is recommended to use ShotDs.Stt.TermFactory.make_fresh_const_term/1 instead for that purpose.

Basic construction of a free variable with the corresponding name and type and returns the ID for its term representation. While unique variables can be created by giving an Erlang reference as name, it is recommended to use ShotDs.Stt.TermFactory.make_fresh_var_term/1 instead for that purpose.

Parses a given string representing a formula in TH0 syntax with full type inference. Types which can't be inferred are assigned type variables. Variables on the outermost level are identified with type o. Returns the assigned ID of the created term.

Parses a TPTP file in TH0 syntax at the provided path into a ShotDs.Data.Problem struct. Returns {:error, reason} if a problem occurred.

Parses a TPTP file in TH0 syntax at the provided path into a ShotDs.Data.Problem struct. Returns {:error, reason} if a problem occurred.

Parses a string representing a full problem file in TPTP's TH0 syntax into a ShotDs.Data.Problem struct.

Parses a HOL type from TPTP syntax into a ShotDs.Data.Type struct.

Functions

app(head_id, arg_ids)

Applies a term to a single argument term or list of argument terms.

Delegates the function call to ShotDs.Util.Builder.app/2.

format!(hol_object)

Pretty-prints the given HOL object taking the ETS cache into accout for recursively traversing term DAGs. This is implemented for singular types, declarations, terms and substitutions.

Delegates the function call to ShotDs.Util.Formatter.format!/1.

format!(hol_object, hide_types)

Pretty-prints the given HOL object taking the ETS cache into accout for recursively traversing term DAGs. This is implemented for singular types, declarations, terms and substitutions. Type annotations may be displayed by setting the second field to false.

Delegates the function call to ShotDs.Util.Formatter.format!/1.

lambda(var_types, body_fn)

Constructs a lambda abstraction over a list of variable types. Temporary fresh free variables will be generated corresponding to the types. Passes the generated variable term IDs to the provided body_fn. The arity of body_fn must correspond to the number of given variables.

Delegates the function call to ShotDs.Util.Builder.lambda/2.

Examples:

iex> lambda(Type.new(:i), fn x -> ... end)

iex> lambda([Type.new(:o), Type.new(:o), Type.new(:o)], fn x, y, z -> ... end)

make_const_term(name, type)

@spec make_const_term(String.t() | reference(), ShotDs.Data.Type.t()) ::
  ShotDs.Data.Term.term_id()

Basic construction of a constant with the corresponding name and type and returns the ID for its term representation. While unique constants can be created by giving an Erlang reference as name, it is recommended to use ShotDs.Stt.TermFactory.make_fresh_const_term/1 instead for that purpose.

Delegates the function call to ShotDs.Stt.TermFactory.make_const_term/2.

Example:

iex> import ShotDs.Hol.Definitions # shorthand type defs etc.
iex> make_const_term("f", type_io())

make_free_var_term(name, type)

@spec make_free_var_term(String.t() | reference(), ShotDs.Data.Type.t()) ::
  ShotDs.Data.Term.term_id()

Basic construction of a free variable with the corresponding name and type and returns the ID for its term representation. While unique variables can be created by giving an Erlang reference as name, it is recommended to use ShotDs.Stt.TermFactory.make_fresh_var_term/1 instead for that purpose.

Delegates the function call to ShotDs.Stt.TermFactory.make_free_var_term/2.

Example:

iex> import ShotDs.Hol.Definitions # shorthand type defs etc.
iex> make_free_var_term("X", type_o())

parse!(formula_str)

@spec parse!(String.t()) :: ShotDs.Data.Term.term_id()

Parses a given string representing a formula in TH0 syntax with full type inference. Types which can't be inferred are assigned type variables. Variables on the outermost level are identified with type o. Returns the assigned ID of the created term.

Delegates the function call to ShotDs.Parser.parse!/1.

Examples:

iex> parse!("X & a") |> format_term()
"X ∧ a"

iex> parse!("X @ Y") |> format_term(_hide_types = false)
"(X_T[OUFDH]>o Y_T[OUFDH])_o"

parse_tptp_file(path)

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

Parses a TPTP file in TH0 syntax at the provided path into a ShotDs.Data.Problem struct. Returns {:error, reason} if a problem occurred.

Delegates the function call to ShotDs.Tptp.parse_tptp_file/1.

parse_tptp_file(path, origin)

@spec parse_tptp_file(String.t(), :tptp_problem | :tptp_relative | :custom) ::
  {:ok, ShotDs.Data.Problem.t()} | {:error, String.t()}

Parses a TPTP file in TH0 syntax at the provided path into a ShotDs.Data.Problem struct. Returns {:error, reason} if a problem occurred.

origin indicates whether it is a file from the TPTP problem library and can be accessed via the environment variable TPTP_ROOT pointing to the root directory of the TPTP library.

Delegates the function call to ShotDs.Tptp.parse_tptp_file/1.

parse_tptp_string(content)

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

Parses a string representing a full problem file in TPTP's TH0 syntax into a ShotDs.Data.Problem struct.

Delegates the function call to ShotDs.Tptp.parse_tptp_string/1.

parse_type!(type_str)

@spec parse_type!(String.t()) :: ShotDs.Data.Type.t()

Parses a HOL type from TPTP syntax into a ShotDs.Data.Type struct.

Delegates the function call to ShotDs.Parser.parse_type!/1.

Example:

iex> parse_type!("$i")
%ShotDs.Data.Type{goal: :i, args: []}