Struct

interface Struct: Term, Any

Fields

Name Description
open isStruct: Boolean

Checks whether the current term is a structure, i.e., either a compound term or an atom. This method is guaranteed to return true if and only if the current term is an instance of Struct.

open isClause: Boolean

Checks whether the current term is a clause, i.e., either a rule or a directive. This method is guaranteed to return true if and only if the current term is an instance of Clause.

open isRule: Boolean

Checks whether the current term is a rule, or a fact. This method is guaranteed to return true if and only if the current term is an instance of Rule.

open isDirective: Boolean

Checks whether the current term is a directive. This method is guaranteed to return true if and only if the current term is an instance of Directive.

open isFact: Boolean

Checks whether the current term is a fact. This method is guaranteed to return true if and only if the current term is an instance of Fact.

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 isAtom: Boolean

Checks whether the current term is an atom. This method is guaranteed to return true if and only if the current term is an instance of Atom.

open isList: Boolean

Checks whether the current term is a (logic) list, i.e., either an empty list or a Cons. This method is guaranteed to return true if and only if the current term is an instance of List.

open isCons: Boolean

Checks whether the current term is a cons. This method is guaranteed to return true if and only if the current term is an instance of Cons.

open isSet: Boolean

Checks whether the current term is a logic set. This method is guaranteed to return true if and only if the current term is an instance of Set.

open isEmptySet: Boolean

Checks whether the current term is an empty logic set. This method is guaranteed to return true if and only if the current term is an instance of EmptySet.

open isEmptyList: Boolean

Checks whether the current term is an empty logic list. This method is guaranteed to return true if and only if the current term is an instance of EmptyList.

open isTrue: Boolean

Checks whether the current term is the true atom. This method is guaranteed to return true if and only if the current term is an instance of Truth and its Truth.value is "true".

open isFail: Boolean

Checks whether the current term is the either the fail atom or the false atom. This method is guaranteed to return true if and only if the current term is an instance of Truth and its Truth.value is "fail" or "false".

open isIndicator: Boolean

Checks whether the current term is an indicator. This method is guaranteed to return true if and only if the current term is an instance of Indicator.

open variables: Sequence<Var>

The sequence of Variables directly or indirectly contained in the current term. Variables are lazily returned in a non-deterministic order. Notice that no occurrence-check is performed. Thus, if a Term contains the same Variable twice or more times, then the variables sequence may contain as many occurrences of that Variable

abstract functor: String
abstract isFunctorWellFormed: Boolean
abstract args: Array<Term>
open arity: Int
open indicator: Indicator
open argsList: List<Term>
open argsSequence: Sequence<Term>

Methods

freshCopy

open fun freshCopy(): Struct

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
Struct

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

freshCopy

open fun freshCopy(scope: Scope): Struct

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
Struct

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

getArgAt

open fun getArgAt(index: Int): Term

Parameters

Name Description
index: Int

ReturnValue

Name Description
Term

get

open operator fun get(index: Int): Term

Parameters

Name Description
index: Int

ReturnValue

Name Description
Term

Extensions

extractSignature

fun Struct.extractSignature(): Signature

Extracts this Struct indicator and converts it to Signature

Receiver

Name Description
Struct

ReturnValue

Name Description
Signature

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

eq

infix fun Term.eq(that: Term): Equation<Term, Term>

Creates an equation with this and that terms

Receiver

Name Description
Term

Parameters

Name Description
that: Term

ReturnValue

Name Description
Equation<Term, Term>

CompanionObject

Struct

interface Struct: Term, Any

Fields

Name Description
val STRUCT_FUNCTOR_REGEX_PATTERN: /** The pattern of a well-formed functor for a Struct */

The pattern of a well-formed functor for a Struct

Methods

escapeFunctor

fun escapeFunctor(string: String): String

Parameters

Name Description
string: String

ReturnValue

Name Description
String

escapeFunctorIfNecessary

fun escapeFunctorIfNecessary(string: String): String

Parameters

Name Description
string: String

ReturnValue

Name Description
String

template

fun template(functor: String, arity: Int): Struct

Parameters

Name Description
functor: String
arity: Int

ReturnValue

Name Description
Struct

of

fun of(functor: String, args: List<Term>): Struct

Parameters

Name Description
functor: String
args: List<Term>

ReturnValue

Name Description
Struct

of

fun of(functor: String, vararg args: Term): Struct

Parameters

Name Description
functor: String
vararg args: Term

ReturnValue

Name Description
Struct

of

fun of(functor: String, args: Sequence<Term>): Struct

Parameters

Name Description
functor: String
args: Sequence<Term>

ReturnValue

Name Description
Struct

of

fun of(functor: String, args: Iterable<Term>): Struct

Parameters

Name Description
functor: String
args: Iterable<Term>

ReturnValue

Name Description
Struct

fold

fun fold(operator: String, terms: List<Term>): Struct

Parameters

Name Description
operator: String
terms: List<Term>

ReturnValue

Name Description
Struct

fold

fun fold(operator: String, terms: List<Term>, terminal: Term?): Struct

Parameters

Name Description
operator: String
terms: List<Term>
terminal: Term?

ReturnValue

Name Description
Struct

fold

fun fold(operator: String, terms: Sequence<Term>, terminal: Term?): Struct

Parameters

Name Description
operator: String
terms: Sequence<Term>
terminal: Term?

ReturnValue

Name Description
Struct

fold

fun fold(operator: String, terms: Sequence<Term>): Struct

Parameters

Name Description
operator: String
terms: Sequence<Term>

ReturnValue

Name Description
Struct

fold

fun fold(operator: String, terms: Iterable<Term>, terminal: Term?): Struct

Parameters

Name Description
operator: String
terms: Iterable<Term>
terminal: Term?

ReturnValue

Name Description
Struct

fold

fun fold(operator: String, terms: Iterable<Term>): Struct

Parameters

Name Description
operator: String
terms: Iterable<Term>

ReturnValue

Name Description
Struct

fold

fun fold(operator: String, vararg terms: Term, terminal: Term?): Struct

Parameters

Name Description
operator: String
vararg terms: Term
terminal: Term?

ReturnValue

Name Description
Struct

fold

fun fold(operator: String, vararg terms: Term): Struct

Parameters

Name Description
operator: String
vararg terms: Term

ReturnValue

Name Description
Struct