MinimalLogicProgrammingScope

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.

Calling a String with one or more arguments builds a Struct with that string as functor:

logicProgramming {
"parent"("abraham", "isaac") // Struct: parent(abraham, isaac)
"ancestor"("X", "Y") // "X"/"Y" are termified to Vars, since they match a variable name pattern
}

Inheritors

Properties

Link copied to clipboard
open val _: Var
Link copied to clipboard
abstract val emptyBlock: EmptyBlock
Link copied to clipboard
Link copied to clipboard
abstract val fail: Truth
Link copied to clipboard

The Termificator used by toTerm to convert arbitrary values into Terms within this scope.

Link copied to clipboard
abstract val variables: Map<String, Var>

Functions

Link copied to clipboard
abstract fun anonymous(): Var
Link copied to clipboard
abstract fun atomOf(value: Char): Atom
abstract fun atomOf(value: String): Atom
Link copied to clipboard
abstract fun blockOf(terms: Iterable<Term>): Block
abstract fun blockOf(terms: Sequence<Term>): Block
abstract fun blockOf(vararg terms: Term): Block

open fun blockOf(vararg terms: Any): Block

Overload of it.unibo.tuprolog.core.Scope.blockOf accepting plain values, toTerm-ing each of terms.

Link copied to clipboard
open fun clause(function: S.() -> Any): Clause

Runs function with a newScope as its receiver and coerces its result to a Clause: returned as-is if it already is a Clause (e.g. a Rule), or wrapped into a Fact via factOf if it is a plain Struct.

Link copied to clipboard
abstract fun clauseOf(head: Struct?, vararg body: Term): Clause
Link copied to clipboard
abstract fun consOf(head: Term, tail: Term): Cons

open fun consOf(head: Any, tail: Any): Cons

Overload of it.unibo.tuprolog.core.Scope.consOf accepting plain values, toTerm-ing both head and tail.

Link copied to clipboard
abstract operator fun contains(variable: Var): Boolean
abstract operator fun contains(variable: String): Boolean
Link copied to clipboard
open fun directive(function: S.() -> Any): Directive

Runs function with a newScope as its receiver and coerces its result to a Directive via directiveOf.

Link copied to clipboard
abstract fun directiveOf(body1: Term, vararg body: Term): Directive

open fun directiveOf(term: Any, vararg terms: Any): Directive

Overload of it.unibo.tuprolog.core.Scope.directiveOf accepting plain values, toTerm-ing term and each of terms.

Link copied to clipboard
open fun fact(function: S.() -> Any): Fact

Runs function with a newScope as its receiver and coerces its result to a Fact via factOf.

Link copied to clipboard
abstract fun factOf(head: Struct): Fact

open fun factOf(term: Any): Fact

Overload of it.unibo.tuprolog.core.Scope.factOf accepting a plain value, toTerm-ing term.

Link copied to clipboard
abstract operator fun get(variable: String): Var?
Link copied to clipboard
abstract fun indicatorOf(name: Term, arity: Term): Indicator
abstract fun indicatorOf(name: String, arity: Int): Indicator
Link copied to clipboard
abstract fun intOf(value: Byte): Integer
abstract fun intOf(value: Int): Integer
abstract fun intOf(value: Long): Integer
abstract fun intOf(value: Short): Integer
abstract fun intOf(value: String): Integer
abstract fun intOf(value: BigInteger): Integer
abstract fun intOf(value: String, radix: Int): Integer
Link copied to clipboard
open operator fun String.invoke(term: Any, vararg terms: Any): Struct

Builds a Struct whose functor is this String and whose arguments are term followed by terms.

Link copied to clipboard
open fun logicList(vararg items: Any, tail: Any? = null): List

Builds a logic list out of items (each toTerm-ed), optionally ending in tail (also toTerm-ed) rather than the empty list — mirroring it.unibo.tuprolog.core.Scope.logicListFrom's last parameter.

Link copied to clipboard
abstract fun logicListFrom(terms: Iterable<Term>, last: Term?): List
abstract fun logicListFrom(terms: Sequence<Term>, last: Term?): List
abstract fun logicListFrom(vararg terms: Term, last: Term?): List
Link copied to clipboard
abstract fun logicListOf(terms: Iterable<Term>): List
abstract fun logicListOf(terms: Sequence<Term>): List
abstract fun logicListOf(vararg terms: Term): List

