Skip to content

About

Agda Native AI Reasoning environment is a research project for building the interaction, retrieval, and evaluation infrastructure that allows modern AI agents to work effectively with Agda.

Resources

Contributing

Stars

1 star

Watchers

0 watching

Forks

Latest commit

Β 

History

1,113 Commits

Folders and files

Repository files navigation

Agda-native AIR

CI License: Apache 2.0 Docs: CC-BY 4.0 Agda Haskell Scala

Agda-native Artificial Intelligence Reasoning environment

agda-native-air is a research project for building the interaction, retrieval, and evaluation infrastructure that allows modern AI agents to interact effectively with Agda, to prove theorems and do general formal verification work.

The project is organized around four core components.

  1. Interaction: programmatic access to Agda proof states and hole filling;
  2. Bridge: an MCP-based interface for AI agents;
  3. Retrieval: structured corpus extraction and search over Agda libraries;
  4. Evaluation: deterministic fixtures, logs, and reproducible proof-completion reports.

Agda remains the final arbiter of correctness.


Why this project exists

AI-assisted theorem proving is advancing rapidly, but most recent infrastructure and benchmarks are concentrated in the Lean ecosystem.

Agda deserves its own serious path into AI-assisted formal reasoning.

This repository focuses on building that path:

  • AgdaDojang: programmatic interaction with Agda;
  • agda-mcp: MCP bridge for frontier coding agents;
  • agda-strux: structured extraction for retrieval- and analysis-friendly Agda corpus data;
  • deterministic evaluation: reproducible proof-completion and benchmarking workflows.

The long-term vision is ambitious: AI systems that help with proof development, library growth, counterexample discovery, and mathematical exploration. But the near-term goal is sharper and more practical: a credible, publishable Agda-native reasoning environment.


Repository layout

agda-native-air/
β”œβ”€β”€ README.md
β”œβ”€β”€ LICENSE, LICENSE-docs, CONTRIBUTING.md
β”œβ”€β”€ .github/                   # CI workflow, CODEOWNERS, issue and PR templates
β”œβ”€β”€ flake.nix, flake.lock      # the pinned toolchain: Agda 2.9.0, stdlib 2.3, GHC, Scala, Spark, Python
β”œβ”€β”€ Makefile                   # the single CLI for extract β†’ transform β†’ ETL β†’ train β†’ eval
β”œβ”€β”€ agda-dojang/               # repo-local Agda library (reflection macros) + evaluation harness
β”œβ”€β”€ agda-mcp/                  # the MCP server (Haskell)
β”œβ”€β”€ agda-strux/                # structured extraction: Agda-as-a-library β†’ JSONL (Haskell)
β”œβ”€β”€ strux-driver/              # Scala driver: runs the extractor, hosts the benchmark runner and the proof search
β”œβ”€β”€ ml-pipeline/               # Spark ETL (Scala) and training / retrieval / evaluation (Python)
β”œβ”€β”€ configs/                   # pipeline configuration: the agda-algebras extraction config, logging
β”œβ”€β”€ data/
β”‚   └── benchmarks/            # the proof-obligation benchmark: fixtures, golds, index
β”œβ”€β”€ docs/
β”‚   β”œβ”€β”€ README.md              # index of the documentation, with a reading order
β”‚   β”œβ”€β”€ adr/                   # architecture decision records (0001 proof search, 0002 agda-mcp)
β”‚   β”œβ”€β”€ agda-mcp/              # the server's design notes
β”‚   β”œβ”€β”€ proof-search/          # how the search works and how to read a run
β”‚   β”œβ”€β”€ benchmarks/            # the difficulty taxonomy
β”‚   β”œβ”€β”€ corpora/               # one dataset card per published corpus
β”‚   β”œβ”€β”€ feedback/              # documents imported from consumer projects
β”‚   β”œβ”€β”€ field-reports/         # the server in real use, one report per session
β”‚   β”œβ”€β”€ notes/                 # working notes and background reading
β”‚   └── mcp-field-reports.md   # the reports through 2026-10-11, one section each (frozen)
β”œβ”€β”€ experiments/               # archived exploratory work (read-only)
β”œβ”€β”€ reports/                   # archived agent transcripts
└── scripts/                   # launchers and Python utilities

