Skip to main content
Ting Reasoner

Read the Ting Reasoner HTML manual

Ting Reasoner

Reason from facts. Keep the explanation.

Ting Reasoner is a deterministic symbolic reasoning and decision library written entirely in Python. Define the knowledge your application needs, provide the facts, and inspect both the conclusions and the evidence behind them.

100% Python · Zero runtime dependencies · Python 3.11+ · Offline HTML manual

Current release: 0.8.5 (pre-1.0)

Ting combines typed facts, declarative rules, explainable decisions, changing observations, and independent-session multiprocessing in one standalone package. Its compiler and reasoning runtime are pure Python. Installing Ting requires no C compiler, native extension, Cython, NumPy, model download, or external service.

Pure Python, measured performance

Ting combines indexed matching, retained reasoning state and prepared rule checks in pure Python. Against Ting 0.8.4, matching ran 1.2–4.7× as fast in five measured workloads. Total time, including engine construction, fact loading and inference, fell about 4–29%. Results and matching counters were identical; peak traced memory was effectively unchanged.

Measurements used Python 3.12.14 on Linux and medians of six trials per release, including first-use preparation. Cases covered wide bindings, scalar conditions, constant membership filters, composite joins and range joins. Separate small input-update controls had mixed results, so gains depend on the workload. Structured execution budgets retain their existing evaluation path. Reproducible benchmarks and full measurements are included in docs/performance.json.

What Ting provides

Capability What you can do
Typed, immutable facts Define named schemas with exact scalar types, nullable fields, type unions, bytes, and fixed-shape array values. Duplicate input facts reuse their handle within a session.
Declarative rules and joins Match facts, bind values, compare fields across patterns, and apply equality, membership, ordering, and range conditions. Set rule priority with salience.
Boolean and quantified conditions Combine all_of, any_of, not_, test, exists, and for_all. Negation and universal conditions follow explicit stratification rules.
Deterministic forward reasoning Derive additional facts, emit conclusions, and follow recursive rule chains in a defined order. Repeated runs resume within documented firing and work limits.
Mutable sessions with immutable views Declare, replace, and retract input facts; inspect handles, facts, conclusions, traces, and snapshots; reset a session for another case.
Atomic transactions Stage several input changes and commit them together. Expected epochs detect stale transactions; commit receipts resolve staged handles and describe the committed changes.
Explanations and provenance Inspect the rules, bindings, and supporting facts behind a conclusion or derived fact. Retained source information adds rule locations, schema origins, and fixed-knowledge origins.
Fixed program knowledge Include named seed facts in Python or readable source. Seeds survive session resets and are protected against direct and transactional modification.
Classifications and inheritance Declare named classifications over typed records, including multiple parents, and reason over their inherited memberships.
Support maintenance Keep grounded facts and conclusions across supported positive-rule input updates. Alternative justifications survive; losing the final valid support removes its consequences, including unsupported cycles. Inspect support-change reports and bounded fallback behavior.
Explicit decision assessment Evaluate named candidates against hard requirements. Distinguish supported, refuted, unknown, and conflicting evidence; preserve ties; select an option only when the decision policy permits it. Use decide() for a fresh case or assess_decision() for an existing session.
Portable named decisions Define decision requests in Python or .ting source, save them in compiled programs or libraries, and retrieve or selectively import them by name.
Readable rule source Parse, format, analyze, and compile UTF-8 .ting modules. Use explicit imports, typed conclusions, named knowledge, classifications, decisions, and embedded tests. Diagnostics identify source locations when available.
Verified compiled programs Save and load .tingir artifacts with format, type, and structural validation. Reuse a verified program across independent engines. Load supported historical binary .ting files with the dedicated loader.
Compiled knowledge libraries Export reusable schemas, rules, classifications, seeds, conclusions, and decisions. CompiledCatalog links selected exports with their declared dependencies from explicitly supplied files.
Fixed-shape multidimensional values Store immutable bool, signed i64, and finite f64 arrays with exact shape and value identity. Match and pass whole arrays through rules without NumPy.
Bounded work and observable costs Limit candidate rows, constraint evaluations, activations, and firings with ExecutionBudget. Separate policies bound authoring, loading, explanations, decisions, support maintenance, and batch work. Inspect matching, optimization, and store metrics.
Matching and storage optimizations Use indexed lookups, shared filtering, composite joins, range pruning, retained activations, and incremental matching. Inspect physical storage counts and explicitly compact tombstones while preserving public state.
Independent cases in parallel Use run_batch() or ordered iter_batch() streams. Choose inline execution, Ting-owned processes, or a supplied executor; control chunking, in-flight work, shared submission permits, and cooperative cancellation. Results retain their explanations.
Command-line tools and project history Use ting-build for readable-source checks and compilation, or the separate RuleSpec JSON builder. Validate, test, inspect, and verify artifacts; checkpoint, compare, export, and restore RuleSpec revisions. Use ting-reasoner or ting-console to inspect and exercise reasoning sessions interactively or through scripts.
Complete offline documentation Read the searchable HTML manual for beginner-friendly Python explanations, complete examples, supported behavior, error handling, and the full public API reference.

Install and verify

Use Python 3.11 or later. Run installation commands in a terminal, using the Python environment that will run your application.

Install the release from PyPI:

python -m pip install ting-reasoner==0.8.5

To install a downloaded wheel, run this from the folder containing the file:

python -m pip install ting_reasoner-0.8.5-py3-none-any.whl

To install from a source bundle, extract it, open a terminal in the folder containing pyproject.toml, and run:

python -m pip install .

