home / skills / plurigrid / asi / lean-proof-walk

lean-proof-walk skill

/skills/lean-proof-walk

This skill generates formal Lean 4 proof state chains using GF(3)-balanced triads to explore proof space and validate transitions.

npx playbooks add skill plurigrid/asi --skill lean-proof-walk

Review the files below or copy the command above to add this skill to your agents.

Files (2)
SKILL.md
3.5 KB
---
name: lean-proof-walk
description: GF(3)-balanced random walk through Lean proof states. Use when generating formal proof chains with parallel triad verification. Invokes 3 agents (Generator +1, Coordinator 0, Validator -1) to traverse proof space via prime geodesics.
version: 1.0.0
---


# Lean Proof Walk

Generate formal Lean 4 proof state chains using GF(3)-balanced random walks.

## Triad Structure

| Agent | Trit | Role | Action |
|-------|------|------|--------|
| Generator | +1 | Create | Propose next proof state |
| Coordinator | 0 | Transport | Formalize transition, derive seed |
| Validator | -1 | Verify | Check soundness, GF(3) conservation |

**Invariant**: `trit(G) + trit(C) + trit(V) = (+1) + 0 + (-1) = 0`

## State Chain Format

```
State N: Γ ⊢ G

where:
  Γ = context (hypotheses: x : τ, h : P)
  ⊢ = turnstile (entailment)
  G = goal (proposition to prove)
```

### Example Chain

```
State 0: a : ℤ, b : ℤ, h : a + b = 0 ⊢ b = -a

State 1: a : ℤ, b : ℤ, h : a + b = 0 ⊢ a + b - a = 0 - a

State 2: a : ℤ, b : ℤ, h : a + b = 0 ⊢ b = -a

State 3: No Goals
```

## Protocol

### 1. Initialize
```
seed := 0x42D (or user-provided)
state := State 0 with full context and goal
triad := spawn 3 parallel agents with trits {-1, 0, +1}
```

### 2. Walk Step (repeat until No Goals)
```
Generator (+1):  propose tactic τ, predict State n+1
Coordinator (0): formalize Γₙ ⊢ Gₙ  →  Γₙ₊₁ ⊢ Gₙ₊₁
Validator (-1):  verify transition sound, Σ trits = 0
Commit:          seed_{n+1} = hash(seed_n ⊕ state_n)
```

### 3. Terminate
```
State m = "No Goals" → QED
Emit: formal statement, informal proof, detailed proof, state chain
```

## Invocation

```
/lean-proof-walk "∀ a b : ℤ, a + b = b + a"
/lean-proof-walk --seed=1069 --theorem="commutativity of addition"
```

## Output Structure

1. **Formal Statement** (Lean 4 syntax)
2. **Informal Proof** (1-2 sentences)
3. **Detailed Informal Proof** (numbered steps)
4. **Chain of States** (with interleaved explanations)

## Tactics Vocabulary

| Tactic | State Transition |
|--------|------------------|
| `intro x` | `Γ ⊢ ∀x.P` → `Γ, x:τ ⊢ P` |
| `apply h` | `Γ, h:P→Q ⊢ Q` → `Γ ⊢ P` |
| `exact h` | `Γ, h:P ⊢ P` → `No Goals` |
| `rfl` | `Γ ⊢ a = a` → `No Goals` |
| `simp` | `Γ ⊢ P` → `Γ ⊢ P'` (simplified) |
| `ring` | `Γ ⊢ polynomial_eq` → `No Goals` |
| `omega` | `Γ ⊢ linear_arith` → `No Goals` |
| `cases h` | `Γ, h:P∨Q ⊢ R` → `Γ, h:P ⊢ R` and `Γ, h:Q ⊢ R` |
| `induction n` | `Γ ⊢ P(n)` → base case + inductive step |

## GF(3) Seed Derivation

```python
γ = 0x9E3779B97F4A7C15  # golden ratio constant

def next_seed(seed, state_hash, trit):
    return (seed ^ (state_hash * γ) ^ trit) & ((1 << 64) - 1)
```

## Bundled Triad Skills

```
lean-proof-walk (0) ⊗ bdd-mathematical-verification (+1) ⊗ chromatic-walk (-1) = 0 ✓
```

## Quick Reference

```
⟦State n⟧ = (Γₙ, Gₙ)
⟦S → S'⟧ = tactic application
⟦No Goals⟧ = proof complete
⟦Σ trits⟧ ≡ 0 (mod 3) always
```

## SDF Interleaving

This skill connects to **Software Design for Flexibility** (Hanson & Sussman, 2021):

### Primary Chapter: 10. Adventure Game Example

**Concepts**: autonomous agent, game, synthesis

### GF(3) Balanced Triad

```
lean-proof-walk (+) + SDF.Ch10 (+) + [balancer] (+) = 0
```

**Skill Trit**: 1 (PLUS - generation)

### Secondary Chapters

- Ch2: Domain-Specific Languages

### Connection Pattern

Adventure games synthesize techniques. This skill integrates multiple patterns.

Overview

This skill runs GF(3)-balanced random walks through Lean 4 proof states to generate formal proof chains with parallel triad verification. It coordinates three agents (Generator +1, Coordinator 0, Validator -1) to propose, formalize, and verify transitions until the proof reaches No Goals. The output includes a Lean formal statement, a short informal proof, a detailed step-by-step informal proof, and the full chain of intermediate states with explanations.

How this skill works

A triplet of agents repeatedly advances a proof state: the Generator proposes the next tactic and predicted state, the Coordinator formalizes the transition into a derived next state and updates a seed, and the Validator checks soundness while enforcing the GF(3) trit invariant. Each step updates a 64-bit seed deterministically from the previous seed, the state hash, and the agent trit. The walk terminates when a state with No Goals is reached and emits the formal and informal artifacts plus the recorded state chain.

When to use it

  • When you need automatically synthesized Lean 4 proof chains with built-in verification.
  • When exploring alternate proof paths or tactic sequences for a target theorem.
  • When wanting reproducible randomization across proof attempts via seed control.
  • When integrating parallel validation into proof generation workflows.
  • When producing human-readable chains for pedagogy or audit trails.

Best practices

  • Provide a clear initial context and goal to reduce irrelevant branching.
  • Control randomness with an explicit seed to reproduce or audit runs.
  • Limit walk depth or step count to avoid combinatorial explosion.
  • Prefer simple tactics first (intro, apply, exact, simp) and escalate to heavy automation (ring, omega) as needed.
  • Inspect the emitted state chain to validate reasoning and recover alternative steps.

Example use cases

  • Generate a Lean proof chain for a basic algebra theorem and output the formal statement plus informal explanation.
  • Explore multiple tactic sequences for a lemma by running several seeded walks and comparing chains.
  • Audit automated proof attempts: use the Validator’s checks to detect unsound transitions.
  • Teach tactic effects by showing interleaved state transitions and the vocabulary that produced them.
  • Integrate into CI to produce reproducible proof attempts with canned seeds for regression.

FAQ

How is reproducibility achieved?

Reproducibility comes from supplying an explicit seed; the seed derivation is deterministic and includes the state hash and trit at each step.

What ensures soundness of generated steps?

The Validator agent checks each transition against Lean-style rules and the Coordinator only commits transitions when the Validator accepts, maintaining a conserved GF(3) triad invariant.