Tuple

interface Tuple: Recursive, Any

Fields

Name Description
open isTuple: Boolean

Checks whether the current term is a logic tuple, i.e., a right-recursive conjunction of 2 or more terms. This method is guaranteed to return true if and only if the current term is an instance of Tuple.

open functor: String

The functor of this Struct.

open arity: Int

The total amount of arguments of this Struct. This is equal to the length of args.

abstract left: Term
abstract right: Term

Methods

asTuple

open fun asTuple(): Tuple

Casts the current Term to Tuple, if possible, or returns null otherwise

ReturnValue

Name Description
Tuple

the current Term, casted to Tuple, or null, if the current term is not an instance of Tuple

toArray

open fun toArray(): Array<Term>

ReturnValue

Name Description
Array<Term>

toList

open fun toList(): List<Term>

ReturnValue

Name Description
List<Term>

toSequence

open fun toSequence(): Sequence<Term>

ReturnValue

Name Description
Sequence<Term>

freshCopy

abstract fun freshCopy(): Tuple

Returns a fresh copy of this Term, that is, an instance of Term which is equal to the current one in any aspect, except variables directly or indirectly contained into this Term, which are refreshed. This means that it could return itself, if no variable is present (ground term), or a new Term with freshly generated variables.

Variables are refreshed consistently, meaning that, if more variables exists within this Term having the same name, all fresh copies of such variables will have the same complete name.

Example: "f(X, g(X))".freshCopy() returns something like "f(X_1, g(X_1))" instead of "f(X_1, g(X_2))"

Notice that, if the current term is ground, the same object may be returned as a result by this method.

ReturnValue

Name Description
Tuple

a fresh copy of the current term which is different because variables are consistently renamed

freshCopy

abstract fun freshCopy(scope: Scope): Tuple

Returns a fresh copy of this Term, similarly to freshCopy, possibly reusing variables from the provided scope, if any

Parameters

Name Description
scope: Scope

the Scope containing variables to be used in copying

ReturnValue

Name Description
Tuple

a fresh copy of the current term which is different because variables are consistently renamed

Extensions

toClause

fun Term.toClause(source: Any?, line: Int, column: Int): Clause

Receiver

Name Description
Term

Parameters

Name Description
source: Any?
line: Int
column: Int

ReturnValue

Name Description
Clause

unfoldGoals

fun Term.unfoldGoals(): Sequence<Term>

Receiver

Name Description
Term

ReturnValue

Name Description
Sequence<Term>

toGoals

fun Term.toGoals(): Cursor<Term>

Receiver

Name Description
Term

ReturnValue

Name Description
Cursor<Term>

isWellFormed

fun Term.isWellFormed(): Boolean

Check whether the receiver term is a well-formed predication

Receiver

Name Description
Term

ReturnValue

Name Description
Boolean

prepareForExecutionAsGoal

fun Term.prepareForExecutionAsGoal(): Struct

Prepares the receiver Goal for execution

For example, the goal A is transformed, after preparation for execution, as the Term: call(A)

Receiver

Name Description
Term

ReturnValue

Name Description
Struct

extractSignature

fun Struct.extractSignature(): Signature

Extracts this Struct indicator and converts it to Signature

Receiver

Name Description
Struct

ReturnValue

Name Description
Signature

evalAsExpression

fun Term.evalAsExpression(request: Request<*>, index: Int?): Term

Receiver

Name Description
Term

Parameters

Name Description
request: Request<*>
index: Int?

ReturnValue

Name Description
Term

evalAsArithmeticExpression

fun Term.evalAsArithmeticExpression(request: Request<*>, index: Int?): Numeric

Receiver

Name Description
Term

Parameters

Name Description
request: Request<*>
index: Int?

ReturnValue

Name Description
Numeric

eq

infix fun Term.eq(that: Term): Equation

Creates an equation with this and that terms

Receiver

Name Description
Term

Parameters

Name Description
that: Term

ReturnValue

Name Description
Equation

CompanionObject

Tuple

interface Tuple: Recursive, Any

Fields

Name Description
const FUNCTOR: String

Methods

wrapIfNeeded

fun wrapIfNeeded(vararg terms: Term, ifEmpty: ()->Term): Term

Parameters

Name Description
vararg terms: Term
ifEmpty: ()->Term

ReturnValue

Name Description
Term

wrapIfNeeded

fun wrapIfNeeded(terms: Iterable<Term>, ifEmpty: ()->Term): Term

Parameters

Name Description
terms: Iterable<Term>
ifEmpty: ()->Term

ReturnValue

Name Description
Term

wrapIfNeeded

fun wrapIfNeeded(terms: Sequence<Term>, ifEmpty: ()->Term): Term

Parameters

Name Description
terms: Sequence<Term>
ifEmpty: ()->Term

ReturnValue

Name Description
Term

of

fun of(left: Term, right: Term): Tuple

Parameters

Name Description
left: Term
right: Term

ReturnValue

Name Description
Tuple

of

fun of(first: Term, second: Term, vararg others: Term): Tuple

Parameters

Name Description
first: Term
second: Term
vararg others: Term

ReturnValue

Name Description
Tuple

of

fun of(terms: Iterable<Term>): Tuple

Parameters

Name Description
terms: Iterable<Term>

ReturnValue

Name Description
Tuple

of

fun of(terms: List<Term>): Tuple

Parameters

Name Description
terms: List<Term>

ReturnValue

Name Description
Tuple