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.3 (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 demonstrates how much a Python reasoner can gain by retaining useful work. For supported sessions, small input changes reuse existing reasoning state and update affected dependencies and lookup entries. Unchanged facts and valid explanations stay available.
Repeated sparse updates measured 6.8–8.7 times faster than Ting 0.8.1 across four benchmark cases, with identical final reasoning snapshots. These gains come from Ting's Python implementation and algorithms.
| Input-update workload | Measured speedup |
|---|---|
| Remove one of multiple supporting inputs | 7.4× |
| Insert new inputs | 6.8× |
| Replace inputs | 8.7× |
| Replace inputs used by a joined rule | 7.9× |
The comparison used Python 3.12.14 on Linux, 512 devices, 16 updates per case,
and the median of five runs. Both releases used MaintenancePolicy(). Timing
includes each input change and subsequent run(), including the first update
that builds the support cache; initial session setup is excluded. Compared
snapshots include facts, handles, conclusions, explanations, and trace.
Caching has a cost: retained session memory increased about 61–66%, approximately
1.2 MB in these cases, while peak traced allocations increased about 1–4%. The
first maintained update can take longer while the cache is built. These results
apply to the measured repeated-update workloads; measure your application's
complete workload when choosing its settings. The source bundle contains the
benchmark and full measurements in benchmarks/input_updates.py and
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.3
To install a downloaded wheel, run this from the folder containing the file:
python -m pip install ting_reasoner-0.8.3-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.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ting_reasoner-0.8.3.tar.gz | 693.5 kB | Without provenance | Details for ting_reasoner-0.8.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ting_reasoner-0.8.3-py3-none-any.whl | Python 3 | none | any | Details for ting_reasoner-0.8.3-py3-none-any.whl |
Total release size: 982.6 kB
Release files / ting_reasoner-0.8.3.tar.gz
| Download URL | ting_reasoner-0.8.3.tar.gz |
|---|---|
| Size | 693.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
822010d140ede03fc1832a18c73da5c411fa02d6ea3bd78f5462be61233f4bee
|
|
BLAKE2b-256 checksum How to use checksums |
918320c2793ef89ac61eb024a9a7dd82908c099b011b5ffa35435afd9b45dc39
|
| 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.3-py3-none-any.whl
| Download URL | ting_reasoner-0.8.3-py3-none-any.whl |
|---|---|
| Size | 289.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5c273327f31f06e65ff015dc7ab8ddc38bace4a4c1aae093bedc4d0e2a70dc0c
|
|
BLAKE2b-256 checksum How to use checksums |
a17f0959a8f77823a99cb983e5b3f2e16e0da8d3b104d0257c6415a23026b840
|
| 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.3
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.