LogicProgrammingScopeWithPrologStandardLibrary

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:

logicProgramming {
findall("X", call("member".invoke("X", "List")), "Bag") // findall(X, call(member(X, List)), Bag)
not(atom("X")) `if` (`var`("X")) // not(atom(X)) :- var(X)
}

Each builder simply wraps its arguments (auto-toTerm-ed) into a Struct named after the predicate; none of them actually run the predicate — that is :dsl-solve's job, further up the DSL stack. A few predicates not representable as legal Kotlin identifiers as-is are escaped with backticks (` `catch` `, ` `throw` `, ` `var` `) or renamed (e.g. naf for \+/1).

Inheritors

Properties

Link copied to clipboard
open val _: Var
Link copied to clipboard

The at_end_of_stream/0 Atom.

Link copied to clipboard
open val cut: Atom

The cut (!/0) Atom.

Link copied to clipboard
abstract val emptyBlock: EmptyBlock
Link copied to clipboard
Link copied to clipboard
abstract val fail: Truth
Link copied to clipboard
open val halt: Atom

The halt/0 Atom.

Link copied to clipboard
open val nl: Atom

The nl/0 Atom.

Link copied to clipboard
open val repeat: Atom

The repeat/0 Atom.

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
open fun abolish(indicator: Any): Struct

Builds an abolish/1 Struct.

Link copied to clipboard
abstract fun anonymous(): Var
Link copied to clipboard
open fun append(left: Any, right: Any, result: Any): Struct

Builds an append/3 Struct.

Link copied to clipboard
open fun arg(index: Any, compound: Any, argument: Any): Struct

Builds an arg/3 Struct.

Link copied to clipboard
open infix fun Any.arithEq(right: Any): Struct

Builds a =:=/2 Struct (arithmetic equality).

Link copied to clipboard
open infix fun Any.arithNeq(right: Any): Struct

Builds a =\=/2 Struct (arithmetic inequality).

Link copied to clipboard
open fun assert(clause: Any): Struct

Builds an assert/1 Struct.

Link copied to clipboard
open fun asserta(clause: Any): Struct

Builds an asserta/1 Struct.

Link copied to clipboard
open fun assertz(clause: Any): Struct

Builds an assertz/1 Struct.

Link copied to clipboard
open fun at_end_of_stream(alias: Any): Struct

Builds an at_end_of_stream/1 Struct.

Link copied to clipboard
open fun atom(atom: Any): Struct

Builds an atom/1 Struct (type-checking predicate, not to be confused with Struct.functor).

Link copied to clipboard
open fun atom_chars(atom: Any, chars: Any): Struct

Builds an atom_chars/2 Struct.

Link copied to clipboard
open fun atom_codes(atom: Any, codes: Any): Struct

Builds an atom_codes/2 Struct.

Link copied to clipboard
open fun atom_concat(first: Any, second: Any, result: Any): Struct

Builds an atom_concat/3 Struct.

Link copied to clipboard
open fun atom_length(atom: Any, length: Any): Struct

Builds an atom_length/2 Struct.

Link copied to clipboard
open fun atomic(atomic: Any): Struct

Builds an atomic/1 Struct.

Link copied to clipboard
abstract fun atomOf(value: Char): Atom
abstract fun atomOf(value: String): Atom
Link copied to clipboard
open fun bagof(template: Any, goal: Any, bag: Any): Struct

Builds a bagof/3 Struct.

Link copied to clipboard
open fun between(min: Any, max: Any, number: Any): Struct

Builds a between/3 Struct.

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
Link copied to clipboard
open fun call(goal: Any): Struct

Builds a call/1 Struct.

Link copied to clipboard
open fun callable(goal: Any): Struct

Builds a callable/1 Struct.

Link copied to clipboard
open fun catch(goal: Any, error: Any, continuation: Any): Struct

Builds a catch/3 Struct.

Link copied to clipboard
open fun char_code(char: Any, code: Any): Struct

Builds a char_code/2 Struct.

Link copied to clipboard
open fun clause(head: Any, body: Any): Struct

Builds a clause/2 Struct; not to be confused with MinimalLogicProgrammingScope.clause.

Link copied to clipboard
abstract fun clauseOf(head: Struct?, vararg body: Term): Clause
Link copied to clipboard
open fun compound(struct: Any): Struct

Builds a compound/1 Struct.

Link copied to clipboard
abstract fun consOf(head: Term, tail: Term): Cons
Link copied to clipboard
open fun consult(url: Any): Struct

Builds a consult/1 Struct.

Link copied to clipboard
abstract operator fun contains(variable: Var): Boolean
abstract operator fun contains(variable: String): Boolean
Link copied to clipboard
open fun copy_term(term: Any, copy: Any): Struct