Source installation may download Python build tools. These are separate from Ting's zero-dependency runtime.

After installation, check the installed package:

python -m ting_reasoner.selftest

The self-test prints a JSON report. Look for "ok": true. It checks compiled programs, explanations, decisions, changing inputs, recursive support handling, and agreement between inline execution and spawned workers. Run it from a terminal because it starts worker processes.

Open the HTML manual

Ting provides one HTML manual. Identical copies are included with the source bundle and the installed package so you can read it before or after installing Ting. It works offline and includes search, code-copy buttons, complete examples, and an API reference.

Distribution Manual location
Extracted source ZIP or source distribution docs/index.html inside the extracted project folder
Installed Python package docs/index.html inside the installed ting_reasoner package directory
Separate downloadable manual ting-reasoner-library.html

For the source bundle, open docs/index.html in your browser. To locate and open the installed copy, save the following as open_ting_manual.py and run python open_ting_manual.py:

from pathlib import Path
import webbrowser
import ting_reasoner

manual = Path(ting_reasoner.__file__).resolve().parent / "docs" / "index.html"
print(manual)
webbrowser.open(manual.as_uri())

The printed path also lets you open the file manually. Start with Install and verify, Understand the Python calls, and Your first reasoner. Later sections cover changing inputs, source files, reusable knowledge, decisions, explanations, arrays, and parallel cases.

A complete Python example

This example requests an inspection when an equipment reading reaches 70. It then replaces the observation and checks that the obsolete conclusion is removed.

Save it as inspection_example.py and run python inspection_example.py in the environment where you installed Ting.

from ting_reasoner import (
    Engine, FactSchema, KnowledgeBase, MaintenancePolicy,
    Rule, bind, emit, ge, use,
)

Reading = FactSchema("reading", device=str, temperature=int)

inspection_rule = Rule(
    "inspect_hot_equipment",
    when=(Reading.pattern(device=bind("device"), temperature=ge(70)),),
    then=(emit("inspection_needed", device=use("device")),),
)

knowledge = KnowledgeBase(rules=(inspection_rule,))
engine = Engine(knowledge, maintenance=MaintenancePolicy())

handle = engine.declare(Reading(device="pump_a", temperature=85))
engine.run()

conclusion = engine.conclusions[0]
print(conclusion["device"])                   # pump_a
print(engine.explain(conclusion)[0].rule)     # default.inspect_hot_equipment@1

engine.replace(handle, Reading(device="pump_a", temperature=40))
engine.run()
assert engine.conclusions == ()

FactSchema defines the accepted fields and types. bind() names a matched value, ge(70) means greater than or equal to 70, and use() passes the bound value into the conclusion. run() applies the rules. explain() identifies the supporting rule and facts. Your application decides how to act on the results.

MaintenancePolicy() enables support retention for eligible positive rules. Call run() after changing observations to discover any new consequences. The manual explains alternative supports, policy limits, and recomputation for rules containing negation or quantified conditions.

Scope and execution behavior

Ting is a symbolic rule system. It derives conclusions from explicit knowledge and observations; it does not train a neural model or require an AI service.

The decision API evaluates hard requirements over an explicit candidate list. It preserves unknowns, conflicts, and multiple feasible choices. Preference ranking, aggregate operators, temporal reasoning, backward chaining, and entity reference fields are outside the current API. Array support concerns immutable whole values; broadcasting, slicing, and numerical reductions are unavailable.

Batch multiprocessing runs independent sessions. A single live Engine is not split across processes. Inline execution is the default; processes are created only when explicitly requested. Process-launching calls belong inside an if __name__ == "__main__": guard in a Python file. Logical work limits do not represent exact memory ceilings or wall-clock deadlines.

License and application scope

Ting Reasoner is distributed under the MIT License; the complete license is in LICENSE. The project's supported application scope excludes banking and financial use. License and project distribution policies are described in LICENSING.md; this application policy is separate from the MIT license text.

Metadata

Release files for ting-reasoner 0.8.5

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

Source distribution (sdist)

Source distribution for ting-reasoner 0.8.5
File Size Uploaded Provenance Actions
ting_reasoner-0.8.5.tar.gz 736.6 kB Without provenance Details for ting_reasoner-0.8.5.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ting-reasoner 0.8.5
File Interpreter ABI Platform Actions
ting_reasoner-0.8.5-py3-none-any.whl Python 3 none any Details for ting_reasoner-0.8.5-py3-none-any.whl

Total release size: 1.0 MB

Release files / ting_reasoner-0.8.5.tar.gz

Download URL ting_reasoner-0.8.5.tar.gz
Size 736.6 kB
Tags Source
SHA-256 checksum
How to use checksums
07e6a2123995d31eeaaaf9f8df6f8c734bb5fe05377b9d52a7eb6b549b3ebc29
BLAKE2b-256 checksum
How to use checksums
d0a55007bb6655ff1d05306c43acb6cb50ba6198452480abd7a1a6c92e8de1cc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/0.0.0 importlib_metadata/4.0.1 pkginfo/1.12.1.2 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.16

Release files / ting_reasoner-0.8.5-py3-none-any.whl

Download URL ting_reasoner-0.8.5-py3-none-any.whl
Size 291.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d00a7c39b82a9284703af7fc56c362c64851a24524baa5128f9fc0f2c71bdb81
BLAKE2b-256 checksum
How to use checksums
1e7674f774499551399269a47044ecada657e975275c7314a007666251df2c34
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/0.0.0 importlib_metadata/4.0.1 pkginfo/1.12.1.2 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.16

Security for ting-reasoner 0.8.5

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.

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