Integer

interface Integer : Numeric

A Numeric whose value is an arbitrary-precision integer, e.g. 1, -42, or a value far outside the range of a Long. Being arbitrary-precision (backed by BigInteger) means arithmetic on Integers never silently overflows, matching how ISO Prolog integers are meant to behave.

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
open override val decimalValue: BigDecimal

The value of this number, widened to a BigDecimal. Always exact for Integers.

Link copied to clipboard
open override val intValue: BigInteger

The value of this number, narrowed to a BigInteger. For Reals, this truncates the fractional part.

Link copied to clipboard
open val 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.

Link copied to clipboard
open val isBlock: Boolean

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

Link copied to clipboard
open val 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.

Link copied to clipboard
open val 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.

Link copied to clipboard
open override val isConstant: Boolean

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

Link copied to clipboard

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.

Link copied to clipboard

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

Link copied to clipboard

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.

Link copied to clipboard
open val 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.

Link copied to clipboard
open val 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".

Link copied to clipboard
open val isGround: Boolean

Checks whether the current object is ground. An object is ground if and only if it does not contain any variable. This method is guaranteed to return true if and only if the variables property of the current object refers to an empty sequence.

Link copied to clipboard

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.

Link copied to clipboard
open override val isInteger: Boolean

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

Link copied to clipboard
open val 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.

Link copied to clipboard
open override val isNumber: Boolean

Checks whether the current term is a number, i.e., either an integer or a real number. This method is guaranteed to return true if and only if the current term is an instance of Numeric.

Link copied to clipboard
open val isReal: Boolean

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

Link copied to clipboard

Checks whether the current term is a recursive structure, i.e., a list, a tuple, or a block. This method is guaranteed to return true if and only if the current term is an instance of Recursive.

Link copied to clipboard
open val 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.

Link copied to clipboard
open val 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.

Link copied to clipboard
open val 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".

Link copied to clipboard
open val isTruth: Boolean

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

Link copied to clipboard
open val 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.

Link copied to clipboard
open val isVar: Boolean

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

Link copied to clipboard
abstract val tags: Map<String, Any>
Link copied to clipboard
abstract override val value: BigInteger

The exact value of this integer.

Link copied to clipboard
open override val variables: Sequence<Var>

The sequence of Variables directly or indirectly contained in the current object. 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

Functions

Link copied to clipboard
abstract fun <T> accept(visitor: TermVisitor<T>): T

Lets the provided TermVisitor navigate the current term and build an object of type T. Such an object is then returned as a result by this method.

Link copied to clipboard
abstract fun apply(substitution: Substitution): Term

Applies a Substitution to the current object, producing a new instance of T which differs from the current object because variables are replaced by their values, according to the binding carried by substitution.

open fun apply(substitution: Substitution, vararg substitutions: Substitution): Term

Applies one or more Substitutions to the current object, producing a new instance of T which differs from the current one because variables are replaced by their values, according to the binding carried by the provided substitutions.

Link copied to clipboard
open override fun <T : Term> as(): T?

Helper method aimed at down-casting Terms using a fluent style

Link copied to clipboard
open fun asAtom(): Atom?

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

Link copied to clipboard
open fun asBlock(): Block?

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

Link copied to clipboard
open fun asClause(): Clause?

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

Link copied to clipboard
open fun asCons(): Cons?

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

Link copied to clipboard
open override fun asConstant(): Constant

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

Link copied to clipboard
open fun asDirective(): Directive?

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

Link copied to clipboard

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

Link copied to clipboard
open fun asEmptyList(): EmptyList?

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

Link copied to clipboard
open fun asFact(): Fact?

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

Link copied to clipboard
open fun asIndicator(): Indicator?

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

Link copied to clipboard
open override fun asInteger(): Integer

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

Link copied to clipboard
open fun asList(): List?

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

Link copied to clipboard
open override fun asNumeric(): Numeric

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

Link copied to clipboard
open fun asReal(): Real?

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

Link copied to clipboard
open fun asRecursive(): Recursive?

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

Link copied to clipboard
open fun asRule(): Rule?

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

Link copied to clipboard
open fun asStruct(): Struct?

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

Link copied to clipboard
open fun asTerm(): Term

