Runtime

Represents a group of Library objects constituting the runtime a logic solver may leverage upon, keyed by Library.alias (as the underlying Map<String, Library> reflects).

A it.unibo.tuprolog.solve.Solver loads exactly one Runtime (see it.unibo.tuprolog.solve.SolverFactory.defaultRuntime); Runtime is what lets several independently-authored Library instances (e.g. :io-lib, :oop-lib, a standard-library Library) coexist within a single solver, aliasing being the mechanism that resolves clashing predicate indicators without either library needing to know about the other.

Construct one via the companion's empty/of factories, or combine Library/Runtime instances with plus.

See also

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
abstract val aliases: Set<String>

The Library.alias of every library in this runtime; same as this map's keys.

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

Rules, facts, or directories to be loaded by a solver when the library is used

Link copied to clipboard
Link copied to clipboard

LogicFunctions to be loaded by a solver when the library is used, indexed by their Signature in the eyes of the solver

Link copied to clipboard
abstract val keys: Set<String>
Link copied to clipboard
abstract val libraries: Set<Library>

All libraries composing this library group

Link copied to clipboard
abstract val operators: OperatorSet

Operators to be loaded by a solver when the library is used

Link copied to clipboard

Primitives to be loaded by a solver when the library is used, indexed by their Signature in the eyes of the solver

Link copied to clipboard

The Signature of every Rule (i.e. non-fact clause) among clauses, deduplicated.

Link copied to clipboard
expect abstract val size: Int
Link copied to clipboard
abstract val values: Collection<Library>

Functions

Link copied to clipboard
abstract fun asTheory(unificator: Unificator): Theory

Merges every library's Pluggable.clauses into a single indexed Theory, using unificator.

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

Checks whether this library contains the definition of provided operator

open operator fun contains(signature: Signature): Boolean

Checks whether this library contains the provided signature.

Link copied to clipboard
abstract fun containsKey(key: String): Boolean
Link copied to clipboard
abstract fun containsValue(value: Library): Boolean
Link copied to clipboard
abstract operator fun get(key: String): Library?
Link copied to clipboard

Shorthand for this Runtime's declared Runtime.operators, as a Sequence.

Link copied to clipboard
open fun hasFunction(signature: Signature): Boolean

Checks whether this library has a LogicFunction with provided signature

Link copied to clipboard
open fun hasPrimitive(signature: Signature): Boolean

Checks whether this library has a Primitive with provided signature

Link copied to clipboard
open fun hasProtected(signature: Signature): Boolean

Checks whether the provided signature, is protected in this library

Link copied to clipboard
abstract fun hasRule(signature: Signature): Boolean

Checks whether this library has a Rule with provided signature

Link copied to clipboard
expect abstract fun isEmpty(): Boolean
Link copied to clipboard
abstract operator fun minus(library: Library): Runtime

Removes the library from this library group.

abstract operator fun minus(alias: String): Runtime

Removes the library aliased alias from this library group.

abstract operator fun minus(aliases: Iterable<String>): Runtime

Same as minus for a single alias, but removes every library aliased by any of aliases.

Link copied to clipboard
abstract operator fun plus(other: Library): Runtime

Returns a new Runtime with other added to libraries.

abstract operator fun plus(runtime: Runtime): Runtime

Adds all libraries in provided libraryGroup to this libraryGroup.

Link copied to clipboard
abstract fun update(library: Library): Runtime

Updates an already contained library, with given library.