Counterexample Debuggerのロゴ

Counterexample Debugger

コミュニティ
ArabelaTso
counterexample-debugger

Debug proof failures using counterexamples from Nitpick (Isabelle) or QuickChick (Coq) to identify specification errors, missing preconditions, and proof strategy issues. Use when: (1) A proof attempt fails and you need to understand why, (2) Counterexamples are generated by Nitpick or QuickChick, (3) Specifications may be incorrect or incomplete, (4) Theorems need validation before proving, (5) Missing preconditions or lemmas need identification, or (6) Proof failures need explanation and correction suggestions. Supports both Isabelle/HOL and Coq equally.

概要

公開者ArabelaTso
リポジトリSkills-4-SE
スキル名counterexample-debugger
スター
258
フォーク
25
同梱ファイル
3
ライセンスApache-2.0
リンク
  • Markdown形式の指示

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

  • どのLLMでも利用可能

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

  • 3個の同梱ファイル

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

  • オープンソース

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

インストール

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

1

TypingMindにインストール

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

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

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

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

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

TypingMindで使用

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

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

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

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

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

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

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

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

スキルの指示

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

Counterexample-Guided Proof Debugger

Analyze counterexamples from Nitpick or QuickChick to explain proof failures and suggest corrections to specifications or proofs.

Workflow

1. Receive Counterexample Information

Identify what information is provided:

  • Counterexample output: From Nitpick or QuickChick
  • Failed theorem: The statement that couldn't be proven
  • Proof attempt: Any partial proof or tactics tried
  • Context: Definitions and lemmas involved

2. Choose Target System

Determine which proof assistant is being used:

  • Isabelle/HOL with Nitpick: Finite model finder
  • Coq with QuickChick: Property-based testing
  • Both: Provide analysis for both systems

3. Analyze the Counterexample

Examine the counterexample systematically:

Verify the counterexample:

  • Manually compute the result for the given values
  • Confirm it actually violates the theorem
  • Check if it's a genuine counterexample or tool limitation

Identify the violation:

  • Which part of the theorem fails?
  • What values cause the failure?
  • Is it an edge case or fundamental issue?

Determine the root cause:

  • Missing precondition?
  • Incorrect specification?
  • Wrong quantifier order?
  • Implementation bug?
  • Off-by-one error?
  • Type constraint issue?

4. Explain the Failure

Provide clear explanation:

What went wrong:

  • Describe why the counterexample violates the theorem
  • Show the computation step-by-step
  • Highlight the specific point of failure

Why it happened:

  • Explain the underlying cause
  • Identify the conceptual error
  • Note any common patterns (empty list, boundary values, etc.)

Impact assessment:

  • Is the theorem fundamentally wrong?
  • Does it need preconditions?
  • Is the specification incomplete?

5. Suggest Corrections

Provide actionable fixes based on the root cause:

For missing preconditions:

isabelle
(* Before *)
lemma "hd xs ∈ set xs"

(* After *)
lemma "xs ≠ [] ⟹ hd xs ∈ set xs"

For incorrect specifications:

coq
(* Before: uses < instead of <= *)
x < y && is_sorted (y :: ys)

(* After *)
x <= y && is_sorted (y :: ys)

For quantifier order:

isabelle
(* Before *)
"∃y. ∀x. P x y"

(* After *)
"∀x. ∃y. P x y"

For incomplete specifications:

coq
(* Before: only checks sortedness *)
is_sorted (sort l)

(* After: also checks permutation *)
is_sorted (sort l) && permutation l (sort l)

6. Recommend Next Steps

Guide the user on what to do:

Retest with fix:

  • Run Nitpick/QuickChick again
  • Verify no counterexample found
  • Check if fix is sufficient

Identify additional issues:

  • Are there other edge cases?
  • Do other lemmas need fixing?
  • Is the specification now complete?

Proceed with proof:

  • If no counterexample, attempt proof
  • Suggest proof strategy
  • Identify needed helper lemmas

Counterexample Analysis Patterns

Pattern 1: Empty Structures

Symptom: Counterexample is [], {}, or None

Common causes:

  • Missing non-empty precondition
  • Undefined behavior on empty input
  • Base case not handled

Fix: Add precondition or handle empty case explicitly

Pattern 2: Boundary Values

Symptom: Counterexample is 0, 1, or type limits

Common causes:

  • Off-by-one errors
  • Boundary condition not considered
  • Edge case in arithmetic

