Skip to content
coqgym logo

CoqGym

coqgym

Machine learning environment for automated theorem proving with Coq.

plurigrid/asi0installs67stars

SKILL.md

Full skill instructions

CoqGym

Machine learning environment for automated theorem proving with Coq.

Overview

CoqGym is a learning environment for theorem proving with the Coq proof assistant. It provides:

  • 71K human-written proofs from 123 Coq projects
  • ASTactic - neural theorem prover using proof state ASTs
  • CoqHammer integration for automated reasoning
  • Benchmark for evaluating ML-based provers

Paper: arXiv:1905.09381

Installation

# Clone repository
git clone https://github.com/​princeton-vl/​CoqGym
cd CoqGym

# Install dependencies
pip install -r requirements.txt

# Install Coq 8.9.1
opam switch create coq891 4.07.1
opam install coq.8.9.1

# Build CoqGym
python setup.py build

Dataset Structure

CoqGym/
├── coq_projects/     # 123 Coq projects
├── data/             # Extracted proof data
│   ├── *.json        # Proof states and tactics
│   └── sexp_cache/   # S-expression cache
├── ASTactic/         # Neural prover
└── coqhammer/        # Hammer integration

Proof State Representation

Each proof state contains:

  • Goals: Current proof obligations
  • Local context: Hypotheses in scope
  • Global context: Available lemmas/​definitions
  • Tactic history: Previous tactics applied
{
    "goals": [...],
    "local_context": [...],
    "tactic": "intros n.",
    "proof_tree": {...}
}

ASTactic Model

Neural network that predicts tactics from proof state ASTs:

from astactic import ASTactic

model = ASTactic.load("models/​astactic.pt")
tactic = model.predict(proof_state)

Architecture:

  • TreeLSTM encoder for AST structure
  • Attention over local/​global context
  • Tactic decoder with copy mechanism

Training

# Extract proofs
python extract_proofs.py --project mathcomp

# Train ASTactic
python train.py \
    --data data/​train.json \
    --model astactic \
    --epochs 100

Evaluation

# Evaluate on test set
python evaluate.py \
    --model models/​astactic.pt \
    --data data/​test.json \
    --timeout 600

Metrics:

  • Proof success rate: % of theorems proved
  • Tactic accuracy: Top-k tactic prediction
  • Proof length: Steps vs human proofs

CoqHammer Integration

Combines ML predictions with automated reasoning:

(* In Coq *)
Require Import Hammer.

Lemma example : forall n, n + 0 = n.
Proof.
  hammer.  (* Calls external ATPs *)
Qed.

Integration with Gay.jl Verification

Use CoqGym to learn proof strategies for Gay.jl properties:

  1. Extract proofs from similar PRNG verification projects
  2. Train on SplitMix64-style proofs
  3. Apply learned tactics to new Gay.jl lemmas
# Find similar proofs
similar = coqgym.search(
    query="deterministic hash function",
    projects=["compcert", "flocq"]
)

GF(3) Trit

RoleTritDescription
Learner-1Extract patterns from proofs
Predictor0Tactic prediction (ergodic)
Prover+1Generate complete proofs

Key Papers

Resources

Related Skills

  • coq-of-rust - Rust to Coq translation
  • narya-proofs - Higher observational type theory
  • proofgeneral-narya - Proof assistant integration
  • forward-forward-learning - Local learning without backprop

Autopoietic Marginalia

The interaction IS the skill improving itself.

Every use of this skill is an opportunity for worlding:

  • MEMORY (-1): Record what was learned
  • REMEMBERING (0): Connect patterns to other skills
  • WORLDING (+1): Evolve the skill based on use

Add Interaction Exemplars here as the skill is used.

More skills from plurigrid

cargo logo
plurigrid/asi

cargo

Rust package manager (36 subcommands).

67 0
View

Translate Figma nodes into production-ready code with 1:1 visual fidelity using the Figma MCP workflow (design context, screenshots, assets, and project-convention translation). Trigger when the user provides Figma URLs or node IDs, or asks to implement designs or components that must match Figma...

67 0
View

**Status**: 🌳 Production Ready (upstream in StringZilla v3+) **Type**: High-Performance String Operations / SIMD-Accelerated Text Processing **Principle**: Zero-copy views, SIMD/SWAR acceleration, deterministic hashing **Frame**: Cross-language interoperability (C, C++, Python, Rust, Go, Swift, ...

67 0
View
conformal-ga logo
plurigrid/asi

conformal-ga

Conformal Geometric Algebra (CGA) for circles, spheres, and Möbius transformations

67 0
View

Verifies code implements exactly what documentation specifies for blockchain audits. Use when comparing code against whitepapers, finding gaps between specs and implementation, or performing compliance checks for protocol implementations.

67 0
View
zig-systems logo
plurigrid/asi

zig-systems

Systems programming and performance optimization using Zig. Provides low-level abstractions, memory-safe compiled code, and performance benchmarking. Use for system-level operations, optimization, and interoperability with C/POSIX APIs.

67 0
View
paypal-mcp logo
plurigrid/asi

paypal-mcp

PayPal MCP server integration for invoices, payments, subscriptions, disputes, and transaction reporting via @paypal/mcp.

67 0
View
unison logo
plurigrid/asi

unison

Unison language - content-addressed functional programming with abilities for effects, distributed computing, and structural types. Use for pure functional code, effect management, distributed systems, and refactoring-safe codebases.

67 0
View
tasks-acset logo
plurigrid/asi

tasks-acset

Google Tasks management via TasksACSet. Transforms task operations into GF(3)-typed Interactions, routes to triadic queues, detects saturation for task-zero-as-condensed-state.

67 0
View
c logo
plurigrid/asi

c

World C Skill

67 0
View
syrup logo
plurigrid/asi

syrup

Syrup binary serialization for OCapN/CapTP wire format. Canonical encoding for capability messages.

67 0
View
skill-installer logo
plurigrid/asi

skill-installer

Install Codex skills into $CODEX_HOME/skills from a curated list or a GitHub repo path. Use when a user asks to list installable skills, install a curated skill, or install a skill from another repo (including private repos).

67 0
View

Popular AI tools

Kaiber logo
Video

Kaiber

Generate, edit, and beat-sync AI video with leading models in one workspace.

Paid
View
Vimcal logo
Productivity

Vimcal

The world's fastest calendar for remote work

Free
View

Transform Your Design with AI Designer by ImgCreator.ai

Freemium
View
Akool AI logo
Content & writing

Akool AI

Revolutionizing Video Production with AI-Powered Creativity

Paid
View

Extend an image past the frame and let AI fill the new aspect ratio.

Freemium
View
StarByFace logo
Security

StarByFace

Discover your celebrity doppelgänger with StarByFace!

Free
View
C

ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.

Freemium
View
Opus Clip logo
Coding & apps

Opus Clip

Opus.ai: Revolutionize Your Web Experience

Free
View