connections

Reinforcement learning environments for classical, intuitionistic, and modal first-order connection calculi.

https://github.com/fredrrom/connections

Science Score: 44.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (13.8%) to scientific vocabulary
Last synced: 6 months ago · JSON representation ·

Repository

Reinforcement learning environments for classical, intuitionistic, and modal first-order connection calculi.

Basic Info
  • Host: GitHub
  • Owner: fredrrom
  • License: mit
  • Language: OpenEdge ABL
  • Default Branch: main
  • Homepage:
  • Size: 958 KB
Statistics
  • Stars: 3
  • Watchers: 1
  • Forks: 1
  • Open Issues: 0
  • Releases: 0
Created about 3 years ago · Last pushed 12 months ago
Metadata Files
Readme License Citation

README.md

Connections

tests License: MIT

Reinforcement learning environments for classical, intuitionistic, and modal first-order connection calculi in Python.

For further details see the paper.

Requirements

  • Python 3.10 or later
  • Git
  • SWI Prolog 8.4.3 (For TPTP/QMLTP translation and to run pyCoP provers)

Installation

Reinforcement Learning Environments

To begin using the reinforcement learning environments, simply install the connections Python package using the folllowing command:

pip install git+https://github.com/fredrrom/connections.git

Conjectures and pyCoP provers

Each connections environment is initialized with a first-order conjecture as input. These conjectures are read in a custom cnf format.

To translate TPTP/QMLTP formated files or run the standalone pyCoP provers, either clone the repository:

git clone https://github.com/fredrrom/connections.git

or download the repository ZIP.

Getting Started

The environments closely follow the OpenAI Gym/Gymnasium interface. Here is a simple connection prover implemented using the ConnectionEnv environment:

```python from connections.calculi.classical import ConnectionEnv

env = ConnectionEnv("problem_path") observation = env.reset()

while True: action = env.action_space[0] observation, reward, done, info = env.step(action)

if done:
    break

```

In addition to classical first-order logic, ConnectionEnv supports intuitionistic logic and modal logics S4, S5, D, and T each for the constant, cumulative, and varying domains. Logic and domain can be specifified during the creation of the environment as by passing settings as follows:

```python settings = Settings(logic="S5", domain="varying")

env = ConnectionEnv("problem_path", settings=settings) ```

NB The environments cannot be registered as gym environments, as their state and action spaces do not inherit from gym.spaces. They are, however, designed to be used as backends for your own gym environments.

A Worked Example

Consider double-negation elimination, that $p$ is equivalent to $\lnot \lnot p$. This is a theorem in classical logic, and is saved in the file tests/cnf_problems/SYN001+1.p

That file contains 5 clauses, which are found by means of Definition 3 in Otten's "Restricting Backtracking in Connection Calculi".

