GitHub - kbr-/elenxis: Proof-backed adversarial specification engineering for humans and AI agents. Challenge contracts, establish realizability, expose ambiguities, and preserve approved intent.

GitHub

11 min read Original article ↗

Elenxis: The proof checks. Does
the spec?

The proof checks. Does the spec?

Elenxis is a proof-backed framework for adversarial specification review, before implementation. It helps engineers and AI agents find out whether the rules they wrote describe the behavior a person actually wants.

Suppose a sorting routine deletes its entire input and returns an empty list. You can prove its output is always sorted. You can ship a verified routine that loses every record. The missing requirement is that sorting must preserve the input elements, including duplicates.

A specification defines which behaviors are allowed. A weak sorting contract admits data loss. Adding a ten-element limit goes too far and excludes valid results. Contradictory rules can leave no possible result at all. Elenxis lets you challenge those boundaries directly. When two readings of a requirement disagree, Lean can check an example that separates them and the owner can decide which behavior to keep.

What can I ask about a specification?

Review Question How Elenxis answers
Requirements coverage Did a clause disappear on the way to a contract? A local draft check compares the draft to the supplied inventory. Model-assisted review can flag omissions from the prose.
Semantic gaps Does this statement say what the requirement says? A configured model proposes missing, weaker, undecided or extra behavior. Findings retain the clause ID for review.
Non-vacuity Can the theorem's premises hold together? Checks supplied inhabitation or emptiness certificates at the specified quantifier scope.
Relational realizability Does every admissible input have an admissible output? Checks a totality proof or its refutation. A named input can witness failure.
Collective consistency Can these requirements share an output on the same input? Checks certificates for the exact group of relations and the requested scope.
Adversarial mutation Which deliberately broken behaviors slip through? Applies selected mutation operators or accepts a supplied model. Checks named certificates for satisfaction, rejection or a changed constraint.
Discrimination Do these two readings actually differ? Checks a supplied comparison theorem or distinguishing witness. Bounded searches report their domain.
Owner-facing witnesses What concrete choice changes the outcome? Reports the scenario, the competing outcomes and the reviewer's question alongside the formal evidence.
Formal evidence auditing What was proved, and on which assumptions? Inspects named Lean declarations, their propositions and axiom dependencies.
Evidence provenance Do these findings still apply here? Groups reports by project and snapshot, validates requirement links where available and compares fingerprints on replay.
Signed owner approval Did the authorized owner accept this specification? Verifies an OpenSSH signature against the configured signer policy and compares the signed snapshot with the current packet.
Contract conformance Does today's contract still say what was approved? Compares the current elaborated contract with its bound, reviewed baseline and reports the comparison separately.

Quickstart

Start with Git, a native C compiler and the Lean toolchain manager elan on your path. The checkout pins Lean 4.36.0 and uses its bundled Lake build tool. The first example runs locally without an LLM, account or API key. Official Lean installation guide

git clone https://github.com/kbr-/elenxis.git
cd elenxis
lake build
lake env lean examples/sorting/Countermodels.lean

Look for this scenario in the output:

Input [2, 1, 2] produces output []. The empty output is ordered and discards the input.

The fixture checks that the same input/output pair satisfies sortedness and violates the stronger sorted-permutation rule. It also checks a mistake in the other direction: adding a ten-element limit rejects a perfectly valid eleven-element result. One command exercises both ways of getting a contract wrong. Executable sorting example

