LogicProgrammingScopeWithOperators
Adds infix/operator builders mirroring Prolog's own arithmetic, relational and logical operators, so that Structs (and Rules, for if/impliedBy) can be written as Kotlin expressions instead of nested BaseLogicProgrammingScope.toTerm/structOf calls:
logicProgramming {
"X" `is` ("Y" + 1) // Struct: is(X, +(Y, 1))
("X" greaterThan 0) and ("Y" lowerThan 10) // Struct: ','(>(X, 0), <(Y, 10))
"even"("X") `if` ("X" rem 2 eq 0) // Rule: even(X) :- =(rem(X, 2), 0)
}Each Prolog operator is overloaded once per receiver type (Term, Any, Number, Boolean, Char, String, ...) only where Kotlin's own operator-overload resolution requires it to disambiguate from conflicting stdlib operators (e.g. Number.plus); the Any-receiver versions (equalsTo, and, is, ...) cover every other case directly, toTerm-ing both operands.
Inheritors
Properties
The Termificator used by toTerm to convert arbitrary values into Terms within this scope.
Functions
Builds a >/2 Struct (arithmetic greater-than).
Builds a >=/2 Struct (arithmetic greater-than-or-equal).
Builds the Rule this :- other, i.e. other implies (is the body of a rule whose head is) this value.
Vararg overload of impliedBy: wraps other into a single conjunction (via Tuple.wrapIfNeeded) before building the Rule, so a multi-goal body can be listed as separate arguments instead of chained with and.
Builds an =</2 Struct (arithmetic lower-than-or-equal).
Builds a -/2 Struct, e.g. "X" - 1.
Creates a fresh scope of type S, backed by a brand-new, empty Scope — so that it.unibo.tuprolog.core.Vars created within it are unrelated to the ones created through this scope. Used by builders such as MinimalLogicProgrammingScope.rule/MinimalLogicProgrammingScope.fact to isolate each clause's variables.
Alias of lowerThanOrEqualsTo.
Alias of greaterThanOrEqualsTo.
Builds a \=/2 Struct (term non-unifiability).
Builds a +/2 Struct, e.g. 1 + "X".
Builds a rem/2 Struct (integer remainder).
Builds a */2 Struct, e.g. "X" * 2.
Converts this value into a Term, via termificator. See Termificator.termify for the conversion rules.