Main components

  • agda-mcp/: the bridge. A Haskell MCP server that exposes Agda's proof state, type-checking verdicts, live scope and type queries, and corpus search to any MCP client. Its design record is docs/adr/0002-agda-mcp.md.
  • agda-dojang/: the interaction layer. A repo-local Agda library whose reflection macros report goals and contexts, plus the proof-completion evaluation harness.
  • agda-strux/: the extractor. A Haskell backend linking Agda as a library; its agda-json executable turns a checked module into canonical JSONL, one row per definition.
  • strux-driver/: the Scala driver. It runs the extractor over a library, validates and transforms the JSONL, hosts the benchmark runner, and hosts the proof search (struxdriver.search), a client of agda-mcp like any agent.
  • ml-pipeline/: the ETL and modelling layer. A Spark job turns JSONL into Parquet features; the Python side holds training, retrieval, and evaluation code.
  • data/benchmarks/: the benchmark suite. Paired obligation and gold modules, a machine-readable index, and the difficulty classification of every row.
  • docs/: design records, notes, dataset cards, and the evidence record; docs/README.md is the map.

Current status

As of October 2026 the following are built, measured, and in use.

  • agda-mcp v0.3.0, unreleased; the latest release is v0.2.0. Thirteen tools over stdio: four proof-state tools (get_goal, fill_hole, check_file, get_diagnostics), a whole-project gate (check_project), five live queries answered by a persistent interaction lane (type_of, normalize, resolve_name, definition_of, exports_of), and three corpus-backed tools (search_by_name, whose inScopeAt keeps the names a file can write and says how, search_by_type, get_dependencies), which the server registers only when it is started with a corpus; a fourteenth, search_in_scope, is presented when --expose names it; and, with --auto, a fifteenth, auto, Agda's own proof search at a hole (issue #205), whose answer is a candidate term for fill_hole to judge. Every verdict on a file is the exit code of the agda run that produced it, check_project reports the exit code of the project's own gate without misreporting it, every response about a file names the tree it checked, and a server pointed at the wrong checkout refuses rather than guesses. The tool contracts are in agda-mcp/README.md; the design decisions and the evidence behind them are ADR 0002; connecting an agent, to this repository or to another Agda project, is docs/HowToRun.md Β§ 13. The server is in use from Claude Code sessions on two external Agda projects, ualib/agda-algebras and the Cardano formal ledger specification, IntersectMBO/formal-ledger-specifications; what those sessions did with it, and where it fell short, is recorded session by session, one file each, in docs/field-reports/ (the reports through 2026-10-11 are sections of docs/mcp-field-reports.md).
  • Two corpora, extracted by agda-strux from pinned library commits and described by dataset cards under docs/corpora/: the Agda standard library 2.3 (55,576 definitions from 1,153 modules; card, reproducible from the flake in minutes) and agda-algebras (13,123 definitions from 409 modules; card, published as the agda-algebras-corpus-v0.1 release).
  • A benchmark of 81 proof obligations with gold solutions: 22 from the standard library, 21 mined from agda-algebras at the corpus commit, 12 standard-library obligations whose proofs need a lemma the fixture imports but never names (the haystack tier), 14 posed in group theory and universal algebra with no proof on disk (the hard tier), and 12 mined from agda-algebras' types whose proofs string two to four library lemmas together (the composition tier). Every row is classified into one of three difficulty tiers. Every gold type-checks under the pinned toolchain, and CI re-verifies a slice whenever the benchmark, the Scala driver, or the flake changes. See data/benchmarks/README.md and docs/benchmarks/taxonomy.md.
  • Proof search on agda-mcp. A beam search in strux-driver proposes terms for the open hole, by rule or by retrieval over a corpus, and lets Agda judge every step. The measured record: the fixed action space solves 8 of the 43 obligations of the first two library tiers and none of the 12 haystack rows, 8 of 55 in all; its 6 of 22 on the standard-library tier is exactly that tier's term-mode ceiling (the other sixteen golds restructure the clause: thirteen inductions, two case splits, and one reasoning chain whose imports the obligation does not carry, none of which a term can express). Retrieval adds no solve under target exclusion on those two tiers, while the labeled controls with exclusion off commit all five excluded standard-library lemmas and one wholesale agda-algebras lemma end to end, so the machinery works; on the agda-algebras tier the ledgers locate the binding constraint in ranking at scale. On the haystack tier, built so that retrieval has a needle to find, retrieval solves 6 of 12 against the fixed space's 0 of 12, the first solves under exclusion. A stronger scorer is in review (#152); the tracking issue, #113, carries the current numbers. How the search works is docs/proof-search/overview.md; its decisions and numbers are ADR 0001.
  • An agent in the loop, measured (#154): a frontier model driving the server over the 55 library obligations, one fresh session per obligation with the server's tools and the one file, judged by the gold verifier's own agda invocation. On fixtures whose headers carry no hints (#219), Sonnet 5 solves 44 of 55 and Opus 5 solves 55 of 55 with the server; with a shell holding the same agda and no server, Sonnet 5 solves 47 and restates 4, and given both it takes every verdict from check_file and never runs agda itself (#162). Neither count is construction: the shell arm could read the library, and had the original's proof in view for 12 of its 14 agda-algebras solves (#188). Every earlier run had the headers' hints in view, a sketch of each proof and, on one tier, the lemma the proof needs; with them the three counts were 46, 54, and 50, and that tier was solved mostly without a query. The tools' descriptions had been cut by the client at 2,048 characters in every earlier arm; trimmed to their contracts (#191), a server arm's per-turn context fell by a third and its cost by 17 to 19 %, with the same tool mix within the run-to-run spread. On the hard tier, where there is nothing to copy, Opus 5 proves all 14 rows with the server, with a shell, and with both, with the headers' proof sketches and without them (#189), and on the composition tier every final file of Opus 5 and of Sonnet 5 type-checks in all three configurations, the lemmas found through the tools or the sources rather than remembered (#160); so both tiers measure the models' ceiling rather than the tools. The search's 8 and 14 are a different instrument, not a baseline for the agents; which instrument produced every number in this section, and how to tell a win from a loss, is docs/reading-the-results.md. A file that names the library's own lemma for the statement is reported restated, never solved (8 rows for Sonnet, 1 for Opus, all on the agda-algebras tier), and the standard-library rows, which every model has memorized, are read as memory rather than search. The harness is make agent-bench; the transcripts and verdicts of every quoted run are archived under reports/agent-bench/, and the record is ADR 0001 Β§ 9.
  • The extraction and evaluation pipeline, end to end: agda-strux β†’ strux-driver β†’ the Spark ETL and Python layers, with a proof-completion evaluator whose reports share one schema with the search's, so a model's result and a search's result sit in the same table.

What comes next, in the order the evidence argues for:

  • Ranking at scale (#19): the agda-algebras ledgers and the haystack nulls locate the binding constraint in ranking thousands of in-scope lemmas; a learned premise-selection scorer slots into the seam the search already exposes.
  • The field stream (Milestone 5): the ergonomics the field reports keep asking for, such as batch verdicts, a library registry that survives worktree churn, and a profiling tool. The first of them to land is fill_hole's apply and returned patch (#136).
  • Local specialist models (Milestones 2 and 4): not started. When they arrive they attach to agda-mcp as extra tools, so the interface an agent sees does not change.

For the plan and the record behind this section, see


Quick start

See docs/HowToRun.md for the full setup.

Typical development flow is as follows (exact commands provided below):

  1. clone the repo;
  2. enter the Nix development shell;
  3. run tests;
  4. run the fixture demo;
  5. explore extraction / evaluation workflows.

Example high-level commands.

git clone git@github.com:formalverification/agda-native-air.git
cd agda-native-air
nix develop
make test
make eval-proof-completion-smoke
make help    # see what's available and working now

The toolchain is Agda 2.9.0, not yet released (agda/agda at the nightly of 2026-10-05), with standard-library 2.3 patched to type-check under it, both pinned by the flake. Until Agda 2.9.0 and a standard library for it are released, the toolchain is available only through nix develop, which needs Nix 2.28 or later and fetches it prebuilt from the formalverification Cachix cache.

The project site (the pages at formalverification.github.io/agda-native-air, including the demo) is built and served locally with its own shell and three targets; docs/HowToRun.md Β§ 16 has the details and the fallback for a machine without Nix.

nix develop .#site      # mkdocs + the pinned Material theme; no Agda
make site               # demo, then the site around it -> public/
make site-serve         # http://127.0.0.1:8000/agda-native-air/ with live reload
make site-check         # nothing fetched off-origin, every link resolves

Project scope

This project is not

  • a mere autocomplete plugin;
  • training local models to compete with frontier models at open-ended reasoning;
  • a finished product.

This project is

  • an Agda-native reasoning environment;
  • a research platform;
  • a place to experiment seriously with AI-assisted proof development in Agda.

Collaboration

We welcome contributors interested in

  • Agda tooling;
  • proof assistant infrastructure;
  • corpus extraction and representation;
  • retrieval and local specialist models;
  • evaluation and benchmarking;
  • constructive, algebraic, category theoretic mathematics, general type theory and/or HoTT.

If you want to join us, please start by reading CONTRIBUTING.md.


Licensing

Three kinds of thing live here and they are licensed differently.

  • Code β€” Apache License 2.0. Everything under agda-strux/, agda-mcp/, strux-driver/, ml-pipeline/, agda-dojang/, and scripts/. It permits commercial use, redistribution, and use in training or evaluating machine-learning models, asking only that you keep the notices, include the license, and say what you changed.
  • Documentation written here β€” CC-BY-4.0. This covers docs/ except for material imported from elsewhere, which this project has no standing to license. There is one such file today: docs/feedback/flrp-agda-mcp-improvements.md, imported verbatim from ualib/agda-algebras and licensed by that project; its own header records the provenance.
  • Data β€” Apache License 2.0 by default, and per dataset where a dataset says otherwise. See below, because the default is not arbitrary.

Why data defaults to the code license

Everything committed under data/ is one of two things, and both land on Apache-2.0 by different routes.

  • Agda source written here. The benchmark obligations and gold solutions under data/benchmarks/ are Agda modules; they are code, and the code license covers them.
  • Material extracted from an Apache-2.0 library. A corpus, or a golden snapshot such as data/agda/agda-algebras-regressions/Noether.jsonl, consists of another library's types and proof terms rendered differently. That makes it a derivative work of that library, and this project cannot relicense it.

So the default is Apache-2.0, and it is not a claim that this project owns the contents β€” for extracted material it is the upstream license passing through, and the required attribution is upstream's.

Two refinements sit on top of the default.

  • A published corpus states its own terms in its dataset card under docs/corpora/, together with the upstream commit and the citation. The card governs; the default applies to committed data that has no card.
  • Artifacts derived from a corpus inherit that corpus's terms. The statistics, indices, and digests computed from a corpus are computed from its rows, so they travel with it. Only a dataset with no upstream-derived content at all can be dedicated to the public domain under CC0-1.0, and where that is done its card says so.

What this changed, and for whom

Before this policy, LICENSE-docs stated that data/ was CC-BY-4.0. That claim is withdrawn, because it was not this project's to make for extracted material. Two consequences worth stating plainly rather than leaving to be inferred:

  • For extracted data the CC-BY claim was never effective; the upstream license always governed, and now the files say so.
  • For any project-authored data the terms do change, from CC-BY-4.0 to Apache-2.0. A licence already granted cannot be withdrawn: anyone who received data from this repository under CC-BY-4.0 may continue to rely on that grant for the copy they received.

If you are assembling training data

Read the card for the corpus you want β€” it names the upstream commit, the governing license, and the citation. For the corpora published so far that license is Apache-2.0, which does not obstruct training, evaluation, or redistribution. A corpus inherited from a library with different terms would say so in its card, so check there rather than assuming this section covers every future case.

If a license here is in your way, please open an issue saying which one and why. That would be a bug in how we have set this up, not a position we are defending.


Citation

DOI

Cite the repository by its name, its version and the version's DOI. CITATION.cff at the root holds the same metadata in machine-readable form, which GitHub's "Cite this repository" button and tools such as cffconvert read.

  • The repository as a whole, the environment with its tools and its data:

    @software{agda-native-air,
      author  = {DeMeo, William},
      title   = {Agda-native {AIR}: an {A}gda-native artificial
                 intelligence reasoning environment},
      version = {0.2.0},
      year    = {2026},
      doi     = {10.5281/zenodo.23378575},
      url     = {https://github.com/formalverification/agda-native-air},
      license = {Apache-2.0},
      note    = {Includes the agda-mcp server, version 0.2.0}
    }
    

    A bibliography style without an @software entry type (plain, amsplain) takes the same fields in an @misc entry, with the version and the URL in note.

  • A component, such as the agda-mcp server: cite the repository and name the component and its version in the text, for instance "the agda-mcp server, version 0.2.0, of Agda-native AIR"; each component's version is in its own package file (agda-mcp/agda-mcp.cabal, agda-strux/agda-json.cabal).

  • A published corpus: its dataset card under docs/corpora/ gives the citation, the upstream commit and the license; cite the card's citation, not this one.

Releases are tagged vX.Y.Z on this repository and archived on Zenodo, which mints a version DOI for each release and one concept DOI for all of them. The version DOI of v0.2.0 is https://doi.org/10.5281/zenodo.23378575, and the concept DOI, which resolves to the latest release, is https://doi.org/10.5281/zenodo.23378574. Cite the version DOI of the release you used. Each release's notes, the record of what it contains and why it was cut where it was, live under docs/releases/, one file per tag. A paper describing the environment is in preparation; until it appears, cite the software as above. The people who did the work are the authors; the AI coding agents that assisted are named in commit messages and in the field reports under docs/field-reports/, and are not authors.


A note on history

This public repository is a curated continuation of prior private development. See docs/public-history.md for migration notes.

About

Agda Native AI Reasoning environment is a research project for building the interaction, retrieval, and evaluation infrastructure that allows modern AI agents to work effectively with Agda.

Resources

Contributing

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages