The term and atom classes inDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/HarvardPL/AbcDatalog/llms.txt
Use this file to discover all available pages before exploring further.
edu.harvard.seas.pl.abcdatalog.ast are the building blocks for constructing Datalog programs in Java without going through the text parser. All concrete types use static factory methods and — for Variable, Constant, and PredicateSym — intern instances in a thread-safe memo table so that the same logical entity is always the same Java object.
PredicateSym
APredicateSym represents a predicate name together with its arity. The same (name, arity) pair always returns the same instance.
The predicate name. Must be a non-empty string. By convention, predicate names in Datalog text start with a lowercase letter.
The number of arguments. Must be non-negative. Throws
IllegalArgumentException if negative.The interned
PredicateSym for (sym, arity). getSym() returns the name; getArity() returns the arity.Variable
AVariable is a logic variable identified by a string name. Variables whose names start with an uppercase letter or _ parse as variables in Datalog text.
The variable name. Instances are interned:
Variable.create("X") == Variable.create("X").The interned
Variable for the given name. getName() returns the name._ in Datalog text) can be obtained with:
Constant
AConstant represents a ground value (a zero-ary function symbol). Constants whose names start with a lowercase letter parse as constants in Datalog text.
The constant name. Instances are interned:
Constant.create("a") == Constant.create("a").The interned
Constant for the given name. getName() returns the name.PositiveAtom
APositiveAtom pairs a PredicateSym with a Term[] argument array. It implements both Head and Premise.
The predicate symbol. Its arity must equal
args.length; otherwise IllegalArgumentException is thrown.The argument array. The array is owned by the created atom and must not be modified after being passed in.
The new atom.
getPred() returns the predicate symbol; getArgs() returns the argument array; isGround() returns true if all arguments are Constant instances.NegatedAtom
NegatedAtom wraps a PositiveAtom with negation. It implements Premise and holds in evaluation when its inner atom is not derivable.
getPred(), getArgs(), and isGround() delegate to the wrapped atom. asPositiveAtom() returns the inner PositiveAtom.
BinaryUnifier
BinaryUnifier represents a left = right premise in a rule body. It implements Premise.
A variable or constant on the left side of
=.A variable or constant on the right side of
=.getLeft() and getRight() return the two terms. Must be enabled via DatalogValidator.withBinaryUnificationInRuleBody().
BinaryDisunifier
BinaryDisunifier represents a left != right premise. It holds when the two terms cannot be unified.
A variable or constant on the left side of
!=.A variable or constant on the right side of
!=.getLeft() and getRight() return the two terms. Must be enabled via DatalogValidator.withBinaryDisunificationInRuleBody().
Code example: building an AST programmatically
The following is adapted fromEngineExample.makeQuery: