Skip to main content

Modular symbolic logic system supporting proofs, predicates, inference rules, truth tables, and LLM integration with Pydantic models.

Project description

🤖 agent-logic

Modular Symbolic Logic for Agent Reasoning, SAT Solving, and LLM-Enhanced Proof Systems

🚀 Overview

agent-logic is a modular Python library for constructing, evaluating, transforming, and proving logical expressions — designed to act as a lightweight symbolic logic and SAT solving engine for LLM-driven agent systems.

It enables:

  • ✅ Propositional Logic (AND, OR, IMPLIES, IFF, NOT)
  • ✅ Predicate Logic (Terms, Predicates, Quantifiers: FORALL ∀, EXISTS ∃)
  • ✅ Formal Proof Validation (Inference Rules, Structured Derivations)
  • ✅ Truth Table Generation and Logical Satisfiability Checking
  • ✅ Logical Transformations (Equivalences, Normal Forms)
  • ✅ Recursive Abstract Syntax Tree (AST) Parsing
  • ✅ Native Pydantic Models and Strong Typing for Safe Structured Outputs

🔗 Structured. Serializable. Reasonable. Agent-Ready.

💪 Current Status

  • Core symbolic logic (propositions, connectives, predicates, quantifiers) is fully implemented.
  • Truth tables, tautology/contradiction checking, and core proof validation are working and tested.
  • Inference rules are largely implemented (Modus Ponens, Modus Tollens, Hypothetical Syllogism, Dilemmas, Biconditional Elimination, etc).
  • AST parsing, SAT-based search, and deeper quantifier handling are in progress.

⚠️ Note:

  • Some features (e.g., deeper quantifier transformations, large proof automation) are actively being debugged.
  • Basic and intermediate logical operations are stable; complex proof search under refinement.

📊 Motivation

Large Language Models can predict, generate, and reflect — but they struggle with formal, structured, symbolic reasoning.

agent-logic empowers:

  • Agents that perform valid, step-by-step derivations.
  • LLMs that validate, transform, and construct proofs.
  • Systems that reason explicitly over symbolic structures, not just language.

By combining a SAT-solving core, formal proof system, and structured Pydantic output models, it provides the foundation for autonomous, interpretable reasoning agents.

"Prediction ends where true reasoning begins."

💡 Key Features

Feature Details
Propositional Logic Build expressions with AND, OR, NOT, IMPLIES, IFF
Predicate Logic Define predicates, terms, universal and existential quantifiers
Inference System Apply formal inference rules to derive conclusions
Truth Tables Generate complete truth tables, detect tautologies and contradictions
AST-Based Parsing Logical expressions modeled as fully typed recursive trees
Pydantic Models All structures serializable, introspectable, LLM-compatible
SAT Solver Backbone Solve satisfiability and consistency of logical expressions (planned)
Type-Safe API Full typing with Pydantic v2, Literal types, structured validation

💡 Example Usage

from agent_logic.core.operations import Proposition, BinaryOp
from agent_logic.evaluation.truth_table import TruthTable

# Define propositions
p = Proposition(name="P")
q = Proposition(name="Q")

# Create an expression: (P AND Q)
expr = BinaryOp(left=p, right=q, operator="AND")

# Generate a truth table
table = TruthTable(expression=expr)
for row in table.generate():
    print(row)

# Check logical properties
print("Is tautology:", table.is_tautology())
print("Is contradiction:", table.is_contradiction())

📙 LLM and Agent Toolkit Use Cases

  • Formal proof verification of LLM-generated outputs
  • Autonomous deduction chains in multi-agent debates
  • Structured symbolic output parsing for LangChain tools / OpenAI functions
  • Hypothetical reasoning, consequence checking, and goal validation
  • Safe, introspectable logical reasoning pipelines for AI agents

All models use Pydantic v2, meaning:

  • JSON-serializable and function-call ready
  • Validatable against strict schemas
  • Compatible with LangChain Structured Tools, OpenAI Tools, JSON mode parsing

"Not just token prediction. Formal reasoning."

🌟 Roadmap

  • Propositional and Predicate Logic Core
  • Truth Tables and Tautology Checking
  • Structured Proof Validation Engine
  • Advanced SAT Solving and Forward/Backward Proof Search
  • Quantifier Manipulation (Skolemization, Unification)
  • Natural Language to Formal Logic Parsing (Experimental)
  • Web Visualizer Playground

🚀 Getting Started

pip install agent-logic

(Coming soon to PyPI. Install locally for now.)

git clone https://github.com/yourusername/agent-logic.git
cd agent-logic
poetry install

👤 Authors

Built by developers passionate about combining symbolic logic, autonomous reasoning, and practical agentic AI design.

Contributions, ideas, and PRs are welcome!

🎉 License

MIT License.

Empower Your Agents with True Reason.

💡 "Teach your models to reason, not just predict."

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

agent_logic-0.1.0.tar.gz (23.0 kB view details)

Uploaded Source

Built Distribution

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

agent_logic-0.1.0-py3-none-any.whl (31.2 kB view details)

Uploaded Python 3

File details

Details for the file agent_logic-0.1.0.tar.gz.

File metadata

  • Download URL: agent_logic-0.1.0.tar.gz
  • Upload date:
  • Size: 23.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.2 CPython/3.12.3 Linux/5.15.167.4-microsoft-standard-WSL2

File hashes

Hashes for agent_logic-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8dcdcf634606b3c47e99bb30874b976f2c6adb3f1412cda265d92c04c8c4a37f
MD5 d552b9e75911e0ead2f3025c019a41a6
BLAKE2b-256 2bc5407bc20cab199028de26e83648fcf3c2558d761c68a3a8f1ce1efb17b38c

See more details on using hashes here.

File details

Details for the file agent_logic-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: agent_logic-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 31.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.2 CPython/3.12.3 Linux/5.15.167.4-microsoft-standard-WSL2

File hashes

Hashes for agent_logic-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 26f71a773e67a4b8b68e155e077bb84df076519856e2bff79052b92b0dc9798d
MD5 6238aa79d6483c33afcd33469495d867
BLAKE2b-256 6faceec2e9de4c46d34e8cf1ddab17ee27a36eb65a5183de11263fcd35d93844

See more details on using hashes here.

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