Package-level declarations

Types

Link copied to clipboard
class LogicProgrammingScopeImpl(val scope: Scope, val termificator: Termificator, val variablesProvider: VariablesProvider, val unificator: Unificator, val theoryFactory: TheoryFactory) : LogicProgrammingScope, VariablesProvider, Unificator, TheoryFactory

Default, stateless implementation of LogicProgrammingScope: forwards VariablesProvider, Unificator and TheoryFactory operations to variablesProvider, unificator and theoryFactory respectively (via Kotlin delegation), and every other scope operation up its supertypes' default implementations. Obtained through LogicProgrammingScope.of/LogicProgrammingScope.empty rather than constructed directly in typical usage.

Link copied to clipboard

Adds theory/clause-database-building sugar to LogicProgrammingScopeWithUnificator: implements TheoryFactory itself (forwarding to theoryFactory, e.g. via TheoryFactory by theoryFactory as LogicProgrammingScopeImpl does) so a it.unibo.tuprolog.theory.Theory/MutableTheory can be built directly from this scope, and adds theory/mutableTheory overloads accepting one DSL lambda per clause (rather than an already-built Clause) plus theoryOf/mutableTheoryOf overloads that concatenate several Iterable/Sequences of clauses into one:

Functions

Link copied to clipboard
fun <R> logicProgramming(unificator: Unificator = LogicProgrammingScope.defaultUnificator, function: LogicProgrammingScope.() -> R): R

Entry point of :dsl-theory's Prolog DSL: like :dsl-unify's it.unibo.tuprolog.dsl.unify.logicProgramming, but the receiver is a LogicProgrammingScope — so it.unibo.tuprolog.theory.Theory/it.unibo.tuprolog.theory.MutableTheory-building sugar (LogicProgrammingScopeWithTheories.theory, LogicProgrammingScopeWithTheories.mutableTheory) is available inside function alongside the rest of the DSL — using unificator (an empty-context it.unibo.tuprolog.unify.Unificator.strict strategy by default) both for unification and (via an IndexedTheoryFactory built on it) for the theories it builds:

Link copied to clipboard
fun <R> lp(unificator: Unificator = LogicProgrammingScope.defaultUnificator, function: LogicProgrammingScope.() -> R): R

Shorthand for logicProgramming.

Link copied to clipboard
fun <R> prolog(unificator: Unificator = LogicProgrammingScope.defaultUnificator, function: LogicProgrammingScope.() -> R): R

Deprecated alias of logicProgramming/lp; kept only for backwards compatibility.

Link copied to clipboard
fun LogicProgrammingScope.withTheories(unificator: Unificator = LogicProgrammingScope.defaultUnificator): LogicProgrammingScope

Upgrades this :dsl-core scope into a :dsl-theory LogicProgrammingScope adding unification and theory-building support to it, reusing its underlying it.unibo.tuprolog.core.Scope, it.unibo.tuprolog.dsl.Termificator and it.unibo.tuprolog.core.VariablesProvider (so it.unibo.tuprolog.core.Vars and terms already built through this scope remain valid and usable in the returned one) and equipping it with unificator (LogicProgrammingScope.defaultUnificator unless stated otherwise) as its unification strategy and an IndexedTheoryFactory built on unificator as its TheoryFactory. Useful when a plain :dsl-core scope is already at hand (e.g. received as a parameter) and unification/theory-building are only needed from that point on.

fun LogicProgrammingScope.withTheories(unificator: Unificator = LogicProgrammingScope.defaultUnificator, theoryFactory: TheoryFactory = IndexedTheoryFactory(unificator)): LogicProgrammingScope

Upgrades this :dsl-unify scope into a :dsl-theory LogicProgrammingScope adding theory-building support to it, reusing its underlying it.unibo.tuprolog.core.Scope, it.unibo.tuprolog.dsl.Termificator and it.unibo.tuprolog.core.VariablesProvider, and equipping it with unificator (LogicProgrammingScope.defaultUnificator unless stated otherwise — not necessarily this scope's own it.unibo.tuprolog.unify.UnificationAware.unificator, so pass it explicitly to preserve it) and theoryFactory (an IndexedTheoryFactory over unificator by default). Useful when a :dsl-unify scope is already at hand and theory-building is only needed from that point on.