Review one requirement of your own

  1. Start with the age-limit ledger. Its minors row quotes “A loan is refused to an applicant under 18,” links the source clause and names the theorem and its premise witness. The theorem uses 16. Run lake env lean examples/age-limit/Wrong.lean and compare the printed proposition with the quote. A successful proof leaves this discrepancy visible. Corrected version
  2. Copy that driver into your Elenxis checkout. Replace the example namespace, decision, theorem, witness, quoted clause and source path with your own. Pass your rows and namespace to SpecTools.Audit.run with emitEvidence := true. Run the file with Lake as above. Read the statement, dependencies and issues in the emitted elenxis.audit.v1 object. For a standalone contract you can edit without a ledger, try the minimal relation review.
  3. To add a second reader, point SPEC_TOOLS_BACKEND at a backend configuration and run the same driver. Its Gaps.runConfigured call sends the source prose and ledger statements for review. Choose Claude Code, Codex or a trusted command adapter according to where those inputs may go. A coding agent can consume the structured reports and submit a proposed counterexample for Lean to check. Backend configuration · Ledger format

Four reviews you can reproduce

1. A proof that lets a broken sorter pass. The quickstart distinguishes two contracts on one input. The mutation review also checks the behavioral model itself: empty-sorted proves that returning an empty list meets sortedness for every list. In empty-length, the input [0] refutes length preservation. Checking that model only on the empty input would miss the defect. Run lake env lean fixtures/MutationReview.lean. Mutation certificates

Candidate Claim checked Result
empty-sorted satisfies established
empty-length refutes established
empty-length satisfies, using evidence about the empty input alone inconclusive

2. Three contracts, no possible output. A permits {0, 1}, B permits {1, 2}, and C permits {2, 0}. Outputs 1, 2 and 0 witness compatibility of A/B, B/C and A/C respectively. For the same admissible input, no output satisfies all three. Run lake env lean fixtures/RelationReview.lean: the group's totality claim has status refuted. The fixture checks the negative certificate for the triple and rejects a pairwise certificate offered for the triple. These fields from the emitted report show exactly which claim failed:

{"requirements":["A","B","C"],"proposition":"total allowed (together (together ab bc) ca)","status":"refuted"}

An implementer can take that contradiction back to the requirements owner before writing any code. Relation audit

3. Two readings, one question for the salon owner. In a fictional booking call, Mae says “Two no-shows and we don't take another booking for a kids' cut.” Later she reads a note setting the online cutoff at four. A language model can flag the discrepancy. The supplied proofs show that the four-miss rule allows every booking the two-miss rule allows, and that exactly two misses separates them. Run lake env lean examples/owners/salon-call/Interpretations.lean. The owner gets a question she can answer: After two missed appointments, can a parent still book a child's haircut online? Original dialogue · Formal comparison

4. A signed decision survives a bad edit. In the signed salon example, the owner chooses two misses. The receipt covers the prose, coverage draft and elaborated baseline. Suppose an agent now changes the current contract from “fewer than two” to “at most two” and updates a proof to match. The signature still verifies, the approved snapshot is current, and contract conformance is failed. The overall owner check reports partial. Change the reviewed prose instead, keeping the revision label, and the old decision is stale. Run the signing walkthrough with OpenSSH and jq. The regression suite exercises both edits using a temporary signing key.

Attribution gets its own check. Even in the same snapshot, a valid mutation certificate tagged with another requirement ID is routed to associationIssues. Reports from different identified snapshots are displayed in separate groups. This lets an agent retain historical evidence while showing the owner precisely what needs another look. Signing regressions · Requirement views

Working with a coding agent

Paste this prompt into Codex, Claude Code or another coding agent in the checkout. Replace the bracketed path with your requirements file.

Review [requirements file] with Elenxis before implementation. Read the Quickstart and
docs/reference.md. Preserve the original clauses and give each a stable ledger ID. Draft
the corresponding Lean contracts and list anything that needs an external check.

Try to break the draft. Check whether the premises can hold together, whether every admissible
input has an output, and whether the whole group can share one. Challenge weak contracts with a
bad model and strong ones with an excluded example. For competing readings, look for an input
that gives different outcomes. Record the exact proposition and run its Lean check.