open fun logicListOf(vararg terms: Any): List

Overload of it.unibo.tuprolog.core.Scope.logicListOf accepting plain values, toTerm-ing each of terms.

Link copied to clipboard
abstract fun newScope(): S

Creates a fresh scope of type S, backed by a brand-new, empty Scope — so that it.unibo.tuprolog.core.Vars created within it are unrelated to the ones created through this scope. Used by builders such as MinimalLogicProgrammingScope.rule/MinimalLogicProgrammingScope.fact to isolate each clause's variables.

Link copied to clipboard
abstract fun numOf(value: Byte): Integer
abstract fun numOf(value: Double): Real
abstract fun numOf(value: Float): Real
abstract fun numOf(value: Int): Integer
abstract fun numOf(value: Long): Integer
abstract fun numOf(value: Number): Numeric
abstract fun numOf(value: Short): Integer
abstract fun numOf(value: String): Numeric
abstract fun numOf(value: BigDecimal): Real
abstract fun numOf(value: BigInteger): Integer
Link copied to clipboard
abstract fun realOf(value: Double): Real
abstract fun realOf(value: Float): Real
abstract fun realOf(value: String): Real
abstract fun realOf(value: BigDecimal): Real
Link copied to clipboard
open fun rule(function: S.() -> Any): Rule

Runs function with a newScope as its receiver and coerces its result to a Rule — typically built via the head ifbody / head impliedBybody infix builders from LogicProgrammingScopeWithOperators.

Link copied to clipboard
abstract fun ruleOf(head: Struct, body1: Term, vararg body: Term): Rule
Link copied to clipboard
open fun <R> scope(function: S.() -> R): R

Runs function with a newScope as its receiver, isolating any it.unibo.tuprolog.core.Var it creates.

Link copied to clipboard
abstract fun structOf(functor: String, args: Iterable<Term>): Struct
abstract fun structOf(functor: String, args: List<Term>): Struct
abstract fun structOf(functor: String, args: Sequence<Term>): Struct
abstract fun structOf(functor: String, vararg args: Term): Struct

open fun structOf(functor: String, vararg args: Any): Struct

Overload of it.unibo.tuprolog.core.Scope.structOf accepting plain values, toTerm-ing each of args.

Link copied to clipboard
abstract fun substitutionOf(assignments: Iterable<Pair<Var, Term>>): Substitution
abstract fun substitutionOf(assignments: Sequence<Pair<Var, Term>>): Substitution
abstract fun substitutionOf(vararg assignments: Pair<String, Term>): Substitution
Link copied to clipboard
open fun <T : Term> Any.toSpecificSubTypeOfTerm(type: KClass<T>, converter: (Struct) -> T): T

Converts this value into a Term (via toTerm) and coerces it to type: returned as-is if it already is a type, passed through converter if it is a Struct (e.g. to turn a plain Struct into a Fact), or rejected otherwise.

Link copied to clipboard
open fun Any.toTerm(): Term

Converts this value into a Term, via termificator. See Termificator.termify for the conversion rules.

Link copied to clipboard
abstract fun truthOf(value: Boolean): Truth
Link copied to clipboard
abstract fun tupleOf(terms: Iterable<Term>): Tuple
abstract fun tupleOf(terms: Sequence<Term>): Tuple
abstract fun tupleOf(vararg terms: Term): Tuple

open fun tupleOf(vararg terms: Any): Tuple

Overload of it.unibo.tuprolog.core.Scope.tupleOf accepting plain values, toTerm-ing each of terms.

Link copied to clipboard
abstract fun unifierOf(assignments: Iterable<Pair<Var, Term>>): Substitution.Unifier
abstract fun unifierOf(assignments: Sequence<Pair<Var, Term>>): Substitution.Unifier
abstract fun unifierOf(vararg assignments: Pair<String, Term>): Substitution.Unifier
Link copied to clipboard
abstract fun varOf(name: Char): Var
abstract fun varOf(name: String): Var
Link copied to clipboard
abstract fun whatever(): Var
Link copied to clipboard
abstract fun where(lambda: Scope.() -> Unit): Scope
Link copied to clipboard
abstract fun <R> with(lambda: Scope.() -> R): R