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. Run an Example

We provide runnable Python scripts to demonstrate the logic harness.

Simple Demo (Single-Shot):

# Clone the repo first if you haven't
git clone https://github.com/Hmbown/peircean-abduction.git
cd peircean-abduction

# Run the quickstart
python examples/quickstart.py

3. Verify Installation

Ensure the MCP server is correctly configured by running the validation script:

python scripts/validate_mcp.py

Full Scenario (International Law):

python examples/international_law.py

🔌 MCP Server Setup

Connect Peircean Abduction to your AI assistant (Claude, Cursor, etc.) to give it abductive reasoning superpowers.

Claude Desktop

Automatic (recommended):

# macOS
peircean-setup-mcp --write "$HOME/Library/Application Support/Claude/claude_desktop_config.json"

# Windows
peircean-setup-mcp --write "%APPDATA%\Claude\claude_desktop_config.json"

Manual Configuration:

{
  "mcpServers": {
    "peircean": {
      "command": "python",
      "args": ["-m", "peircean.mcp.server"]
    }
  }
}

Cursor / VS Code

  1. Run peircean-setup-mcp to generate the config JSON.
  2. Paste it into your editor's MCP settings.

🧠 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.

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.0.0.tar.gz (84.0 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.0.0-py3-none-any.whl (39.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: peircean_abduction-1.0.0.tar.gz
  • Upload date:
  • Size: 84.0 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.0.0.tar.gz
Algorithm Hash digest
SHA256 68c9f0b4e5c88beca6cd3c32350a5b79d5b05ff81489e64865acfa74ff989c20
MD5 8e3a6e68b80f5563438f689763459e75
BLAKE2b-256 c203f283aee3ec2c6283b5b509b77e3916af2b234f35aee09c71f798a75e0c7c

See more details on using hashes here.

Provenance

The following attestation bundles were made for peircean_abduction-1.0.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.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for peircean_abduction-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9ace9905977a227cc398dfec7ec13b70e6be6250db679a30945198d71992e61e
MD5 f7b6667e2861ff922ec3ed4fe1d684dd
BLAKE2b-256 38f9ccd2abb382c37134290b088fc9cd86da6f12e472e3336fddd8f991d15f96

See more details on using hashes here.

Provenance

The following attestation bundles were made for peircean_abduction-1.0.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