本文へ移動
cccskills
無料GitHub で公開

foundations-formal-methods

Proves protocols and agent workflows with TLA+, P, Alloy, Z3, Dafny, or Lean. Use when proving protocols correct, writing TLA+ specs, or verifying LLM proofs.

インストール方法を見る

含まれるファイル(15)

  • SKILL.md8.5 KB
  • agents/openai.yaml373 B
  • assets/tla/IdempotentRetry.cfg166 B
  • assets/tla/IdempotentRetry.tla3.7 KB
  • assets/verification-report.md683 B
  • data/sources.json8.1 KB
  • references/agent-workflows.md7.5 KB
  • references/finite-checker.md2.2 KB
  • references/llm-generated-specs.md5.6 KB
  • references/model-checking.md2.2 KB
  • references/refinement.md2.1 KB
  • references/specification.md2.2 KB
  • references/tool-selection.md9.2 KB
  • scripts/check_finite_model.py3.8 KB
  • scripts/test_check_finite_model.py4.4 KB

SKILL.md(原文)

インストールする前に、エージェントに与えられる指示の中身を確認できます。

Formal Methods Foundations

Turn a requirement into a checkable property, pick the cheapest method that can catch the bug class, and report precisely what the evidence establishes. A verified finite abstraction is evidence about that abstraction; implementation correctness needs a demonstrated correspondence.

When to use

Triggers: "prove this protocol is correct", "write a TLA+ / PlusCal spec", "model check this workflow", "find a race condition formally", "verify with Z3 / cvc5 / Lean / Dafny / Verus", "TLA+ or property-based testing?", "check this LLM-generated proof or spec", "can any policy combination allow X", "safety versus liveness", "refinement mapping", "find a counterexample".

Not this skill:

Use this skill when the specification, the choice of verification method, or the meaning of a result is the central question.

Quick Reference

Method ladder (full version in tool-selection.md):

Bug classCheapest adequate rungResult means
Edge-case inputs, sequential logicProperty-based testing or fuzzingFound or not found in the sampled inputs
Rare interleavings in real codeDeterministic simulationFound in the explored seeds
Design races, retries, failures, handoffsTLA+/PlusCal (TLC), P, Alloy 6; Apalache for symbolic checksCompleted exhaustive checks cover the finite model; P schedule testing and bounded symbolic checks cover only their reported exploration
Policy or config equivalence; "can any input reach X"SMT (Z3, cvc5)sat gives a witness; unsat holds for the encoding; unknown proves nothing
Small high-value core, all sizesDafny, Verus, Lean 4, Rocq, IsabelleProof against the stated spec and trusted base

Climb past PBT only for interleaving-heavy designs, authorization logic, irreversible side effects, or aggressive optimizations. For costs, when NOT to climb, and industrial evidence, read tool-selection.md.

Workflow

  1. State the requirement.
    • Name the requirement, the prohibited or required behavior, the environment, and the observed interface.
    • Classify it as state safety, temporal safety, liveness, or a performance requirement. Read specification.md.
  2. Build the model.
    • Define initial states, variables, transitions, atomicity, and environment assumptions, including the failures and concurrency the property depends on.
    • Choose constants large enough to express the bug class. Two concurrent actors is the minimum for a race.
    • Track every abstraction and every omitted behavior.
  3. Pick a rung. Use tool-selection.md and model-checking.md. State the scope and tool limits before interpreting any result.
  4. Run the check.
    • Preserve the model, config, tool version, property, result, and trace.
    • Triage each counterexample: it is a system defect, an abstraction artifact, or a wrong property.
    • Add vacuity probes: the good path must be reachable.
  5. Gate LLM output. If a model drafted or edited the spec, invariant, proof, or config, run the gate in llm-generated-specs.md before accepting any result.
  6. Tie the claim to code. For claims about deployed code, read refinement.md and name the correspondence obligations. Trace conformance is the practical bridge.
  7. Report. Produce the verification-report.md. Use "holds in this finite model", "counterexample found", or "inconclusive". Never upgrade a bounded or model result to general correctness.