Deliver the ledger, review drivers, commands, and emitted reports. For each requirement record
the witness or certificate, assumptions, provenance and open obligations. Keep model suggestions
separate from checked claims. At a material choice the text leaves open, give the owner the
original clause, a concrete scenario, and both outcomes. Stop that decision there and continue
independent checks. Leave approval pending until the owner decides and signs. Replay the signed
packet against current contracts before handing it on. Leave implementation to the next stage.
Stage Responsibility What the next person or tool receives
Capture intent A human supplies clauses. An agent can propose ledger rows, formalizations and proof obligations. A draft mapping each clause to a contract or an external check.
Challenge the draft Reviewers and LLMs propose gaps, mutants and competing interpretations. An explicit claim to test, such as “the four-miss reading admits an extra booking.”
Check the claim Lean checks formal statements and certificates. Elenxis records their scope, requirements, assumptions and provenance. A checkable result, a distinguishing input, or an unresolved obligation.
Decide and approve The owner answers the behavioral question and signs the chosen specification. An approved baseline against which subsequent contract edits can be checked.
Implement External development tools build against that baseline. Implementation work proceeds with the review evidence available for replay.

A standalone LLM review can notice the two cutoffs. Elenxis adds a checked witness and a path back to the clauses. Conventional formal verification establishes that a program meets its stated contract. Elenxis also asks which other behaviors that contract permits. Implementation mutation testing changes a program to see whether its tests catch the edit. Here the reviewer can weaken a contract or supply a deliberately broken model to see whether the specification excludes it.

Reading a result

  • A proof has a scope. Inspect the actual proposition, quantifiers and axiom dependencies. Totality establishes existence of an output for each admissible input. Producing executable code remains a separate task. Missing proof leaves an obligation unresolved.
  • A requirement link has a source. A validated association checks the ID and declaration against the ledger or manifest. A reviewer still has to judge fidelity to the prose. Zero reported gaps leaves semantic completeness open.
  • Freshness depends on replay. Structural fingerprints detect changes in trusted inputs, declarations and review configuration. They provide no cryptographic authentication. Repeating a model request can yield a different judgment. A saved owner check is historical until reverified against the current packet.
  • Approval has a scope too. Signature authenticity, snapshot freshness and contract conformance are separate observations. The requirement view exposes outstanding semantic questions independently of approval. Evidence fields and trust assumptions

Experimental results

In a historical synthetic comparison, Opus reading the files alone located 60 of 60 planted gaps with zero false alarms. Offering it the tools yielded 60 of 60 with six false alarms and higher time and token use. The scorer credited matching locations, even when the explanation was wrong. These results support inspecting the evidence behind each finding. They establish no detection advantage over the standalone model. Full tables, costs and scoring limits · Salon benchmark and replay instructions

Documentation and contributions

  • Reference — ledger format, audit scopes, mutation operators, certificates and report schemas.
  • Worked examples — age-limit and sorting transcripts, model configuration and historical measurements.
  • Backends — connect an agent or model and understand where review inputs go.
  • Run lake exe spec-tools --help for command names and arguments. If Lean cannot find SpecTools, run lake build from the directory containing lakefile.toml, then retry with lake env lean. If a mutation is inconclusive, inspect its obligation and reason before changing the specification.
  • To report a problem, include the requirement, expected behavior, command and observed output in a GitHub issue. For changes, include a small fixture that distinguishes the old behavior from the proposed one and run lake test.

Inspiration

The problem this repository works on is the one Formal Vibefication (Keagan McClelland, 12 May 2026) names as still missing once AI writes the code: machine-assisted specification, a model that can "help a human author a faithful formal specification — proposing properties, surfacing implicit assumptions, flagging where the spec under-determines the system". The article is an inspiration only; its author has not reviewed or endorsed this project.

License

Elenxis is licensed under the Apache License, Version 2.0.

Commercial use, modification, redistribution, and proprietary integrations are welcome under the terms of the license.

See NOTICE for attribution information and TRADEMARKS.md for the Elenxis trademark policy.