Casts the current Term to Term

Link copied to clipboard
open fun asTruth(): Truth?

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

Link copied to clipboard
open fun asTuple(): Tuple?

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

Link copied to clipboard
open fun asVar(): Var?

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

Link copied to clipboard
open override fun <T : Term> castTo(): T

Helper method aimed at down-casting Terms using a fluent style

Link copied to clipboard
open fun castToAtom(): Atom

Casts the current Term to Atom, if possible

Link copied to clipboard
open fun castToBlock(): Block

Casts the current Term to Block, if possible

Link copied to clipboard
open fun castToClause(): Clause

Casts the current Term to Clause, if possible

Link copied to clipboard
open fun castToCons(): Cons

Casts the current Term to Cons, if possible

Link copied to clipboard

Casts the current Term to Constant, if possible

Link copied to clipboard

Casts the current Term to Directive, if possible

Link copied to clipboard

Casts the current Term to EmptyBlock, if possible

Link copied to clipboard

Casts the current Term to EmptyList, if possible

Link copied to clipboard
open fun castToFact(): Fact

Casts the current Term to Fact, if possible

Link copied to clipboard

Casts the current Term to Indicator, if possible

Link copied to clipboard

Casts the current Term to Integer, if possible

Link copied to clipboard
open fun castToList(): List

Casts the current Term to List, if possible

Link copied to clipboard

Casts the current Term to Numeric, if possible

Link copied to clipboard
open fun castToReal(): Real

Casts the current Term to Real, if possible

Link copied to clipboard

Casts the current Term to Recursive, if possible

Link copied to clipboard
open fun castToRule(): Rule

Casts the current Term to Rule, if possible

Link copied to clipboard
open fun castToStruct(): Struct

Casts the current Term to Struct, if possible

Link copied to clipboard
open fun castToTerm(): Term

Casts the current Term to Term

Link copied to clipboard
open fun castToTruth(): Truth

Casts the current Term to Truth, if possible

Link copied to clipboard
open fun castToTuple(): Tuple

Casts the current Term to Tuple, if possible

Link copied to clipboard
open fun castToVar(): Var

Casts the current Term to Var, if possible

Link copied to clipboard
open operator override fun compareTo(other: Term): Int

Compares this term to the provided one, returning a positive integer if this term precedes other, a negative integer if other precedes this term, or 0 otherwise

Link copied to clipboard
open fun compareValueTo(other: Numeric): Int

Compares this number to other by numeric value alone (via decimalValue), regardless of whether either is an Integer or a Real. This is different from Term.compareTo, which orders integers before reals of the same the term-comparison sense rather than by value.

Link copied to clipboard
open fun containsTag(name: String): Boolean
Link copied to clipboard
abstract operator override fun equals(other: Any?): Boolean

abstract fun equals(other: Term, useVarCompleteName: Boolean): Boolean

Checks whether another term is equals to the current one or not, by explicitly letting the client decide whether to rely or not on Varriables complete names for checking equality among two Variables. If useVarCompleteName is true, Variables are compared through their Var.completeName property. Otherwise, they are compared through their Var.name property. Other sorts of terms are compared as Term.equals(Any?).

Link copied to clipboard
abstract override fun freshCopy(): Integer

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

abstract override fun freshCopy(scope: Scope): Integer

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

Link copied to clipboard
open operator fun get(substitution: Substitution, vararg substitutions: Substitution): Term

This is an alias for apply aimed at supporting a square-brackets syntax for substitutions applications in Kotlin programs. It lets programmers write object[substitution] instead of object.apply(substitution). It applies one or more Substitutions to the current object, producing a new Term which differs from the current one because variables are replaced by their values, according to the binding carried by the provided substitutions.

Link copied to clipboard
open fun <T : Any> getTag(name: String): T?
Link copied to clipboard
abstract override fun hashCode(): Int
Link copied to clipboard
abstract fun replaceTags(tags: Map<String, Any>): Term
Link copied to clipboard
abstract infix fun structurallyEquals(other: Term): Boolean

Checks whether another term is structurally equals to the current one or not. Structural equivalence is a looser type of equivalence (w.r.t. term equivalence) where:

Link copied to clipboard
abstract override fun toString(): String