ClausePartitioner

class ClausePartitioner(val unificator: Unificator, source: Iterable<Clause>, staticByDefault: Boolean = true) : ClausePartition, DirectiveSelector

The concrete ClausePartition/DirectiveSelector implementation, lazily partitioning source's clauses on first access to any of ClausePartition's properties (and caching the result thereafter). Plain Rules/Facts are routed to dynamicClauses or staticClauses depending on whether their signature was declared dynamic/1 or static/1 by a directive, falling back to staticByDefault when neither was declared.

See also

Constructors

Link copied to clipboard
constructor(unificator: Unificator, source: Iterable<Clause>, staticByDefault: Boolean = true)

Properties

Link copied to clipboard
open override val dynamicClauses: Theory

Clauses bound for the dynamic knowledge base (see it.unibo.tuprolog.solve.ExecutionContextAware.dynamicKb).

Link copied to clipboard
open override val flagStore: FlagStore

Flags set via :- set_flag(Name, Value)/:- set_prolog_flag(Name, Value) directives.

Link copied to clipboard
open override val includes: List<Atom>

Names of other theories to be loaded, declared via :- include(Name)/:- load(Name) directives.

Link copied to clipboard
open override val initialGoals: List<Struct>

Goals to be solved once, at load time, declared via :- initialization(Goal)/:- solve(Goal) directives.

Link copied to clipboard
open override val operators: OperatorSet

Operators declared via :- op(Priority, Specifier, Name) directives.

Link copied to clipboard
open override val patterns: List<Term>

The directive-body patterns recognized by this listener, tried in order.

Link copied to clipboard
open override val staticClauses: Theory

Clauses bound for the static knowledge base (see it.unibo.tuprolog.solve.ExecutionContextAware.staticKb).

Link copied to clipboard
open override val unificator: Unificator

The Unificator used to match a directive's body against patterns.

Functions

Link copied to clipboard
open override fun listen(clause: Clause)

Dispatches clause to onDirective/onFact/onRule/onClause, depending on its concrete kind.

Link copied to clipboard
open fun listenDirective(directive: Directive)

Tries to unify directive's body against each of patterns, in order; on the first match, delegates to listenDirectiveMatchingPattern, otherwise falls back to ClauseListener.onDirective.

Link copied to clipboard
open override fun listenDirectiveMatchingPattern(directive: Directive, pattern: Term, unifier: Substitution.Unifier)

Invoked by listenDirective on a match; by default just forwards to onDirectiveMatchingPattern.

Link copied to clipboard
open override fun onClause(clause: Clause)

Invoked when listening any Clause that is neither a Directive, Fact, nor Rule.

Link copied to clipboard
open override fun onDirective(directive: Directive)

Invoked when listening a Directive (a :- Goal clause).

Link copied to clipboard
open override fun onDirectiveMatchingPattern(directive: Directive, pattern: Term, unifier: Substitution.Unifier)

Invoked when a directive's body unifies with one of patterns, via unifier.

Link copied to clipboard
open override fun onDynamic(directive: Directive, indicator: Indicator)

Invoked on a dynamic(indicator) directive.

Link copied to clipboard
open override fun onFact(fact: Fact)

Invoked when listening a Fact (a clause with an empty body).

Link copied to clipboard
open override fun onLoad(directive: Directive, goal: Term)

Invoked on an include(goal)/load(goal) directive.

Link copied to clipboard
open override fun onOperator(directive: Directive, priority: Term, specifier: Term, name: Term)

Invoked on an op(priority, specifier, name) directive.

Link copied to clipboard
open override fun onRule(rule: Rule)

Invoked when listening a Rule (a clause with a non-empty body, other than a Directive).

Link copied to clipboard
open override fun onSetFlag(directive: Directive, name: Term, value: Term)

Invoked on a set_flag(name, value)/set_prolog_flag(name, value) directive.

Link copied to clipboard
open override fun onSolve(directive: Directive, goal: Term)

Invoked on an initialization(goal)/solve(goal) directive.

Link copied to clipboard
open override fun onStatic(directive: Directive, indicator: Indicator)

Invoked on a static(indicator) directive.

Link copied to clipboard
open operator fun plus(other: ClausePartition): ClausePartition

Merges this partition with other, concatenating/summing each corresponding component.

Link copied to clipboard

Null-safe ClausePartition.plus: merges two possibly-null partitions, returning null only if both are.