Fix: Adjust bounds or add special case handling

Pattern 3: Duplicate Elements

Symptom: Counterexample has repeated values like [0, 0]

Common causes:

  • Using < instead of ≤
  • Assuming distinctness
  • Set vs. multiset confusion

Fix: Use appropriate comparison or add distinctness assumption

Pattern 4: Small Counterexamples

Symptom: Very small counterexample (1-2 elements)

Common causes:

  • Fundamental specification error
  • Wrong base case
  • Incorrect inductive step

Fix: Review base definitions and inductive structure

Pattern 5: Type-Specific Values

Symptom: Counterexample at type boundaries

Common causes:

  • Type constraints not considered
  • Overflow/underflow issues
  • Finite vs. infinite types

Fix: Add type constraints or adjust specification

Tool-Specific Guidance

Nitpick (Isabelle/HOL)

For detailed Nitpick usage and interpretation:

Key points:

  • Searches for finite models
  • Configurable cardinality bounds
  • May miss counterexamples beyond bounds
  • "No counterexample" ≠ proof

QuickChick (Coq)

For detailed QuickChick usage and interpretation:

Key points:

  • Random testing with shrinking
  • Configurable test count
  • May miss rare counterexamples
  • "Success" ≠ proof

Common Root Causes

Specification Errors

Symptoms:

  • Counterexample shows spec doesn't match intent
  • Multiple unrelated counterexamples
  • Spec too weak or too strong

Fixes:

  • Strengthen postconditions
  • Add completeness requirements
  • Review specification against intent

Missing Preconditions

Symptoms:

  • Counterexample is edge case
  • Empty structures or boundary values
  • Undefined behavior

Fixes:

  • Add non-empty constraints
  • Add type bounds
  • Add well-formedness conditions

Quantifier Issues

Symptoms:

  • Counterexample shows wrong order
  • Existential/universal confusion
  • Skolem constant issues

Fixes:

  • Swap quantifier order
  • Review logical structure
  • Check variable dependencies

Implementation Bugs

Symptoms:

  • Counterexample shows function doesn't work
  • Output doesn't match specification
  • Logic error in definition

Fixes:

  • Fix the implementation
  • Review algorithm correctness
  • Test implementation separately

Debugging Checklist

When analyzing a counterexample:

  1. Verify manually: Compute the result for the counterexample values
  2. Identify violation: Which part of the theorem fails?
  3. Find root cause: Why does it fail? (precondition, spec, impl, quantifiers)
  4. Suggest fix: What needs to change?
  5. Check completeness: Are there other issues?
  6. Retest: Run tool again after fix
  7. Proceed: If no counterexample, attempt proof

Examples

For complete debugging examples including:

  • Incorrect sortedness definition
  • Missing preconditions
  • Wrong quantifier order
  • Off-by-one errors
  • Incomplete specifications

See examples.md

Tips

  • Trust the counterexample: If tool finds one, investigate thoroughly
  • Verify manually: Always check the counterexample by hand
  • Look for patterns: Empty, boundary, duplicates are common
  • Fix root cause: Don't just patch symptoms
  • Retest after fixing: Ensure fix is complete
  • Use tools early: Run Nitpick/QuickChick before proving
  • Iterate: May need multiple rounds of debugging
  • Document assumptions: Make preconditions explicit
  • Check completeness: Ensure specification is sufficient

同梱ファイル

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

よくある質問

AIスキル「Counterexample Debugger」では何ができますか?

Debug proof failures using counterexamples from Nitpick (Isabelle) or QuickChick (Coq) to identify specification errors, missing preconditions, and proof strategy issues. Use when: (1) A proof attempt fails and you need to understand why, (2) Counterexamples are generated by Nitpick or QuickChick, (3) Specifications may be incorrect or incomplete, (4) Theorems need validation before proving, (5) Missing preconditions or lemmas need identification, or (6) Proof failures need explanation and correction suggestions. Supports both Isabelle/HOL and Coq equally.

TypingMindでCounterexample Debuggerを使うメリットは何ですか?

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

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

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

Counterexample Debuggerを使えるAIモデルはどれですか?

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

Counterexample Debuggerは何個のAIモデルで使えますか?

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

AIスキル「Counterexample Debugger」は無料ですか?

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

AIスキルとは何ですか?

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

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

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

すべて見る

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

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