ClauseCollection

A general-purpose, immutable container of Clauses, matched by unification rather than by equality: this is the low-level storage abstraction that a it.unibo.tuprolog.theory.Theory builds its Prolog-flavoured API (assertA/assertZ/retract) on top of. Every mutating operation (add, addAll, retrieve, retrieveAll) returns a new collection, leaving this untouched — see MutableClauseCollection for the in-place counterpart.

The default implementations returned by this interface's factory methods (and by ClauseQueue/ ClauseMultiSet) are backed by a RETE-style discrimination tree (see it.unibo.tuprolog.collections.rete.custom.ReteTree) indexed by directive-vs-rule, functor, arity and first-argument shape, so get/retrieve-like lookups only re-check clauses that could plausibly unify with the query, rather than scanning the whole collection.

See also

Inheritors

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

Only the clauses in this collection that are Directives.

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

Only the clauses in this collection that are Rules.

Link copied to clipboard
abstract val size: Int

Computes the size of the ClauseCollection

Link copied to clipboard
abstract val unificator: Unificator

The Unificator used to match clauses against each other in this collection.

Functions

Link copied to clipboard
abstract fun add(clause: Clause): ClauseCollection

Gives a freshly produced ClauseCollection including the given Clause and the content of this one

Link copied to clipboard
abstract fun addAll(clauses: Iterable<Clause>): ClauseCollection

Gives a freshly produced ClauseCollection including all the given Clause and the content of this one

Link copied to clipboard
abstract operator fun contains(element: Clause): Boolean

Tells if the ClauseCollection contains a clause unifying against the given element

Link copied to clipboard
abstract fun containsAll(elements: Iterable<Clause>): Boolean

Tells if, for each of the given elements, the ClauseCollection contains a unifying clause

Link copied to clipboard
abstract fun isEmpty(): Boolean

Tells if the ClauseCollection contains any Clause

Link copied to clipboard
abstract fun isNonEmpty(): Boolean

Tells if the ClauseCollection contains at least one Clause; the negation of isEmpty.

Link copied to clipboard
abstract operator override fun iterator(): Iterator<Clause>

Iterates over all the clauses in this collection, in an order that depends on the concrete implementation (e.g. insertion order for a ClauseQueue, unspecified for a ClauseMultiSet).

Link copied to clipboard
abstract fun retrieve(clause: Clause): RetrieveResult<out ClauseCollection>

Produces a RetrieveResult as a consequence of the attempt at deleting the given Clause from this ClauseCollection

Link copied to clipboard

Produces a RetrieveResult as a consequence of the attempt at deleting all the given Clause from this ClauseCollection