--- id: logical-unification version: "0.4.7" license: BSD-3-Clause license_treatment: permissive maintenance: active --- # logical-unification — Logical unification in Python License: permissive · Maintenance: active · Downloads: 1.3M/mo ## What it is and what it does Logical unification is a computer science technique for finding substitutions that make different terms equivalent. This package implements unification in Python, allowing you to match patterns against data structures and extract variable bindings. It supports built-in Python types (tuples, dicts, namedtuples) and can be extended to custom classes via the @unifiable decorator. The package also provides pattern-matching dispatch, letting you define multiple function implementations that are selected based on pattern matching against arguments. It uses a generator-based design to handle deeply nested structures without hitting Python's recursion limit, making it suitable for symbolic computation, logic programming, and complex pattern-based control flow. Use it for: - Extract values from nested data structures using pattern matching with logic variables instead of manual traversal. - Implement logic-programming-style algorithms like recursive pattern matching (e.g., Fibonacci via pattern dispatch). - Route or dispatch function calls based on complex structural patterns in dictionaries or custom objects. - Unify and reify custom domain objects (e.g., Account records) to find matching instances or extract fields. - Build symbolic computation systems where you need to reason about term equivalence and substitution. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Logical unification in Python with support for pattern matching and custom data types, extensible via dispatch on toolz and multipledispatch. Yes. The package is actively maintained, has no known vulnerabilities, installs with low friction, and offers a unique capability for pattern matching and logical unification that is not easily replicated with standard Python. It is well-suited for logic programming, symbolic computation, and complex pattern-based dispatch. The BSD-3-Clause license is permissive and poses no barrier. ## Install pip install logical-unification uv add logical-unification poetry add logical-unification ## Installing logical-unification Before you install: Low install friction with a pure Python wheel and only two lightweight runtime dependencies. Active maintenance with a recent commit on 2026-02-25 and stable production status. License in practice: BSD-3-Clause permissive license allows use in most projects, including commercial, with minimal restrictions beyond attribution. Quickstart: pip install logical-unification from unification import var, unify, reify x = var() result = unify((1, x), (1, 2)) print(result) # {~x: 2} print(reify((1, x), {x: 2})) # (1, 2) Requires Python 3.9 or later. Verify before relying: - Whether the package is actively maintained beyond the latest release date (2025-10-20); last commit is 2026-02-25 but days_since_release is 298. - Performance characteristics for very large unification problems beyond the benchmarked nested list scenarios. ## Package facts - License: BSD-3-Clause (permissive) - Python support: supports_current - Install friction: low - Maintenance: active - Downloads: 1.3M/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags logical unification pattern matching, unify variables in data structures, logic programming python, pattern matching dispatch, unification reification, logic variable binding, symbolic pattern matching, logic-programming, pattern-matching, symbolic-computation [View on SkillFed](https://skillfed.io/packages/logical-unification) · [View on PyPI](https://pypi.org/project/logical-unification/)