Real
A Numeric whose value is an arbitrary-precision decimal number, e.g. 1.0, -3.14. Being backed by BigDecimal rather than a Double avoids the rounding surprises of binary floating point, at the cost of requiring explicit conversion when interoperating with APIs that expect a native floating-point type.
Properties
The value of this number, widened to a BigDecimal. Always exact for Integers.
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.
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.
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.
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.
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".
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.
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.
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".
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
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.
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.
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.
Casts the current Term to EmptyBlock, if possible, or returns null otherwise
Casts the current Term to EmptyBlock, if possible
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.
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?).
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.
Returns a fresh copy of this object, similarly to freshCopy(), possibly reusing variables from the provided scope, if any
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.
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: