Skip to main content

Python library for running proof search using CoPra

Project description

Build Status PyPI version PyPI downloads

copra

COPRA: An in-COntext PRoof Agent which uses LLMs like GPTs to prove theorems in formal languages.

Setup Steps:

Quick Setup for Lean 4:

  1. Install itp-interface using the following command: (Our package is available on PyPI: https://pypi.org/project/copra-theorem-prover/)
pip install copra-theorem-prover
  1. Run the following command to prepare the REPL for Lean 4. (The default version is 4.7.0-rc2. You can change the version by setting the LEAN_VERSION environment variable. If no version is set, then 4.7.0-rc2 is used.)

NOTE: The Lean 4 version must match the version of the Lean 4 project you are working with.

export LEAN_VERSION="4.15.0"
install-lean-repl
  1. Run the following command to build the REPL for Lean 4. Make sure that lean --version returns the correct version before running the command below. If not then check if $HOME/.elan/bin is in your path. Recommended to run source $HOME/.elan/env before running the command below.
install-itp-interface

NOTE: These steps are only tested on Linux. For Windows, you can use WSL. These steps will not setup the Coq interface.

Full Setup for Coq and Lean:

  1. Install OCaml first. Use the instructions here: https://opam.ocaml.org/doc/Install.html. Note that OCaml officially only supports Linux installations. One can use WSL on Windows machines.

  2. Run the following to install Coq on Linux.

sudo apt install build-essential unzip bubblewrap
sh <(curl -sL https://raw.githubusercontent.com/ocaml/opam/master/shell/install.sh)
  1. Add the following to your .bashrc file: (sometimes the path ~/.opam/default might not exist, so use the directory with version number present in the ~/.opam directory)
export PATH="/home/$USER/.opam/default/bin:$PATH"
  1. Create a Miniconda environment and activate it.

  2. Run the commands for installing the Lean 4 interface as mentioned in Quick Setup for Lean 4.

  3. Add the following to your .bashrc file for Lean:

export PATH="/home/$USER/.elan/bin:$PATH"

Setting up OpenAI API and Running Experiments:

  1. You need to create a file .secrets/openai_key.json in the root directory of the project with the OpenAI API key. The file should contain the following:
{
    "organization": "<your-organization-id>",
    "api_key": "<your-api-key>"
}
  1. The experiments are not necessarily thread safe. So, it is recommended to run them sequentially. The commands to run the desired experiments can be found in the file ./src/copra/main/config/experiments.yaml.

  2. Run the following command to run the experiments:

python src/copra/main/eval_benchmark.py
#^ This will run the experiments mentioned in the file `./src/copra/main/config/experiments.yaml`.
# Change the file path in the command above to run other experiments.

Important Note:

The ITP projects must be built before running COPRA. Make sure that the switch is set correctly while running it for Coq projects because the Coq projects can be using different versions of Coq.

Paper:

You can cite our paper:

@inproceedings{thakur2024context,
  title={An in-context learning agent for formal theorem-proving},
  author={Thakur, Amitayush and Tsoukalas, George and Wen, Yeming and Xin, Jimmy and Chaudhuri, Swarat},
  booktitle={First Conference on Language Modeling},
  year={2024}
}

Our paper can be found here: OpenReview and ArXiv

Project details


Download files

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

Source Distribution

copra_theorem_prover-1.1.10.tar.gz (5.2 MB view details)

Uploaded Source

Built Distribution

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

copra_theorem_prover-1.1.10-py3-none-any.whl (224.8 kB view details)

Uploaded Python 3

File details

Details for the file copra_theorem_prover-1.1.10.tar.gz.

File metadata

  • Download URL: copra_theorem_prover-1.1.10.tar.gz
  • Upload date:
  • Size: 5.2 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.23

File hashes

Hashes for copra_theorem_prover-1.1.10.tar.gz
Algorithm Hash digest
SHA256 87e9d06e002d4773e1fdeaadc89e727fe90e067e43d46b0095ac74994a616a54
MD5 937b26c91e2e8d7ad62decbcb5004794
BLAKE2b-256 fa8ccc0b0db15052ffd87e366357f6e39bd2c74f23717c88d5bf1b11e599e42a

See more details on using hashes here.

File details

Details for the file copra_theorem_prover-1.1.10-py3-none-any.whl.

File metadata

File hashes

Hashes for copra_theorem_prover-1.1.10-py3-none-any.whl
Algorithm Hash digest
SHA256 0f2e5ca4d0e4f0b7dd9258a71e91a8d3ff2012b3cffed75e793d7d6a7fcf1e22
MD5 4343c993072be373d58e779d358c097c
BLAKE2b-256 5e6461826f6c9baf6d12b3eacdb24a7503062ad2dd88790dec092ea32233c642

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