Reformatting

This commit is contained in:
Artur Meski
2018-03-28 21:00:44 +01:00
parent c90a87875a
commit 5f1a759c8f
18 changed files with 2204 additions and 2056 deletions

View File

@@ -9,18 +9,20 @@ CtxAut::CtxAut(Options *opts, RctSys *parent_rctsys)
bool CtxAut::hasState(std::string name)
{
if (states_names.find(name) == states_names.end())
if (states_names.find(name) == states_names.end()) {
return false;
else
}
else {
return true;
}
}
State CtxAut::getStateID(std::string name)
{
if (!hasState(name))
{
if (!hasState(name)) {
FERROR("No such state: " << name);
}
return states_names[name];
}
@@ -32,8 +34,7 @@ std::string CtxAut::getStateName(State state_id)
void CtxAut::addState(std::string name)
{
if (!hasState(name))
{
if (!hasState(name)) {
State new_state_id = states_ids.size();
VERB_L2("Adding state: " << name << " index=" << new_state_id);
@@ -41,8 +42,7 @@ void CtxAut::addState(std::string name)
states_ids.push_back(name);
states_names[name] = new_state_id;
if (!init_state_defined)
{
if (!init_state_defined) {
setInitState(name);
}
}
@@ -73,9 +73,11 @@ void CtxAut::showStates(void)
{
cout << "# Context Automaton States:" << endl;
cout << " = Init state: " << getStateName(init_state_id) << endl;
for (const auto &s : states_ids)
for (const auto &s : states_ids) {
cout << " * " << s << endl;
}
}
void CtxAut::pushContextEntity(Entity entity_id)
{
@@ -98,9 +100,10 @@ void CtxAut::addTransition(std::string srcStateName, std::string dstStateName)
void CtxAut::showTransitions(void)
{
cout << "# Context Automaton Transitions:" << endl;
for (const auto &t : transitions)
{
cout << " * [" << getStateName(t.src_state) << " -> " << getStateName(t.dst_state)
for (const auto &t : transitions) {
cout << " * [" << getStateName(t.src_state) << " -> " << getStateName(
t.dst_state)
<< "]: {" << parent_rctsys->entitiesToStr(t.ctx) << "}" << endl;
}
}

View File

@@ -42,8 +42,14 @@ class CtxAut
void addTransition(std::string srcStateName, std::string dstStateName);
void showTransitions(void);
void pushContextEntity(Entity entity_id);
void setOptions(Options *opts) { this->opts = opts; }
size_t statesCount(void) { return states_ids.size(); }
void setOptions(Options *opts)
{
this->opts = opts;
}
size_t statesCount(void)
{
return states_ids.size();
}
private:
RctSys *parent_rctsys;

View File

@@ -11,34 +11,31 @@
std::string BoolContexts::toStr(void) const
{
if (oper == BCTX_PV)
{
if (oper == BCTX_PV) {
return name;
}
else if (oper == BCTX_TF)
{
if (tf) return "true";
else return "false";
else if (oper == BCTX_TF) {
if (tf) {
return "true";
}
else if (oper == BCTX_AND)
{
else {
return "false";
}
}
else if (oper == BCTX_AND) {
return "(" + arg[0]->toStr() + " AND " + arg[1]->toStr() + ")";
}
else if (oper == BCTX_OR)
{
else if (oper == BCTX_OR) {
return "(" + arg[0]->toStr() + " OR " + arg[1]->toStr() + ")";
}
else if (oper == BCTX_XOR)
{
else if (oper == BCTX_XOR) {
return "(" + arg[0]->toStr() + " XOR " + arg[1]->toStr() + ")";
}
else if (oper == BCTX_NOT)
{
else if (oper == BCTX_NOT) {
return "~" + arg[0]->toStr();
}
else
{
else {
return "??";
assert(0);
}
@@ -46,33 +43,30 @@ std::string BoolContexts::toStr(void) const
BDD BoolContexts::getBDD(const SymRS *srs) const
{
if (oper == BCTX_PV)
{
if (oper == BCTX_PV) {
return srs->encActStrEntity(name);
}
else if (oper == BCTX_TF)
{
if (tf) return srs->getBDDtrue();
else return srs->getBDDfalse();
else if (oper == BCTX_TF) {
if (tf) {
return srs->getBDDtrue();
}
else if (oper == BCTX_AND)
{
else {
return srs->getBDDfalse();
}
}
else if (oper == BCTX_AND) {
return arg[0]->getBDD(srs) * arg[1]->getBDD(srs);
}
else if (oper == BCTX_OR)
{
else if (oper == BCTX_OR) {
return arg[0]->getBDD(srs) + arg[1]->getBDD(srs);
}
else if (oper == BCTX_XOR)
{
else if (oper == BCTX_XOR) {
return arg[0]->getBDD(srs) ^ arg[1]->getBDD(srs);
}
else if (oper == BCTX_NOT)
{
else if (oper == BCTX_NOT) {
return !arg[0]->getBDD(srs);
}
else
{
else {
assert(0);
FERROR("Undefined operator used in Boolean context definition. This should not happen.");
return srs->getBDDfalse();
@@ -81,102 +75,84 @@ BDD BoolContexts::getBDD(const SymRS *srs) const
std::string FormRSCTL::toStr(void) const
{
if (oper == RSCTL_PV)
{
if (oper == RSCTL_PV) {
return name;
}
else if (oper == RSCTL_TF)
{
if (tf) return "true";
else return "false";
else if (oper == RSCTL_TF) {
if (tf) {
return "true";
}
else if (oper == RSCTL_AND)
{
else {
return "false";
}
}
else if (oper == RSCTL_AND) {
return "(" + arg[0]->toStr() + " AND " + arg[1]->toStr() + ")";
}
else if (oper == RSCTL_OR)
{
else if (oper == RSCTL_OR) {
return "(" + arg[0]->toStr() + " OR " + arg[1]->toStr() + ")";
}
else if (oper == RSCTL_XOR)
{
else if (oper == RSCTL_XOR) {
return "(" + arg[0]->toStr() + " XOR " + arg[1]->toStr() + ")";
}
else if (oper == RSCTL_IMPL)
{
else if (oper == RSCTL_IMPL) {
return "(" + arg[0]->toStr() + " IMPLIES " + arg[1]->toStr() + ")";
}
else if (oper == RSCTL_NOT)
{
else if (oper == RSCTL_NOT) {
return "~" + arg[0]->toStr();
}
else if (oper == RSCTL_EX)
{
else if (oper == RSCTL_EX) {
return "EX(" + arg[0]->toStr() + ")";
}
else if (oper == RSCTL_EG)
{
else if (oper == RSCTL_EG) {
return "EG(" + arg[0]->toStr() + ")";
}
else if (oper == RSCTL_EU)
{
else if (oper == RSCTL_EU) {
return "EU(" + arg[0]->toStr() + "," + arg[1]->toStr() + ")";
}
else if (oper == RSCTL_EF)
{
else if (oper == RSCTL_EF) {
return "EF(" + arg[0]->toStr() + ")";
}
else if (oper == RSCTL_AX)
{
else if (oper == RSCTL_AX) {
return "AX(" + arg[0]->toStr() + ")";
}
else if (oper == RSCTL_AG)
{
else if (oper == RSCTL_AG) {
return "AG(" + arg[0]->toStr() + ")";
}
else if (oper == RSCTL_AU)
{
else if (oper == RSCTL_AU) {
return "AU(" + arg[0]->toStr() + "," + arg[1]->toStr() + ")";
}
else if (oper == RSCTL_AF)
{
else if (oper == RSCTL_AF) {
return "AF(" + arg[0]->toStr() + ")";
}
else if (oper == RSCTL_EX_ACT)
{
else if (oper == RSCTL_EX_ACT) {
return "E" + getActionsStr() + "X(" + arg[0]->toStr() + ")";
}
else if (oper == RSCTL_EG_ACT)
{
else if (oper == RSCTL_EG_ACT) {
return "E" + getActionsStr() + "G(" + arg[0]->toStr() + ")";
}
else if (oper == RSCTL_EU_ACT)
{
return "E" + getActionsStr() + "U(" + arg[0]->toStr() + "," + arg[1]->toStr() + ")";
else if (oper == RSCTL_EU_ACT) {
return "E" + getActionsStr() + "U(" + arg[0]->toStr() + "," + arg[1]->toStr()
+ ")";
}
else if (oper == RSCTL_EF_ACT)
{
else if (oper == RSCTL_EF_ACT) {
return "E" + getActionsStr() + "F(" + arg[0]->toStr() + ")";
}
else if (oper == RSCTL_AX_ACT)
{
else if (oper == RSCTL_AX_ACT) {
return "A" + getActionsStr() + "X(" + arg[0]->toStr() + ")";
}
else if (oper == RSCTL_AG_ACT)
{
else if (oper == RSCTL_AG_ACT) {
return "A" + getActionsStr() + "G(" + arg[0]->toStr() + ")";
}
else if (oper == RSCTL_AU_ACT)
{
return "A" + getActionsStr() + "U(" + arg[0]->toStr() + "," + arg[1]->toStr() + ")";
else if (oper == RSCTL_AU_ACT) {
return "A" + getActionsStr() + "U(" + arg[0]->toStr() + "," + arg[1]->toStr()
+ ")";
}
else if (oper == RSCTL_AF_ACT)
{
else if (oper == RSCTL_AF_ACT) {
return "A" + getActionsStr() + "F(" + arg[0]->toStr() + ")";
}
else
{
else {
return "??";
assert(0);
}
@@ -184,61 +160,62 @@ std::string FormRSCTL::toStr(void) const
bool FormRSCTL::hasOper(Oper op) const
{
if (oper == op)
if (oper == op) {
return true;
else
{
}
else {
bool result = false;
if (arg[0] != nullptr) result = arg[0]->hasOper(op);
if (!result && arg[1] != nullptr) result = arg[1]->hasOper(op);
if (arg[0] != nullptr) {
result = arg[0]->hasOper(op);
}
if (!result && arg[1] != nullptr) {
result = arg[1]->hasOper(op);
}
return result;
}
}
void FormRSCTL::encodeEntities(const SymRS *srs)
{
if (RSCTL_COND_1ARG(oper))
{
if (RSCTL_COND_1ARG(oper)) {
arg[0]->encodeEntities(srs);
}
else if (RSCTL_COND_2ARG(oper))
{
else if (RSCTL_COND_2ARG(oper)) {
arg[0]->encodeEntities(srs);
arg[1]->encodeEntities(srs);
}
else if (oper == RSCTL_PV)
{
else if (oper == RSCTL_PV) {
bdd = new BDD(srs->encEntity(name));
}
}
bool FormRSCTL::isERSCTL(void) const
{
if (oper == RSCTL_PV)
{
if (oper == RSCTL_PV) {
return true;
}
if (oper == RSCTL_NOT)
{
if (arg[0]->getOper() == RSCTL_PV || arg[0]->getOper() == RSCTL_TF)
if (oper == RSCTL_NOT) {
if (arg[0]->getOper() == RSCTL_PV || arg[0]->getOper() == RSCTL_TF) {
return true;
else
}
else {
return false;
}
}
if (RSCTL_COND_IS_UNIVERSAL(oper)) {
return false;
}
if (RSCTL_COND_IS_UNIVERSAL(oper))
{
return false;
}
if (RSCTL_COND_1ARG(oper))
{
if (RSCTL_COND_1ARG(oper)) {
return arg[0]->isERSCTL();
}
if (RSCTL_COND_2ARG(oper))
{
if (RSCTL_COND_2ARG(oper)) {
return arg[0]->isERSCTL() && arg[1]->isERSCTL();
}
@@ -249,74 +226,84 @@ bool FormRSCTL::isERSCTL(void) const
std::string FormRSCTL::getActionsStr(void) const
{
if (actions != nullptr)
{
if (actions != nullptr) {
std::string r = "[ ";
bool firstact = true;
for (ActionsVec_f::iterator act = actions->begin(); act != actions->end(); ++act)
{
if (!firstact) r += ",";
else firstact = false;
for (ActionsVec_f::iterator act = actions->begin(); act != actions->end();
++act) {
if (!firstact) {
r += ",";
}
else {
firstact = false;
}
r += "{";
bool firstent = true;
for (Action_f::iterator ent = act->begin(); ent != act->end(); ++ent)
{
if (!firstent) r += ",";
else firstent = false;
for (Action_f::iterator ent = act->begin(); ent != act->end(); ++ent) {
if (!firstent) {
r += ",";
}
else {
firstent = false;
}
r += *ent;
}
r += "}";
}
r += " ]";
return r;
}
else if (boolCtx != nullptr)
{
else if (boolCtx != nullptr) {
return "< " + boolCtx->toStr() + " >";
}
else
{
else {
FERROR("Context not specified. This should not happen.");
}
}
void FormRSCTL::encodeActions(const SymRS *srs)
{
if (RSCTL_COND_ACT(oper))
{
if (actions_bdd != nullptr) forgetActionsBDD();
if (RSCTL_COND_ACT(oper)) {
if (actions_bdd != nullptr) {
forgetActionsBDD();
}
actions_bdd = new BDD(srs->getBDDfalse());
assert(actions != nullptr || boolCtx != nullptr);
assert(!(actions != nullptr && boolCtx != nullptr));
if (actions != nullptr)
{
for (ActionsVec_f::iterator act = actions->begin(); act != actions->end(); ++act)
{
if (actions != nullptr) {
for (ActionsVec_f::iterator act = actions->begin(); act != actions->end();
++act) {
BDD single_action = srs->getBDDtrue();
for (Action_f::iterator ent = act->begin(); ent != act->end(); ++ent)
{
for (Action_f::iterator ent = act->begin(); ent != act->end(); ++ent) {
single_action *= srs->encActStrEntity(*ent);
}
single_action = srs->compContext(single_action);
*actions_bdd += single_action;
}
}
else if (boolCtx != nullptr)
{
else if (boolCtx != nullptr) {
*actions_bdd = boolCtx->getBDD(srs);
}
else
else {
assert(0);
}
}
if (RSCTL_COND_1ARG(oper))
{
if (RSCTL_COND_1ARG(oper)) {
arg[0]->encodeActions(srs);
}
if (RSCTL_COND_2ARG(oper))
{
if (RSCTL_COND_2ARG(oper)) {
arg[0]->encodeActions(srs);
arg[1]->encodeActions(srs);
}

View File

@@ -91,7 +91,8 @@ public:
*
* @param val value of the logical constant
*/
BoolContexts(bool val) {
BoolContexts(bool val)
{
oper = BCTX_TF;
tf = val;
arg[0] = nullptr;
@@ -101,7 +102,8 @@ public:
/**
* @brief Constructor for one-argument formula.
*/
BoolContexts(Oper op, BoolContexts *form1) {
BoolContexts(Oper op, BoolContexts *form1)
{
assert(op == BCTX_NOT);
oper = op;
arg[0] = form1;
@@ -111,14 +113,16 @@ public:
/**
* @brief Constructor for two-argument formula.
*/
BoolContexts(Oper op, BoolContexts *form1, BoolContexts *form2) {
BoolContexts(Oper op, BoolContexts *form1, BoolContexts *form2)
{
assert(BCTX_COND_2ARG(op));
oper = op;
arg[0] = form1;
arg[1] = form2;
}
~BoolContexts() {
~BoolContexts()
{
delete arg[0];
delete arg[1];
}
@@ -127,15 +131,18 @@ public:
BDD getBDD(const SymRS *srs) const;
Oper getOper(void) const {
Oper getOper(void) const
{
assert(BCTX_IS_VALID(oper));
return oper;
}
BoolContexts *getLeftSF(void) const {
BoolContexts *getLeftSF(void) const
{
assert(arg[0] != nullptr);
return arg[0];
}
BoolContexts *getRightSF(void) const {
BoolContexts *getRightSF(void) const
{
assert(BCTX_COND_2ARG(oper));
assert(arg[1] != nullptr);
return arg[1];
@@ -159,7 +166,8 @@ public:
* @param varName variable name used mostly for printing the variable.
* @param varBDD the BDD describing the set where the variable holds.
*/
FormRSCTL(std::string varName) {
FormRSCTL(std::string varName)
{
oper = RSCTL_PV;
name = varName;
arg[0] = nullptr;
@@ -175,7 +183,8 @@ public:
*
* @param val value of the logical constant
*/
FormRSCTL(bool val) {
FormRSCTL(bool val)
{
oper = RSCTL_TF;
tf = val;
arg[0] = nullptr;
@@ -189,7 +198,8 @@ public:
/**
* @brief Constructor for two-argument formula.
*/
FormRSCTL(Oper op, FormRSCTL *form1, FormRSCTL *form2) {
FormRSCTL(Oper op, FormRSCTL *form1, FormRSCTL *form2)
{
assert(RSCTL_COND_2ARG(op));
assert(!RSCTL_COND_ACT(op));
oper = op;
@@ -204,7 +214,8 @@ public:
/**
* @brief Constructor for two-argument formula with action restrictions.
*/
FormRSCTL(Oper op, ActionsVec_f *acts, FormRSCTL *form1, FormRSCTL *form2) {
FormRSCTL(Oper op, ActionsVec_f *acts, FormRSCTL *form1, FormRSCTL *form2)
{
assert(acts != nullptr);
assert(RSCTL_COND_2ARG(op));
assert(RSCTL_COND_ACT(op));
@@ -220,7 +231,8 @@ public:
/**
* @brief Constructor for two-argument formula with Boolean context restrictions.
*/
FormRSCTL(Oper op, BoolContexts *bctx, FormRSCTL *form1, FormRSCTL *form2) {
FormRSCTL(Oper op, BoolContexts *bctx, FormRSCTL *form1, FormRSCTL *form2)
{
assert(bctx != nullptr);
assert(RSCTL_COND_2ARG(op));
assert(RSCTL_COND_ACT(op));
@@ -236,7 +248,8 @@ public:
/**
* @brief Constructor for one-argument formula.
*/
FormRSCTL(Oper op, FormRSCTL *form1) {
FormRSCTL(Oper op, FormRSCTL *form1)
{
assert(RSCTL_COND_1ARG(op));
assert(!RSCTL_COND_ACT(op));
oper = op;
@@ -251,7 +264,8 @@ public:
/**
* @brief Constructor for one-argument formula with action restrictions.
*/
FormRSCTL(Oper op, ActionsVec_f *acts, FormRSCTL *form1) {
FormRSCTL(Oper op, ActionsVec_f *acts, FormRSCTL *form1)
{
assert(acts != nullptr);
assert(RSCTL_COND_1ARG(op));
assert(RSCTL_COND_ACT(op));
@@ -267,7 +281,8 @@ public:
/**
* @brief Constructor for one-argument formula with Boolean context restrictions.
*/
FormRSCTL(Oper op, BoolContexts *bctx, FormRSCTL *form1) {
FormRSCTL(Oper op, BoolContexts *bctx, FormRSCTL *form1)
{
assert(bctx != nullptr);
assert(RSCTL_COND_1ARG(op));
assert(RSCTL_COND_ACT(op));
@@ -283,7 +298,8 @@ public:
/**
* @brief Destructor.
*/
~FormRSCTL() {
~FormRSCTL()
{
delete arg[0];
delete arg[1];
delete bdd;
@@ -293,38 +309,47 @@ public:
}
std::string toStr(void) const;
bool hasOper(Oper op) const;
const BDD *getBDD(void) const {
const BDD *getBDD(void) const
{
assert(oper == RSCTL_PV);
assert(bdd != nullptr);
return bdd;
}
const BDD *getActionsBDD(void) const {
const BDD *getActionsBDD(void) const
{
assert(RSCTL_COND_ACT(oper));
assert(actions_bdd != nullptr);
return actions_bdd;
}
Oper getOper(void) const {
Oper getOper(void) const
{
assert(RSCTL_IS_VALID(oper));
return oper;
}
FormRSCTL *getLeftSF(void) const {
FormRSCTL *getLeftSF(void) const
{
assert(arg[0] != nullptr);
return arg[0];
}
FormRSCTL *getRightSF(void) const {
FormRSCTL *getRightSF(void) const
{
assert(RSCTL_COND_2ARG(oper));
assert(arg[1] != nullptr);
return arg[1];
}
std::string getActionsStr(void) const;
bool getTF(void) const {
bool getTF(void) const
{
assert(oper == RSCTL_TF);
return tf;
}
void encodeEntities(const SymRS *srs);
void encodeActions(const SymRS *srs);
void forgetActionsBDD(void) {
if (actions_bdd != nullptr) delete actions_bdd;
void forgetActionsBDD(void)
{
if (actions_bdd != nullptr) {
delete actions_bdd;
}
}
bool isERSCTL(void) const;
};

93
main.cc
View File

@@ -24,8 +24,7 @@ int main(int argc, char **argv)
bool usage_error = false;
bool print_parsed_sys = false;
static struct option long_options[] =
{
static struct option long_options[] = {
{"trace-parsing", no_argument, 0, 0 },
{"trace-scanning", no_argument, 0, 0 },
{0, 0, 0, 0 }
@@ -34,65 +33,84 @@ int main(int argc, char **argv)
int c;
int option_index = 0;
while ((c = getopt_long(argc, argv, "cbBmpPrsStTvxzh", long_options, &option_index)) != -1)
{
while ((c = getopt_long(argc, argv, "cbBmpPrsStTvxzh", long_options,
&option_index)) != -1) {
switch (c) {
case 0:
printf("option %s", long_options[option_index].name);
if (optarg)
if (optarg) {
printf(" with arg %s", optarg);
}
printf("\n");
if (strcmp(long_options[option_index].name, "trace-parsing"))
if (strcmp(long_options[option_index].name, "trace-parsing")) {
driver.trace_parsing = true;
else if (strcmp(long_options[option_index].name, "trace-scanning"))
}
else if (strcmp(long_options[option_index].name, "trace-scanning")) {
driver.trace_scanning = true;
}
break;
//case 'b':
// printf("-b with %s\n", optarg);
// break;
case 'b':
bmc = false;
break;
case 'p':
opts->show_progress = true;
break;
case 'P':
print_parsed_sys = true;
break;
case 'r':
show_reactions = true;
break;
case 'c':
rstl_model_checking = true;
break;
case 'm':
opts->measure = true;
break;
case 'B':
benchmarking = true;
opts->measure = true;
break;
case 's':
reach_states = true;
break;
case 't':
reach_states_succ = true;
break;
case 'v':
opts->verbose++;
break;
case 'x':
opts->part_tr_rel = true;
break;
case 'z':
opts->reorder_reach = true;
opts->reorder_trans = true;
break;
case 'h':
usage_error = true;
break;
default:
usage_error = true;
break;
@@ -100,36 +118,32 @@ int main(int argc, char **argv)
}
std::string inputfile;
if (optind < argc)
{
if (optind < argc) {
inputfile = argv[optind];
}
else
{
else {
cout << "Missing input file" << endl;
usage_error = true;
}
if (usage_error)
{
if (usage_error) {
print_help(std::string(argv[0]));
return 100;
}
if (!(reach_states || reach_states_succ || rstl_model_checking || show_reactions || print_parsed_sys))
{
if (!(reach_states || reach_states_succ || rstl_model_checking
|| show_reactions || print_parsed_sys)) {
FERROR("No task specified: -c, -P, -r, or -s needs to be used");
}
if (opts->verbose > 0)
{
if (opts->verbose > 0) {
cout << "Verbose level: " << opts->verbose << endl;
}
VERB("Parsing " << inputfile);
if (driver.parse(inputfile))
{
if (driver.parse(inputfile)) {
FERROR("Parse error");
}
@@ -144,51 +158,47 @@ int main(int argc, char **argv)
rs.setOptions(opts); // these need to be passed to the driver
if (show_reactions)
if (show_reactions) {
rs.showReactions();
}
if (print_parsed_sys)
if (print_parsed_sys) {
rs.printSystem();
}
if (reach_states || reach_states_succ || rstl_model_checking)
{
if (reach_states || reach_states_succ || rstl_model_checking) {
SymRS srs(&rs, opts);
ModelChecker mc(&srs, opts);
if (reach_states)
{
if (reach_states) {
mc.printReach();
}
if (reach_states_succ)
{
if (reach_states_succ) {
mc.printReachWithSucc();
}
if (rstl_model_checking)
{
if (bmc)
{
if (rstl_model_checking) {
if (bmc) {
cout << "Using BDD-based Bounded Model Checking" << endl;
mc.checkRSCTL(driver.getFormRSCTL());
}
else
{
else {
mc.checkRSCTLfull(driver.getFormRSCTL());
}
}
}
if (opts->measure)
{
if (opts->measure) {
cout << endl << std::setprecision(4)
<< "Encoding time: " << opts->enc_time << " sec" << endl
<< "Verification time: " << opts->ver_time << " sec" << endl
<< "Encoding memory: " << opts->enc_mem << " MB" << endl
<< "Memory (total): " << opts->ver_mem << " MB" << endl
<< "TOTAL time: " << opts->enc_time + opts->ver_time << " sec" << endl;
if (benchmarking)
{
if (benchmarking) {
cout << std::setprecision(4)
<< "STAT; " << opts->enc_time
<< " ; " << opts->ver_time
@@ -228,12 +238,15 @@ void print_help(std::string path_str)
<< " -P -- print parsed system" << endl
<< " -r -- print reactions" << endl
<< " -s -- print the set of all the reachable states" << endl
<< " -t -- print the set of all the reachable states with their successors" << endl
<< " -t -- print the set of all the reachable states with their successors"
<< endl
<< endl << " OTHER:" << endl
<< " -b -- disable bounded model checking (BMC) heuristic" << endl
<< " -x -- use partitioned transition relation (may use less memory)" << endl
<< " -x -- use partitioned transition relation (may use less memory)" <<
endl
<< " -z -- use reordering of the BDD variables" << endl
<< " -v -- verbose (can be used more than once to increase verbosity)" << endl
<< " -v -- verbose (can be used more than once to increase verbosity)" <<
endl
<< " -p -- show progress (where possible)" << endl
<< endl
<< " Benchmarking options:" << endl

271
mc.cc
View File

@@ -27,22 +27,24 @@ ModelChecker::ModelChecker(SymRS *srs, Options *opts)
// If we use trp, then trm is nullptr (same for trm)
//
trp = srs->getEncPartTrans();
if (trp == nullptr)
if (trp == nullptr) {
trp_size = 0;
else
}
else {
trp_size = trp->size();
}
trm = srs->getEncMonoTrans();
if (srs->usingContextAutomaton())
{
if (srs->usingContextAutomaton()) {
using_ctx_aut = true;
pv_ca = srs->getEncCtxAutPV();
pv_ca_succ = srs->getEncCtxAutPVsucc();
pv_ca_E = srs->getEncCtxAutPV_E();
pv_ca_succ_E = srs->getEncCtxAutPVsucc_E();
}
else
{
else {
using_ctx_aut = false;
pv_ca = nullptr;
pv_ca_succ = nullptr;
@@ -59,17 +61,16 @@ inline BDD ModelChecker::getSucc(const BDD &states)
BDD q = BDD_TRUE;
VERB_L2("Computing successors");
if (opts->part_tr_rel)
{
for (unsigned int i = 0; i < trp_size; ++i)
{
if (opts->part_tr_rel) {
for (unsigned int i = 0; i < trp_size; ++i) {
q *= states * (*trp)[i];
}
}
else
{
else {
q *= states * *trm;
}
q = (q.ExistAbstract(*pv_E)).SwapVariables(*pv_succ, *pv);
q = q.ExistAbstract(*pv_act_E);
@@ -81,15 +82,16 @@ inline BDD ModelChecker::getPreE(const BDD &states)
BDD q = BDD_TRUE;
VERB_L2("Computing preE");
BDD x = states.SwapVariables(*pv, *pv_succ);
if (opts->part_tr_rel)
{
for (unsigned int i = 0; i < trp_size; ++i)
if (opts->part_tr_rel) {
for (unsigned int i = 0; i < trp_size; ++i) {
q *= x * (*trp)[i];
}
else
{
}
else {
q *= x * *trm;
}
q = q.ExistAbstract(*pv_succ_E);
q = q.ExistAbstract(*pv_act_E);
return q;
@@ -100,15 +102,16 @@ inline BDD ModelChecker::getPreEctx(const BDD &states, const BDD *contexts)
BDD q = BDD_TRUE;
VERB_L2("Computing (context-restricted) preE");
BDD x = states.SwapVariables(*pv, *pv_succ);
if (opts->part_tr_rel)
{
for (unsigned int i = 0; i < trp_size; ++i)
if (opts->part_tr_rel) {
for (unsigned int i = 0; i < trp_size; ++i) {
q *= x * (*trp)[i] * *contexts;
}
else
{
}
else {
q *= x * *trm * *contexts;
}
q = q.ExistAbstract(*pv_succ_E);
q = q.ExistAbstract(*pv_act_E);
return q;
@@ -123,8 +126,9 @@ void ModelChecker::printReach(void)
{
VERB_LN(2, "Printing/generating reachable states");
if (opts->measure)
if (opts->measure) {
opts->ver_time = cpuTime();
}
assert(initStates != nullptr);
@@ -133,12 +137,11 @@ void ModelChecker::printReach(void)
unsigned int k = 0;
while (*reach != reach_p)
{
if (opts->show_progress)
{
while (*reach != reach_p) {
if (opts->show_progress) {
cout << "\rIteration " << ++k << flush;
}
reach_p = *reach;
*reach += getSucc(*reach);
}
@@ -149,8 +152,7 @@ void ModelChecker::printReach(void)
cleanup();
if (opts->measure)
{
if (opts->measure) {
opts->ver_time = cpuTime() - opts->ver_time;
opts->ver_mem = memUsed();
}
@@ -163,8 +165,7 @@ void ModelChecker::printReachWithSucc(void)
BDD *reach = new BDD(*initStates);
BDD reach_p = cuddMgr->bddZero();
while (*reach != reach_p)
{
while (*reach != reach_p) {
reach_p = *reach;
BDD newStates = getSucc(*reach) - *reach;
*reach += newStates;
@@ -172,8 +173,8 @@ void ModelChecker::printReachWithSucc(void)
}
BDD unproc = *reach;
while (!unproc.IsZero())
{
while (!unproc.IsZero()) {
BDD t;
t = unproc.PickOneMinterm(*pv);
cout << "Successors of " << srs->decodedRctSysStateToStr(t) << ":" << endl;
@@ -186,29 +187,28 @@ void ModelChecker::printReachWithSucc(void)
bool ModelChecker::checkReach(const Entities testState)
{
if (opts->measure)
if (opts->measure) {
opts->ver_time = cpuTime();
}
BDD st = srs->getEncState(testState);
BDD reach = *initStates;
BDD reach_p = cuddMgr->bddZero();
while (reach != reach_p)
{
if (reach * st != cuddMgr->bddZero())
{
while (reach != reach_p) {
if (reach * st != cuddMgr->bddZero()) {
cleanup();
return true;
}
reach_p = reach;
reach += getSucc(reach);
}
cleanup();
if (opts->measure)
{
if (opts->measure) {
opts->ver_time = cpuTime() - opts->ver_time;
opts->ver_mem = memUsed();
}
@@ -220,124 +220,112 @@ BDD ModelChecker::getStatesRSCTL(const FormRSCTL *form)
{
assert(reach != nullptr);
Oper oper = form->getOper();
if (oper == RSCTL_PV)
{
if (oper == RSCTL_PV) {
return *form->getBDD() * *reach;
}
else if (oper == RSCTL_TF)
{
if (form->getTF() == true)
else if (oper == RSCTL_TF) {
if (form->getTF() == true) {
return *reach;
else
}
else {
return cuddMgr->bddZero();
}
else if (oper == RSCTL_AND)
{
}
else if (oper == RSCTL_AND) {
return getStatesRSCTL(form->getLeftSF()) * getStatesRSCTL(form->getRightSF());
}
else if (oper == RSCTL_OR)
{
else if (oper == RSCTL_OR) {
return getStatesRSCTL(form->getLeftSF()) + getStatesRSCTL(form->getRightSF());
}
else if (oper == RSCTL_XOR)
{
else if (oper == RSCTL_XOR) {
return getStatesRSCTL(form->getLeftSF()) ^ getStatesRSCTL(form->getRightSF());
}
else if (oper == RSCTL_IMPL)
{
return (!getStatesRSCTL(form->getLeftSF()) * *reach) + getStatesRSCTL(form->getRightSF());
else if (oper == RSCTL_IMPL) {
return (!getStatesRSCTL(form->getLeftSF()) * *reach) + getStatesRSCTL(
form->getRightSF());
}
else if (oper == RSCTL_NOT)
{
else if (oper == RSCTL_NOT) {
return !getStatesRSCTL(form->getLeftSF()) * *reach;
}
else if (oper == RSCTL_EX)
{
else if (oper == RSCTL_EX) {
return getPreE(getStatesRSCTL(form->getLeftSF())) * *reach;
}
else if (oper == RSCTL_EG)
{
else if (oper == RSCTL_EG) {
return statesEG(getStatesRSCTL(form->getLeftSF()));
}
else if (oper == RSCTL_EU)
{
else if (oper == RSCTL_EU) {
return statesEU(
getStatesRSCTL(form->getLeftSF()),
getStatesRSCTL(form->getRightSF())
);
}
else if (oper == RSCTL_EF)
{
else if (oper == RSCTL_EF) {
return statesEF(getStatesRSCTL(form->getLeftSF()));
}
else if (oper == RSCTL_AX)
{
else if (oper == RSCTL_AX) {
return !getPreE(!getStatesRSCTL(form->getLeftSF()) * *reach) * *reach;
}
else if (oper == RSCTL_AG)
{
else if (oper == RSCTL_AG) {
return !statesEF(
!getStatesRSCTL(form->getLeftSF()) * *reach) * *reach;
}
else if (oper == RSCTL_AU)
{
else if (oper == RSCTL_AU) {
BDD ng = !getStatesRSCTL(form->getRightSF()) * *reach;
BDD nf = !getStatesRSCTL(form->getLeftSF()) * *reach;
BDD x = !statesEU(ng, ng * nf) * *reach;
if (!x.IsZero())
if (!x.IsZero()) {
x = x * !statesEG(ng) * *reach;
}
return x;
}
else if (oper == RSCTL_AF)
{
else if (oper == RSCTL_AF) {
return !statesEG(
!getStatesRSCTL(form->getLeftSF()) * *reach) * *reach;
}
/***** CONTEXT RESTRICTIONS: ******/
else if (oper == RSCTL_EX_ACT)
{
return getPreEctx(getStatesRSCTL(form->getLeftSF()), form->getActionsBDD()) * *reach;
else if (oper == RSCTL_EX_ACT) {
return getPreEctx(getStatesRSCTL(form->getLeftSF()),
form->getActionsBDD()) * *reach;
}
else if (oper == RSCTL_EG_ACT)
{
return statesEGctx(form->getActionsBDD(), getStatesRSCTL(form->getLeftSF())); /***** EG? *****/
else if (oper == RSCTL_EG_ACT) {
return statesEGctx(form->getActionsBDD(),
getStatesRSCTL(form->getLeftSF())); /***** EG? *****/
}
else if (oper == RSCTL_EU_ACT)
{
else if (oper == RSCTL_EU_ACT) {
return statesEUctx(
form->getActionsBDD(),
getStatesRSCTL(form->getLeftSF()),
getStatesRSCTL(form->getRightSF())
);
}
else if (oper == RSCTL_EF_ACT)
{
else if (oper == RSCTL_EF_ACT) {
return statesEFctx(form->getActionsBDD(), getStatesRSCTL(form->getLeftSF()));
}
else if (oper == RSCTL_AX_ACT)
{
return !getPreEctx(!getStatesRSCTL(form->getLeftSF()) * *reach, form->getActionsBDD()) * *reach;
else if (oper == RSCTL_AX_ACT) {
return !getPreEctx(!getStatesRSCTL(form->getLeftSF()) * *reach,
form->getActionsBDD()) * *reach;
}
else if (oper == RSCTL_AG_ACT)
{
else if (oper == RSCTL_AG_ACT) {
return !statesEFctx(form->getActionsBDD(),
!getStatesRSCTL(form->getLeftSF()) * *reach) * *reach;
}
else if (oper == RSCTL_AU_ACT)
{
else if (oper == RSCTL_AU_ACT) {
BDD ng = !getStatesRSCTL(form->getRightSF()) * *reach;
BDD nf = !getStatesRSCTL(form->getLeftSF()) * *reach;
BDD x = !statesEUctx(form->getActionsBDD(), ng, ng * nf) * *reach;
if (!x.IsZero())
if (!x.IsZero()) {
x = x * !statesEGctx(form->getActionsBDD(), ng) * *reach;
}
return x;
}
else if (oper == RSCTL_AF_ACT)
{
else if (oper == RSCTL_AF_ACT) {
return !statesEGctx(form->getActionsBDD(),
!getStatesRSCTL(form->getLeftSF()) * *reach) * *reach;
}
@@ -350,11 +338,12 @@ BDD ModelChecker::statesEG(const BDD &states)
{
BDD x = states;
BDD x_p = cuddMgr->bddZero();
while (x != x_p)
{
while (x != x_p) {
x_p = x;
x = x * getPreE(x);
}
return x;
}
@@ -362,11 +351,12 @@ BDD ModelChecker::statesEU(const BDD &statesA, const BDD &statesB)
{
BDD x = statesA;
BDD x_p = *reach;
while (x != x_p)
{
while (x != x_p) {
x_p = x;
x = x + (statesA * getPreE(x));
}
return x;
}
@@ -374,11 +364,12 @@ BDD ModelChecker::statesEF(const BDD &states)
{
BDD x = states;
BDD x_p = *reach;
while (x != x_p)
{
while (x != x_p) {
x_p = x;
x = x + (*reach * getPreE(x));
}
return x;
}
@@ -386,23 +377,26 @@ BDD ModelChecker::statesEGctx(const BDD *contexts, const BDD &states)
{
BDD x = states;
BDD x_p = cuddMgr->bddZero();
while (x != x_p)
{
while (x != x_p) {
x_p = x;
x = x * getPreEctx(x, contexts);
}
return x;
}
BDD ModelChecker::statesEUctx(const BDD *contexts, const BDD &statesA, const BDD &statesB)
BDD ModelChecker::statesEUctx(const BDD *contexts, const BDD &statesA,
const BDD &statesB)
{
BDD x = statesA;
BDD x_p = *reach;
while (x != x_p)
{
while (x != x_p) {
x_p = x;
x = x + (statesA * getPreEctx(x, contexts));
}
return x;
}
@@ -410,26 +404,30 @@ BDD ModelChecker::statesEFctx(const BDD *contexts, const BDD &states)
{
BDD x = states;
BDD x_p = *reach;
while (x != x_p)
{
while (x != x_p) {
x_p = x;
x = x + (*reach * getPreEctx(x, contexts));
}
return x;
}
bool ModelChecker::checkRSCTL(FormRSCTL *form)
{
if (form->isERSCTL())
if (form->isERSCTL()) {
return checkRSCTLbmc(form);
else
}
else {
return checkRSCTLfull(form);
}
}
bool ModelChecker::checkRSCTLfull(FormRSCTL *form)
{
if (opts->measure)
if (opts->measure) {
opts->ver_time = cpuTime();
}
assert(form != nullptr);
@@ -454,16 +452,13 @@ bool ModelChecker::checkRSCTLfull(FormRSCTL *form)
unsigned int k = 0;
while (*reach != reach_p)
{
while (*reach != reach_p) {
if (opts->show_progress)
{
if (opts->show_progress) {
cout << "\rIteration " << ++k << flush;
}
if (opts->reorder_reach)
{
if (opts->reorder_reach) {
VERB_L2("Reordering")
Cudd_ReduceHeap(cuddMgr->getManager(), CUDD_REORDER_SIFT, 10000);
}
@@ -472,26 +467,26 @@ bool ModelChecker::checkRSCTLfull(FormRSCTL *form)
*reach += getSucc(*reach);
}
if (opts->show_progress) cout << endl;
if (opts->show_progress) {
cout << endl;
}
VERB("Checking the formula");
//if (*initStates * getStatesRSCTL(form) != cuddMgr->bddZero())
if (*initStates * getStatesRSCTL(form) == *initStates)
{
if (*initStates * getStatesRSCTL(form) == *initStates) {
result = true;
}
else
{
else {
result = false;
}
cleanup();
cout << "Formula " << form->toStr() << (result ? " holds" : " does not hold") << endl;
cout << "Formula " << form->toStr() << (result ? " holds" : " does not hold")
<< endl;
if (opts->measure)
{
if (opts->measure) {
opts->ver_time = cpuTime() - opts->ver_time;
opts->ver_mem = memUsed();
}
@@ -501,14 +496,15 @@ bool ModelChecker::checkRSCTLfull(FormRSCTL *form)
bool ModelChecker::checkRSCTLbmc(FormRSCTL *form)
{
if (opts->measure)
if (opts->measure) {
opts->ver_time = cpuTime();
}
assert(form != nullptr);
if (!form->isERSCTL())
{
FERROR("Formula " << form->toStr() << " is not syntactically an ERSCTL formula");
if (!form->isERSCTL()) {
FERROR("Formula " << form->toStr() <<
" is not syntactically an ERSCTL formula");
}
bool result = false;
@@ -530,16 +526,13 @@ bool ModelChecker::checkRSCTLbmc(FormRSCTL *form)
unsigned int k = 0;
while (*reach != reach_p)
{
if (opts->show_progress)
{
while (*reach != reach_p) {
if (opts->show_progress) {
cout << "\rIteration " << ++k << flush;
}
//if (*initStates * getStatesRSCTL(form) != cuddMgr->bddZero())
if (*initStates * getStatesRSCTL(form) == *initStates)
{
if (*initStates * getStatesRSCTL(form) == *initStates) {
result = true;
break;
}
@@ -548,14 +541,16 @@ bool ModelChecker::checkRSCTLbmc(FormRSCTL *form)
*reach += getSucc(*reach);
}
if (opts->show_progress) cout << endl;
if (opts->show_progress) {
cout << endl;
}
cleanup();
cout << "Formula " << form->toStr() << " " << (result ? "holds" : "does not hold") << endl;
cout << "Formula " << form->toStr() << " " << (result ? "holds" :
"does not hold") << endl;
if (opts->measure)
{
if (opts->measure) {
opts->ver_time = cpuTime() - opts->ver_time;
opts->ver_mem = memUsed();
}

View File

@@ -40,16 +40,19 @@ static inline int memReadStat(void)
pid_t pid = getpid();
sprintf(name, "/proc/%d/statm", pid);
FILE *in = fopen(name, "rb");
if (in == nullptr)
{
if (in == nullptr) {
return 0;
}
int value;
for (int field = 0; field >= 0; --field)
{
if (fscanf(in, "%d", &value) == EOF)
for (int field = 0; field >= 0; --field) {
if (fscanf(in, "%d", &value) == EOF) {
FERROR("EOF");
}
}
fclose(in);
return value;
}

View File

@@ -1,7 +1,8 @@
#ifndef RS_OPTIONS_HH
#define RS_OPTIONS_HH
class Options {
class Options
{
public:
unsigned int verbose;

121
rs.cc
View File

@@ -16,16 +16,17 @@ RctSys::RctSys(void)
bool RctSys::hasEntity(std::string name)
{
if (entities_names.find(name) == entities_names.end())
if (entities_names.find(name) == entities_names.end()) {
return false;
else
}
else {
return true;
}
}
void RctSys::addEntity(std::string name)
{
if (!hasEntity(name))
{
if (!hasEntity(name)) {
Entity new_entity_id = entities_ids.size();
VERB_L2("Adding entity: " << name << " index=" << new_entity_id);
@@ -37,10 +38,10 @@ void RctSys::addEntity(std::string name)
std::string RctSys::getEntityName(Entity entityID)
{
if (entityID < entities_ids.size())
if (entityID < entities_ids.size()) {
return entities_ids[entityID];
else
{
}
else {
FERROR("No such entity ID: " << entityID);
return "??";
}
@@ -48,10 +49,10 @@ std::string RctSys::getEntityName(Entity entityID)
Entity RctSys::getEntityID(std::string name)
{
if (!hasEntity(name))
{
if (!hasEntity(name)) {
FERROR("No such entity: " << name);
}
return entities_names[name];
}
@@ -59,8 +60,7 @@ void RctSys::setCurrentProcess(std::string processName)
{
VERB_LN(2, "Current Process: " << processName);
if (!hasProcess(processName))
{
if (!hasProcess(processName)) {
addProcess(processName);
}
@@ -70,8 +70,7 @@ void RctSys::setCurrentProcess(std::string processName)
void RctSys::addProcess(std::string processName)
{
if (!hasProcess(processName))
{
if (!hasProcess(processName)) {
Process new_proc_id = processes_ids.size();
VERB_L2("Adding process: " << processName << " index=" << new_proc_id);
@@ -87,56 +86,64 @@ void RctSys::addProcess(std::string processName)
bool RctSys::hasProcess(std::string processName)
{
if (processes_names.find(processName) == processes_names.end())
if (processes_names.find(processName) == processes_names.end()) {
return false;
else
}
else {
return true;
}
}
Process RctSys::getProcessID(std::string processName)
{
if (!hasProcess(processName))
{
if (!hasProcess(processName)) {
FERROR("No such process: " << processName);
}
return processes_names[processName];
}
std::string RctSys::getProcessName(Process processID)
{
if (processID < processes_ids.size())
if (processID < processes_ids.size()) {
return processes_ids[processID];
else
{
}
else {
FERROR("No such process ID: " << processID);
}
}
void RctSys::pushReactant(std::string entityName)
{
if (!hasEntity(entityName))
if (!hasEntity(entityName)) {
addEntity(entityName);
}
tmpReactants.insert(getEntityID(entityName));
}
void RctSys::pushInhibitor(std::string entityName)
{
if (!hasEntity(entityName))
if (!hasEntity(entityName)) {
addEntity(entityName);
}
tmpInhibitors.insert(getEntityID(entityName));
}
void RctSys::pushProduct(std::string entityName)
{
if (!hasEntity(entityName))
if (!hasEntity(entityName)) {
addEntity(entityName);
}
tmpProducts.insert(getEntityID(entityName));
}
void RctSys::addReactionForCurrentProcess(Reaction reaction)
{
if (!current_process_defined)
{
if (!current_process_defined) {
FERROR("Internal error. Current process is not set!");
}
proc_reactions[current_proc_id].push_back(reaction);
}
@@ -160,10 +167,11 @@ void RctSys::commitReaction(void)
std::string RctSys::entitiesToStr(const Entities &entities)
{
std::string s = " ";
for (auto a = entities.begin(); a != entities.end(); ++a)
{
for (auto a = entities.begin(); a != entities.end(); ++a) {
s += entityToStr(*a) + " ";
}
return s;
}
@@ -171,101 +179,113 @@ void RctSys::showReactions(void)
{
cout << "# Reactions:" << endl;
for (unsigned int proc_id = 0; proc_id < processes_ids.size(); ++proc_id)
{
for (unsigned int proc_id = 0; proc_id < processes_ids.size(); ++proc_id) {
cout << endl;
cout << " . proc = \"" << getProcessName(proc_id) << "\":" << endl;
for (const auto &r : proc_reactions[proc_id])
{
for (const auto &r : proc_reactions[proc_id]) {
cout << " * (R={" << entitiesToStr(r.rctt) << "},"
<< "I={" << entitiesToStr(r.inhib) << "},"
<< "P={" << entitiesToStr(r.prod) << "})" << endl;
}
}
cout << endl;
}
void RctSys::pushStateEntity(std::string entityName)
{
if (!hasEntity(entityName))
{
if (!hasEntity(entityName)) {
FERROR("No such entity: " << entityName);
}
tmpState.insert(getEntityID(entityName));
}
void RctSys::commitInitState(void)
{
if (ctx_aut != nullptr)
{
if (ctx_aut != nullptr) {
FERROR("Initial RS states must not be used with context automaton");
}
initStates.insert(tmpState);
tmpState.clear();
}
void RctSys::addActionEntity(std::string entityName)
{
if (!hasEntity(entityName))
if (!hasEntity(entityName)) {
addEntity(entityName);
}
actionEntities.insert(getEntityID(entityName));
}
void RctSys::addActionEntity(Entity entity)
{
if (!isActionEntity(entity))
if (!isActionEntity(entity)) {
actionEntities.insert(entity);
}
}
bool RctSys::isActionEntity(Entity entity)
{
if (actionEntities.count(entity) > 0)
if (actionEntities.count(entity) > 0) {
return true;
else
}
else {
return false;
}
}
void RctSys::showActionEntities(void)
{
cout << "# Context entities:";
for (auto a = actionEntities.begin(); a != actionEntities.end(); ++a)
{
for (auto a = actionEntities.begin(); a != actionEntities.end(); ++a) {
cout << " " << getEntityName(*a);
}
cout << endl;
}
void RctSys::showInitialStates(void)
{
cout << "# Initial states:" << endl;
for (auto s = initStates.begin(); s != initStates.end(); ++s)
{
for (auto s = initStates.begin(); s != initStates.end(); ++s) {
cout << " *";
for (auto a = s->begin(); a != s->end(); ++a)
{
for (auto a = s->begin(); a != s->end(); ++a) {
cout << " " << getEntityName(*a);
}
cout << endl;
}
}
void RctSys::printSystem(void)
{
if (!usingContextAutomaton())
if (!usingContextAutomaton()) {
showInitialStates();
}
showActionEntities();
showReactions();
if (ctx_aut != nullptr) ctx_aut->printAutomaton();
if (ctx_aut != nullptr) {
ctx_aut->printAutomaton();
}
}
void RctSys::ctxAutEnable(void)
{
assert(ctx_aut == nullptr);
if (initStatesDefined())
{
if (initStatesDefined()) {
FERROR("Initial states must not be defined if using context automaton");
}
ctx_aut = new CtxAut(opts, this);
}
@@ -281,7 +301,8 @@ void RctSys::ctxAutSetInitState(std::string stateName)
ctx_aut->setInitState(stateName);
}
void RctSys::ctxAutAddTransition(std::string srcStateName, std::string dstStateName)
void RctSys::ctxAutAddTransition(std::string srcStateName,
std::string dstStateName)
{
assert(ctx_aut != nullptr);
ctx_aut->addTransition(srcStateName, dstStateName);

40
rs.hh
View File

@@ -34,7 +34,10 @@ class RctSys
public:
RctSys(void);
void setOptions(Options *opts) { this->opts = opts; }
void setOptions(Options *opts)
{
this->opts = opts;
}
bool hasEntity(std::string entityName);
void addEntity(std::string entityName);
std::string getEntityName(Entity entityID);
@@ -51,7 +54,10 @@ class RctSys
void pushInhibitor(std::string entityName);
void pushProduct(std::string entityName);
void commitReaction(void);
std::string entityToStr(const Entity entity) { return entities_ids[entity]; }
std::string entityToStr(const Entity entity)
{
return entities_ids[entity];
}
std::string entitiesToStr(const Entities &entities);
void showReactions(void);
void pushStateEntity(std::string entityName);
@@ -59,10 +65,22 @@ class RctSys
void addActionEntity(std::string entityName);
void addActionEntity(Entity entity);
bool isActionEntity(Entity entity);
void resetInitStates(void) { initStates.clear(); }
unsigned int getEntitiesSize(void) { return entities_ids.size(); }
unsigned int getReactionsSize(void) { return reactions.size(); }
unsigned int getActionsSize(void) { return actionEntities.size(); }
void resetInitStates(void)
{
initStates.clear();
}
unsigned int getEntitiesSize(void)
{
return entities_ids.size();
}
unsigned int getReactionsSize(void)
{
return reactions.size();
}
unsigned int getActionsSize(void)
{
return actionEntities.size();
}
void showInitialStates(void);
void showActionEntities(void);
void printSystem(void);
@@ -73,8 +91,14 @@ class RctSys
void ctxAutAddTransition(std::string srcStateName, std::string dstStateName);
void ctxAutPushNamedContextEntity(std::string entity_name);
bool initStatesDefined(void) { return initStates.size() != 0; }
bool usingContextAutomaton(void) { return ctx_aut != nullptr; }
bool initStatesDefined(void)
{
return initStates.size() != 0;
}
bool usingContextAutomaton(void)
{
return ctx_aut != nullptr;
}
private:
Reactions reactions; // TODO: to be removed later

View File

@@ -51,8 +51,7 @@ void rsin_driver::error(const std::string &m)
FormRSCTL *rsin_driver::getFormRSCTL(void)
{
if (rsctlform == nullptr)
{
if (rsctlform == nullptr) {
FERROR("RSCTL formula was not supplied!");
}
@@ -64,17 +63,17 @@ FormRSCTL *rsin_driver::getFormRSCTL(void)
//
void rsin_driver::ensureOptionsAllowed(void)
{
if (rs != nullptr)
{
if (rs != nullptr) {
FERROR("Options cannot be set/modified after the reaction system is initialised")
}
}
void rsin_driver::ensureReactionSystemReady(void)
{
if (rs == nullptr)
if (rs == nullptr) {
setupReactionSystem();
}
}
void rsin_driver::setupReactionSystem(void)
{

View File

@@ -41,13 +41,23 @@ public:
std::string file;
bool trace_parsing;
void setOptions(Options *opts) { this->opts = opts; };
void addFormRSCTL(FormRSCTL *f) { rsctlform = f; };
void setOptions(Options *opts)
{
this->opts = opts;
};
void addFormRSCTL(FormRSCTL *f)
{
rsctlform = f;
};
FormRSCTL *getFormRSCTL(void);
void ensureOptionsAllowed(void);
void useContextAutomaton(void);
void useConcentrations(void) { ensureOptionsAllowed(); use_concentrations = true; };
void useConcentrations(void)
{
ensureOptionsAllowed();
use_concentrations = true;
};
void ensureReactionSystemReady(void);
void setupReactionSystem(void);

246
symrs.cc
View File

@@ -32,10 +32,12 @@ BDD SymRS::encEntity_raw(Entity entity, bool succ) const
{
BDD r;
if (succ)
if (succ) {
r = (*pv_succ)[entity];
else
}
else {
r = (*pv)[entity];
}
return r;
}
@@ -44,10 +46,13 @@ BDD SymRS::encEntitiesConj_raw(const Entities &entities, bool succ)
{
BDD r = BDD_TRUE;
for (const auto &entity : entities)
{
if (succ) r *= encEntitySucc(entity);
else r *= encEntity(entity);
for (const auto &entity : entities) {
if (succ) {
r *= encEntitySucc(entity);
}
else {
r *= encEntity(entity);
}
}
return r;
@@ -57,10 +62,13 @@ BDD SymRS::encEntitiesDisj_raw(const Entities &entities, bool succ)
{
BDD r = BDD_FALSE;
for (const auto &entity : entities)
{
if (succ) r += encEntitySucc(entity);
else r += encEntity(entity);
for (const auto &entity : entities) {
if (succ) {
r += encEntitySucc(entity);
}
else {
r += encEntity(entity);
}
}
return r;
@@ -70,14 +78,14 @@ BDD SymRS::encStateActEntitiesConj(const Entities &entities)
{
BDD r = BDD_TRUE;
for (const auto &entity : entities)
{
for (const auto &entity : entities) {
BDD state_act = encEntity(entity);
int actEntity;
// if entity is also an action entity, we include it in the encoding
if ((actEntity = getMappedStateToActID(entity)) >= 0)
if ((actEntity = getMappedStateToActID(entity)) >= 0) {
state_act += encActEntity(actEntity);
}
r *= state_act;
}
@@ -89,14 +97,14 @@ BDD SymRS::encStateActEntitiesDisj(const Entities &entities)
{
BDD r = BDD_FALSE;
for (const auto &entity : entities)
{
for (const auto &entity : entities) {
BDD state_act = encEntity(entity);
int actEntity;
// if entity is also an aciton entity, we include it in the encoding
if ((actEntity = getMappedStateToActID(entity)) >= 0)
if ((actEntity = getMappedStateToActID(entity)) >= 0) {
state_act += encActEntity(actEntity);
}
r += state_act;
}
@@ -108,8 +116,7 @@ BDD SymRS::encActEntitiesConj(const Entities &entities)
{
BDD r = BDD_TRUE;
for (const auto &entity : entities)
{
for (const auto &entity : entities) {
Entity actEntity = getMappedStateToActID(entity);
r *= encActEntity(actEntity);
}
@@ -121,11 +128,11 @@ BDD SymRS::compState(const BDD &state) const
{
BDD s = state;
for (unsigned int i = 0; i < totalRctSysStateVars; ++i)
{
if (!(*pv)[i] * state != cuddMgr->bddZero())
for (unsigned int i = 0; i < totalRctSysStateVars; ++i) {
if (!(*pv)[i] * state != cuddMgr->bddZero()) {
s *= !(*pv)[i];
}
}
return s;
}
@@ -134,11 +141,11 @@ BDD SymRS::compContext(const BDD &context) const
{
BDD c = context;
for (unsigned int i = 0; i < totalActions; ++i)
{
if (!(*pv_act)[i] * context != cuddMgr->bddZero())
for (unsigned int i = 0; i < totalActions; ++i) {
if (!(*pv_act)[i] * context != cuddMgr->bddZero()) {
c *= !(*pv_act)[i];
}
}
return c;
}
@@ -146,13 +153,13 @@ BDD SymRS::compContext(const BDD &context) const
std::string SymRS::decodedRctSysStateToStr(const BDD &state)
{
std::string s = "{ ";
for (unsigned int i = 0; i < totalRctSysStateVars; ++i)
{
if (!(encEntity(i) * state).IsZero())
{
for (unsigned int i = 0; i < totalRctSysStateVars; ++i) {
if (!(encEntity(i) * state).IsZero()) {
s += rs->entityToStr(i) + " ";
}
}
s += "}";
return s;
}
@@ -160,14 +167,16 @@ std::string SymRS::decodedRctSysStateToStr(const BDD &state)
void SymRS::printDecodedRctSysStates(const BDD &states)
{
BDD unproc = states;
while (!unproc.IsZero())
{
while (!unproc.IsZero()) {
BDD t = unproc.PickOneMinterm(*pv_rs);
cout << decodedRctSysStateToStr(t) << endl;
if (opts->verbose > 9) {
t.PrintMinterm();
cout << endl;
}
unproc -= t;
}
}
@@ -198,8 +207,7 @@ void SymRS::initBDDvars(void)
pv_rs_E = new BDD(BDD_TRUE);
pv_rs_succ_E = new BDD(BDD_TRUE);
for (unsigned int i = 0; i < totalRctSysStateVars; ++i)
{
for (unsigned int i = 0; i < totalRctSysStateVars; ++i) {
(*pv_rs)[i] = cuddMgr->bddVar(bdd_var_idx++);
(*pv_rs_succ)[i] = cuddMgr->bddVar(bdd_var_idx++);
*pv_rs_E *= (*pv_rs)[i];
@@ -211,8 +219,7 @@ void SymRS::initBDDvars(void)
}
// CA
if (usingContextAutomaton())
{
if (usingContextAutomaton()) {
VERB("Context automaton variables");
pv_ca = new vector<BDD>(totalCtxAutStateVars);
@@ -220,8 +227,7 @@ void SymRS::initBDDvars(void)
pv_ca_E = new BDD(BDD_TRUE);
pv_ca_succ_E = new BDD(BDD_TRUE);
for (unsigned int i = 0; i < totalCtxAutStateVars; ++i)
{
for (unsigned int i = 0; i < totalCtxAutStateVars; ++i) {
(*pv_ca)[i] = cuddMgr->bddVar(bdd_var_idx++);
(*pv_ca_succ)[i] = cuddMgr->bddVar(bdd_var_idx++);
*pv_ca_E *= (*pv_ca)[i];
@@ -237,8 +243,7 @@ void SymRS::initBDDvars(void)
pv_act = new vector<BDD>(totalActions);
pv_act_E = new BDD(BDD_TRUE);
for (unsigned int i = 0; i < totalActions; ++i)
{
for (unsigned int i = 0; i < totalActions; ++i) {
(*pv_act)[i] = cuddMgr->bddVar(bdd_var_idx++);
*pv_act_E *= (*pv_act)[i];
}
@@ -248,8 +253,7 @@ void SymRS::initBDDvars(void)
*pv_E = *pv_rs_E;
*pv_succ_E = *pv_rs_succ_E;
if (usingContextAutomaton())
{
if (usingContextAutomaton()) {
*pv_E *= *pv_ca_E;
*pv_succ_E *= *pv_ca_succ_E;
}
@@ -262,73 +266,66 @@ void SymRS::encodeTransitions(void)
DecompReactions dr;
VERB("Decomposing reactions");
for (unsigned int i = 0; i < totalReactions; ++i)
{
for (unsigned int i = 0; i < totalReactions; ++i) {
ReactionCond cond;
cond.rctt = rs->reactions[i].rctt;
cond.inhib = rs->reactions[i].inhib;
for (Entities::iterator p = rs->reactions[i].prod.begin();
p != rs->reactions[i].prod.end(); ++p)
{
p != rs->reactions[i].prod.end(); ++p) {
dr[*p].push_back(cond);
}
}
VERB("Encoding reactions");
if (opts->part_tr_rel)
{
if (opts->part_tr_rel) {
VERB("Using partitioned transition relation encoding");
partTrans = new vector<BDD>(totalRctSysStateVars);
}
else
{
else {
VERB("Using monolithic transition relation encoding");
monoTrans = new BDD(BDD_TRUE);
}
for (unsigned int p = 0; p < totalRctSysStateVars; ++p)
{
for (unsigned int p = 0; p < totalRctSysStateVars; ++p) {
VERB_L3("Encoding for successor " << p);
DecompReactions::iterator di;
if ((di = dr.find(p)) == dr.end())
{
if ((di = dr.find(p)) == dr.end()) {
// there is no reaction producing p:
if (opts->part_tr_rel)
if (opts->part_tr_rel) {
(*partTrans)[p] = !encEntitySucc(p);
else
{
}
else {
*monoTrans *= !encEntitySucc(p);
}
}
else
{
else {
// di - reactions producing p
BDD conditions = BDD_FALSE;
assert(di->second.size() > 0);
for (unsigned int j = 0; j < di->second.size(); ++j)
{
conditions += encStateActEntitiesConj(di->second[j].rctt) * !encStateActEntitiesDisj(di->second[j].inhib);
for (unsigned int j = 0; j < di->second.size(); ++j) {
conditions += encStateActEntitiesConj(di->second[j].rctt) *
!encStateActEntitiesDisj(di->second[j].inhib);
}
if (opts->part_tr_rel)
{
if (opts->part_tr_rel) {
(*partTrans)[p] = conditions * encEntitySucc(p);
(*partTrans)[p] += !conditions * !encEntitySucc(p);
}
else
{
*monoTrans *= (conditions * encEntitySucc(p)) + (!conditions * !encEntitySucc(p));
else {
*monoTrans *= (conditions * encEntitySucc(p)) + (!conditions * !encEntitySucc(
p));
}
}
if (opts->reorder_trans)
{
if (opts->reorder_trans) {
VERB_L2("Reordering");
Cudd_ReduceHeap(cuddMgr->getManager(), CUDD_REORDER_SIFT, 10000);
}
@@ -337,15 +334,13 @@ void SymRS::encodeTransitions(void)
VERB("Reactions ready");
if (usingContextAutomaton())
{
if (usingContextAutomaton()) {
VERB("Augmenting transition relation encoding with the transition relation for context automaton");
if (opts->part_tr_rel)
{
if (opts->part_tr_rel) {
assert(0);
}
else
{
else {
assert(tr_ca != nullptr);
*monoTrans *= *tr_ca;
}
@@ -369,8 +364,7 @@ BDD SymRS::encNoContext(void)
{
BDD noContextBDD = BDD_TRUE;
for (unsigned int i = 0; i < totalActions; ++i)
{
for (unsigned int i = 0; i < totalActions; ++i) {
noContextBDD *= !(*pv_act)[i];
}
@@ -379,16 +373,15 @@ BDD SymRS::encNoContext(void)
void SymRS::encodeInitStates(void)
{
if (usingContextAutomaton())
{
if (usingContextAutomaton()) {
VERB("Encoding initial states (using context automaton)");
encodeInitStatesForCtxAut();
}
else
{
else {
VERB("Encoding initial states (for the action entities method -- no CA)");
encodeInitStatesNoCtxAut();
}
VERB("Initial states encoded");
}
@@ -396,8 +389,7 @@ void SymRS::encodeInitStatesForCtxAut(void)
{
initStates = new BDD(BDD_TRUE);
for (unsigned int i = 0; i < totalRctSysStateVars; ++i)
{
for (unsigned int i = 0; i < totalRctSysStateVars; ++i) {
*initStates *= !(*pv)[i];
}
@@ -407,28 +399,28 @@ void SymRS::encodeInitStatesForCtxAut(void)
void SymRS::encodeInitStatesNoCtxAut(void)
{
#ifndef NDEBUG
if (opts->part_tr_rel)
if (opts->part_tr_rel) {
assert(partTrans != nullptr);
}
#endif
initStates = new BDD(BDD_FALSE);
for (auto state = rs->initStates.begin();
state != rs->initStates.end();
++state)
{
++state) {
VERB("Encoding a single inital state");
BDD newInitState = compState(encEntitiesConj(*state));
BDD q = BDD_TRUE;
if (opts->part_tr_rel)
{
for (unsigned int i = 0; i < partTrans->size(); ++i)
{
if (opts->part_tr_rel) {
for (unsigned int i = 0; i < partTrans->size(); ++i) {
q *= newInitState * (*partTrans)[i] * encNoContext();
}
}
else
{
else {
q *= newInitState * *monoTrans * encNoContext();
}
@@ -443,22 +435,22 @@ void SymRS::mapStateToAct(void)
{
VERB("Mapping state variables to action variables");
unsigned int j = 0;
for (unsigned int i = 0; i < totalRctSysStateVars; ++i)
{
for (unsigned int i = 0; i < totalRctSysStateVars; ++i) {
if (rs->isActionEntity(i)) {
stateToAct.push_back(j++);
}
else
{
else {
stateToAct.push_back(-1);
}
}
const unsigned int verbosity_level = 9;
if (opts->verbose > verbosity_level)
{
for (unsigned int i = 0; i < stateToAct.size(); ++i)
{
cout << "ii VERBOSE(" << verbosity_level << "): stateToAct[" << i << "] = " << stateToAct[i] << endl;
if (opts->verbose > verbosity_level) {
for (unsigned int i = 0; i < stateToAct.size(); ++i) {
cout << "ii VERBOSE(" << verbosity_level << "): stateToAct[" << i << "] = " <<
stateToAct[i] << endl;
}
}
}
@@ -467,8 +459,7 @@ void SymRS::encode(void)
{
VERB("Encoding...");
if (opts->measure)
{
if (opts->measure) {
opts->enc_time = cpuTime();
opts->enc_mem = memUsed();
}
@@ -477,20 +468,17 @@ void SymRS::encode(void)
initBDDvars();
if (usingContextAutomaton())
{
if (usingContextAutomaton()) {
encodeCtxAutTrans();
}
else
{
else {
VERB_LN(3, "Not using context automata, not encoding TR for CA")
}
encodeTransitions();
encodeInitStates();
if (opts->measure)
{
if (opts->measure) {
opts->enc_time = cpuTime() - opts->enc_time;
opts->enc_mem = memUsed() - opts->enc_mem;
}
@@ -501,26 +489,29 @@ void SymRS::encode(void)
BDD SymRS::encActStrEntity(std::string name) const
{
int id = getMappedStateToActID(rs->getEntityID(name));
if (id < 0)
{
if (id < 0) {
FERROR("Entity \"" << name << "\" not defined as context entity");
return BDD_FALSE;
} else {
}
else {
return encActEntity(getMappedStateToActID(rs->getEntityID(name)));
}
}
size_t SymRS::getCtxAutStateEncodingSize(void)
{
if (!usingContextAutomaton()) return 0;
if (!usingContextAutomaton()) {
return 0;
}
assert(rs->ctx_aut != nullptr);
size_t bitCount = 0;
size_t bitCountMaxVal = 1;
size_t numStates = rs->ctx_aut->statesCount();
while (bitCountMaxVal <= numStates)
{
while (bitCountMaxVal <= numStates) {
bitCount++;
bitCountMaxVal *= 2;
}
@@ -533,33 +524,34 @@ BDD SymRS::encCtxAutState_raw(State state_id, bool succ) const
{
// select appropriate BDD vector
vector<BDD> *enc_vec;
if (succ)
if (succ) {
enc_vec = pv_ca_succ;
else
}
else {
enc_vec = pv_ca;
}
assert(enc_vec != nullptr);
BDD r = BDD_TRUE;
State val = state_id;
for (unsigned int i = 0; i < totalCtxAutStateVars; ++i)
{
if (val != 0)
{
if (val % 2 == 1)
{
for (unsigned int i = 0; i < totalCtxAutStateVars; ++i) {
if (val != 0) {
if (val % 2 == 1) {
r *= (*enc_vec)[i];
}
else
{
else {
r *= !(*enc_vec)[i];
}
val /= 2;
}
else
else {
r *= !(*enc_vec)[i];
}
}
return r;
}
@@ -577,16 +569,14 @@ void SymRS::encodeCtxAutTrans(void)
{
VERB_LN(2, "Encoding context automaton's transition relation");
if (tr_ca != nullptr)
{
if (tr_ca != nullptr) {
VERB_LN(1, "Encoding for context automaton already present, not replacing")
return;
}
tr_ca = new BDD(BDD_FALSE);
for (auto &t : rs->ctx_aut->transitions)
{
for (auto &t : rs->ctx_aut->transitions) {
VERB_LN(2, "Encoding CA transition " << rs->ctx_aut->getStateName(t.src_state)
<< " -> " << rs->ctx_aut->getStateName(t.dst_state));
BDD enc_src = encCtxAutState(t.src_state);

129
symrs.hh
View File

@@ -72,28 +72,35 @@ class SymRS
unsigned int totalCtxAutStateVars;
BDD encEntity_raw(Entity entity, bool succ) const;
BDD encEntity(Entity entity) const {
BDD encEntity(Entity entity) const
{
return encEntity_raw(entity, false);
}
BDD encActEntity(Entity entity) const {
BDD encActEntity(Entity entity) const
{
assert(entity < pv_act->size());
return (*pv_act)[entity];
}
BDD encEntitySucc(Entity entity) const {
BDD encEntitySucc(Entity entity) const
{
return encEntity_raw(entity, true);
}
BDD encEntitiesConj_raw(const Entities &entities, bool succ);
BDD encEntitiesConj(const Entities &entities) {
BDD encEntitiesConj(const Entities &entities)
{
return encEntitiesConj_raw(entities, false);
}
BDD encEntitiesConjSucc(const Entities &entities) {
BDD encEntitiesConjSucc(const Entities &entities)
{
return encEntitiesConj_raw(entities, true);
}
BDD encEntitiesDisj_raw(const Entities &entities, bool succ);
BDD encEntitiesDisj(const Entities &entities) {
BDD encEntitiesDisj(const Entities &entities)
{
return encEntitiesDisj_raw(entities, false);
}
BDD encEntitiesDisjSucc(const Entities &entities) {
BDD encEntitiesDisjSucc(const Entities &entities)
{
return encEntitiesDisj_raw(entities, true);
}
BDD encStateActEntitiesConj(const Entities &entities);
@@ -135,32 +142,75 @@ class SymRS
public:
SymRS(RctSys *rs, Options *opts);
vector<BDD> *getEncPV(void) { return pv; }
vector<BDD> *getEncPVsucc(void) { return pv_succ; }
BDD *getEncPV_E(void) { return pv_E; }
BDD *getEncPVsucc_E(void) { return pv_succ_E; }
BDD *getEncPVact_E(void) { return pv_act_E; }
vector<BDD> *getEncPartTrans(void) { return partTrans; }
BDD *getEncMonoTrans(void) { return monoTrans; }
vector<BDD> *getEncPV(void)
{
return pv;
}
vector<BDD> *getEncPVsucc(void)
{
return pv_succ;
}
BDD *getEncPV_E(void)
{
return pv_E;
}
BDD *getEncPVsucc_E(void)
{
return pv_succ_E;
}
BDD *getEncPVact_E(void)
{
return pv_act_E;
}
vector<BDD> *getEncPartTrans(void)
{
return partTrans;
}
BDD *getEncMonoTrans(void)
{
return monoTrans;
}
BDD getEncState(const Entities &entities);
BDD *getEncInitStates(void) { return initStates; }
Cudd *getCuddMgr(void) { return cuddMgr; }
unsigned int getTotalStateVars(void) { return totalStateVars; }
unsigned int getTotalRctSysStateVars(void) { return totalRctSysStateVars; }
BDD encEntity(std::string name) const {
BDD *getEncInitStates(void)
{
return initStates;
}
Cudd *getCuddMgr(void)
{
return cuddMgr;
}
unsigned int getTotalStateVars(void)
{
return totalStateVars;
}
unsigned int getTotalRctSysStateVars(void)
{
return totalRctSysStateVars;
}
BDD encEntity(std::string name) const
{
return encEntity(rs->getEntityID(name));
}
BDD encActStrEntity(std::string name) const;
BDD getBDDtrue(void) const { return BDD_TRUE; }
BDD getBDDfalse(void) const { return BDD_FALSE; }
BDD getBDDtrue(void) const
{
return BDD_TRUE;
}
BDD getBDDfalse(void) const
{
return BDD_FALSE;
}
/**
* @brief Checks if context automaton is used
*
* @return True if CA is used
*/
bool usingContextAutomaton(void) { return rs->ctx_aut != nullptr; }
bool usingContextAutomaton(void)
{
return rs->ctx_aut != nullptr;
}
/**
* @brief Encodes a context automaton's state
@@ -174,14 +224,20 @@ public:
*
* @return Returns the encoded state
*/
BDD encCtxAutState(State state_id) const { return encCtxAutState_raw(state_id, false); }
BDD encCtxAutState(State state_id) const
{
return encCtxAutState_raw(state_id, false);
}
/**
* @brief Encodes a context automaton's state (as successor/primed)
*
* @return Returns the encoded state
*/
BDD encCtxAutStateSucc(State state_id) const { return encCtxAutState_raw(state_id, true); }
BDD encCtxAutStateSucc(State state_id) const
{
return encCtxAutState_raw(state_id, true);
}
/**
* @brief Encodes the initial state of context automaton
@@ -195,28 +251,40 @@ public:
*
* @return Returns a vector of BDDs
*/
vector<BDD> *getEncCtxAutPV(void) { return pv_ca; }
vector<BDD> *getEncCtxAutPV(void)
{
return pv_ca;
}
/**
* @brief Getter for context automaton's successor (primed) state variables
*
* @return Returns a vector of BDDs
*/
vector<BDD> *getEncCtxAutPVsucc(void) { return pv_ca_succ; }
vector<BDD> *getEncCtxAutPVsucc(void)
{
return pv_ca_succ;
}
/**
* @brief Getter for context automaton's quantification BDD (for non-primed vars)
*
* @return Returns a BDD for quantification
*/
BDD *getEncCtxAutPV_E(void) { return pv_ca_E; }
BDD *getEncCtxAutPV_E(void)
{
return pv_ca_E;
}
/**
* @brief Getter for context automaton's quantification BDD (for primed vars)
*
* @return Returns a BDD for quantification
*/
BDD *getEncCtxAutPVsucc_E(void) { return pv_ca_succ_E; }
BDD *getEncCtxAutPVsucc_E(void)
{
return pv_ca_succ_E;
}
/**
* @brief Encodes the monolithic transition relation
@@ -228,7 +296,10 @@ public:
*
* @return Returns a BDD encoding the transition relation
*/
BDD *getEncCtxAutTrans(void) { return tr_ca; }
BDD *getEncCtxAutTrans(void)
{
return tr_ca;
}
};
#endif