paperproof-validator
Formal Proof Visualization and Verification for Lean 4
Best use case
paperproof-validator is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Formal Proof Visualization and Verification for Lean 4
Teams using paperproof-validator should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/paperproof-validator/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How paperproof-validator Compares
| Feature / Agent | paperproof-validator | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Formal Proof Visualization and Verification for Lean 4
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# paperproof-validator
> Formal Proof Visualization and Verification for Lean 4
**Version**: 1.0.0
**Trit**: -1 (Validator - verifies proof correctness)
**Bundle**: verification
**Status**: ✅ New (Lean 4 theorem proof visualization)
**Repository**: [Paper-Proof/paperproof](https://github.com/Paper-Proof/paperproof)
---
## Overview
**Paperproof Validator** transforms formal Lean 4 proofs into intuitive, paper-like visualizations. It bridges the gap between abstract formal proofs and human understanding by displaying how hypotheses and goals evolve throughout a proof.
**Key Innovation**: Makes formal proofs accessible by visualizing proof structure in a way that mirrors mathematical notation on paper.
### What Paperproof Does
Instead of abstract Lean code:
```lean
theorem example : P → Q := by
intro h
apply some_lemma
exact h.right
```
Paperproof shows:
```
┌─────────────────────────────────────┐
│ Hypotheses (green nodes): │
│ - h : P │
├─────────────────────────────────────┤
│ Goal (red node): │
│ - Q │
├─────────────────────────────────────┤
│ Tactics (transparent): │
│ - apply some_lemma │
│ - exact h.right │
└─────────────────────────────────────┘
```
---
## Architecture
### Three Core Components
#### 1. **Lean 4 Library Integration**
```lean
import Paperproof
theorem my_theorem : P ∧ Q → R := by
-- Paperproof automatically extracts proof state
intro ⟨hp, hq⟩
-- Visualization tracks hypotheses and goals
exact some_proof_term
```
**Capabilities**:
- Integrates with Lean 4 InfoTree
- Extracts proof state at each tactic
- Provides proof metadata to VS Code extension
---
#### 2. **VS Code Extension**
**Responsibilities**:
- Tracks cursor position (detects which theorem is being visualized)
- Communicates with Lean server for proof data
- Hosts webview panel for visualization
- Provides commands and settings
- Bridges Lean InfoTree to React frontend
**Commands**:
```bash
Paperproof: Open Paperproof Panel
Paperproof: Show Current Theorem
Paperproof: Export Proof as Image
Paperproof: Settings
```
**Architecture Flow**:
```
User Cursor on Theorem
↓
Selection Changed Event
↓
Request Proof Data from Lean Server
↓
Lean Server Returns InfoTree
↓
BetterParser (extract structure)
↓
Converter Service (optimize for visualization)
↓
Send to React Frontend
↓
Render Visual Proof Tree
```
---
#### 3. **React Frontend Visualization**
**Component Hierarchy**:
```
ProofTree (root)
├── GlobalContext Provider
├── Header (title, controls)
└── BoxEl (variable scope container)
├── Hypotheses Section
│ └── HypothesisNode (green)
│ └── Transparency = "in scope"
├── Tactics Section
│ └── TacticNode (transparent, dashed border)
│ └── Arrows to related nodes
└── Goals Section
└── GoalNode (red)
```
**Visual Cues**:
- **Hypotheses**: Green nodes at the top
- **Goals**: Red nodes at the bottom
- **Tactics**: Transparent nodes with dashed borders
- **Scope**: Nested boxes with darkening backgrounds
- **Availability**: Node opacity indicates scope accessibility
---
## Capabilities
### 1. visualize-proof-structure
Display proof as hierarchical tree with visual nodes:
```python
from paperproof_validator import PaperproofVisualizer
visualizer = PaperproofVisualizer(
lean_file="example.lean",
theorem_name="my_theorem"
)
# Extract and render proof
proof_visual = visualizer.visualize(
show_hypotheses=True,
show_goals=True,
show_tactics=True,
show_scopes=True
)
# Output: Interactive HTML/React visualization
```
### 2. extract-proof-metadata
Pull structured proof information from Lean InfoTree:
```lean
-- Lean 4 code
theorem and_comm (p q : Prop) : p ∧ q → q ∧ p := by
intro ⟨hp, hq⟩ -- Step 1: intro creates hypotheses
exact ⟨hq, hp⟩ -- Step 2: exact provides proof term
```
**Extracted Structure**:
```json
{
"theorem": "and_comm",
"steps": [
{
"tactic": "intro",
"hypotheses": [
{"name": "hp", "type": "p"},
{"name": "hq", "type": "q"}
],
"goals": [{"type": "q ∧ p"}]
},
{
"tactic": "exact",
"hypotheses": [
{"name": "hp", "type": "p"},
{"name": "hq", "type": "q"}
],
"goals": []
}
]
}
```
### 3. validate-proof-correctness
Verify that proof reaches expected conclusion:
```python
validation = visualizer.validate_proof(
expected_conclusion="Q"
)
if validation.passes:
print("✓ Proof correctly establishes Q")
else:
print(f"✗ Proof does not establish Q")
print(f" Final goal: {validation.final_goal}")
```
### 4. analyze-tactic-effects
Show how each tactic transforms proof state:
```python
analysis = visualizer.analyze_tactics()
for step in analysis.steps:
print(f"\nTactic: {step.name}")
print(f"Hypotheses before: {step.hypotheses_before}")
print(f"Hypotheses after: {step.hypotheses_after}")
print(f"Goals before: {step.goals_before}")
print(f"Goals after: {step.goals_after}")
print(f"Variables in scope: {step.scope}")
```
### 5. support-multiple-proof-tactics
Handle common Lean 4 tactics:
```lean
-- apply: Uses a hypothesis/lemma to transform goal
theorem proof_with_apply : P → Q := by
intro hp
apply lemma_p_implies_q
exact hp
-- have: Introduces intermediate hypothesis
theorem proof_with_have : P → Q → R := by
intro hp hq
have h : X := lemma_from_p hp
apply lemma_h_q_to_r h hq
-- induction: Proves by induction
theorem induction_proof : ∀ n, P n := by
intro n
induction n with
| zero => exact base_case
| succ k ih => exact inductive_step k ih
-- by_contra: Proof by contradiction
theorem by_contra_proof : P := by
by_contra hnp
have : False := contradiction_from_not_p hnp
exact absurd this (by simp)
-- cases: Case analysis
theorem cases_proof : P := by
cases some_disjunction with
| left h => exact left_proof h
| right h => exact right_proof h
```
All tactics are visualized with their proof state transformations.
### 6. export-proof-visualization
Generate static or interactive proof representations:
```python
# Export as interactive HTML
visualizer.export_html("proof.html")
# Export as static image (PNG/SVG)
visualizer.export_image("proof.png", format="png")
# Export as LaTeX (for papers)
visualizer.export_latex("proof.tex")
# Export as JSON (for programmatic use)
visualizer.export_json("proof.json")
```
---
## Integration with Lean 4 Ecosystem
### Installation
```bash
# 1. Install VS Code Extension
# Via VS Code Extensions marketplace: search "Paperproof"
# 2. Add to Lean project (lakefile.toml)
require paperproof from git
"https://github.com/Paper-Proof/paperproof.git"
# 3. Update
lake update
# 4. Import in Lean files
import Paperproof
```
### Usage in Lean 4
```lean
import Paperproof
-- Define a theorem
theorem associativity : ∀ (a b c : Nat), (a + b) + c = a + (b + c) := by
intro a b c
-- When cursor is here, Paperproof shows:
-- - Hypotheses: a : Nat, b : Nat, c : Nat
-- - Goal: (a + b) + c = a + (b + c)
induction a with
| zero =>
-- Paperproof shows base case context
rfl
| succ k ih =>
-- Paperproof shows inductive step
-- - ih : (k + b) + c = k + (b + c) [inductive hypothesis]
simp [Nat.add_succ, ih]
```
---
## Formal Proof Theory Background
### Proof Trees and Natural Deduction
Paperproof visualization is based on natural deduction systems:
```
Hypotheses (context)
───────────────────────
| Tactics apply
| Goal transforms
───────────────────────
Final conclusion
```
### Gentzen Sequent Calculus Connection
Paperproof extends traditional proof visualization with modern web technologies:
**Traditional Gentzen style**:
```
Γ ⊢ A Γ ⊢ B
──────────────────
Γ ⊢ A ∧ B
```
**Paperproof visualization**:
- Shows Γ (hypotheses) visually
- Shows goals in red
- Shows proof steps with connecting arrows
- Indicates variable scope with nested boxes
### Color Semantics
| Color | Element | Meaning |
|-------|---------|---------|
| Green | Hypotheses | Available facts in scope |
| Red | Goals | Targets to prove |
| Transparent | Tactics | Proof steps (white box) |
| Dark gray | Scope boundaries | Variable scope nesting |
| Opacity | Node visibility | Whether element is in scope |
---
## GF(3) Integration
### Trit Assignment
**Paperproof Validator**: -1 (MINUS - critical validator)
Can form balanced triads with:
**Potential Triad (Formal Verification)**:
| Trit | Skill | Role |
|------|-------|------|
| -1 | **paperproof-validator** | Validates formal proofs |
| 0 | proof-instrumentation | Tracks proof steps |
| +1 | theorem-generator | Generates provable theorems |
| **Sum** | **0 (mod 3)** | **✓ Conserved** |
---
## Comparison with Other Proof Tools
### vs. Lean Native REPL
| Aspect | Lean REPL | Paperproof |
|--------|-----------|-----------|
| **Visualization** | Text-based | Visual tree |
| **Scope Tracking** | Implicit | Explicit boxes |
| **Learning Curve** | Steep | Gentle |
| **Understanding** | Abstract | Intuitive |
| **Accessibility** | Expert-only | Beginner-friendly |
### vs. Tactic State Window
**Tactic State (raw)**:
```
⊢ (0 + 0) + 0 = 0
```
**Paperproof (visual)**:
```
┌─────────────────────────────┐
│ Goal: (0 + 0) + 0 = 0 │
│ (After simp) │
└─────────────────────────────┘
```
---
## Configuration
```yaml
# paperproof-validator.yaml
visualization:
show_hypotheses: true
show_goals: true
show_tactics: true
show_scopes: true
show_arrows: true
rendering:
color_scheme: dark # or 'light'
node_size: medium # small, medium, large
scope_nesting_depth: 5
export:
formats: [html, png, svg, json, latex]
include_metadata: true
lean_integration:
lean_version: "v4.0.0"
vscode_extension: true
webview_enabled: true
```
---
## Example Workflow
```bash
# 1. Install extension
# Open VS Code Extensions, search "Paperproof", click Install
# 2. Add to Lean project
# Edit lakefile.toml, add dependency
# 3. Import in Lean file
# Add: import Paperproof
# 4. Open Paperproof panel
# Cmd+Shift+P → "Paperproof: Open Panel"
# 5. Click on theorem
# Click on any 'theorem' or 'lemma' in editor
# 6. View visualization
# Paperproof shows interactive proof tree in side panel
# 7. Export proof
# Cmd+Shift+P → "Paperproof: Export Proof as Image"
```
---
## Technical Implementation
### BetterParser
Converts Lean InfoTree (raw proof structure) to simplified representation:
```
Lean 4 InfoTree (complex, nested)
↓
BetterParser
↓
Simplified Proof Structure (clean)
↓
Converter
↓
React-Friendly Format
↓
Visual Rendering
```
### Converter Service
Optimizes proof structure for visualization:
```python
# Input: Lean InfoTree
lean_tree = {
"kind": "Tactic",
"name": "intro",
"children": [...]
}
# Process through converter
visual_tree = convert_to_visual_format(lean_tree)
# Output: { "type": "intro", "hypotheses": [...], "goals": [...] }
# Pass to React
render_to_webview(visual_tree)
```
### VS Code Extension Communication
```typescript
// VS Code Extension (TypeScript)
vscode.window.onDidChangeTextEditorSelection((e) => {
const theorem_name = getSymbolAtCursor(e);
// Request proof from Lean server
const proof_data = getLeanProofData(theorem_name);
// Send to webview
webview.postMessage({
type: "updateProof",
data: proof_data
});
});
// React Webview receives message
window.addEventListener("message", (event) => {
if (event.data.type === "updateProof") {
renderProofTree(event.data.data);
}
});
```
---
## Related Skills
- **bisimulation-game** - Verifies equivalence of proofs
- **langevin-dynamics-skill** - Analyzes proof dynamics
- **fokker-planck-analyzer** - Validates proof convergence
- **spi-parallel-verify** - Checks proof structure invariants
---
## Learning Resources
**Examples from the wild**:
- Proofs from "Mathematics in Lean 4"
- Proofs from Mathlib4
- The Hitchhiker's Guide to Logical Verification
- Lean 4 tutorials and documentation
**Tutorial Examples Included**:
- Natural deduction proofs
- Inductive proofs
- Proof by contradiction
- Case-by-case proofs
---
## Development
Paperproof is actively developed and welcomes contributions:
- **Repository**: [GitHub - Paper-Proof/paperproof](https://github.com/Paper-Proof/paperproof)
- **Issues & Discussion**: Open for feature requests and bug reports
- **License**: Open source (check repository for details)
### Development Setup
```bash
# Clone repository
git clone https://github.com/Paper-Proof/paperproof.git
# Install dependencies
npm install
# Development environment
# See repository for full setup guide
# Build extension
npm run build
# Package for distribution
npm run package
```
---
## Example: Proving Commutativity of Addition
### Lean 4 Proof
```lean
theorem add_comm (m n : Nat) : m + n = n + m := by
induction m with
| zero => simp
| succ k ih =>
rw [Nat.succ_add, Nat.add_succ, ih]
```
### Paperproof Visualization
**Step 1: Base Case (zero)**
```
┌─────────────────────────────────────┐
│ Hypotheses: │
│ - n : Nat │
├─────────────────────────────────────┤
│ Goal: 0 + n = n + 0 │
├─────────────────────────────────────┤
│ Tactic: simp │
│ (simplifies by reflexivity) │
└─────────────────────────────────────┘
```
**Step 2: Inductive Case (succ)**
```
┌─────────────────────────────────────────────────┐
│ Hypotheses: │
│ - k : Nat │
│ - n : Nat │
│ - ih : k + n = n + k [inductive hypothesis] │
├─────────────────────────────────────────────────┤
│ Goal: succ k + n = n + succ k │
├─────────────────────────────────────────────────┤
│ Tactics: │
│ - rw [Nat.succ_add] │
│ - rw [Nat.add_succ] │
│ - rw [ih] │
│ (rewrites transform goal to reflexivity) │
└─────────────────────────────────────────────────┘
```
---
## Integration with AI Agents
### Use in Plurigrid
Paperproof Validator can integrate with AI agent learning:
**Agent learns by proving theorems**:
```
Agent Generates Theorem
↓
Lean 4 Verifies Proof
↓
Paperproof Visualizes Structure
↓
Agent Learns from Visualization
```
**Feedback Loop**:
```python
# Agent proposes proof
proof_sketch = agent.propose_theorem_proof(statement)
# Paperproof validates
validation = paperproof.validate(proof_sketch)
if validation.passes:
# Extract visualization for learning
structure = paperproof.extract_structure()
agent.update_knowledge(structure)
else:
# Return error visualization to agent
agent.learn_from_error(validation.error_path)
```
---
## Status & Roadmap
✅ **Current**: Lean 4 support, VS Code integration, proof visualization
🔄 **Planned**:
- Proof search assistance
- Tactic suggestions based on goal
- Machine learning integration
- Export to LaTeX for papers
---
**Skill Name**: paperproof-validator
**Type**: Formal Proof Visualization / Verification
**Trit**: -1 (MINUS - validator)
**Key Property**: Transforms formal proofs into intuitive paper-like visualizations
**Status**: ✅ Production Ready
**Repository**: [Paper-Proof/paperproof](https://github.com/Paper-Proof/paperproof)
**VS Code Extension**: Available in marketplaceRelated Skills
Frontend Functional Validator (Detective)
Clicks through the running UI to identify broken features and missing backend endpoints.
env-config-validator
Validate environment configuration files across local, staging, and production environments. Ensure required secrets, database URLs, API keys, and public variables are properly scoped and set. Use this skill when setting up environments, validating configuration, checking for missing secrets, auditing environment variables, ensuring proper scoping of public vs private vars, or troubleshooting environment issues. Trigger terms include env, environment variables, secrets, configuration, .env file, environment validation, missing variables, config check, NEXT_PUBLIC, env vars, database URL, API keys.
debug-validator-checkpoint-inconsistency
Debug validator checkpoint inconsistencies where some validators are behind others. Use when alerts mention "checkpoint inconsistency", "validators behind", or "inconsistent latest checkpoints", or when asked to debug validator sets, investigate validator delays, or troubleshoot metadata fetch failures for a chain. Defaults to default_ism app context if not specified.
artifact-validator
Validate and grade Claude Code Skills, Commands, Subagents, and Hooks for quality and correctness. Check YAML syntax, verify naming conventions, validate required fields, test activation patterns, assess description quality. Generate quality scores using Q = 0.40R + 0.30C + 0.20S + 0.10E framework with specific improvement recommendations. Use when validating artifacts, checking quality, troubleshooting activation issues, or ensuring artifact correctness before deployment.
architecture-validator
Validate hexagonal architecture (Domain, Application, Infrastructure, Presentation). Use when creating new files in src/, reorganizing code, or when the user requests architecture validation.
anti-ai-validator
AI 탐지 가능 패턴을 감지하고 제거하는 독립 검증 스킬. 금지 표현, 반복 단어, 부자연스러운 구조를 탐지한다. 게시 전 콘텐츠를 검증하거나 AI 패턴을 자동 교정할 때 사용한다.
AI Cross Validator
Dual-AI code validation using both Claude and Google Gemini to catch 20% more issues. Validates React Native screens for security vulnerabilities, performance anti-patterns, accessibility gaps, and best practices. Use when user says "validate with Gemini", "cross-validate", "AI review", or before deploying code to production.
ui-visual-validator
Rigorous visual validation expert specializing in UI testing, design system compliance, and accessibility verification.
trinity-auto-boot-validator
Generated skill from request: trinity auto-boot validator
openclaw-config-validator
Validate, analyze, and explain OpenClaw configuration files. Use when users need to check config.json for errors, understand what a config field does, compare configs, or safely modify OpenClaw configuration. Triggers on config validation requests, schema questions, or config editing tasks.
doc-ctr-validator
Validate Data Contracts (CTR) documents against Layer 8 schema standards
conductor-validator
Validates Conductor project artifacts for completeness, consistency, and correctness. Use after setup, when diagnosing issues, or before implementation to verify project context.