Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

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от 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:

  1. 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.
  2. IDL exists (target/idl/<program>.json) → Run qedgen spec --idl <path> to generate a draft SPEC.md with TODO markers, then refine interactively.
  3. 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:

  1. Define the state as a Lean structure (map fields from source/spec)
  2. Define the transition as Option StateType (return none on precondition failure)
  3. State the theorem matching the SPEC.md property
  4. Write the proof using the patterns below
  5. Run lake build and 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_ID
  • U8_MAX, U16_MAX, U32_MAX, U64_MAX, U128_MAX

Functions:

  • findByKey : List Account → Pubkey → Option Account
  • findByAuthority : List Account → Pubkey → Option Account
  • canWrite : Pubkey → Account → Prop
  • transferCpiValid : TransferCpi → Prop
  • closes : Lifecycle → Lifecycle → Prop
  • valid_u64 : Nat → Prop (and u8, u16, u32, u128)

Key lemmas:

  • closes_is_closed, closes_was_open, closed_irreversible
  • valid_u64_preserved_by_zero, valid_u64_preserved_by_same
  • `find_map_update_othe
Полный SKILL.md на GitHub

Установить qedgen в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

.gitignore.npmignoreCargo.lockCargo.tomlLICENSEREADME.mdbin/leanstralclaude.mdcrates/qedgen/Cargo.tomlcrates/qedgen/lean_support/QEDGen.leancrates/qedgen/lean_support/QEDGen/Solana.leancrates/qedgen/lean_support/QEDGen/Solana/Account.leancrates/qedgen/lean_support/QEDGen/Solana/Authority.leancrates/qedgen/lean_support/QEDGen/Solana/Cpi.leancrates/qedgen/lean_support/QEDGen/Solana/State.leancrates/qedgen/lean_support/QEDGen/Solana/Token.leancrates/qedgen/lean_support/QEDGen/Solana/Valid.leancrates/qedgen/lean_support/README.mdcrates/qedgen/lean_support/lake-manifest.jsoncrates/qedgen/lean_support/lakefile.leancrates/qedgen/lean_support/lean-toolchaincrates/qedgen/lean_support/test_lemmas.leancrates/qedgen/src/api.rscrates/qedgen/src/consolidate.rscrates/qedgen/src/main.rscrates/qedgen/src/project.rscrates/qedgen/src/spec.rscrates/qedgen/src/validate.rscrates/qedgen/templates/.gitignorecrates/qedgen/templates/Main.leancrates/qedgen/templates/PROMPT_TEMPLATE.mdcrates/qedgen/templates/README.lean.mdcrates/qedgen/templates/lakefile.leancrates/qedgen/templates/lean-toolchaindocs/CNAMEdocs/index.htmldocs/llms-full.txtdocs/llms.txtdocs/logo-dark.pngdocs/logo-dark.svg

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), без исполняемых скриптов.

Похожие скиллы

Сравнить qedgen с