Struct
Base type for compound Terms, a.k.a. structures. A Struct is characterised by a functor and a given (non-negative) amount of args, namely arity. Each argument can be a Term of any sort.
Most other non-atomic, non-variable terms in this hierarchy (Clause, Rule, Fact, Directive, List, Cons, Tuple, Block, Indicator, and even 0-arity Atoms) are, under the hood, just a Struct with a conventional functor and a folding convention for its arguments. This lets code written generically against Struct (e.g. pattern-matching on functor/arity, or walking args) work uniformly across all of them without special-casing.
Struct.of is the general-purpose factory: it inspects functor and the number/shape of args and automatically delegates to the most specific applicable sub-type's factory (e.g. Struct.of(",", a, b) returns a Tuple, Struct.of(":-", head, body) returns a Rule). Reach for a sub-type's own factory directly (e.g. Tuple.of, Cons.of) when the sub-type is already known, or for the DSL builders in :dsl-core/Scope when building many related terms with shared variables.
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: