Skip to main content

An OpenAI Gym environment for saturation provers

Project description

Saturation Gym

Saturation Gym is an OpenAI Gym environment for saturation provers (like PyRes).

Installation

pip install gym-saturation

Usage

See examples/example.ipynb notebook for more information.

What is going on

One can write theorems in a machine-readable form. This package uses the CNF sublanguage of TPTP. Before using the environment, you will need to download a recent TPTP archive (ca 600MB).

A statement of a theorem becomes a list of clauses. In a given clause algorithm, one divides the clauses in processed and not processed yet. Then at each step, one selects a not processed yet clause as a given clause. If it's empty (we arrived at a contradiction, i.e. found a refutation proof), the algorithm stops with success. If not, one computes all possible resolvents (the results of applying a simple but powerful resolution deduction rule to the given clause and all processed clauses). Then we add resolvents to the unprocessed set, and the given clause goes into the processed. The algorithm iterates if we didn't run out of time and unprocessed clauses.

For the choice of a given clause, one usually employs a clever combination of heuristics. Of course, we can reformulate the same process as a reinforcement learning task.

What is a State

(More or less resembles ProofState class of PyRes)

The environment's state is a list of logical clauses. Each clause is a list of literals and also has several properties:

  • label --- comes from the problem file or starts with inferred_ if inferred during the episode
  • processed --- boolean value splitting clauses into unprocessed and processed ones; in the beginning, everything is not processed
  • birth_step --- a number of the step when the clause appeared in the unprocessed set; clauses from the problem have birth_step zero
  • inference_parents --- a list of labels from which the clause was inferred. For clauses from the problem statement, this list is empty.

Literal is a predicate, negated or not. A predicate can have arguments, which can be functions or variables. Functions can have arguments, which in turn can be functions or variables.

Grammar is encoded in Python objects in a self-explanatory way. Each grammar object is a dictionary with an obligatory key class (Clause, Literal, Predicate, Function, Variable), and other keys representing this object's properties (such as being negated or having a list of arguments). To parse these JSON representation into package's inner representation, use gym_saturation.parsing.json_grammar.dict_to_clause.

What is an Action

Action is an index of a clause from the state. Valid actions are only indices of not processed clauses.

What is a Reward

1.0 if the proof is found (a clause with an empty list of literals is selected as an action).

-1.0, if all clauses from the state are processed or step limit is reached, but no proof is found

0.0 in any other case (valid action chosen, saturation step performed, step limit not reached yes, no proof is found, there are still not processed clauses)

Important notice

Usually, saturation provers use a timeout in seconds since they work in real-time mode. Here, we live in a discrete time, so we limit a prover by the number of saturation algorithm steps taken, not wall-clock time.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gym-saturation-0.0.2.tar.gz (32.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gym_saturation-0.0.2-py3-none-any.whl (40.6 kB view details)

Uploaded Python 3

File details

Details for the file gym-saturation-0.0.2.tar.gz.

File metadata

  • Download URL: gym-saturation-0.0.2.tar.gz
  • Upload date:
  • Size: 32.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.7 CPython/3.6.14 Linux/5.8.0-63-generic

File hashes

Hashes for gym-saturation-0.0.2.tar.gz
Algorithm Hash digest
SHA256 b1c78f7c29d6c9ebc07cec30dd634b29fbf77a1f0824d961d61bab2beaad9235
MD5 999ec7394d215aa289c1b1458c856ee0
BLAKE2b-256 d65caea52d85e2f5b4179a4f91f4fdbdac332379fffb2255392f93c2c6864401

See more details on using hashes here.

File details

Details for the file gym_saturation-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: gym_saturation-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 40.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.7 CPython/3.6.14 Linux/5.8.0-63-generic

File hashes

Hashes for gym_saturation-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 3a98db661b7eb49a60caa75bf4aa559a01dde863cb02ded946bbf58091c9eeac
MD5 95887e1b300e24c36e98e67774358f9f
BLAKE2b-256 bea051b0ddb3ceeb66271f8d46f4611c78a7ca4dd1c4f5131b70ca7085a793a0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page