souffle
2.0.2-371-g6315b36
|
Go to the documentation of this file.
49 TEST(AstUtils, Grounded) {
51 auto clause = mk<Clause>();
57 auto* head =
new Atom(
"r");
58 head->addArgument(Own<Argument>(
new Variable(
"X")));
59 head->addArgument(Own<Argument>(
new Variable(
"Y")));
60 head->addArgument(Own<Argument>(
new Variable(
"Z")));
64 auto* a =
new Atom(
"a");
74 auto*
b =
new Atom(
"b");
82 auto program = mk<Program>();
83 program->addClause(std::move(clause));
91 auto args = head->getArguments();
98 TEST(AstUtils, GroundedRecords) {
104 .type R = [ a : N, B : N ]
114 Program& program = tu->getProgram();
135 TEST(AstUtils, ReorderClauseAtoms) {
141 .decl a,b,c,d,e(x:number)
142 a(x) :- b(x), c(x), 1 != 2, d(y), !e(z), c(z), e(x).
147 Program& program = tu->getProgram();
156 EXPECT_EQ(
"a(x) :- \n b(x),\n c(x),\n 1 != 2,\n d(y),\n !e(z),\n c(z),\n e(x).",
162 EXPECT_EQ(
"a(x) :- \n b(x),\n c(x),\n 1 != 2,\n d(y),\n !e(z),\n c(z),\n e(x).",
168 EXPECT_EQ(
"a(x) :- \n d(y),\n c(z),\n 1 != 2,\n e(x),\n !e(z),\n c(x),\n b(x).",
static Own< ast::TranslationUnit > parseTranslationUnit(const std::string &filename, FILE *in, ErrorReport &errorReport, DebugReport &debugReport)
std::vector< Argument * > getArguments() const
Return arguments.
Clause * reorderAtoms(const Clause *clause, const std::vector< unsigned int > &newOrder)
Reorders the atoms of a clause to be in the given order.
l j a showGridBackground &&c b raw series this eventEmitter e
Defines a relation with a name, attributes, qualifiers, and internal representation.
Intermediate representation of a horn clause.
A variable to be utilized within constraints to be handled by the constraint solver.
Atom * getHead() const
Return the atom that represents the head of the clause.
std::map< const Argument *, bool > getGroundedTerms(const TranslationUnit &tu, const Clause &clause)
Analyse the given clause and computes for each contained argument whether it is a grounded value or n...
const std::string & toString(const std::string &str)
A generic function converting strings into strings (trivial case).
The program class consists of relations, clauses and types.
Relation * getRelation(const Program &program, const QualifiedName &name)
Returns the relation with the given name in the program.
Class representing a HTML report, consisting of a list of sections.
Negation of an atom negated atom.
std::vector< Own< Clause > > clauses
Translation unit class for the translation pipeline.
Defines an abstract class for literals in a horn clause.
std::vector< Relation * > getRelations() const
Return relations.
std::vector< Clause * > getClauses(const Program &program, const QualifiedName &relationName)
Returns a vector of clauses in the program describing the relation with the given name.
l j a showGridBackground &&c b raw series this eventEmitter b
std::vector< Literal * > getBodyLiterals() const
Obtains a copy of the internally maintained body literals.