Atom
Base type for constant, alphanumeric Terms, a.k.a. strings. An Atom is at the same time a String-valued Constant and a 0-argument Struct, whose functor is equal to value. Modelling it as both, rather than picking a single parent, is what lets generic code written against Struct (functor/arity/argument-based) keep working on atoms without special-casing, while code that only cares about "a ground value" can use Constant instead.
Atom.of is the standard way to build one; it also recognizes a handful of reserved functors ([], {}, true, false, fail) and transparently returns the corresponding singleton (EmptyList, EmptyBlock, or Truth) instead of a plain Atom in those cases.
Inheritors
Properties
Sequence of arguments of this Struct.
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".
Returns true if and only if functor matches Struct.WELL_FORMED_FUNCTOR_PATTERN.
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
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.
Alias for getArgAt. In Kotlin, this method enables the syntax struct[index].
Creates a novel Struct which is a copy of the current one, expect that is has a different functor.
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: