# What Reasoning Engines Are Supported by Semantica? A Complete Guide

> Discover the four reasoning engines Semantica supports: a built-in engine, a provenance wrapper, Datalog style, and custom plug-ins. Explore Semantica's full capabilities.

- Repository: [Semantica /semantica](https://github.com/semantica-agi/semantica)
- Tags: how-to-guide
- Published: 2026-09-06

---

**Semantica supports four reasoning engines: a built-in forward/backward-chaining rule engine, a provenance-enabled wrapper, Datalog-style reasoning via the rule syntax, and custom engine plug-ins.**

Semantica is an open-source AGI framework that provides a unified **reasoning façade** for knowledge graph operations. Understanding the available reasoning engines helps developers choose the right inference approach for their use case. This guide examines each engine based on the actual implementation in the [semantica-agi/semantica](https://github.com/semantica-agi/semantica) repository.

## Built-in Rule Engine (Reasoner)

The **core reasoning engine** in Semantica is the `Reasoner` class located in [`semantica/reasoning/reasoner.py`](https://github.com/semantica-agi/semantica/blob/main/semantica/reasoning/reasoner.py). This engine implements **forward-chaining** inference by default, with support for **backward-chaining proof searches** when needed.

### Key Capabilities

- **IF-THEN rule definitions** with pattern matching (e.g., `Person(?x) AND LivesIn(?x, ?city) THEN Resident(?x, ?city)`)
- **Actions**: assert facts, retract facts, emit events, and call external functions
- **Provenance tracking** when enabled via wrapper

The rule parser and pattern matcher are implemented in `Reasoner._parse_rule_definition` and `Reasoner._match_pattern` respectively. These methods enable the **Datalog-style syntax** that makes the engine accessible to users familiar with logic programming.

## Provenance-Enabled Wrapper (ReasoningEngineWithProvenance)

For applications requiring **audit trails and explainability**, Semantica provides `ReasoningEngineWithProvenance` in [`semantica/reasoning/reasoning_provenance.py`](https://github.com/semantica-agi/semantica/blob/main/semantica/reasoning/reasoning_provenance.py).

This thin wrapper records:

- Activity timestamps
- Confidence scores
- Inference metadata

Toggle provenance tracking via the `provenance` flag in the constructor:

```python
from semantica.reasoning.reasoning_provenance import ReasoningEngineWithProvenance

# Enable provenance tracking

engine = ReasoningEngineWithProvenance(
    reasoner=custom_reasoner,
    provenance=True
)

```

## Datalog-Style Reasoning

While there is **no separate `DatalogReasoner` class**, the `Reasoner` implements a **Datalog-like pattern-matching language** through its rule syntax. Users get Datalog-style reasoning capabilities out of the box without additional dependencies.

Example rule structure:

```

Premise1(?var) AND Premise2(?var, ?const) THEN Conclusion(?var)

```

This pattern-matching approach is handled internally by `Reasoner._match_pattern` in [`semantica/reasoning/reasoner.py`](https://github.com/semantica-agi/semantica/blob/main/semantica/reasoning/reasoner.py).

## Custom Engine Plug-ins

Semantica's architecture supports **pluggable reasoning engines** through two extension points:

1. **Action interface**: Supply any callable conforming to the `Action` protocol (e.g., `CallAction`)
2. **Custom Reasoner subclasses**: Pass to `ReasoningEngineWithProvenance` for provenance-aware operation

The wrapper's constructor accepts `**config` kwargs that custom engines can consume, enabling seamless integration of:

- LLM-based reasoners
- Domain-specific solvers
- External inference systems

Example integration pattern:

```python
from semantica.reasoning.reasoning_provenance import ReasoningEngineWithProvenance

class MyLLMReasoner:
    def infer(self, facts, rules):
        # Custom LLM-based inference

        pass

# Wrap custom engine with provenance

engine = ReasoningEngineWithProvenance(
    reasoner=MyLLMReasoner(),
    llm_model="gpt-4",  # consumed via **config

    provenance=True
)

```

## Summary

- **Built-in Rule Engine (`Reasoner`)**: Forward and backward chaining with IF-THEN rules — located in [`semantica/reasoning/reasoner.py`](https://github.com/semantica-agi/semantica/blob/main/semantica/reasoning/reasoner.py)
- **Provenance Wrapper (`ReasoningEngineWithProvenance`)**: Adds inference tracking via `provenance` flag — located in [`semantica/reasoning/reasoning_provenance.py`](https://github.com/semantica-agi/semantica/blob/main/semantica/reasoning/reasoning_provenance.py)
- **Datalog-style syntax**: Native pattern-matching language through `Reasoner._parse_rule_definition` and `_match_pattern`
- **Custom plug-ins**: Extend via `Action` interface or `Reasoner` subclass with full provenance support

## Frequently Asked Questions

### Does Semantica require an external reasoning engine?

No. Semantica includes a **fully functional built-in rule engine** (`Reasoner`) that handles forward-chaining, backward-chaining, and Datalog-style pattern matching without external dependencies.

### How do I enable provenance tracking in Semantica?

Pass `provenance=True` to `ReasoningEngineWithProvenance` when wrapping your reasoner. This records timestamps, confidence scores, and metadata for every inference step without modifying the underlying engine.

### Can I use an LLM as a reasoning engine in Semantica?

Yes. Implement the `Action` interface or subclass `Reasoner`, then pass your custom engine to `ReasoningEngineWithProvenance`. The `**config` kwargs allow you to pass model parameters (e.g., `llm_model="gpt-4"`) that your implementation can consume.

### What is the difference between forward and backward chaining in Semantica's Reasoner?

**Forward chaining** starts from known facts and applies rules to derive new conclusions. **Backward chaining** starts from a goal and works backwards to find supporting facts. The `Reasoner` class in [`semantica/reasoning/reasoner.py`](https://github.com/semantica-agi/semantica/blob/main/semantica/reasoning/reasoner.py) supports both modes, with forward chaining as the default for rule execution.