Skip to main content

A Logic Harness for abductive inference. Anomaly in → Hypothesis out.

Project description

Peircean Abduction

CI PyPI Python 3.10+ License: MIT

A Logic Harness for Abductive Inference.

Peircean Abduction forces LLMs to stop guessing and start investigating. It implements Charles Sanders Peirce's logical framework to make uncertainty visible and hypotheses testable.

Anomaly in → Hypothesis out.

"The surprising fact, C, is observed.
But if A were true, C would be a matter of course.
Hence, there is reason to suspect that A is true."
— Charles Sanders Peirce, Collected Papers 5.189

🔍 What is this?

Most LLMs act like a Jury: they weigh the evidence they have and give you a verdict (probability-based). They tend to "lump" distinct possibilities into a single, safe conclusion.

Peircean Abduction acts like a Detective: it doesn't just decide; it investigates. It splits anomalies into distinct, testable hypotheses and tells you how to find the truth.

Key Features

  • Explicit Uncertainty: Forces the model to quantify "surprise" (0.0 - 1.0).
  • Structured Hypotheses: Every explanation comes with specific, testable predictions.
  • Inference to Best Explanation (IBE): A rigorous selection process based on Explanatory Power, Parsimony, and Testability.
  • Council of Critics: Automatically simulates 5 specialist perspectives (Empiricist, Logician, Pragmatist, Economist, Skeptic) to stress-test ideas.
  • MCP Ready: Built as a Model Context Protocol (MCP) server, ready to plug into Claude Desktop, Cursor, or any MCP client.

🚀 Quick Start

1. Install

pip install peircean-abduction

2. Verify Environment

Ensure everything is set up correctly (Python version, dependencies, path):

peircean --verify

3. Run the Demo

See the logic harness in action (generates an abductive prompt):

python examples/quickstart.py

🔌 MCP Server Setup (Claude Desktop / Cursor)

Give your AI assistant abductive reasoning superpowers.

1. Install Config

Automatically configure Claude Desktop to use the Peircean MCP server:

peircean --install

This adds the server to your claude_desktop_config.json.

2. Restart Claude

Restart Claude Desktop. You should see a 🔌 icon indicating the tool is active.

3. Try it out

Ask Claude:

"Analyze this anomaly: My server latency spiked 10x but CPU usage is flat."


🧠 How It Works (The 3-Phase Loop)

The harness enforces a strict 3-step logical flow:

Phase 1: Observe (peircean_observe_anomaly)

  • Input: A raw observation (e.g., "Server latency spiked 10x but CPU is normal").
  • Output: A structured "Anomaly" object defining why this is surprising and what baseline was violated.

Phase 2: Hypothesize (peircean_generate_hypotheses)

  • Input: The Anomaly from Phase 1.
  • Output: A list of distinct, falsifiable hypotheses (A's). Each must explain the anomaly if true.

Phase 3: Evaluate (peircean_evaluate_via_ibe)

  • Input: The Hypotheses from Phase 2.
  • Output: A final Verdict selected via Inference to Best Explanation (IBE). This phase can optionally convene a "Council of Critics" to debate the options.

⚡ Case Study: The "Lumping" Problem

Scenario: A "defunct" military satellite collides with a commercial station. Flight logs show a controlled burn 10s before impact.

  • Standard LLM: "It was likely a malfunction or a hidden military test." (Lumps distinct ideas together, vague).
  • Peircean Harness:
    1. H1 (Attack): "Sleeper weapon activated." -> Prediction: Check for uplink signals at T-10s.
    2. H2 (Glitch): "Deorbit script misfire." -> Prediction: Check code for specific trigger conditions.
    • Verdict: Investigate H1 first because it explains the vector (steering into target), whereas H2 only explains the burn.

🛠️ Troubleshooting

"Module not found: peircean" in Claude

  • This usually happens if peircean was installed in a virtual environment (venv/conda) but Claude is using the system Python.
  • Fix: Run peircean --install from within your active environment. It will automatically register the absolute path to the correct Python executable.

"No LLM backend configured"

  • The CLI tool (peircean "observation") currently outputs prompts for you to paste into an LLM.
  • For fully automated abduction, use the MCP integration with Claude Desktop.

Verify Command Failed

  • Run peircean --verify to see detailed diagnostics.
  • Ensure you are on Python 3.10+.

Documentation

Contributing

License

MIT License. See LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

peircean_abduction-1.1.0.tar.gz (86.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

peircean_abduction-1.1.0-py3-none-any.whl (41.8 kB view details)

Uploaded Python 3

File details

Details for the file peircean_abduction-1.1.0.tar.gz.

File metadata

  • Download URL: peircean_abduction-1.1.0.tar.gz
  • Upload date:
  • Size: 86.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for peircean_abduction-1.1.0.tar.gz
Algorithm Hash digest
SHA256 507b88055a16291315a2d4da4039bd14ec1e17917f7345a8a71c1a84e5ebe982
MD5 5002119ed0bab190aaa271f669e1821d
BLAKE2b-256 0bf65d4f9f66d453ff829d51348bae987a9562ae349818d741ca217ad1058941

See more details on using hashes here.

Provenance

The following attestation bundles were made for peircean_abduction-1.1.0.tar.gz:

Publisher: publish.yml on Hmbown/peircean-abduction

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file peircean_abduction-1.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for peircean_abduction-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a65fccbd3e6dd40ac16c0904c12379676d95e0c2d97c7ccd0ffb88e13d4efbc1
MD5 3a019e85386bccdf2132ac22d3c73ea2
BLAKE2b-256 08b0674b4ea3b302152cb9aa570d1d1554dd9137e87b718cc5546f8c339103a5

See more details on using hashes here.

Provenance

The following attestation bundles were made for peircean_abduction-1.1.0-py3-none-any.whl:

Publisher: publish.yml on Hmbown/peircean-abduction

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page