Agent-shaped worked example

agent-workflows.md holds a TLC-checked spec of an idempotent tool call with retries (spec, TLC config). It shows three things:

  • A check-then-act race that TLC finds only with two workers, so a one-worker model gives a false "holds".
  • A phantom-acknowledgement bug introduced by the first fix.
  • The protocol that passes both invariants, with vacuity probes.

The same reference covers approval gates bound to argument hashes, cancellation, leases, and policy-as-SMT.

Lightweight finite checker

scripts/check_finite_model.py checks a state invariant over an explicit, fully enumerated finite graph and returns the shortest violating trace. It does not check liveness or code correspondence. For the contract and tests, see finite-checker.md. Run it with python3 scripts/check_finite_model.py model.json.

Assumptions and pitfalls

  • An invariant must hold in initial states as well as after transitions. An unreachable prohibited state is not a violation of reachable-state safety.
  • Stuttering, action granularity, scheduling, and fairness can change temporal claims. Safety success cannot establish eventual completion.
  • A bounded SAT/SMT unsat result excludes counterexamples only within its encoding and bound. unknown, timeouts, and partial searches establish no absence claim.
  • A satisfiable formula is a witness for its encoded constraints, not automatically an execution. Inspect the encoding and decode the witness.
  • Symmetry reduction, constraints, abstractions, and omitted failures each need justification relative to each property. Undersized constants hide races.
  • A proof of a wrong specification does not establish the intended requirement. Check requirements and implementation mappings separately.
  • Verify tool semantics and versions against the tool's current primary documentation before treating them as current. Quote benchmark figures with model, version, and date. Do not present generated claims, parser success, or bounded searches as proof beyond their stated evidence.

Completion criteria

A useful result identifies:

  • the property and the model
  • the assumptions and the method or tool, with its version
  • the bounds and constants
  • the evidence and the counterexample status
  • the vacuity probes
  • the conformance gap

Report verification failures directly, and never silently weaken a property to make a check pass.

Navigation

Related skills

レビュー

まだレビューはありません。使ってみた感想をお寄せください。

同じリポジトリのスキル

概要と使いどころ

Configures Claude Code hooks and Codex hooks.json/notify. Use when adding PreToolUse guards, Stop hooks, managed hooks, format-on-save, preflight, audits, or worktree/budget hooks.

日本語の概要は準備中です。原文の説明を表示しています。

vasilyu1983/AI-Agents-public932026年10月12日 更新

Configures and hardens Claude Code and Codex MCP servers. Use when connecting databases, APIs, SaaS, building servers, or serving a clearance-filtered knowledge base.

日本語の概要は準備中です。原文の説明を表示しています。

vasilyu1983/AI-Agents-public932026年10月12日 更新

Owns instruction files: AGENTS.md, CLAUDE.md, personal and repo rules. Use when writing, pruning, auditing them, sharing rules across Claude and Codex, or fixing ignored rules.

日本語の概要は準備中です。原文の説明を表示しています。

vasilyu1983/AI-Agents-public932026年10月12日 更新

Creates and audits agent skills: SKILL.md, references, scripts, runtime metadata. Use when writing, validating, or security-reviewing a skill, or fixing truncated skill listings.

日本語の概要は準備中です。原文の説明を表示しています。

vasilyu1983/AI-Agents-public932026年10月12日 更新

Adds per-skill learnings loops for dated patterns, mistakes, and domain facts. Use when wiring skill memory, consolidation, or drift audits.

日本語の概要は準備中です。原文の説明を表示しています。

vasilyu1983/AI-Agents-public932026年10月12日 更新

Chooses subagent, team, workflow, or debate and launches it on Claude Code or Codex. Use when delegating, running agent review boards, or installing shared agents.

日本語の概要は準備中です。原文の説明を表示しています。

vasilyu1983/AI-Agents-public932026年10月12日 更新

vasilyu1983 のスキルをすべて見る

このスキルの問題を報告する