| souffle
    2.0.2-371-g6315b36
    | 
 
 
 
#include <ExplainProvenanceImpl.h>
|  | 
| Own< TreeNode > | explain (std::string relName, std::vector< RamDomain > tuple, int ruleNum, int levelNum, size_t depthLimit) | 
|  | 
| Own< TreeNode > | explain (std::string relName, std::vector< std::string > args, size_t depthLimit) override | 
|  | 
| Own< TreeNode > | explainNegation (std::string relName, size_t ruleNum, const std::vector< std::string > &tuple, std::map< std::string, std::string > &bodyVariables) override | 
|  | 
| std::vector< std::string > | explainNegationGetVariables (std::string relName, std::vector< std::string > args, size_t ruleNum) override | 
|  | 
|  | ExplainProvenanceImpl (SouffleProgram &prog) | 
|  | 
| Own< TreeNode > | explainSubproof (std::string relName, RamDomain subproofNum, size_t depthLimit) override | 
|  | 
| std::string | getRule (std::string relName, size_t ruleNum) override | 
|  | 
| std::vector< std::string > | getRules (const std::string &relName) override | 
|  | 
| std::string | measureRelation (std::string relName) override | 
|  | 
| void | printRulesJSON (std::ostream &os) override | 
|  | 
| void | queryProcess (const std::vector< std::pair< std::string, std::vector< std::string >>> &rels) override | 
|  | Process query with given arguments.  More... 
 | 
|  | 
| void | setup () override | 
|  | 
|  | ExplainProvenance (SouffleProgram &prog) | 
|  | 
| virtual | ~ExplainProvenance ()=default | 
|  | 
|  | 
| std::vector< std::string > | constraintList | 
|  | 
| std::map< std::pair< std::string, size_t >, std::vector< std::string > > | info | 
|  | 
| std::map< std::pair< std::string, size_t >, std::string > | rules | 
|  | 
| std::vector< std::vector< RamDomain > > | subproofs | 
|  | 
Definition at line 54 of file ExplainProvenanceImpl.h.
 
◆ arity_type
◆ ExplainProvenanceImpl()
  
  | 
        
          | souffle::ExplainProvenanceImpl::ExplainProvenanceImpl | ( | SouffleProgram & | prog | ) |  |  | inline | 
 
 
◆ containsTuple()
  
  | 
        
          | bool souffle::ExplainProvenanceImpl::containsTuple | ( | Relation * | relation, |  
          |  |  | const std::vector< RamDomain > & | constTuple |  
          |  | ) |  |  |  | inlineprivate | 
 
 
◆ explain() [1/2]
  
  | 
        
          | Own<TreeNode> souffle::ExplainProvenanceImpl::explain | ( | std::string | relName, |  
          |  |  | std::vector< RamDomain > | tuple, |  
          |  |  | int | ruleNum, |  
          |  |  | int | levelNum, |  
          |  |  | size_t | depthLimit |  
          |  | ) |  |  |  | inline | 
 