Running the following code (from inside this project's directory): ```python from connections.calculi.classical import ConnectionEnv

env = ConnectionEnv("tests/cnf_problems/SYN001+1.p") observation = env.reset()

while True: action = env.actionspace[0] observation, reward, done, info = env.step(action) if done: print(observation.proofsequence, "\n") print(info) break ```

should print ``` [st0: [pdefini(1), pdefini(2)], ex0: pdefini(1) -> [-pdefini(1), p], ex1: p -> [-pdefini(1), -p], re0: -pdefini(1) <- pdefini(1), ex0: pdefini(2) -> [-pdefini(2), p], ex0: p -> [-pdefini(2), -p], re0: -pdefini(2) <- pdefini(2)]

{'status': 'Theorem'} `` The latter line tells us that this is a theorem, i.e. that the formula is valid. The former line gives us the proof sequence reached at the end, from which one can reconstruct the full proof tree. Alternatively, one can inspect the tableau by callingprint(observation.tableau)`.

TPTP/QMLTP Translation

To translate TPTP/QMLTP formatted files into the connections format, run the following command

translation/<logic>/translate.sh <file>

where <file> is the name of the problem file in TPTP/QMLTP syntax and <logic> is one of classical, intuitionistic, and modal depending on the target proof logic.

To guarantee correct translation, please use SWI-Prolog version 8.4.3 and ensure that the PROLOG_PATH and TPTP variables in translation/<logic>/translate.sh are set to your SWI Prolog installation location and TPTP/QMLTP directory location, respectively.

The pyCoP, ipyCoP and mpyCoP Connection Provers

pycop.py contains the standalone provers pyCoP, ipyCoP, and mpyCoP for classical, intuitionistic, and modal logics, respectively.

The provers can be invoked (at the top level directory of this repository) with the following command

python pycop.py <file> [logic] [domain]

where <file> is the path to the problem file in TPTP/QMLTP syntax, the optional argument [logic] is one of classical (default), intuitionistic, D, T, S4, or S5, and the optional argument [domain] is one of constant (default), cumulative, and varying. Note that the value of [domain] is inconsequential if [logic] is classical or intuitionistic. If the formula in <file> is valid for the logic [logic] (with [domain] domains if logic is modal), then the prover reports Theorem.

These connection provers are equivalent to version 1.0f of the leanCoP, ileanCoP and MleanCoP provers for classical, intuitionistic and modal logic, respectively, which can be found in the comparisons directory.

BibTeX Citation

@inproceedings{connections_2023, author = {Rømming, Fredrik and Otten, Jens and Holden, Sean B.}, title = {Connections: {Markov} {Decision} {Processes} for {Classical}, {Intuitionistic} and {Modal} {Connection} {Calculi}}, booktitle = {Proceedings of the 1st {International} {Workshop} on {Automated} {Reasoning} with {Connection} {Calculi}}, series = {{CEUR} {Workshop} {Proceedings}}, volume = {3613}, year = {2023}, pages = {107--118}, }

Owner

  • Name: Fredrik Rømming
  • Login: fredrrom
  • Kind: user

Citation (CITATION.cff)

# This CITATION.cff file was generated with cffinit.
# Visit https://bit.ly/cffinit to generate yours today!

cff-version: 1.2.0
title: Connections
message: >-
  If you use this software, please cite it using the
  metadata from this file.
type: software
authors:
  - given-names: Fredrik
    family-names: 'R{\o}mming'
    orcid: 'https://orcid.org/0000-0001-7545-4662'
identifiers:
  - type: url
    value: 'https://github.com/fredrrom/connections'
repository-code: 'https://github.com/fredrrom/connections'

GitHub Events

Total
  • Push event: 3
  • Create event: 1
Last Year
  • Push event: 3
  • Create event: 1

Dependencies

.github/workflows/python-app.yml actions
  • actions/checkout v3 composite
  • actions/setup-python v3 composite
poetry.lock pypi
  • anyio 3.6.2 develop
  • appnope 0.1.3 develop
  • argon2-cffi 21.3.0 develop
  • argon2-cffi-bindings 21.2.0 develop
  • arrow 1.2.3 develop
  • asttokens 2.2.1 develop
  • attrs 22.2.0 develop
  • backcall 0.2.0 develop
  • beautifulsoup4 4.11.1 develop
  • bleach 5.0.1 develop
  • cffi 1.15.1 develop
  • colorama 0.4.6 develop
  • comm 0.1.2 develop
  • coverage 7.0.5 develop
  • debugpy 1.6.5 develop
  • decorator 5.1.1 develop
  • defusedxml 0.7.1 develop
  • entrypoints 0.4 develop
  • exceptiongroup 1.1.0 develop
  • executing 1.2.0 develop
  • fastjsonschema 2.16.2 develop
  • fqdn 1.5.1 develop
  • idna 3.4 develop
  • iniconfig 2.0.0 develop
  • ipykernel 6.20.2 develop
  • ipython 8.8.0 develop
  • ipython-genutils 0.2.0 develop
  • ipywidgets 8.0.4 develop
  • isoduration 20.11.0 develop
  • jedi 0.18.2 develop
  • jinja2 3.1.2 develop
  • jsonpointer 2.3 develop
  • jsonschema 4.17.3 develop
  • jupyter 1.0.0 develop
  • jupyter-client 7.4.9 develop
  • jupyter-console 6.4.4 develop
  • jupyter-core 5.1.3 develop
  • jupyter-events 0.6.3 develop
  • jupyter-server 2.1.0 develop
  • jupyter-server-terminals 0.4.4 develop
  • jupyterlab-pygments 0.2.2 develop
  • jupyterlab-widgets 3.0.5 develop
  • markupsafe 2.1.1 develop
  • matplotlib-inline 0.1.6 develop
  • mistune 2.0.4 develop
  • nbclassic 0.4.8 develop
  • nbclient 0.7.2 develop
  • nbconvert 7.2.8 develop
  • nbformat 5.7.3 develop
  • nest-asyncio 1.5.6 develop
  • notebook 6.5.2 develop
  • notebook-shim 0.2.2 develop
  • numpy 1.24.1 develop
  • packaging 23.0 develop
  • pandas 1.5.2 develop
  • pandocfilters 1.5.0 develop
  • parso 0.8.3 develop
  • pexpect 4.8.0 develop
  • pickleshare 0.7.5 develop
  • platformdirs 2.6.2 develop
  • pluggy 1.0.0 develop
  • prometheus-client 0.15.0 develop
  • prompt-toolkit 3.0.36 develop
  • psutil 5.9.4 develop
  • ptyprocess 0.7.0 develop
  • pure-eval 0.2.2 develop
  • pycparser 2.21 develop
  • pygments 2.14.0 develop
  • pyrsistent 0.19.3 develop
  • pytest 7.2.1 develop
  • pytest-cov 4.0.0 develop
  • python-dateutil 2.8.2 develop
  • python-json-logger 2.0.4 develop
  • pytz 2022.7.1 develop
  • pywin32 305 develop
  • pywinpty 2.0.10 develop
  • pyyaml 6.0 develop
  • pyzmq 25.0.0 develop
  • qtconsole 5.4.0 develop
  • qtpy 2.3.0 develop
  • rfc3339-validator 0.1.4 develop
  • rfc3986-validator 0.1.1 develop
  • send2trash 1.8.0 develop
  • six 1.16.0 develop
  • sniffio 1.3.0 develop
  • soupsieve 2.3.2.post1 develop
  • stack-data 0.6.2 develop
  • terminado 0.17.1 develop
  • tinycss2 1.2.1 develop
  • tomli 2.0.1 develop
  • tornado 6.2 develop
  • tqdm 4.64.1 develop
  • traitlets 5.8.1 develop
  • uri-template 1.2.0 develop
  • wcwidth 0.2.6 develop
  • webcolors 1.12 develop
  • webencodings 0.5.1 develop
  • websocket-client 1.4.2 develop
  • widgetsnbextension 4.0.5 develop
pyproject.toml pypi
  • jupyter ^1.0.0 develop
  • pandas ^1.5.1 develop
  • pytest ^7.2.0 develop
  • pytest-cov ^4.0.0 develop
  • tqdm ^4.64.1 develop
  • python ^3.10