Proof Simplifyのロゴ

Proof Simplify

組織
opum-ai
proof-simplify

Use verified TLA+ specs and Lean proofs to simplify real code safely — delete defensive checks the invariants make dead, remove locks/transactions/retries that do no work, collapse redundant states and flags, replace complex implementations with simpler ones proven equivalent, and encode invariants in types — re-verifying every change (re-check, refinement, reachable-state equivalence) before touching code. Use this skill whenever the user asks to simplify, clean up, de-risk a refactor, or reduce complexity in code that has (or could get) a formal model; asks "do we still need this lock / check / retry / state"; wants to turn proofs into code improvements; or finishes a formal-verify bug hunt and wants the payoff. If no verified model exists yet, it starts one via formal-verify first.

概要

公開者opum-ai
リポジトリproof-skills
スキル名proof-simplify
スター
27
フォーク
6
同梱ファイル
8
ライセンスMIT
リンク
  • Markdown形式の指示

    モデルが必要に応じて読み込むSKILL.mdファイルです。関連するリクエストがあったときだけトークンを消費します。

  • どのLLMでも利用可能

    AIスキルはプロバイダー固有のコードではなく、通常のMarkdownなので、GPT、Claude、Gemini、Grok、ローカルモデルで利用できます。

  • 8個の同梱ファイル

    モデルが作業中に読み取れるスクリプト、テンプレート、参考資料です。ファイルは読み取り専用で、実行されることはありません。

  • オープンソース

    opum-aiがGitHubで公開しています。インストールする前にソースを確認してください。

インストール

AIスキルProof SimplifyをTypingMindにインストールすれば、どのLLMでも利用できます。SKILL.mdを読み取れる別のAIエージェントに追加することもできます。

1

TypingMindにインストール

TypingMindはGitHubフォルダから直接スキルをインストールします。SKILL.mdを読み取り、リソースファイルをまとめてローカルに保存します。

  1. アプリを開き、「プラグイン」→「スキル」に移動します。
  2. 「GitHubからインストール」を選択します。
  3. 以下のスキルフォルダのURLを貼り付けて確定します。
    https://github.com/opum-ai/proof-skills/tree/main/skills/proof-simplify
  4. スキルを利用したいチャットごとに、そのスキルを有効にしてください。
「プラグイン」→「スキル」→「スキルを追加」→「GitHubのURLから」を選択し、フォルダのURLを貼り付けて「続行」を押します。
2

別のAIエージェントにインストール

Agent Skills形式を読み取れるAIエージェントなら、このスキルを利用できます。フォルダをそのAIエージェントのスキルディレクトリにコピーしてください。

Claude Code — .claude/skills
git clone --depth 1 https://github.com/opum-ai/proof-skills.git /tmp/proof-skills
mkdir -p .claude/skills
cp -r /tmp/proof-skills/skills/proof-simplify .claude/skills/proof-simplify
コピー後、新しいスキルを読み込むためにClaude Codeを再起動してください。

TypingMindで使用

TypingMindのチャットでProof Simplifyを有効にするだけで、あとはモデルが対応します。名前と説明がシステムプロンプトに含まれ、関連するリクエストがあると、モデルが指示の全文を自動で読み込みます。手動で呼び出す必要はなく、実際に使用されるまでトークンを消費しません。

関連するリクエストがあると、モデルが自動的にProof Simplifyを読み込みます。

どのAIモデルでも利用可能

AIスキルはプロバイダー固有のコードではなく、通常のMarkdownで書かれた指示です。そのため、Proof Simplifyは作成時に想定されたモデルに縛られません。TypingMindに一度インストールすれば、ご自身のAPIキーを使って、GPT-5、Claude、Gemini、Grok、DeepSeek、Mistral、Llama、またはご自身で実行するローカルモデルで利用できます。

  • 必要なときだけ読み込み

    システムプロンプトには名前と説明だけが含まれます。関連するリクエストが初めてあったときに指示を取得するため、未使用のスキルにはコストがかかりません。

  • チャットの途中でモデルを切り替え

    スキルはコードではなく指示なので、モデルを切り替えてもそのまま使えます。次のモデルも同じSKILL.mdを読み込みます。

スキルの指示

モデルが読み込むSKILL.mdの内容です。スキルはモデルが従う指示なので、インストールする前に確認してください。

proof-simplify

A proof tells you what is always true of the system. Code written without that knowledge defends against states that cannot happen: guards that never fail, locks that protect nothing, retries that never fire, flags that duplicate other state. Each piece costs reading time, test time, and latency, and each is a place for new bugs.

This skill turns proven facts into deletions. It proves every deletion safe before making it, then re-verifies afterwards.

