Print rules for integer parameters

For every integer parameter of the predicates visible in the output,
this prints a short fact to the output to make this explicit.
This commit is contained in:
Patrick Lühne 2018-04-20 16:23:02 +02:00
parent 2f54b7d60e
commit 5bda14342b
Signed by: patrick
GPG Key ID: 05F3611E97A70ABF

View File

@ -125,6 +125,38 @@ void translate(const char *fileName, std::istream &stream, Context &context)
ast::print(context.logger.outputStream(), completedFormula, printContext); ast::print(context.logger.outputStream(), completedFormula, printContext);
context.logger.outputStream() << std::endl; context.logger.outputStream() << std::endl;
} }
// Print specifiers for integer predicate parameters
for (auto &predicateDeclaration : context.predicateDeclarations)
{
// Check that the predicate is used and not declared #external
if (!predicateDeclaration->isUsed || predicateDeclaration->isExternal)
continue;
const auto isPredicateVisible =
(predicateDeclaration->visibility == ast::PredicateDeclaration::Visibility::Visible)
|| (predicateDeclaration->visibility == ast::PredicateDeclaration::Visibility::Default
&& context.defaultPredicateVisibility == ast::PredicateDeclaration::Visibility::Visible);
// If the predicate ought to be visible, dont eliminate it
if (!isPredicateVisible)
continue;
for (size_t i = 0; i < predicateDeclaration->parameters.size(); i++)
{
auto &parameter = predicateDeclaration->parameters[i];
if (parameter.domain != ast::Domain::Integer)
continue;
context.logger.outputStream()
<< output::Keyword("int")
<< "(" << predicateDeclaration->name
<< "/" << output::Number(predicateDeclaration->arity())
<< "@" << output::Number(i)
<< ")." << std::endl;
}
}
} }
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////