Skip to main content

Solver for plane geometric problems.

Project description

Newclid is an open-source, easy-to-use fast solver for plane geometry problems.

Fury - PyPi stable version PePy - Downloads PePy - Downloads per week Python - Tests Codacy - Grade Codacy - Coverage CodeStyle - Ruff

Installation

Using pip

pip install newclid[yuclid]

Building from source

Follow uv installation instructions

git clone https://github.com/Newclid/Newclid.git
cd Newclid
uv sync

If you run into issues to build yuclid, you might need to set an environment variable like CXX=/usr/bin/g++-14, try adding environment variable that are present in .env. If you still have issues, submit an issue.

Quickstart

To simply solve a problem using Newclid, use the command line.

For example with a JGEX problem:

newclid jgex --problem-id orthocenter_consequence_aux --file ./problems_datasets/examples.txt

Or with a ggb problem:

newclid ggb --file ./notebooks/ggb_exports/incenter.ggb --goals "eqangle C B B D B D B A"

See other command line interface options with:

uv run newclid --help
uv run newclid jgex --help
uv run newclid ggb --help

For more complex applications, use the Python interface. Below is a minimal example to build a problem setup from a JGEX string, then solve it:

from newclid import GeometricSolverBuilder, GeometricSolver
import numpy as np

# Set the random generator
rng = np.random.default_rng()

# Build the problem setup from JGEX string
problem_setup = JGEXProblemBuilder(rng=rng).with_problem_from_txt(
  "a b c = triangle a b c; "
  "d = on_tline d b a c, on_tline d c a b; "
  "e = on_line e a c, on_line e b d "
  "? perp a d b c"
).build()

# We now build the solver on the problem
solver: GeometricSolver = GeometricSolverBuilder().build(problem_setup)

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

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

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

In the notebooks folder you will find more tutorials. You can also check tests to see some more advanced examples of scripts using the Python interface.

Documentation

See the online documentation for more detailed information about Newclid.

Contributing

  1. Clone the repository

git clone https://github.com/Newclid/Newclid.git
cd Newclid
  1. Install uv

Follow installation instructions

  1. Install as an editable package with dev requirements

uv sync
  1. Install pre-commit and pre-push checks

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

pytest tests

About Newclid

Newclid is a successor to AlphaGeometry, introduced in this early 2024 Nature paper: Solving Olympiad Geometry without Human Demonstrations. whose original codebase can be found here.

If you found Newclid useful, please cite us as:

@article{newclid2024sicca,
  author  = {Sicca, Vladmir and Xia, Tianxiang and F\'ed\'erico, Math\"is and Gorinski, Philip John and Frieder, Simon and Jui, Shangling},
  journal = {arXiv preprint},
  title   = {Newclid: A User-Friendly Replacement for AlphaGeometry with Agentic Support},
  year    = {2024}
}

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-3.0.1.tar.gz (358.5 kB view details)

Uploaded Source

File details

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

File metadata

  • Download URL: newclid-3.0.1.tar.gz
  • Upload date:
  • Size: 358.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for newclid-3.0.1.tar.gz
Algorithm Hash digest
SHA256 c555d22afac64071567d9dc1b07e653b001489707f05ef19e063d966646169fc
MD5 473e1c56a93f768e49453fc1cb0ffd5d
BLAKE2b-256 a7fc5036798e867db4069cd4e06f6f9df89ca633398a97976591e440b866bb66

See more details on using hashes here.

Provenance

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

Publisher: publish-newclid.yml on Newclid/Newclid

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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