Definition at line 94 of file ExplainProvenanceImpl.h.
   96             return mk<LeafNode>(relName + 
"(" + joinedArgsStr + 
")");
 
   99         assert(
info.find(std::make_pair(relName, ruleNum)) != 
info.end() && 
"invalid rule for tuple");
 
  102         if (depthLimit <= 1) {
 
  103             tuple.push_back(ruleNum);
 
  104             tuple.push_back(levelNum);
 
  116             return mk<LeafNode>(
"subproof " + relName + 
"(" + std::to_string(idx) + 
")");
 
  119         tuple.push_back(levelNum);
 
  122                 mk<InnerNode>(relName + 
"(" + joinedArgsStr + 
")", 
"(R" + std::to_string(ruleNum) + 
")");
 
  125         std::vector<RamDomain> ret;
 
  131         size_t tupleCurInd = 0;
 
  132         auto bodyRelations = 
info[std::make_pair(relName, ruleNum)];
 
  135         for (
auto it = bodyRelations.begin() + 1; it < bodyRelations.end(); it++) {
 
  136             std::string bodyLiteral = *it;
 
  138             std::string bodyRel = 
splitString(bodyLiteral, 
',')[0];
 
  141             assert(bodyRel.size() > 0 && 
"body of a relation should have positive length");
 
  145             auto bodyRelAtomName = bodyRel;
 
  146             if (bodyRel[0] == 
'!' && bodyRel != 
"!=") {
 
  147                 bodyRelAtomName = bodyRel.substr(1);
 
  152             size_t auxiliaryArity;
 
  162             auto tupleEnd = tupleCurInd + arity;
 
  165             std::vector<RamDomain> subproofTuple;
 
  167             for (; tupleCurInd < tupleEnd - auxiliaryArity; tupleCurInd++) {
 
  168                 subproofTuple.push_back(ret[tupleCurInd]);
 
  171             int subproofRuleNum = ret[tupleCurInd];
 
  172             int subproofLevelNum = ret[tupleCurInd + 1];
 
  177             if (bodyRel[0] == 
'!' && bodyRel != 
"!=") {
 
  178                 std::stringstream joinedTuple;
 
  180                 auto joinedTupleStr = joinedTuple.str();
 
  181                 internalNode->add_child(mk<LeafNode>(bodyRel + 
"(" + joinedTupleStr + 
")"));
 
  182                 internalNode->setSize(internalNode->getSize() + 1);
 
  184             } 
else if (isConstraint) {
 
  185                 std::stringstream joinedConstraint;
 
  190                     joinedConstraint << subproofTuple[0] << 
" " << bodyRel << 
" " << subproofTuple[1];
 
  192                     joinedConstraint << bodyRel << 
"(\"" << 
symTable.
resolve(subproofTuple[0]) << 
"\", \"" 
  196                 internalNode->add_child(mk<LeafNode>(joinedConstraint.str()));
 
  197                 internalNode->setSize(internalNode->getSize() + 1);
 
  201                         explain(bodyRel, subproofTuple, subproofRuleNum, subproofLevelNum, depthLimit - 1);
 
  202                 internalNode->setSize(internalNode->getSize() + child->getSize());
 
  203                 internalNode->add_child(std::move(child));
 
  206             tupleCurInd = tupleEnd;
 
  212     Own<TreeNode> 
explain(std::string relName, std::vector<std::string> args, 
size_t depthLimit)
 override {
 
  215             return mk<LeafNode>(
"Relation not found");
 
 
 
 
◆ explain() [2/2]
  
  | 
        
          | Own<TreeNode> souffle::ExplainProvenanceImpl::explain | ( | std::string | relName, |  
          |  |  | std::vector< std::string > | args, |  
          |  |  | size_t | depthLimit |  
          |  | ) |  |  |  | inlineoverridevirtual | 
 
 
◆ explainNegation()
  
  | 
        
          | Own<TreeNode> souffle::ExplainProvenanceImpl::explainNegation | ( | std::string | relName, |  
          |  |  | size_t | ruleNum, |  
          |  |  | const std::vector< std::string > & | tuple, |  
          |  |  | std::map< std::string, std::string > & | bodyVariables |  
          |  | ) |  |  |  | inlineoverridevirtual | 
 
Implements souffle::ExplainProvenance.
Definition at line 321 of file ExplainProvenanceImpl.h.
  332             return !(
isNumber(arg.c_str()) || arg[0] == 
'\"' || arg == 
"_");
 
  336         for (
auto it = atoms.begin() + 1; it < atoms.end(); it++) {
 
  341             for (
auto atomIt = atomRepresentation.begin() + 1; atomIt < atomRepresentation.end(); atomIt++) {
 
  342                 if (!
contains(uniqueVariables, *atomIt) && !
contains(headVariables, *atomIt)) {
 
  344                     if (!isVariable(*atomIt)) {
 
  348                     uniqueVariables.push_back(*atomIt);
 
  353                         assert(currentRel != 
nullptr &&
 
  354                                 (
"relation " + atomRepresentation[0] + 
" doesn't exist").c_str());
 
  355                         variableTypes[*atomIt] =
 
  356                                 *currentRel->getAttrType(atomIt - atomRepresentation.begin() - 1);
 
  357                     } 
else if (atomIt->find(
"agg_") != std::string::npos) {
 
  358                         variableTypes[*atomIt] = 
'i';
 
  364         std::vector<RamDomain> args;
 
  366         size_t varCounter = 0;
 
  373         args.insert(args.end(), tupleNums.begin(), tupleNums.end());
 
  374         varCounter += tuple.size();
 
  376         while (varCounter < uniqueVariables.size()) {
 
  377             auto var = uniqueVariables[varCounter];
 
  378             auto varValue = bodyVariables[var];
 
  379             if (variableTypes[var] == 
's') {
 
  380                 if (varValue.size() >= 2 && varValue[0] == 
'"' && varValue[varValue.size() - 1] == 
'"') {
 
  381                     auto originalStr = varValue.substr(1, varValue.size() - 2);
 
  388                 args.push_back(std::stoi(varValue));
 
  395         std::vector<RamDomain> ret;
 
  401         assert(ret.size() == atoms.size() - 1);
 
  404         std::stringstream joinedArgsStr;
 
  405         joinedArgsStr << 
join(tuple, 
",");
 
  406         auto internalNode = mk<InnerNode>(
 
  407                 relName + 
"(" + joinedArgsStr.str() + 
")", 
"(R" + std::to_string(ruleNum) + 
")");
 
  410         for (
size_t i = 0; 
i < headVariables.size(); 
i++) {
 
  411             bodyVariables[headVariables[
i]] = tuple[
i];
 
  416         int literalCounter = 1;
 
  419             bool atomExists = 
true;
 
  420             if (returnCounter == 0) {
 
  425             auto atomRepresentation = 
splitString(atoms[literalCounter], 
',');
 
  426             std::string bodyRel = atomRepresentation[0];
 
  432             auto bodyRelAtomName = bodyRel;
 
  433             if (bodyRel[0] == 
'!' && bodyRel != 
"!=") {
 
  434                 bodyRelAtomName = bodyRel.substr(1);
 
  438             std::stringstream childLabel;
 
  441                 assert(atomRepresentation.size() == 3 && 
"not a binary constraint");
 
  443                 childLabel << bodyVariables[atomRepresentation[1]] << 
" " << bodyRel << 
" " 
  444                            << bodyVariables[atomRepresentation[2]];
 
  446                 childLabel << bodyRel << 
"(";
 
  447                 for (
size_t i = 1; 
i < atomRepresentation.size(); 
i++) {
 
  449                     if (!isVariable(atomRepresentation[
i])) {
 
  450                         childLabel << atomRepresentation[
i];
 
  452                         childLabel << bodyVariables[atomRepresentation[
i]];
 
  454                     if (
i < atomRepresentation.size() - 1) {
 
  463                 childLabel << 
" ✓";
 
  468             internalNode->add_child(mk<LeafNode>(childLabel.str()));
 
  469             internalNode->setSize(internalNode->getSize() + 1);
 
  477     std::string 
getRule(std::string relName, 
size_t ruleNum)
 override {
 
  478         auto key = make_pair(relName, ruleNum);
 
 
 
 
◆ explainNegationGetVariables()
  
  | 
        
          | std::vector<std::string> souffle::ExplainProvenanceImpl::explainNegationGetVariables | ( | std::string | relName, |  
          |  |  | std::vector< std::string > | args, |  
          |  |  | size_t | ruleNum |  
          |  | ) |  |  |  | inlineoverridevirtual | 
 
Implements souffle::ExplainProvenance.
Definition at line 256 of file ExplainProvenanceImpl.h.
  258             return std::vector<std::string>({
"@"});
 
  262         auto atoms = 
info[std::make_pair(relName, ruleNum)];
 
  266         if (atoms.size() <= 1) {
 
  267             return std::vector<std::string>({
"@fact"});
 
  273         auto isVariable = [&](std::string arg) {
 
  274             return !(
isNumber(arg.c_str()) || arg[0] == 
'\"' || arg == 
"_");
 
  279         std::map<std::string, std::string> headVariableMapping;
 
  280         for (
size_t i = 0; 
i < headVariables.size(); 
i++) {
 
  281             if (!isVariable(headVariables[
i])) {
 
  285             if (headVariableMapping.find(headVariables[
i]) == headVariableMapping.end()) {
 
  286                 headVariableMapping[headVariables[
i]] = args[
i];
 
  288                 if (headVariableMapping[headVariables[
i]] != args[
i]) {
 
  289                     return std::vector<std::string>({
"@non_matching"});
 
  295         std::vector<std::string> uniqueBodyVariables;
 
  296         for (
auto it = atoms.begin() + 1; it < atoms.end(); it++) {
 
  301             for (
auto atomIt = atomRepresentation.begin() + 1; atomIt < atomRepresentation.end(); atomIt++) {
 
  302                 if (!isVariable(*atomIt)) {
 
  306                 if (!
contains(uniqueBodyVariables, *atomIt) && !
contains(headVariables, *atomIt)) {
 
  307                     uniqueBodyVariables.push_back(*atomIt);
 
  312         return uniqueBodyVariables;
 
  315     Own<TreeNode> 
explainNegation(std::string relName, 
size_t ruleNum, 
const std::vector<std::string>& tuple,
 
  316             std::map<std::string, std::string>& bodyVariables)
 override {
 
  318         std::vector<std::string> uniqueVariables;
 
 
 
 
◆ explainSubproof()
  
  | 
        
          | Own<TreeNode> souffle::ExplainProvenanceImpl::explainSubproof | ( | std::string | relName, |  
          |  |  | RamDomain | subproofNum, |  
          |  |  | size_t | depthLimit |  
          |  | ) |  |  |  | inlineoverridevirtual | 
 
 
◆ findQuerySolution()
  
  | 
        
          | void souffle::ExplainProvenanceImpl::findQuerySolution | ( | const std::vector< Relation * > & | varRels, |  
          |  |  | const std::map< std::string, Equivalence > & | nameToEquivalence, |  
          |  |  | const ConstConstraint & | constConstraints |  
          |  | ) |  |  |  | inlineprivate | 
 
Definition at line 800 of file ExplainProvenanceImpl.h.
  808             bool isSolution = 
true;
 
  811             std::vector<tuple> element;
 
  812             for (
auto it : varRelationIterators) {
 
  813                 element.push_back(*it);
 
  816             for (
auto var : nameToEquivalence) {
 
  817                 if (!var.second.verify(element)) {
 
  824                 isSolution = constConstraints.verify(element);
 
  828                 std::cout << solution.str();  
 
  829                 solution.str(std::string());  
 
  832                 for (
auto&& var : nameToEquivalence) {
 
  833                     auto idx = var.second.getFirstIdx();
 
  834                     auto raw = element[idx.first][idx.second];
 
  836                     solution << var.second.getSymbol() << 
" = ";
 
  837                     switch (var.second.getType()) {
 
  838                         case 'i': solution << ramBitCast<RamSigned>(raw); 
break;
 
  839                         case 'f': solution << ramBitCast<RamFloat>(raw); 
break;
 
  840                         case 'u': solution << ramBitCast<RamUnsigned>(raw); 
break;
 
  842                         default: 
fatal(
"invalid type: `%c`", var.second.getType());
 
  845                     auto sep = ++c < nameToEquivalence.size() ? 
", " : 
" ";
 
  851                 if (1 < solutionCount) {
 
  852                     for (std::string input; getline(std::cin, input);) {
 
  853                         if (input == 
";") 
break;   
 
  854                         if (input == 
".") 
return;  
 
  856                         std::cout << 
"use ; to find next solution, use . to break from current query\n";
 
  862             size_t i = varRels.size() - 1;
 
  863             bool terminate = 
true;
 
  864             for (
auto it = varRelationIterators.rbegin(); it != varRelationIterators.rend(); ++it) {
 
  865                 if ((++(*it)) != varRels[
i]->end()) {
 
  869                     (*it) = varRels[
i]->begin();
 
  876                 if (solutionCount == 0) {
 
  877                     std::cout << 
"false." << std::endl;
 
  880                     std::cout << solution.str() << 
"." << std::endl;
 
  889         bool tupleExist = 
false;
 
 
 
 
◆ findTuple()
  
  | 
        
          | std::tuple<int, int> souffle::ExplainProvenanceImpl::findTuple | ( | const std::string & | relName, |  
          |  |  | std::vector< RamDomain > | tup |  
          |  | ) |  |  |  | inlineprivate | 
 
Definition at line 740 of file ExplainProvenanceImpl.h.
  744             std::vector<RamDomain> currentTuple;
 
  748                 if (*
rel->getAttrType(
i) == 
's') {
 
  752                 } 
else if (*
rel->getAttrType(
i) == 
'f') {
 
  756                 } 
else if (*
rel->getAttrType(
i) == 
'u') {
 
  764                 currentTuple.push_back(
n);
 
  779                 return std::make_tuple(ruleNum, levelNum);
 
  784         return std::make_tuple(-1, -1);
 
 
References i, n, souffle::ramBitCast(), and rel().
 
 
◆ getRule()
  
  | 
        
          | std::string souffle::ExplainProvenanceImpl::getRule | ( | std::string | relName, |  
          |  |  | size_t | ruleNum |  
          |  | ) |  |  |  | inlineoverridevirtual | 
 
 
◆ getRules()
  
  | 
        
          | std::vector<std::string> souffle::ExplainProvenanceImpl::getRules | ( | const std::string & | relName | ) |  |  | inlineoverridevirtual | 
 
 
◆ measureRelation()
  
  | 
        
          | std::string souffle::ExplainProvenanceImpl::measureRelation | ( | std::string | relName | ) |  |  | inlineoverridevirtual | 
 
Implements souffle::ExplainProvenance.
Definition at line 506 of file ExplainProvenanceImpl.h.
  514         std::stringstream 
ss;
 
  520         for (
auto& tuple : *
rel) {
 
  523             if (numTuples % skip != 0) {
 
  528             std::vector<RamDomain> currentTuple;
 
  531                 if (*
rel->getAttrType(
i) == 
's') {
 
  535                 } 
else if (*
rel->getAttrType(
i) == 
'f') {
 
  539                 } 
else if (*
rel->getAttrType(
i) == 
'u') {
 
  547                 currentTuple.push_back(
n);
 
  556             std::cout << 
"Tuples expanded: " 
  557                       << 
explain(relName, currentTuple, ruleNum, levelNum, 10000)->getSize();
 
  564                     std::chrono::duration_cast<std::chrono::duration<double>>(tupleEnd - tupleStart);
 
  566             std::cout << 
", Time: " << tupleDuration.count() << 
"\n";
 
  570         auto duration = std::chrono::duration_cast<std::chrono::duration<double>>(after_time - before_time);
 
  572         ss << 
"total: " << proc << 
" ";
 
  579         os << 
"\"rules\": [\n";
 
  581         for (
auto const& cur : 
rules) {
 
 
 
 
◆ printRulesJSON()
  
  | 
        
          | void souffle::ExplainProvenanceImpl::printRulesJSON | ( | std::ostream & | os | ) |  |  | inlineoverridevirtual | 
 
Implements souffle::ExplainProvenance.
Definition at line 584 of file ExplainProvenanceImpl.h.
  587             os << 
"\t{ \"rule-number\": \"(R" << cur.first.second << 
")\", \"rule\": \"" 
  593     void queryProcess(
const std::vector<std::pair<std::string, std::vector<std::string>>>& rels)
 override {
 
  594         std::regex varRegex(
"[a-zA-Z_][a-zA-Z_0-9]*", std::regex_constants::extended);
 
  595         std::regex symbolRegex(
"\"([^\"]*)\"", std::regex_constants::extended);
 
  596         std::regex numberRegex(
"[0-9]+", std::regex_constants::extended);
 
 
 
 
◆ queryProcess()
  
  | 
        
          | void souffle::ExplainProvenanceImpl::queryProcess | ( | const std::vector< std::pair< std::string, std::vector< std::string >>> & | rels | ) |  |  | inlineoverridevirtual | 
 
Process query with given arguments. 
- Parameters
- 
  
    | rels,vector | of relation, argument pairs |  
 
Implements souffle::ExplainProvenance.
Definition at line 599 of file ExplainProvenanceImpl.h.
  616             std::vector<RamDomain> constTuple;
 
  619                 std::cout << 
"Relation <" << 
rel.first << 
"> does not exist" << std::endl;
 
  623             if (
relation->getPrimaryArity() != 
rel.second.size()) {
 
  624                 std::cout << 
"<" + 
rel.first << 
"> has arity of " << 
relation->getPrimaryArity() << std::endl;
 
  629             bool containVar = 
false;
 
  630             for (
size_t j = 0; 
j < 
rel.second.size(); ++
j) {
 
  632                 if (std::regex_match(
rel.second[
j], argsMatcher, varRegex)) {
 
  634                     auto nameToEquivalenceIter = nameToEquivalence.find(argsMatcher[0]);
 
  637                     if (nameToEquivalenceIter == nameToEquivalence.end()) {
 
  638                         nameToEquivalence.insert(
 
  639                                 {argsMatcher[0], Equivalence(*(
relation->getAttrType(
j)), argsMatcher[0],
 
  640                                                          std::make_pair(idx, 
j))});
 
  642                         nameToEquivalenceIter->second.push_back(std::make_pair(idx, 
j));
 
  650                         if (!std::regex_match(
rel.second[
j], argsMatcher, symbolRegex)) {
 
  651                             std::cout << argsMatcher.str(0) << 
" does not match type defined in relation" 
  659                             std::cout << 
rel.second[
j] << 
" does not match type defined in relation" 
  667                             std::cout << 
rel.second[
j] << 
" does not match type defined in relation" 
  675                             std::cout << 
rel.second[
j] << 
" does not match type defined in relation" 
  684                 constConstraints.push_back(std::make_pair(std::make_pair(idx, 
j), rd));
 
  686                     constTuple.push_back(rd);
 
  696                     constConstraints.getConstraints().erase(constConstraints.getConstraints().end() -
 
  699                             constConstraints.getConstraints().end());
 
  702                     std::cout << 
"false." << std::endl;
 
  703                     std::cout << 
"Tuple " << 
rel.first << 
"(";
 
  704                     for (
size_t l = 0; 
l < 
rel.second.size() - 1; ++
l) {
 
  705                         std::cout << 
rel.second[
l] << 
", ";
 
  707                     std::cout << 
rel.second.back() << 
") does not exist" << std::endl;
 
  718         if (varRels.size() == 0) {
 
  719             std::cout << 
"true." << std::endl;
 
  728     std::map<std::pair<std::string, size_t>, std::vector<std::string>> 
info;
 
  729     std::map<std::pair<std::string, size_t>, std::string> 
rules;
 
  730     std::vector<std::vector<RamDomain>> 
subproofs;
 
 
References souffle::canBeParsedAsRamFloat(), souffle::canBeParsedAsRamSigned(), souffle::canBeParsedAsRamUnsigned(), souffle::ConstConstraint::getConstraints(), j, l, souffle::ConstConstraint::push_back(), souffle::ramBitCast(), souffle::RamFloatFromString(), souffle::RamSignedFromString(), souffle::RamUnsignedFromString(), rel(), and relation.
 
 
◆ setup()
  
  | 
        
          | void souffle::ExplainProvenanceImpl::setup | ( |  | ) |  |  | inlineoverridevirtual | 
 
Implements souffle::ExplainProvenance.
Definition at line 62 of file ExplainProvenanceImpl.h.
   67             for (
auto& tuple : *
rel) {
 
   68                 std::vector<std::string> bodyLiterals;
 
   73                 for (
size_t i = 1; 
i + 1 < 
rel->getArity(); 
i++) {
 
   76                     bodyLiterals.push_back(bodyLit);
 
   82                 info.insert({std::make_pair(name.substr(0, name.find(
".@info")), ruleNum), bodyLiterals});
 
   83                 rules.insert({std::make_pair(name.substr(0, name.find(
".@info")), ruleNum), 
rule});
 
   89             std::string relName, std::vector<RamDomain> tuple, 
int ruleNum, 
int levelNum, 
size_t depthLimit) {
 
   90         std::stringstream joinedArgs;
 
   92         auto joinedArgsStr = joinedArgs.str();
 
 
 
 
◆ constraintList
  
  | 
        
          | std::vector<std::string> souffle::ExplainProvenanceImpl::constraintList |  | private | 
 
Initial value:= {
            "=", "!=", "<", "<=", ">=", ">", "match", "contains", "not_match", "not_contains"}
Definition at line 737 of file ExplainProvenanceImpl.h.
 
 
◆ info
  
  | 
        
          | std::map<std::pair<std::string, size_t>, std::vector<std::string> > souffle::ExplainProvenanceImpl::info |  | private | 
 
 
◆ rules
  
  | 
        
          | std::map<std::pair<std::string, size_t>, std::string> souffle::ExplainProvenanceImpl::rules |  | private | 
 
 
◆ subproofs
  
  | 
        
          | std::vector<std::vector<RamDomain> > souffle::ExplainProvenanceImpl::subproofs |  | private | 
 
 
The documentation for this class was generated from the following file:
 
void findQuerySolution(const std::vector< Relation * > &varRels, const std::map< std::string, Equivalence > &nameToEquivalence, const ConstConstraint &constConstraints)
RamSigned RamSignedFromString(const std::string &str, std::size_t *position=nullptr, const int base=10)
Converts a string to a RamSigned.
const std::string & resolve(const RamDomain index) const
Find a symbol in the table by its index, note that this gives an error if the index is out of bounds.
std::map< std::pair< std::string, size_t >, std::vector< std::string > > info
bool isNumber(const char *str)
Check whether a string is a sequence of digits.
bool canBeParsedAsRamFloat(const std::string &string)
Can a string be parsed as RamFloat.
std::vector< std::string > getRules(const std::string &relName) override
std::vector< std::vector< RamDomain > > subproofs
bool contains(const C &container, const typename C::value_type &element)
A utility to check generically whether a given element is contained in a given container.
Own< TreeNode > explainSubproof(std::string relName, RamDomain subproofNum, size_t depthLimit) override
Own< TreeNode > explainNegation(std::string relName, size_t ruleNum, const std::vector< std::string > &tuple, std::map< std::string, std::string > &bodyVariables) override
std::vector< std::string > constraintList
RamDomain lookup(const std::string &symbol)
Find the index of a symbol in the table, inserting a new symbol if it does not exist there already.
RamDomain lookupExisting(const std::string &symbol) const
Finds the index of a symbol in the table, giving an error if it's not found.
void queryProcess(const std::vector< std::pair< std::string, std::vector< std::string >>> &rels) override
Process query with given arguments.
std::string stringify(const std::string &input)
Stringify a string using escapes for escape, newline, tab, double-quotes and semicolons.
std::string getRule(std::string relName, size_t ruleNum) override
detail::joined_sequence< Iter, Printer > join(const Iter &a, const Iter &b, const std::string &sep, const Printer &p)
Creates an object to be forwarded to some output stream for printing sequences of elements interspers...
void printRulesJSON(std::ostream &os) override
std::vector< RamDomain > argsToNums(const std::string &relName, const std::vector< std::string > &args) const
BinaryConstraintOp toBinaryConstraintOp(const std::string &symbol)
Converts symbolic representation of an operator to the operator.
bool canBeParsedAsRamUnsigned(const std::string &string)
Can a string be parsed as RamUnsigned.
BinaryConstraintOp
Binary Constraint Operators.
std::vector< Relation * > getAllRelations() const
Getter of allRelations, which this vector structure contains all relations.
long duration(const time_point &start, const time_point &end)
std::vector< std::string > decodeArguments(const std::string &relName, const std::vector< RamDomain > &nums) const
Decode arguments from their ram representation and return as strings.
virtual arity_type getAuxiliaryArity() const =0
Return the number of auxiliary attributes.
Own< TreeNode > explain(std::string relName, std::vector< RamDomain > tuple, int ruleNum, int levelNum, size_t depthLimit)
virtual void executeSubroutine(std::string, const std::vector< RamDomain > &, std::vector< RamDomain > &)
Execute a subroutine.
Relation * getRelation(const std::string &name) const
Get Relation by its name from relationMap, if relation not found, return a nullptr.
virtual arity_type getArity() const =0
Return the arity of a relation.
bool canBeParsedAsRamSigned(const std::string &string)
Can a string be parsed as RamSigned.
std::vector< std::string > splitString(const std::string &str, char delimiter)
Splits a string given a delimiter.
void fatal(const char *format, const Args &... args)
Relation::arity_type arity_type
RamUnsigned RamUnsignedFromString(const std::string &str, std::size_t *position=nullptr, const int base=10)
Converts a string to a RamUnsigned.
To ramBitCast(From source)
In C++20 there will be a new way to cast between types by reinterpreting bits (std::bit_cast),...
std::map< std::pair< std::string, size_t >, std::string > rules
bool containsTuple(Relation *relation, const std::vector< RamDomain > &constTuple)
RamFloat RamFloatFromString(const std::string &str, std::size_t *position=nullptr)
Converts a string to a RamFloat.
void rel(size_t limit, bool showLimit=true)
bool isOrderedBinaryConstraintOp(const BinaryConstraintOp op)
Determines whether arguments of constraint are orderable.
virtual SymbolTable & getSymbolTable()=0
Get the symbol table of the program.
class souffle::profile::Tui ss