Skip to main content

PyPI - Version PyPI - Python Version PyPI - Downloads codecov

InferLingo

InferLingo is a small Python rule engine for deriving explainable policy, eligibility, compliance, and impact results from facts your application already knows.

Use it when facts and rules have different lifecycles: collect trustworthy observations in Python or external systems, keep changing policy in readable rule files, and retain proofs showing which conditions and evidence produced a result. InferLingo applies explicit rules; it is not a chatbot, planner, arithmetic engine, source-code analyzer, or action runner.

Python / APIs / scanners collect facts
                 |
                 v
InferLingo derives consequences from explicit rules
                 |
                 v
proofs + provenance explain successful results
                 |
                 v
your application decides what to do

Install

python -m pip install inferlingo

The base package is usable offline and uses exact unification by default in both Python APIs and the CLI. This quickstart needs no Jev extra or network access:

inferlingo run examples/birds.nl "{bird} can fly?"

Use --semantic only when differently worded statements may express the same fact. Install the optional backend with:

python -m pip install 'inferlingo[jev]'

Existing CLI scripts may keep using --exact-only; it remains a compatibility alias for the default.

Optional pyjev matching compares candidate facts. It does not invent logical implications or replace explicit policy rules. For authorization and other high-consequence decisions, prefer exact inference.

60-second example: release policy

From a source checkout, run the flagship example and its rule scenarios:

python -m pip install -e .
python examples/release_gate.py
inferlingo test examples/release_policy.nl examples/release_policy.cases.toml

Python supplies simulated facts from CI, change management, a security scanner, and a release calendar. The rules derive that checkout is ready and report four actionable blockers for billing, with evidence locations. The rule pack and TOML scenarios can be reviewed and tested independently of fact collection. InferLingo does not contact those systems or decide what action to take.

Embed policy in Python

from inferlingo import ExactUnifier, Fact, Provenance, RuleSet

rules = RuleSet.from_file("examples/release_policy.nl", unifier=ExactUnifier())
facts = [
    Fact(
        "{service} has passing tests",
        {"service": "checkout"},
        provenance=Provenance(source="ci/test-results.json", line=1, kind="ci"),
    ),
    Fact("{service} has an approved change", {"service": "checkout"}),
    Fact("{service} has acceptable vulnerability status", {"service": "checkout"}),
]
result = rules.ask_sync("{service} is release-ready?", facts=facts)

if result.matched:
    print(result.values("service"))  # ('checkout',)

RuleSet keeps reusable rules separate from per-evaluation facts. Each call gets an isolated fact set; structured Fact values are safely quoted, and provenance flows into successful proof steps. Use await rules.ask(...) in async applications. KnowledgeBase remains available for mutable, backwards-compatible workflows.

Why not just Python?

A few conditions may be simpler as an if statement. InferLingo becomes useful when multiple independent evidence sources feed rules that change separately from collectors, when rule packs need scenario tests, or when decisions need inspectable derivations and source provenance. Keep numeric, date, API, and parsing work in deterministic application code; turn its results into facts for the rule engine.

Documentation

Development

python -m pip install -e '.[dev,docs]'
python -m compileall inferlingo examples docs
pytest
ruff check .
python docs/make.py html
python -m build
twine check dist/*

The test suite is offline. Semantic tests use fake or injected clients and do not require live credentials.

License

Apache-2.0

Metadata

Release files for inferlingo 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for inferlingo 0.1.1
File Size Uploaded Provenance Actions
inferlingo-0.1.1.tar.gz 81.4 kB Without provenance Details for inferlingo-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for inferlingo 0.1.1
File Interpreter ABI Platform Actions
inferlingo-0.1.1-py3-none-any.whl Python 3 none any Details for inferlingo-0.1.1-py3-none-any.whl

Total release size: 119.0 kB

Release files / inferlingo-0.1.1.tar.gz

Download URL inferlingo-0.1.1.tar.gz
Size 81.4 kB
Tags Source
SHA-256 checksum
How to use checksums
2f3eb20c7735041a0158c491adf742431622c716e0dcc78f2dd2ac9ff616d431
BLAKE2b-256 checksum
How to use checksums
f719276664c9e01efbd2955578e06803a49da20e203d898bbf36014cb3992055
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Release files / inferlingo-0.1.1-py3-none-any.whl

Download URL inferlingo-0.1.1-py3-none-any.whl
Size 37.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0259de9d94cb27564f3bb3578019c9eac34d532bac4e449fe2edd09ec37869d6
BLAKE2b-256 checksum
How to use checksums
20e66152b2140df5a14131008edca49078e5087b673a23d6c355bc062e8f355e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Security for inferlingo 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page