Metadata-Version: 2.4
Name: judgment-prover
Version: 1.0.0
Summary: Checked symbolic proofs, mathematical profiles, and optional persistence for Python
Author-email: Anatoly Vitold Stankyavichyus <anatolyvitold@outlook.com>
License-Expression: Apache-2.0 WITH LLVM-exception
License-File: LICENSE
Project-URL: Homepage, https://spellbound-mojo.github.io/judgment/
Project-URL: Documentation, https://spellbound-mojo.github.io/judgment/
Project-URL: Repository, https://github.com/Spellbound-Mojo/judgment
Requires-Python: >=3.10
Requires-Dist: mojo-compiler>=1.2.0,<1.3.0
Description-Content-Type: text/markdown

# Judgment

**Higher-order logic theorem prover for Mojo and Python.**

With `judgment` (v1.0.0), you write ordinary Mojo or Python programs that state
mathematical claims, construct derivations, and verify them through a small
polymorphic HOL kernel. Supported on **Linux (`linux-64`, `linux-aarch64`) and
Apple Silicon macOS (`osx-arm64`)** with Mojo 1.2 and Python 3.

## What `judgment` provides

- **Kernel-checked proofs:** Every theorem (whether constructed by hand,
  tactics, algebraic engines, or imported from a library) is checked by the HOL
  kernel (`judgment_core`). Inspect `statement()`, `axioms()`, `admissions()`,
  and dependency closures at any time, or export proofs in OpenTheory v6 format
  for independent verification in other HOL provers (such as Isabelle/HOL).
- **HOL polymorphism and type classes:** Declare generic constants, nonempty
  subset types, overloaded operators, order-sorted class hierarchies, and custom
  ACU (associative-commutative-unit) conversion without dependent-type
  bookkeeping.
- **Out-of-core storage:** Cap live workspace memory (`set_memory_limit`) and
  spill verified proof-DAG pages to disk (`spill`) for workloads exceeding RAM.
- **Extended-complex `Scalar` mathematics and cut-aware refutation:** Reason
  over finite complex numbers, directed infinities, complex infinity, and
  indeterminate values. Derive exact generic guards with `transfer`, prove
  polynomial identities with `reify` and `identity`, and detect missing poles or
  branch-cut guards with `refute`.
- **Versioned binary libraries and theory interpretations:** Persist checked
  proofs in content-addressed format-2.2 libraries, exchange OpenTheory v6
  articles, and transport abstract theorems into concrete theories via `reuse`.

## Quick start

### Install with Pixi (`modular-community`)

Once the `modular-community` channel pull request merges, add `judgment` to any
[Pixi](https://pixi.sh/latest/installation/) project with the `max`,
`modular-community`, and `conda-forge` channels:

```toml
[workspace]
channels = ["https://conda.modular.com/max", "https://repo.prefix.dev/modular-community", "conda-forge"]
platforms = ["linux-64", "linux-aarch64", "osx-arm64"]
```

```sh
pixi add judgment mojo=1.2
```

The conda package ships the compiled shared library (`libjudgment_store`), the
Mojo package (`judgment.mojoc`, loaded automatically via `dlopen` with no linker
flags), the Python package (`import judgment`), and the `judgment-fetch-mathlib`
helper:

```sh
# Mojo (zero -I or linker flags)
pixi run mojo run my_proof.mojo

# Python (zero PYTHONPATH or env vars)
pixi run python my_proof.py

# Optional: download the 591 MiB verified Isabelle math library (judgment_mathlib)
pixi run judgment-fetch-mathlib
```

You can also download `judgment_mathlib` programmatically with the same API in
both languages: `judgment.fetch_mathlib()` (defaulting to `$JUDGMENT_MATHLIB` or
`~/.local/share/judgment_mathlib`).

### Build from source

To work from a source checkout, build the shared library once with Pixi:

```sh
git clone https://github.com/Spellbound-Mojo/judgment.git
cd judgment
pixi install --locked
pixi run build-core            # builds libjudgment.so / .dylib once
pixi run build-core-store      # optional: adds libjudgment_store.so / .dylib
```

Run the starter proof in either language:

```sh
# Mojo (loads the prebuilt core via dlopen in seconds)
pixi run core-run docs/examples/library/quick_start_goal.mojo

# Python (~30 ms startup, no compilation)
PYTHONPATH=bindings/python pixi run python docs/examples/python/library/quick_start_goal.py
```

Both print:

```text
⊢ P ∧ Q → Q ∧ P
```

### Minimal example

**Python:**

```python
from judgment import Session, implies

s = Session()
P, Q = s.prop("P"), s.prop("Q")

proof = s.theorem("swap", implies(P & Q, Q & P))
h = proof.intro("h")
proof.exact(proof.conjoin(proof.right(h), proof.left(h)))
theorem = proof.finish()
print(theorem)
```

**Mojo:**

```mojo
from judgment import Session, implies

def main() raises:
    var s = Session()
    var P = s.prop("P")
    var Q = s.prop("Q")

    var proof = s.theorem("swap", implies(P & Q, Q & P))
    var h = proof.intro("h")
    proof.exact(proof.conjoin(proof.right(h), proof.left(h)))
    var theorem = proof.finish()
    print(theorem)
```

## Documentation

Build and browse the full site locally with `pixi run -e docs docs-serve`, or
read the Markdown sources directly:

| Topic | Start here |
|---|---|
| Rationale for HOL and OpenTheory | [Why HOL?](docs/content/architecture/why-hol.md) |
| Setup for Mojo and Python | [Getting started](docs/content/guides/getting-started.md) · [Proofs from Python](docs/content/guides/python.md) · [Use in your project](docs/content/guides/your-project.md) |
| 38 hands-on Mojo + Python lessons | [Tutorials (Parts 1–5)](docs/content/tutorials/index.md) · [Verify Cantor's theorem in Isabelle/HOL](docs/content/tutorials/verify-in-isabelle.md) |
| Everyday lookup and full API | [Quick reference](docs/content/guides/quick-reference.md) · [Using the API](docs/content/guides/api.md) |
| Scalar algebra and binary libraries | [Scalar workflows](docs/content/guides/scalar-workflows.md) · [Proof libraries & OpenTheory](docs/content/store/guides/index.md) |
| Capabilities, limits, and trust boundary | [Capabilities and limits](docs/content/guides/status.md) · [The trusted base](docs/content/architecture/trusted-base.md) · [Troubleshooting](docs/content/guides/troubleshooting.md) |

## Repository packages

This repository contains the unified Mojo 1.2 workspace:

- `judgment`: public authoring entry point (thin prebuilt-core client and direct package).
- `judgment_core`: stateless HOL checking kernel.
- `termbank`: content-addressed proof-DAG storage (`termbank.dag`), budgets, and out-of-core spill.
- `judgment_shell`: proof authoring, tactics, rewriting, and calculations.
- `scalar`: extended-complex mathematical profile, symbolic proof helpers, and cut-aware numeric engine.
- `judgment_store`: optional versioned binary libraries, OpenTheory v6 interchange, and theory interpretations (`pixi run build-core-store` or `pixi run build-store`).
- `judgment_nat`: optional conservative Peano natural numbers, induction, and primitive recursion (`pixi run build-nat`, direct Mojo).
- `judgment_search`: optional deterministic concurrent tactic racing and parallel lemma checking (`pixi run build-search`, direct Mojo).

Runtime dependencies `apn_mojo` and `fp_mojo` are installed automatically by
Pixi from the `modular-community` channel at the versions pinned in `pixi.toml`.

## License

Apache-2.0 WITH LLVM-exception. See [LICENSE](LICENSE).
