Package-level declarations

Types

Link copied to clipboard
abstract class AbstractTermificator(val scope: Scope) : Termificator

Skeletal implementation of Termificator, providing the type-dispatch machinery (termify) and a library of protected handleXxxAsYyy conversion functions that subclasses register (via handleType) to implement Termificator.default/Termificator.legacy and any other custom conversion policy.

Link copied to clipboard

Root mixin of the Prolog DSL scope hierarchy: extends Scope (so every term-building factory method it exposes is directly available) with a termificator and the toTerm extension it powers, letting every other mixin in the hierarchy (see MinimalLogicProgrammingScope, LogicProgrammingScopeWithOperators, ...) accept a plain Any wherever a Term is expected.

Link copied to clipboard

Adds infix/operator builders mirroring Prolog's own arithmetic, relational and logical operators, so that Structs (and Rules, for if/impliedBy) can be written as Kotlin expressions instead of nested BaseLogicProgrammingScope.toTerm/structOf calls:

Adds one builder per predicate of (roughly) the ISO Prolog standard library — plus a handful of well-known de-facto standard ones (assert, findall, member, ...) — so common goals can be written as ordinary Kotlin function/property calls instead of structOf("member", item, list)-style boilerplate:

Link copied to clipboard

Adds builders and accessors for Substitutions, so a Var to value pair can be written directly ("X" to 1, mirroring Kotlin's own kotlin.to for Pairs) and a built Substitution can be queried by a plain Var-like value instead of a variable name/Var pair:

Link copied to clipboard

Adds fresh-variable creation to the scope by mixing in VariablesProvider (delegating to variablesProvider), so idiomatic single-letter variables (A, B, C, ... from VariablesProvider) and by-delegated ones (val x by variablesProvider) are available directly inside a logicProgramming block, alongside every other BaseLogicProgrammingScope mixin.

Link copied to clipboard

Core term/clause-building mixin of the Prolog DSL: overloads it.unibo.tuprolog.core.Scope's own structOf/tupleOf/logicListOf/... factory methods to accept plain Any arguments (auto-toTerm-ed), adds the "calling a String" shorthand for building Structs, and adds scoped clause builders (rule/fact/directive/clause) that isolate each clause's variables in their own newScope.

Link copied to clipboard
interface Termificator

Converts arbitrary Kotlin values into Prolog Terms, so that DSL builders (see MinimalLogicProgrammingScope and friends) can accept a plain Any — a String, a Number, a Boolean, a List, ... — wherever a Term is expected, instead of forcing callers to spell out atomOf/intOf/logicListOf everywhere.

Functions

Link copied to clipboard
fun <R> logicProgramming(function: LogicProgrammingScope.() -> R): R

Entry point of the Prolog term-construction DSL: runs function with a fresh, empty LogicProgrammingScope as its receiver, and returns whatever function returns. This is the idiomatic way of building it.unibo.tuprolog.core.Terms, it.unibo.tuprolog.core.Clauses and the like through the DSL, instead of instantiating a LogicProgrammingScope by hand:

Link copied to clipboard
fun <R> lp(function: LogicProgrammingScope.() -> R): R

Shorthand for logicProgramming.

Link copied to clipboard
fun <R> prolog(function: LogicProgrammingScope.() -> R): R

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