Labsco
angrysky56 logo

MCP-Logic

โ˜… 44

from angrysky56

Provides automated reasoning for AI systems using the Prover9 and Mace4 theorem provers.

๐Ÿ”ฅ๐Ÿ”ฅ๐Ÿ”ฅโœ“ VerifiedFreeQuick setup

MCP-Logic

CI

An MCP server for automated first-order logic reasoning using Prover9 and Mace4.

Features

  • Theorem Proving - Prove logical statements with Prover9
  • Model Finding - Find finite models with Mace4
  • Counterexample Finding - Show why statements don't follow
  • Syntax Validation - Pre-validate formulas with helpful error messages
  • Categorical Reasoning - Built-in support for category theory proofs
  • Propositional Contingency - Purely analytical HCC prover for fast propositional checks
  • Abductive Reasoning - Rank hypotheses using Variational Free Energy (VFE)
  • Self-Contained - All dependencies install automatically

Available Tools

ToolPurpose
proveProve statements using Prover9
check-well-formedValidate formula syntax with detailed errors
find_modelFind finite models satisfying premises
find_counterexampleFind counterexamples showing statements don't follow
verify_commutativityGenerate FOL for categorical diagram commutativity
get_category_axiomsGet axioms for category/functor/group/monoid
check_contingencyCheck truth-functional contingency via HCC prover
abductive_explainFind the VFE-minimizing explanation for an observation

Project Structure

Copy & paste โ€” that's it
mcp-logic/
โ”œโ”€โ”€ src/mcp_logic/
โ”‚   โ”œโ”€โ”€ server.py              # Main MCP server (8 tools)
โ”‚   โ”œโ”€โ”€ mace4_wrapper.py       # Mace4 model finder
โ”‚   โ”œโ”€โ”€ syntax_validator.py    # Formula syntax validation
โ”‚   โ”œโ”€โ”€ categorical_helpers.py # Category theory utilities
โ”‚   โ”œโ”€โ”€ hcc_prover.py          # Hypersequent Contingency Calculus prover
โ”‚   โ”œโ”€โ”€ vfe_engine.py          # Variational Free Energy abductive engine
โ”‚   โ””โ”€โ”€ formula_ast.py         # Propositional logic AST and parser
โ”œโ”€โ”€ ladr/                      # Auto-installed Prover9/Mace4 binaries
โ”‚   โ””โ”€โ”€ bin/
โ”‚       โ”œโ”€โ”€ prover9
โ”‚       โ””โ”€โ”€ mace4
โ”œโ”€โ”€ tests/                     # Test suite
โ”œโ”€โ”€ linux-setup-script.sh      # Linux/macOS setup
โ”œโ”€โ”€ windows-setup-mcp-logic.bat # Windows setup
โ”œโ”€โ”€ run_mcp_logic.sh           # Linux/macOS run script
โ””โ”€โ”€ run_mcp_logic.bat          # Windows run script

What's New in v0.3.0

Cognitive Architecture Enhancements:

  • โœ… Hypersequent Contingency Calculus (HCC): Added a rigorous deductive checker for evaluating propositional formula contingencies instantly without brute-force modeling.
  • โœ… Variational Free Energy (VFE) Engine: Implemented abductive reasoning that ranks hypotheses using a non-dogmatic Cournot-Gaifman prior to elegantly satisfy Ockham's Razor.
  • โœ… Smart Prover Routing: prove tool automatically routes pure propositional queries to the HCC engine, and first-order queries to Prover9.
  • โœ… Configurable Model Finder: find_model and find_counterexample now support custom timeouts and structured predicate/function extraction.

What's New in v0.2.0

Enhanced Features:

  • โœ… Mace4 model finding and counterexample detection
  • โœ… Detailed syntax validation with position-specific errors
  • โœ… Categorical reasoning support (category theory axioms, commutativity verification)
  • โœ… Structured JSON output from all tools
  • โœ… Self-contained installation (no manual path configuration)

Development

Run tests:

Copy & paste โ€” that's it
source .venv/bin/activate
pytest tests/ -v

Test components directly:

Copy & paste โ€” that's it
python tests/test_enhancements.py

Documentation

License

MIT

Credits

  • Prover9/Mace4: William McCune's LADR library
  • LADR Repository: laitep/ladr
  • Hypersequent Contingency Calculus (HCC): Based on the logical framework from "A Hypersequent Calculus for Classical Contingencies" by Eugenio Orlandelli, Giannandrea Pulcini, and Achille C. Varzi (2024).