Builds a copy_term/2 Struct.

Link copied to clipboard
open fun current_flag(name: Any, value: Any): Struct

Builds a current_flag/2 Struct.

Link copied to clipboard
open fun current_op(precedence: Any, specifier: Any, functor: Any): Struct

Builds a current_op/3 Struct.

Link copied to clipboard
open fun current_prolog_flag(name: Any, value: Any): Struct

Builds a current_prolog_flag/2 Struct. Deprecated in favor of current_flag.

Link copied to clipboard
abstract fun directiveOf(body1: Term, vararg body: Term): Directive
Link copied to clipboard
open fun dynamic(indicator: Any): Struct

Builds a dynamic/1 Struct.

Link copied to clipboard
open infix fun Any.eq(right: Any): Struct
Link copied to clipboard
abstract fun factOf(head: Struct): Fact
Link copied to clipboard
open fun findall(template: Any, goal: Any, bag: Any): Struct

Builds a findall/3 Struct.

Link copied to clipboard
open fun float(number: Any): Struct

Builds a float/1 Struct.

Link copied to clipboard
open fun functor(struct: Any, functor: Any, arity: Any): Struct

Builds a functor/3 Struct.

Link copied to clipboard
abstract operator fun get(variable: String): Var?
Link copied to clipboard
open fun ground(term: Any): Struct

Builds a ground/1 Struct.

Link copied to clipboard
open infix fun Any.id(right: Any): Struct

Builds a ==/2 Struct (term structural equality).

Link copied to clipboard
open fun include(url: Any): Struct

Builds an include/1 Struct.

Link copied to clipboard
abstract fun indicatorOf(name: Term, arity: Term): Indicator
abstract fun indicatorOf(name: String, arity: Int): Indicator
Link copied to clipboard
open fun initialization(goal: Any): Struct

Builds an initialization/1 Struct.

Link copied to clipboard
open fun integer(number: Any): Struct

Builds an integer/1 Struct.

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 fun load(url: Any): Struct

Builds a load/1 Struct.

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
Link copied to clipboard
open fun member(item: Any, list: Any): Struct

Builds a member/2 Struct.

Link copied to clipboard
open fun naf(goal: Any): Struct

Builds a \+/1 Struct (negation as failure).

Link copied to clipboard
open fun natural(number: Any): Struct

Builds a natural/1 Struct.

Link copied to clipboard
open infix fun Any.neq(right: Any): Struct
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
open infix fun Any.nid(right: Any): Struct

Builds a \==/2 Struct (term structural inequality).

Link copied to clipboard
open fun nonvar(number: Any): Struct

Builds a nonvar/1 Struct.

Link copied to clipboard
open fun not(goal: Any): Struct

Builds a not/1 Struct.

Link copied to clipboard
open fun number(number: Any): Struct

Builds a number/1 Struct.

Link copied to clipboard
open fun number_chars(first: Any, second: Any): Struct

Builds a number_chars/2 Struct.

Link copied to clipboard
open fun number_codes(first: Any, second: Any): Struct

Builds a number_codes/2 Struct.

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
open fun op(precedence: Any, specifier: Any, functor: Any): Struct

Builds an op/3 Struct.

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 retract(clause: Any): Struct

Builds a retract/1 Struct.

Link copied to clipboard
open fun retractall(clause: Any): Struct

Builds a retractall/1 Struct.

Link copied to clipboard
abstract fun ruleOf(head: Struct, body1: Term, vararg body: Term): Rule
Link copied to clipboard
open fun set_flag(name: Any, value: Any): Struct

Builds a set_flag/2 Struct.

Link copied to clipboard
open fun set_prolog_flag(name: Any, value: Any): Struct

Builds a set_prolog_flag/2 Struct. Deprecated in favor of set_flag.

Link copied to clipboard
open fun setof(template: Any, goal: Any, bag: Any): Struct

Builds a setof/3 Struct.

Link copied to clipboard
open fun solve(goal: Any): Struct

Builds a solve/1 Struct.

Link copied to clipboard
open fun static(indicator: Any): Struct

Builds a static/1 Struct.

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
Link copied to clipboard
open fun sub_atom(atom: Any, before: Any, length: Any, after: Any, sub_atom: Any): Struct

Builds a sub_atom/5 Struct.

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 throw(error: Any): Struct

Builds a throw/1 Struct.

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
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
open infix fun Any.univ(other: Any): Struct

Builds a =../2 Struct (univ).

Link copied to clipboard
open fun var(term: Any): Struct

Builds a var/1 Struct.

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
Link copied to clipboard
open fun write(term: Any): Struct

Builds a write/1 Struct.