int main(int argc, char **argv) { assert(argc == 4); // TODO: maybe we want to get them from prompt args int num_vars = stoi(argv[2]); int depth = stoi(argv[3]); ifstream stream(argv[1]); StateTransitionSystemLoader loader(stream); unique_ptr<StateTransitionSystem> sts = loader.make(); State* si = sts->states()[0]; VariableAssignment vars = VariableAssignment(num_vars); for (auto *var : sts->variables()) { vars.set(var, false); } ReachabilitySet rs = computeReachabilitySet(Configuration(si, move(vars))); size_t siex = (num_vars + 1) + pow(2, depth + 1) - 1; cout << endl << "SIZE expected: " << siex; size_t size = rs.size(); cout << endl << "SIZE: " << size << endl; if (size - siex != 0) return 1; return 0; }
bool Rank1Constraint::isSatisfied(const VariableAssignment& assignment, const PrintOptions& printOnFail) const { const FElem ares = a_.eval(assignment); const FElem bres = b_.eval(assignment); const FElem cres = c_.eval(assignment); if (ares*bres != cres) { # ifdef DEBUG if (printOnFail == PrintOptions::DBG_PRINT_IF_NOT_SATISFIED) { cerr << GADGETLIB2_FMT("Constraint named \"%s\" not satisfied. Constraint is:", name().c_str()) << endl; cerr << annotation() << endl; cerr << "Variable assignments are:" << endl; const Variable::set varSet = getUsedVariables(); for(const Variable& var : varSet) { cerr << var.name() << ": " << assignment.at(var).asString() << endl; } cerr << "a: " << ares.asString() << endl; cerr << "b: " << bres.asString() << endl; cerr << "a*b: " << (ares*bres).asString() << endl; cerr << "c: " << cres.asString() << endl; } # endif return false; } return true; }
FElem Variable::eval(const VariableAssignment& assignment) const { try { return assignment.at(*this); } catch (::std::out_of_range) { GADGETLIB_FATAL(GADGETLIB2_FMT("Attempted to evaluate unassigned Variable \"%s\", idx:%lu", name().c_str(), index_)); } }
bool PolynomialConstraint::isSatisfied(const VariableAssignment& assignment, const PrintOptions& printOnFail) const { const FElem aEval = a_.eval(assignment); const FElem bEval = b_.eval(assignment); if (aEval != bEval) { # ifdef DEBUG if(printOnFail == PrintOptions::DBG_PRINT_IF_NOT_SATISFIED) { cerr << GADGETLIB2_FMT("Constraint named \"%s\" not satisfied. Constraint is:", name().c_str()) << endl; cerr << annotation() << endl; cerr << "Expecting: " << aEval << " == " << bEval << endl; cerr << "Variable assignments are:" << endl; const Variable::set varSet = getUsedVariables(); for(const Variable& var : varSet) { cerr << var.name() << ": " << assignment.at(var).asString() << endl; } } # endif return false; } return true; }
size_t numVars() const {return assignment_.size();} // TODO change to take num from constraintSys_