elenctic
A testing and analysis library for answer set programs, with a thin CLI. Claims about a program
live in its own comments (@expect, @count, @answer-set, @cautious, @brave, @query,
@cost) and are checked under clingo or clingcon.
Elenctic, from Greek ἐλεγκτικός (ἔλεγχος, elenchos), "serving to refute by
cross-examination": the Socratic elenchus. A contract is a thesis about the program; FAIL is
its refutation, and UNDECIDED is aporia, an honest "cannot say" rather than a false "no".
Install
Requires Python 3.14+ and clingo 5.8. The optional theory extra pulls in clingcon 5.2 for
contracts that declare % @elenctic solver clingcon; the optional tui extra pulls in Textual 8
for the interactive view.
# pip
pip install elenctic
pip install 'elenctic[theory]'
pip install 'elenctic[tui]'
# uv — as a project dependency, or as a tool on PATH
uv add elenctic
uv add 'elenctic[theory]'
uv tool install elenctic
uv tool install 'elenctic[theory]'
# pixi — from conda-forge
pixi add elenctic
# pixi — from PyPI
pixi add --pypi elenctic
pixi add --pypi 'elenctic[theory]'
# conda / mamba (conda-forge)
conda install -c conda-forge elenctic
mamba install -c conda-forge elenctic
From source, straight from Git or from a clone:
pip install 'elenctic[theory] @ git+https://github.com/GregoryGelfond/elenctic'
git clone https://github.com/GregoryGelfond/elenctic && cd elenctic
pip install '.[theory]'
uv tool install '.[theory]'
pixi install -e theory # the locked environment
Container
No prebuilt image is published. The Containerfile is a local recipe: build it yourself with
Docker or Podman, then mount a directory of .lp files and run a check.
docker build -f Containerfile -t elenctic .
podman build -f Containerfile -t elenctic .
docker run --rm -v "$PWD":/work:ro elenctic drinks.lp
podman run --rm -v "$PWD":/work:ro elenctic drinks.lp
The image includes the theory extra (clingo and clingcon). The entrypoint is elenctic; pass
the same arguments you would on the host.
Quick start
Save this as drinks.lp:
% @expect sat
% @count 2
% @brave { tea, coffee }
% @cautious { biscuit }
% @query unknown { tea }
{ tea; coffee } = 1.
biscuit.
#show tea/0.
#show coffee/0.
#show biscuit/0.
$ elenctic drinks.lp
1/1 passed
Change @count 2 to @count 3 and run again:
$ elenctic drinks.lp
drinks.lp — FAIL
[FAIL] @count 3 (line 2): 3 expected, 2 distinct shown answer sets
0/1 passed, 1 fail
elenctic PATH… is elenctic test PATH…. From Python the same check is silent and returns a
value:
from elenctic import Limits, Program, check
report = check(Program.read("drinks.lp"), limits=Limits(max_seconds=10))
ask answers a query of a program, naming the answer sets that show its answer; why adds a
derivation in each:
$ elenctic ask drinks.lp tea --format text
ask: { tea }
--> drinks.lp
|
= answer: unknown
= true in answer set 1: { biscuit, tea }
= neither tea nor -tea in answer set 2: { biscuit, coffee }
|
= help: `elenctic why drinks.lp tea --answer-set 1` shows why
Usage
elenctic [test] PATH… |
check programs against their contracts (reference) |
elenctic explain PATH… |
test, and why each failed claim fails (evidence) |
elenctic ask PATH QUERY |
answer a query, yes, no or unknown, and name the answer sets that show it (command line) |
elenctic why PATH QUERY |
ask, with a derivation in each answer set it names; with --answer-set K, why a literal holds or fails in one (evidence) |
--mode default|cautious|brave |
how ask and why answer: three-valued, true in every answer set, or in some (semantics) |
--format text|json|tui |
text, JSON, or the interactive view, the default of explain, why and ask on a terminal with the tui extra (output, interactive view) |
--with FILE |
load a library, such as a base encoding, with every case (command line) |
--short |
one line per diagnostic (diagnostics) |
Exit 0 / 1 / 2 / 3 |
claims hold, claim unmet, fault, internal error (exit codes) |
Claims, ask and why with real command output:
docs/reference/examples.md.
Tutorial: docs/tutorial/first-contract.md.
Full map: docs/index.md.
Develop
pixi install -e theory
pixi run -e theory check # format, lint, strict types, import contracts, tests
pixi run -e py314 test # or -e py315
pixi run -e theory check is the one gate; ./check.sh runs it. uv.lock is tracked so
uv sync --locked reproduces the same dependencies.
License
Licensed under the MIT license. Changes are in the changelog.
Metadata
Release files for elenctic 1.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| elenctic-1.1.0.tar.gz | 469.7 kB | With provenance | Details for elenctic-1.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| elenctic-1.1.0-py3-none-any.whl | Python 3 | none | any | Details for elenctic-1.1.0-py3-none-any.whl |
Total release size: 656.6 kB
Release files / elenctic-1.1.0.tar.gz
| Download URL | elenctic-1.1.0.tar.gz |
|---|---|
| Size | 469.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1b371a930550af98ac7592365d21fcaa3916ddfdf2913ea372d4fd7d4f2f4e3d
|
|
BLAKE2b-256 checksum How to use checksums |
756f36a7d1f6e5599ce20c54a3cdc16733df3d48f8ed396bf5b322249445b087
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.
Transparency logRelease files / elenctic-1.1.0-py3-none-any.whl
| Download URL | elenctic-1.1.0-py3-none-any.whl |
|---|---|
| Size | 186.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
67d4183caf90a9b25d2f6fc962517a6034c5809b90687694afd4db667d84d7a5
|
|
BLAKE2b-256 checksum How to use checksums |
27a350a0556e4bf66b627aab07865eb9077ff1baffa68adc4e6e0ee62a092ff6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.
Transparency logSecurity for elenctic 1.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for elenctic-1.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.