ReteTree

interface ReteTree

A RETE-style discrimination network storing Clauses and indexing them for fast retrieval by unification.

Clauses are first split into directives and rules (see Directive/Rule), then, within each of those two families, indexed by their head's functor, then by arity, then recursively by the shape of their first argument (variable, atomic, numeric or compound — see the it.unibo.tuprolog.collections.rete.custom.leaf package), narrowing the set of clauses that get has to actually attempt to unify against a query. This is the storage engine backing both it.unibo.tuprolog.collections.ClauseQueue (ordered) and it.unibo.tuprolog.collections.ClauseMultiSet (unordered), and therefore, transitively, Theory itself.

See also

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
abstract val clauses: Sequence<Clause>

Returns all the Clause this ReteTree is storing

Link copied to clipboard

Returns all the Directives this ReteTree is storing.

Link copied to clipboard
abstract val isEmpty: Boolean

Whether this ReteTree stores no clause at all.

Link copied to clipboard
abstract val isOrdered: Boolean

Whether this ReteTree preserves insertion order among clauses of the same family (functor/arity/shape); an unordered tree may return matching clauses in any order, but does not support assertA.

Link copied to clipboard
abstract val rules: Sequence<Rule>

Returns all the Rules this ReteTree is storing.

Link copied to clipboard
abstract val size: Int

Returns the number of Clause stored in this tree

Link copied to clipboard
abstract val unificator: Unificator

The Unificator used to match Clauses stored in this tree against query clauses.

Functions

Link copied to clipboard
abstract fun assertA(clause: Clause)

Inserts the given clause before all other clauses of its own family (same directive-vs-rule status, functor and arity) currently stored in this tree, mutating it in place.

Link copied to clipboard
abstract fun assertZ(clause: Clause)

Inserts the given clause after all other clauses of its own family currently stored in this tree, mutating it in place.

Link copied to clipboard
open operator fun contains(clause: Clause): Boolean

Tells if the given Clause is stored in this ReteTree

Link copied to clipboard
abstract fun deepCopy(): ReteTree

Produces a fully instantiated complete copy of this ReteTree

Link copied to clipboard
abstract fun get(clause: Clause): Sequence<Clause>

Reads all the clauses matching the given Clause

Link copied to clipboard
abstract fun retractAll(clause: Clause): Sequence<Clause>

Retracts all the matching clauses from this ReteTree

Link copied to clipboard
abstract fun retractFirst(clause: Clause): Sequence<Clause>

Retract the first occurrence of the given Clause from this ReteTree. The meaning of "first" may vary between implementations

Link copied to clipboard
abstract fun retractOnly(clause: Clause, limit: Int): Sequence<Clause>

Retracts only the given number of matching clauses from this ReteTree