x402agent/SolanaOS / skills/solana-formal-verification
qedgen
FlaggedFormally verify programs by writing Lean 4 proofs. Trigger this skill whenever the user wants to formally verify code, generate Lean 4 proofs, prove properties about algorithms or smart contracts, verify invariants, convert program logic into formal specifications, or anything involving Lean 4 and formal verification. Also trigger when the user mentions "qedgen", "lean proof", "formal proof", "verify my code", "prove correctness", "formal verification", or wants mathematical guarantees about their implementation.
crates/qedgen/lean_support/README.md
View on GitHub# QEDGen.Solana Support Library
This directory contains the **canonical** Lean support library for Solana program verification.
## Purpose
Provides pre-bundled axioms and types that model:
- **Account**: Solana account structure (key, authority, balance)
- **Token**: SPL Token operations as trusted axioms
- **State**: Lifecycle and state machine types
- **Authority**: Authorization predicates
## Trust Boundary
These axioms represent the **trust boundary** between:
- ✅ **Program logic** (what we verify)
- ⚠️ **External dependencies** (what we trust)
See `QEDGen/Solana/Token.lean` for detailed documentation of trust assumptions.
## Usage in Projects
### Option 1: Copy to Project (Recommended)
When generating proofs for a project:
```bash
# The qedgen tool automatically copies this library
./bin/qedgen analyze --input program.rs --output-dir /tmp/analysis
./bin/qedgen generate ... --output-dir /tmp/proofs
```
The generated Lean project will include a `lean_support/` directory with this library.
### Option 2: Symlink (For Development)
If you're actively developing the support library:
```bash
cd your-project/formal_verification/
ln -s ../../../crates/qedgen/lean_support .
```
## Pre-Bundled Axioms
### Token Conservation
```lean
-- Single transfer preserves total
axiom transfer_preserves_total : ...
-- Four-way transfer (escrow-style exchanges) preserves total
axiom four_way_transfer_preserves_total : ...
-- Balance updates with zero delta preserve total
axiom balance_update_preserves_total : ...
```
### Utility Lemmas
```lean
-- List operations on tracked totals
axiom trackedTotal_cons : ...
axiom trackedTotal_append : ...
theorem trackedTotal_map_id : ...
```
## Adding New Axioms
When adding axioms that are reusable across **all** Solana programs:
1. Add to the appropriate module in `QEDGen/Solana/`
2. Export in the `QEDGen.Solana` namespace
3. Document the trust assumption
4. Update `templates.rs` to include in support API documentation
5. Test by rebuilding: `lake build`
## Design Principles
1. **Axioms, not proofs**: External dependencies are trusted, not verified
2. **Minimal surface**: Only include what's needed for common Solana patterns
3. **Composable**: Axioms should compose to prove program properties
4. **Clear trust boundary**: Document what we verify vs. what we trust
## Testing
```bash
# Build the support library
lake build
# Test that all axioms are well-typed
lake env lean test_lemmas.lean
```
## Files
- `lakefile.lean`: Lake build configuration
- `QEDGen.lean`: Root module that exports everything
- `QEDGen/Solana/Account.lean`: Account structure and field access
- `QEDGen/Solana/Token.lean`: Token operations and conservation axioms
- `QEDGen/Solana/State.lean`: Lifecycle and state machine types
- `QEDGen/Solana/Authority.lean`: Authorization predicates
- `test_lemmas.lean`: Smoke tests for type-checking axioms
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis. | Stars: 472k | Updated | Claude CodeCodex | Verified | Install |
| diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness. | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependencies | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is available | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |