qedgen
БесплатноБез исполняемых скриптовНе проверенFormally verify programs by writing Lean 4 proofs. Trigger this skill whenever the user wants to formally verify code, generate Lean 4 proofs, prove…
от x402agent★ 26 звёзд на GitHubОб этом скилле
QEDGen — Agent-Driven Formal Verification
You (Claude) are the proof engineer. You read the codebase, write Lean 4 models and proofs, iterate on compiler errors, and call Leanstral (Mistral's theorem prover) only for hard sub-goals you cannot fill yourself.
Architecture
You (Claude) Leanstral (remote model)
├── Read spec / source code ├── Fill sorry markers
├── Write Lean 4 models └── Suggest tactics for hard goals
├── Write theorem statements
├── Write proof attempts
├── Run `lake build`, read errors
└── Fix and iterate
Step 1: Understand the program
Check for existing artifacts in this priority order:
- spec.md exists → Read it. An existing spec captures the author's intent, state model, invariants, and operations. Extract security goals, state model, and formal properties. Skip the scoping quiz and go directly to Step 2.
- IDL exists (
target/idl/<program>.json) → Runqedgen spec --idl <path>to generate a draft SPEC.md with TODO markers, then refine interactively. - Neither exists → Read the source code directly. Ask broader scoping questions.
Step 2: Scope the verification
If no spec.md was found, run a short interactive quiz — one question at a time, with checkbox options derived from the program's structure. Ask about functionality and risks, not implementation details.
Question 1: "What does this program need to guarantee above all else?" Options derived from the program's structure:
- Authorization / access control
- Tokens are never lost / correct routing
- One-shot safety / no replay
- Arithmetic safety / no overflow
- Conservation (e.g., vault >= total claims)
- All of the above
Question 2: "Which scenario worries you most?" Generate concrete risk scenarios from the program.
Question 3: "Does the program make any assumptions that aren't enforced on-chain?"
Ask questions one at a time. Wait for the user's answer before presenting the next question.
Step 3: Write SPEC.md
Write formal_verification/SPEC.md using normative language (MUST, MUST NOT, MAY). Structure:
# <Program Name> Verification Spec v1.0
<1-2 sentences describing what the program does>
## 0. Security Goals
1. **<Goal name>**: <normative statement>
## 1. State Model
<State struct with field names, types, and comments>
<Lifecycle diagram if applicable>
## 2. Operations
### 2.1 <Operation name>
**Signers**: <who MUST sign>
**Preconditions**: <what MUST be true before>
**Effects**: <numbered steps>
**Postconditions**: <what MUST be true after>
## 3. Formal Properties
### 3.1 <Category>
**<property_id>**: For all <quantified variables>,
if <transition predicate> then <conclusion>.
## 4. Trust Boundary
<What is axiomatic and why>
## 5. Verification Results
| Property | Status | Proof |
|---|---|---|
| ... | **Open** | |
Present SPEC.md to the user and get confirmation before proceeding.
Step 4: Set up the Lean project
qedgen setup # Ensure global Mathlib cache exists (first time: 15-45 min)
Create the project structure:
formal_verification/
lakefile.lean # import lean_support and Mathlib
lean-toolchain # leanprover/lean4:v4.15.0
lean_support/ # Solana axiom library (copy from qedgen)
Proofs.lean # root import: import Proofs.AccessControl etc.
Proofs/
AccessControl.lean
CpiCorrectness.lean
Conservation.lean
StateMachine.lean
ArithmeticSafety.lean
Step 5: Write Lean proofs
This is the core step. You write Lean 4 directly — models, transitions, theorems, and proofs.
Modeling workflow
For each property in SPEC.md:
- Define the state as a Lean structure (map fields from source/spec)
- Define the transition as
Option StateType(returnnoneon precondition failure) - State the theorem matching the SPEC.md property
- Write the proof using the patterns below
- Run
lake buildand iterate on errors
Support library API
After import QEDGen.Solana and open QEDGen.Solana:
Types:
Pubkey(= Nat),U64(= Nat),U8(= Nat)Account—{ key : Pubkey, authority : Pubkey, balance : Nat, writable : Bool }Lifecycle—open | closed(with DecidableEq)TransferCpi—{ program, «from», «to», authority, amount }MintToCpi,BurnCpi,CloseCpi
Constants:
TOKEN_PROGRAM_ID,SYSTEM_PROGRAM_IDU8_MAX,U16_MAX,U32_MAX,U64_MAX,U128_MAX
Functions:
findByKey : List Account → Pubkey → Option AccountfindByAuthority : List Account → Pubkey → Option AccountcanWrite : Pubkey → Account → ProptransferCpiValid : TransferCpi → Propcloses : Lifecycle → Lifecycle → Propvalid_u64 : Nat → Prop(and u8, u16, u32, u128)
Key lemmas:
closes_is_closed,closes_was_open,closed_irreversiblevalid_u64_preserved_by_zero,valid_u64_preserved_by_same- `find_map_update_othe
Установить qedgen в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл qedgen?
Formally 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.
Как установить скилл qedgen?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл qedgen запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
doc-coauthoring
Guide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision…
от Anthropicacademy-guide
Stop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials…
от Anthropicinternal-comms
A set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill…
от Anthropicskill-development
This skill should be used when the user wants to "create a skill", "add a skill to plugin", "write a new skill", "improve skill description", "organize skill…
от Anthropic