The standard of evidence: a simplification is justified only by a property the model proved, under assumptions the code actually enforces. Anything less is a guess dressed up in proof vocabulary.

Preconditions

You need all four of these; without them there is nothing to justify a deletion. If any is missing, run formal-verify (W1) first:

  • a model that passes (TLA+ at stated bounds, or Lean with check_trust.sh clean);
  • frozen properties (Properties.tla / Properties.lean);
  • the model's sanity checks passed (must-fail invariants fail, bug toggles fail);
  • CORRESPONDENCE.md, including its Assumptions list.

Workflow

  1. Harvest candidates. Read the model and the code side by side. Use references/catalog.md for the eight kinds of candidate and how to spot each:

    • a guard implied by the invariant,
    • redundant synchronization,
    • a dead branch or unreachable state,
    • a dead retry or timeout path,
    • a redundant variable or flag,
    • mergeable (bisimilar) states,
    • an implementation replaceable by a simpler proven-equal one,
    • an invariant that can be encoded in types.

    List each candidate with its code location, the model element it maps to, and the fact that would justify it.

  2. Prove each candidate in the model before touching code. Techniques, from cheapest to strongest (references/equivalence.md):

    • Re-check. Apply the simplification to the model, then re-run every frozen property, the sanity checks, and the bug toggles, at the same or larger bounds.
    • Guard implication. In Lean, prove the guard follows from the invariant in every reachable state. In TLA+, check Enabled_A_without_G => G as an invariant.
    • Refinement. Show the simplified spec implements the current one: TLA+ INSTANCE … WITH checked as a PROPERTY, or a Lean simulation theorem. All safety properties then transfer automatically. Liveness must be re-checked.
    • Reachable-state equivalence (Lean reach_iff). The two versions reach exactly the same states. This is the strongest form.
    • Function equality (Lean theorem simple_eq : ∀ x, simple x = current x). Use it for replacing an algorithm.
  3. Audit assumptions. For each candidate, list which Assumptions from CORRESPONDENCE.md the proof relies on, then decide:

    • Remove when every assumption is enforced by code or infrastructure you control (a type, a DB constraint, a single-writer design).
    • Downgrade to an assertion (a debug assert, a metric, or a log-and-continue) when the proof holds but an assumption is only conventional. The next person who breaks the assumption then gets a signal instead of silent corruption.
    • Keep when the code sits on a trust boundary (network input, user input, disk, another team's service, a rolling deploy with mixed versions), or when the assumption is outside your control. Internal invariants never justify deleting validation of external input.
  4. Apply one simplification at a time. For each accepted candidate:

    • make the code change,
    • update the model to match it (the simplified model is now the model),
    • update CORRESPONDENCE.md,
    • run the project's tests and the reproduction tests from earlier findings,
    • re-run the model.

    Use one commit per simplification, whose message names the property that justifies it.

  5. Report. Add simplifications[] to formal/findings.json, then publish the Artifact report (formal-verify/references/report-artifact.md, section "Simplifications"). For each change it shows:

    • the diff,
    • the justifying property or theorem, and its evidence,
    • the assumptions relied on,
    • the decision (removed / downgraded / kept), and
    • the lines-of-code delta.

    Also include the candidates you rejected, with the reason. They are useful knowledge ("the lock looks redundant but protects the cron path, which is not modeled").

Worked examples (both verified)

  • TLA+: a lock that does nothing. assets/tla/CancelOrder.tla models a cancel handler that takes a row lock and uses a conditional UPDATE, while the payment webhook never takes the lock.

    • MC_current.cfg and MC_cas_only.cfg pass.
    • MC_lock_only.cfg fails (exit 13): the lock alone never prevented paid → cancelled.
    • CancelOrderSimple.tla removes the lock, and MC_refines.cfg proves it refines the current spec under a mapping that reconstructs the lock.
    • Mutating the simplified spec to drop the CAS guard makes the check fail, so the refinement check has teeth.

    Decision: remove the lock, keep the CAS, and write the model's finding into the code comment.

  • Lean: a defensive guard the invariant makes dead. lean-model/assets/lean-patterns/ProofPatterns/RedundantGuard.lean:

    • guard_implied: the k ∉ applied re-check follows from the idempotency invariant.
    • reach_iff: with or without it, exactly the same states are reachable.

    Decision: delete it, citing applied_nodup.

Run them:

bash
T=${CLAUDE_SKILL_DIR}/../tlaplus-model/scripts/tlc.sh
for c in MC_current MC_cas_only MC_lock_only; do $T ${CLAUDE_SKILL_DIR}/assets/tla/CancelOrder.tla --config $c.cfg; done
$T ${CLAUDE_SKILL_DIR}/assets/tla/CancelOrderSimple.tla --config MC_refines.cfg

What not to do

  • Don't simplify on the strength of a model that never failed. Sanity checks come first.
  • Don't carry a property from a bounded check into an unbounded claim. "Holds for 2 workers" does not justify deleting a lock that matters at 3. Either argue that the bound covers it (symmetry, or the property is per-pair), prove it in Lean, or re-check at larger bounds.
  • Don't merge several simplifications into one unverified leap. Re-verify after each one. Two individually safe deletions can be jointly unsafe.
  • Don't delete observability (logs, metrics) because a state is "unreachable". Consider turning the branch into an alert.
  • Don't let a refinement proof stand in for liveness. Refinement preserves safety, so re-check liveness separately.

Reference files

  • references/catalog.md — the eight candidate kinds: how to spot them, how to justify them in TLA+ and Lean, and the typical code change.
  • references/equivalence.md — re-check, guard implication, refinement mappings, reachable-state equivalence, and function equality, with verified templates.

同梱ファイル

スキルが読み込まれている間、モデルは必要に応じてこれらを読み取ります。読み取り可能なファイルとして提供され、実行されることはありません。

よくある質問

AIスキル「Proof Simplify」では何ができますか?

Use verified TLA+ specs and Lean proofs to simplify real code safely — delete defensive checks the invariants make dead, remove locks/transactions/retries that do no work, collapse redundant states and flags, replace complex implementations with simpler ones proven equivalent, and encode invariants in types — re-verifying every change (re-check, refinement, reachable-state equivalence) before touching code. Use this skill whenever the user asks to simplify, clean up, de-risk a refactor, or reduce complexity in code that has (or could get) a formal model; asks "do we still need this lock / c...

TypingMindでProof Simplifyを使うメリットは何ですか?

一度インストールすれば、どのモデルでも使えるからです。Proof Simplifyはプロバイダー固有のコードではなく、通常のMarkdownで記述されているため、同じスキルをGPT-5、Claude、Gemini、Grok、ローカルモデルで利用できます。チャットの途中でモデルを切り替えても、そのまま使い続けられます。TypingMindは自分のAPIキーで動作するため、シート単位のサブスクリプションではなく、プロバイダーに直接料金を支払います。スキルとチャットは自分のストレージに保持されます。

TypingMindにProof Simplifyをインストールするにはどうすればよいですか?

TypingMindで「プラグイン」→「スキル」→「GitHubからインストール」を開き、https://github.com/opum-ai/proof-skills/tree/main/skills/proof-simplifyを貼り付けてください。TypingMindがSKILL.mdを読み込み、関連ファイルをまとめて、チャットごとに有効にできるスキルとしてインストールします。

Proof Simplifyを使えるAIモデルはどれですか?

TypingMindに接続したどのモデルでも利用できます。AIスキルはプロバイダー固有のコードではなく、通常のMarkdownで書かれた指示です。そのため、GPT、Claude、Gemini、Grok、ローカルモデルのいずれも、リクエストが合致したときにこのスキルを読み込めます。

Proof Simplifyは何個のAIモデルで使えますか?

数に制限はありません。スキルに対応したモデルであれば、GPT、Claude、Gemini、Grok、DeepSeek、Mistral、Llamaなど、どのモデルでもProof Simplifyを利用できます。すべてTypingMind上で、自分のAPIキーを使って利用できます。

AIスキル「Proof Simplify」は無料ですか?

はい。opum-aiがGitHubでMITライセンスの下で公開しています。支払いが必要なのは、利用したトークンに対する、ご自身が契約するAIプロバイダーへの料金だけです。

AIスキルとは何ですか?

AIスキルは、特定のタスクの実行方法をAIモデルに教える、再利用可能な指示のセットです。オープンなAgent Skills形式に従い、名前と説明を含むSKILL.mdファイルに加え、モデルが必要とするスクリプト、テンプレート、参照ファイルで構成されます。モデルはリクエストがスキルに合致したときだけ指示を読み込むため、インストール済みのスキルも、使うまでは費用がかかりません。

AIスキルは、プラグインやMCPサーバーとどう違いますか?

プラグインやMCPサーバーは、モデルが呼び出せる新しいツールを提供します。ツールとは、どこかで実行され、結果を返すコードです。一方、AIスキルは、タスクへの取り組み方、従うべき手順、望ましい出力の例といった知識や進め方をモデルに伝えます。スキルは通常のMarkdownで記述されているため、サーバー、APIキー、実行環境は不要で、どのモデルでも利用できます。

すべて見る

今すぐ自分専用のAIワークスペースを作成

ニュースレターに登録すると、新機能や今後のプレゼント企画のお知らせが届きます👇