Skip to main content

Symbolic solver for geometric problems.

Project description

An extension of the geometric solver introduced in the Nature 2024 paper: Solving Olympiad Geometry without Human Demonstrations.

Where a geometric problem is fed to a solver (DDAR) and helped by an LLM to build auxiliary constructions.

AlphaGeometry can be seen as an extension of GeoSolver equipped with a language model that proposes new auxiliary constructions if a problem gets stuck.

Currently new auxiliary constructions can only be added in Geosolver as human suggested constructions if the HumanAgent is used instead of BFSDDAR (default).

Installation

Using pip

pip install 'newclid>=2,<3'

From source

git clone https://github.com/LMCRC/Newclid.git
pip install -e .

Quickstart

To simply solve a problem using newclid, use the command line:

newclid --problem path/to/problem:problem_name

For example:

newclid --problem problems_datasets/examples.txt:orthocenter_consequence_aux

See other command line interface options with:

newclid --help

For more complex applications, use the python interface. Below is a minimal example to load a specific problem, then uses the built solver to solve it:

from newclid import GeometricSolverBuilder, GeometricSolver

solver_builder = GeometricSolverBuilder()
solver_builder.load_problem_from_txt(
    "a b c = triangle a b c; "
    "d = on_tline d b a c, on_tline d c a b "
    "? perp a d b c"
)

# We now obtain the GeometricSolver with the build method
solver: GeometricSolver = solver_builder.build()

# And run the GeometricSolver
success = solver.run()

if success:
    print("Successfuly solved the problem!")
else:
    print("Failed to solve the problem...")

print(f"Run infos {solver.run_infos}")

Some more advanced examples of script using the python interface are displayed in the folder examples or used in tests.

Documentation

See the online documentation for more detailed informations about newclid.

Contributing

  1. Clone the repository

git clone https://github.com/LMCRC/Newclid.git
cd path/to/repo
  1. (Optional) Create a virtual environment, for example with venv:

python -m venv venv

# On UNIX
source ./bin/activate

# On Windows
.\venv\Scripts\activate
  1. Install as an editable package with dev requirements

pip install -e .[dev]
  1. Install pre-commit and pre-push checks

pre-commit install -t pre-commit -t pre-push
  1. Run tests

pytest tests

About AlphaGeometry

See original repository.

@Article{AlphaGeometryTrinh2024,
  author  = {Trinh, Trieu and Wu, Yuhuai and Le, Quoc and He, He and Luong, Thang},
  journal = {Nature},
  title   = {Solving Olympiad Geometry without Human Demonstrations},
  year    = {2024},
  doi     = {10.1038/s41586-023-06747-5}
}

The AlphaGeometry checkpoints and vocabulary are made available under the terms of the Creative Commons Attribution 4.0 International (CC BY 4.0) license. You can find details at: https://creativecommons.org/licenses/by/4.0/legalcode

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

newclid-2.0.2.tar.gz (3.0 MB view details)

Uploaded Source

Built Distribution

newclid-2.0.2-py3-none-any.whl (121.1 kB view details)

Uploaded Python 3

File details

Details for the file newclid-2.0.2.tar.gz.

File metadata

  • Download URL: newclid-2.0.2.tar.gz
  • Upload date:
  • Size: 3.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for newclid-2.0.2.tar.gz
Algorithm Hash digest
SHA256 9d09dd96354fb4606e4be4c1c8aeaaf31f056fc5df0123539d8f77cdddb7b53a
MD5 9df232e9035d6e41f449e8602b13e92d
BLAKE2b-256 ff3002aa810d6fc292980c8c295e8d43dc0f5f6d6b0708d11e25dca22b36a24d

See more details on using hashes here.

Provenance

The following attestation bundles were made for newclid-2.0.2.tar.gz:

Publisher: pypi.yml on LMCRC/Newclid

Attestations:

File details

Details for the file newclid-2.0.2-py3-none-any.whl.

File metadata

  • Download URL: newclid-2.0.2-py3-none-any.whl
  • Upload date:
  • Size: 121.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for newclid-2.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 7b1353676138c0a820773fc3ec3b4a4846c5f5b4182818a08acf0353f0bf3f28
MD5 25b71e82b4106dc7f23db87e2387d5e7
BLAKE2b-256 9981f13cf9a0c6bc63fcd0f0c69c419cdb390603ef3a6966f156c816ba1da267

See more details on using hashes here.

Provenance

The following attestation bundles were made for newclid-2.0.2-py3-none-any.whl:

Publisher: pypi.yml on LMCRC/Newclid

Attestations:

Supported by

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