Reformatting
This commit is contained in:
27
ctx_aut.cc
27
ctx_aut.cc
@@ -9,18 +9,20 @@ CtxAut::CtxAut(Options *opts, RctSys *parent_rctsys)
|
|||||||
|
|
||||||
bool CtxAut::hasState(std::string name)
|
bool CtxAut::hasState(std::string name)
|
||||||
{
|
{
|
||||||
if (states_names.find(name) == states_names.end())
|
if (states_names.find(name) == states_names.end()) {
|
||||||
return false;
|
return false;
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
State CtxAut::getStateID(std::string name)
|
State CtxAut::getStateID(std::string name)
|
||||||
{
|
{
|
||||||
if (!hasState(name))
|
if (!hasState(name)) {
|
||||||
{
|
|
||||||
FERROR("No such state: " << name);
|
FERROR("No such state: " << name);
|
||||||
}
|
}
|
||||||
|
|
||||||
return states_names[name];
|
return states_names[name];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -32,8 +34,7 @@ std::string CtxAut::getStateName(State state_id)
|
|||||||
|
|
||||||
void CtxAut::addState(std::string name)
|
void CtxAut::addState(std::string name)
|
||||||
{
|
{
|
||||||
if (!hasState(name))
|
if (!hasState(name)) {
|
||||||
{
|
|
||||||
State new_state_id = states_ids.size();
|
State new_state_id = states_ids.size();
|
||||||
|
|
||||||
VERB_L2("Adding state: " << name << " index=" << new_state_id);
|
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_ids.push_back(name);
|
||||||
states_names[name] = new_state_id;
|
states_names[name] = new_state_id;
|
||||||
|
|
||||||
if (!init_state_defined)
|
if (!init_state_defined) {
|
||||||
{
|
|
||||||
setInitState(name);
|
setInitState(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -73,9 +73,11 @@ void CtxAut::showStates(void)
|
|||||||
{
|
{
|
||||||
cout << "# Context Automaton States:" << endl;
|
cout << "# Context Automaton States:" << endl;
|
||||||
cout << " = Init state: " << getStateName(init_state_id) << endl;
|
cout << " = Init state: " << getStateName(init_state_id) << endl;
|
||||||
for (const auto &s : states_ids)
|
|
||||||
|
for (const auto &s : states_ids) {
|
||||||
cout << " * " << s << endl;
|
cout << " * " << s << endl;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CtxAut::pushContextEntity(Entity entity_id)
|
void CtxAut::pushContextEntity(Entity entity_id)
|
||||||
{
|
{
|
||||||
@@ -98,9 +100,10 @@ void CtxAut::addTransition(std::string srcStateName, std::string dstStateName)
|
|||||||
void CtxAut::showTransitions(void)
|
void CtxAut::showTransitions(void)
|
||||||
{
|
{
|
||||||
cout << "# Context Automaton Transitions:" << endl;
|
cout << "# Context Automaton Transitions:" << endl;
|
||||||
for (const auto &t : transitions)
|
|
||||||
{
|
for (const auto &t : transitions) {
|
||||||
cout << " * [" << getStateName(t.src_state) << " -> " << getStateName(t.dst_state)
|
cout << " * [" << getStateName(t.src_state) << " -> " << getStateName(
|
||||||
|
t.dst_state)
|
||||||
<< "]: {" << parent_rctsys->entitiesToStr(t.ctx) << "}" << endl;
|
<< "]: {" << parent_rctsys->entitiesToStr(t.ctx) << "}" << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
10
ctx_aut.hh
10
ctx_aut.hh
@@ -42,8 +42,14 @@ class CtxAut
|
|||||||
void addTransition(std::string srcStateName, std::string dstStateName);
|
void addTransition(std::string srcStateName, std::string dstStateName);
|
||||||
void showTransitions(void);
|
void showTransitions(void);
|
||||||
void pushContextEntity(Entity entity_id);
|
void pushContextEntity(Entity entity_id);
|
||||||
void setOptions(Options *opts) { this->opts = opts; }
|
void setOptions(Options *opts)
|
||||||
size_t statesCount(void) { return states_ids.size(); }
|
{
|
||||||
|
this->opts = opts;
|
||||||
|
}
|
||||||
|
size_t statesCount(void)
|
||||||
|
{
|
||||||
|
return states_ids.size();
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
RctSys *parent_rctsys;
|
RctSys *parent_rctsys;
|
||||||
|
|||||||
267
formrsctl.cc
267
formrsctl.cc
@@ -11,34 +11,31 @@
|
|||||||
|
|
||||||
std::string BoolContexts::toStr(void) const
|
std::string BoolContexts::toStr(void) const
|
||||||
{
|
{
|
||||||
if (oper == BCTX_PV)
|
if (oper == BCTX_PV) {
|
||||||
{
|
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
else if (oper == BCTX_TF)
|
else if (oper == BCTX_TF) {
|
||||||
{
|
if (tf) {
|
||||||
if (tf) return "true";
|
return "true";
|
||||||
else return "false";
|
|
||||||
}
|
}
|
||||||
else if (oper == BCTX_AND)
|
else {
|
||||||
{
|
return "false";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (oper == BCTX_AND) {
|
||||||
return "(" + arg[0]->toStr() + " AND " + arg[1]->toStr() + ")";
|
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() + ")";
|
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() + ")";
|
return "(" + arg[0]->toStr() + " XOR " + arg[1]->toStr() + ")";
|
||||||
}
|
}
|
||||||
else if (oper == BCTX_NOT)
|
else if (oper == BCTX_NOT) {
|
||||||
{
|
|
||||||
return "~" + arg[0]->toStr();
|
return "~" + arg[0]->toStr();
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
return "??";
|
return "??";
|
||||||
assert(0);
|
assert(0);
|
||||||
}
|
}
|
||||||
@@ -46,33 +43,30 @@ std::string BoolContexts::toStr(void) const
|
|||||||
|
|
||||||
BDD BoolContexts::getBDD(const SymRS *srs) const
|
BDD BoolContexts::getBDD(const SymRS *srs) const
|
||||||
{
|
{
|
||||||
if (oper == BCTX_PV)
|
if (oper == BCTX_PV) {
|
||||||
{
|
|
||||||
return srs->encActStrEntity(name);
|
return srs->encActStrEntity(name);
|
||||||
}
|
}
|
||||||
else if (oper == BCTX_TF)
|
else if (oper == BCTX_TF) {
|
||||||
{
|
if (tf) {
|
||||||
if (tf) return srs->getBDDtrue();
|
return srs->getBDDtrue();
|
||||||
else return srs->getBDDfalse();
|
|
||||||
}
|
}
|
||||||
else if (oper == BCTX_AND)
|
else {
|
||||||
{
|
return srs->getBDDfalse();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (oper == BCTX_AND) {
|
||||||
return arg[0]->getBDD(srs) * arg[1]->getBDD(srs);
|
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);
|
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);
|
return arg[0]->getBDD(srs) ^ arg[1]->getBDD(srs);
|
||||||
}
|
}
|
||||||
else if (oper == BCTX_NOT)
|
else if (oper == BCTX_NOT) {
|
||||||
{
|
|
||||||
return !arg[0]->getBDD(srs);
|
return !arg[0]->getBDD(srs);
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
assert(0);
|
assert(0);
|
||||||
FERROR("Undefined operator used in Boolean context definition. This should not happen.");
|
FERROR("Undefined operator used in Boolean context definition. This should not happen.");
|
||||||
return srs->getBDDfalse();
|
return srs->getBDDfalse();
|
||||||
@@ -81,102 +75,84 @@ BDD BoolContexts::getBDD(const SymRS *srs) const
|
|||||||
|
|
||||||
std::string FormRSCTL::toStr(void) const
|
std::string FormRSCTL::toStr(void) const
|
||||||
{
|
{
|
||||||
if (oper == RSCTL_PV)
|
if (oper == RSCTL_PV) {
|
||||||
{
|
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
else if (oper == RSCTL_TF)
|
else if (oper == RSCTL_TF) {
|
||||||
{
|
if (tf) {
|
||||||
if (tf) return "true";
|
return "true";
|
||||||
else return "false";
|
|
||||||
}
|
}
|
||||||
else if (oper == RSCTL_AND)
|
else {
|
||||||
{
|
return "false";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (oper == RSCTL_AND) {
|
||||||
return "(" + arg[0]->toStr() + " AND " + arg[1]->toStr() + ")";
|
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() + ")";
|
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() + ")";
|
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() + ")";
|
return "(" + arg[0]->toStr() + " IMPLIES " + arg[1]->toStr() + ")";
|
||||||
}
|
}
|
||||||
else if (oper == RSCTL_NOT)
|
else if (oper == RSCTL_NOT) {
|
||||||
{
|
|
||||||
return "~" + arg[0]->toStr();
|
return "~" + arg[0]->toStr();
|
||||||
}
|
}
|
||||||
else if (oper == RSCTL_EX)
|
else if (oper == RSCTL_EX) {
|
||||||
{
|
|
||||||
return "EX(" + arg[0]->toStr() + ")";
|
return "EX(" + arg[0]->toStr() + ")";
|
||||||
}
|
}
|
||||||
else if (oper == RSCTL_EG)
|
else if (oper == RSCTL_EG) {
|
||||||
{
|
|
||||||
return "EG(" + arg[0]->toStr() + ")";
|
return "EG(" + arg[0]->toStr() + ")";
|
||||||
}
|
}
|
||||||
else if (oper == RSCTL_EU)
|
else if (oper == RSCTL_EU) {
|
||||||
{
|
|
||||||
return "EU(" + arg[0]->toStr() + "," + arg[1]->toStr() + ")";
|
return "EU(" + arg[0]->toStr() + "," + arg[1]->toStr() + ")";
|
||||||
}
|
}
|
||||||
else if (oper == RSCTL_EF)
|
else if (oper == RSCTL_EF) {
|
||||||
{
|
|
||||||
return "EF(" + arg[0]->toStr() + ")";
|
return "EF(" + arg[0]->toStr() + ")";
|
||||||
}
|
}
|
||||||
else if (oper == RSCTL_AX)
|
else if (oper == RSCTL_AX) {
|
||||||
{
|
|
||||||
return "AX(" + arg[0]->toStr() + ")";
|
return "AX(" + arg[0]->toStr() + ")";
|
||||||
}
|
}
|
||||||
else if (oper == RSCTL_AG)
|
else if (oper == RSCTL_AG) {
|
||||||
{
|
|
||||||
return "AG(" + arg[0]->toStr() + ")";
|
return "AG(" + arg[0]->toStr() + ")";
|
||||||
}
|
}
|
||||||
else if (oper == RSCTL_AU)
|
else if (oper == RSCTL_AU) {
|
||||||
{
|
|
||||||
return "AU(" + arg[0]->toStr() + "," + arg[1]->toStr() + ")";
|
return "AU(" + arg[0]->toStr() + "," + arg[1]->toStr() + ")";
|
||||||
}
|
}
|
||||||
else if (oper == RSCTL_AF)
|
else if (oper == RSCTL_AF) {
|
||||||
{
|
|
||||||
return "AF(" + arg[0]->toStr() + ")";
|
return "AF(" + arg[0]->toStr() + ")";
|
||||||
}
|
}
|
||||||
else if (oper == RSCTL_EX_ACT)
|
else if (oper == RSCTL_EX_ACT) {
|
||||||
{
|
|
||||||
return "E" + getActionsStr() + "X(" + arg[0]->toStr() + ")";
|
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() + ")";
|
return "E" + getActionsStr() + "G(" + arg[0]->toStr() + ")";
|
||||||
}
|
}
|
||||||
else if (oper == RSCTL_EU_ACT)
|
else if (oper == RSCTL_EU_ACT) {
|
||||||
{
|
return "E" + getActionsStr() + "U(" + arg[0]->toStr() + "," + arg[1]->toStr()
|
||||||
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() + ")";
|
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() + ")";
|
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() + ")";
|
return "A" + getActionsStr() + "G(" + arg[0]->toStr() + ")";
|
||||||
}
|
}
|
||||||
else if (oper == RSCTL_AU_ACT)
|
else if (oper == RSCTL_AU_ACT) {
|
||||||
{
|
return "A" + getActionsStr() + "U(" + arg[0]->toStr() + "," + arg[1]->toStr()
|
||||||
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() + ")";
|
return "A" + getActionsStr() + "F(" + arg[0]->toStr() + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
return "??";
|
return "??";
|
||||||
assert(0);
|
assert(0);
|
||||||
}
|
}
|
||||||
@@ -184,61 +160,62 @@ std::string FormRSCTL::toStr(void) const
|
|||||||
|
|
||||||
bool FormRSCTL::hasOper(Oper op) const
|
bool FormRSCTL::hasOper(Oper op) const
|
||||||
{
|
{
|
||||||
if (oper == op)
|
if (oper == op) {
|
||||||
return true;
|
return true;
|
||||||
else
|
}
|
||||||
{
|
else {
|
||||||
bool result = false;
|
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;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FormRSCTL::encodeEntities(const SymRS *srs)
|
void FormRSCTL::encodeEntities(const SymRS *srs)
|
||||||
{
|
{
|
||||||
if (RSCTL_COND_1ARG(oper))
|
if (RSCTL_COND_1ARG(oper)) {
|
||||||
{
|
|
||||||
arg[0]->encodeEntities(srs);
|
arg[0]->encodeEntities(srs);
|
||||||
}
|
}
|
||||||
else if (RSCTL_COND_2ARG(oper))
|
else if (RSCTL_COND_2ARG(oper)) {
|
||||||
{
|
|
||||||
arg[0]->encodeEntities(srs);
|
arg[0]->encodeEntities(srs);
|
||||||
arg[1]->encodeEntities(srs);
|
arg[1]->encodeEntities(srs);
|
||||||
}
|
}
|
||||||
else if (oper == RSCTL_PV)
|
else if (oper == RSCTL_PV) {
|
||||||
{
|
|
||||||
bdd = new BDD(srs->encEntity(name));
|
bdd = new BDD(srs->encEntity(name));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FormRSCTL::isERSCTL(void) const
|
bool FormRSCTL::isERSCTL(void) const
|
||||||
{
|
{
|
||||||
if (oper == RSCTL_PV)
|
if (oper == RSCTL_PV) {
|
||||||
{
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (oper == RSCTL_NOT)
|
if (oper == RSCTL_NOT) {
|
||||||
{
|
if (arg[0]->getOper() == RSCTL_PV || arg[0]->getOper() == RSCTL_TF) {
|
||||||
if (arg[0]->getOper() == RSCTL_PV || arg[0]->getOper() == RSCTL_TF)
|
|
||||||
return true;
|
return true;
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (RSCTL_COND_IS_UNIVERSAL(oper)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (RSCTL_COND_IS_UNIVERSAL(oper))
|
if (RSCTL_COND_1ARG(oper)) {
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (RSCTL_COND_1ARG(oper))
|
|
||||||
{
|
|
||||||
return arg[0]->isERSCTL();
|
return arg[0]->isERSCTL();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (RSCTL_COND_2ARG(oper))
|
if (RSCTL_COND_2ARG(oper)) {
|
||||||
{
|
|
||||||
return arg[0]->isERSCTL() && arg[1]->isERSCTL();
|
return arg[0]->isERSCTL() && arg[1]->isERSCTL();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -249,74 +226,84 @@ bool FormRSCTL::isERSCTL(void) const
|
|||||||
|
|
||||||
std::string FormRSCTL::getActionsStr(void) const
|
std::string FormRSCTL::getActionsStr(void) const
|
||||||
{
|
{
|
||||||
if (actions != nullptr)
|
if (actions != nullptr) {
|
||||||
{
|
|
||||||
std::string r = "[ ";
|
std::string r = "[ ";
|
||||||
bool firstact = true;
|
bool firstact = true;
|
||||||
|
|
||||||
for (ActionsVec_f::iterator act = actions->begin(); act != actions->end(); ++act)
|
for (ActionsVec_f::iterator act = actions->begin(); act != actions->end();
|
||||||
{
|
++act) {
|
||||||
if (!firstact) r += ",";
|
if (!firstact) {
|
||||||
else firstact = false;
|
r += ",";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
firstact = false;
|
||||||
|
}
|
||||||
|
|
||||||
r += "{";
|
r += "{";
|
||||||
bool firstent = true;
|
bool firstent = true;
|
||||||
for (Action_f::iterator ent = act->begin(); ent != act->end(); ++ent)
|
|
||||||
{
|
for (Action_f::iterator ent = act->begin(); ent != act->end(); ++ent) {
|
||||||
if (!firstent) r += ",";
|
if (!firstent) {
|
||||||
else firstent = false;
|
r += ",";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
firstent = false;
|
||||||
|
}
|
||||||
|
|
||||||
r += *ent;
|
r += *ent;
|
||||||
}
|
}
|
||||||
|
|
||||||
r += "}";
|
r += "}";
|
||||||
}
|
}
|
||||||
|
|
||||||
r += " ]";
|
r += " ]";
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
else if (boolCtx != nullptr)
|
else if (boolCtx != nullptr) {
|
||||||
{
|
|
||||||
return "< " + boolCtx->toStr() + " >";
|
return "< " + boolCtx->toStr() + " >";
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
FERROR("Context not specified. This should not happen.");
|
FERROR("Context not specified. This should not happen.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FormRSCTL::encodeActions(const SymRS *srs)
|
void FormRSCTL::encodeActions(const SymRS *srs)
|
||||||
{
|
{
|
||||||
if (RSCTL_COND_ACT(oper))
|
if (RSCTL_COND_ACT(oper)) {
|
||||||
{
|
if (actions_bdd != nullptr) {
|
||||||
if (actions_bdd != nullptr) forgetActionsBDD();
|
forgetActionsBDD();
|
||||||
|
}
|
||||||
|
|
||||||
actions_bdd = new BDD(srs->getBDDfalse());
|
actions_bdd = new BDD(srs->getBDDfalse());
|
||||||
assert(actions != nullptr || boolCtx != nullptr);
|
assert(actions != nullptr || boolCtx != nullptr);
|
||||||
assert(!(actions != nullptr && boolCtx != nullptr));
|
assert(!(actions != nullptr && boolCtx != nullptr));
|
||||||
if (actions != nullptr)
|
|
||||||
{
|
if (actions != nullptr) {
|
||||||
for (ActionsVec_f::iterator act = actions->begin(); act != actions->end(); ++act)
|
for (ActionsVec_f::iterator act = actions->begin(); act != actions->end();
|
||||||
{
|
++act) {
|
||||||
BDD single_action = srs->getBDDtrue();
|
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->encActStrEntity(*ent);
|
||||||
}
|
}
|
||||||
|
|
||||||
single_action = srs->compContext(single_action);
|
single_action = srs->compContext(single_action);
|
||||||
*actions_bdd += single_action;
|
*actions_bdd += single_action;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (boolCtx != nullptr)
|
else if (boolCtx != nullptr) {
|
||||||
{
|
|
||||||
*actions_bdd = boolCtx->getBDD(srs);
|
*actions_bdd = boolCtx->getBDD(srs);
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
assert(0);
|
assert(0);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (RSCTL_COND_1ARG(oper))
|
if (RSCTL_COND_1ARG(oper)) {
|
||||||
{
|
|
||||||
arg[0]->encodeActions(srs);
|
arg[0]->encodeActions(srs);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (RSCTL_COND_2ARG(oper))
|
if (RSCTL_COND_2ARG(oper)) {
|
||||||
{
|
|
||||||
arg[0]->encodeActions(srs);
|
arg[0]->encodeActions(srs);
|
||||||
arg[1]->encodeActions(srs);
|
arg[1]->encodeActions(srs);
|
||||||
}
|
}
|
||||||
|
|||||||
73
formrsctl.hh
73
formrsctl.hh
@@ -91,7 +91,8 @@ public:
|
|||||||
*
|
*
|
||||||
* @param val value of the logical constant
|
* @param val value of the logical constant
|
||||||
*/
|
*/
|
||||||
BoolContexts(bool val) {
|
BoolContexts(bool val)
|
||||||
|
{
|
||||||
oper = BCTX_TF;
|
oper = BCTX_TF;
|
||||||
tf = val;
|
tf = val;
|
||||||
arg[0] = nullptr;
|
arg[0] = nullptr;
|
||||||
@@ -101,7 +102,8 @@ public:
|
|||||||
/**
|
/**
|
||||||
* @brief Constructor for one-argument formula.
|
* @brief Constructor for one-argument formula.
|
||||||
*/
|
*/
|
||||||
BoolContexts(Oper op, BoolContexts *form1) {
|
BoolContexts(Oper op, BoolContexts *form1)
|
||||||
|
{
|
||||||
assert(op == BCTX_NOT);
|
assert(op == BCTX_NOT);
|
||||||
oper = op;
|
oper = op;
|
||||||
arg[0] = form1;
|
arg[0] = form1;
|
||||||
@@ -111,14 +113,16 @@ public:
|
|||||||
/**
|
/**
|
||||||
* @brief Constructor for two-argument formula.
|
* @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));
|
assert(BCTX_COND_2ARG(op));
|
||||||
oper = op;
|
oper = op;
|
||||||
arg[0] = form1;
|
arg[0] = form1;
|
||||||
arg[1] = form2;
|
arg[1] = form2;
|
||||||
}
|
}
|
||||||
|
|
||||||
~BoolContexts() {
|
~BoolContexts()
|
||||||
|
{
|
||||||
delete arg[0];
|
delete arg[0];
|
||||||
delete arg[1];
|
delete arg[1];
|
||||||
}
|
}
|
||||||
@@ -127,15 +131,18 @@ public:
|
|||||||
|
|
||||||
BDD getBDD(const SymRS *srs) const;
|
BDD getBDD(const SymRS *srs) const;
|
||||||
|
|
||||||
Oper getOper(void) const {
|
Oper getOper(void) const
|
||||||
|
{
|
||||||
assert(BCTX_IS_VALID(oper));
|
assert(BCTX_IS_VALID(oper));
|
||||||
return oper;
|
return oper;
|
||||||
}
|
}
|
||||||
BoolContexts *getLeftSF(void) const {
|
BoolContexts *getLeftSF(void) const
|
||||||
|
{
|
||||||
assert(arg[0] != nullptr);
|
assert(arg[0] != nullptr);
|
||||||
return arg[0];
|
return arg[0];
|
||||||
}
|
}
|
||||||
BoolContexts *getRightSF(void) const {
|
BoolContexts *getRightSF(void) const
|
||||||
|
{
|
||||||
assert(BCTX_COND_2ARG(oper));
|
assert(BCTX_COND_2ARG(oper));
|
||||||
assert(arg[1] != nullptr);
|
assert(arg[1] != nullptr);
|
||||||
return arg[1];
|
return arg[1];
|
||||||
@@ -159,7 +166,8 @@ public:
|
|||||||
* @param varName variable name used mostly for printing the variable.
|
* @param varName variable name used mostly for printing the variable.
|
||||||
* @param varBDD the BDD describing the set where the variable holds.
|
* @param varBDD the BDD describing the set where the variable holds.
|
||||||
*/
|
*/
|
||||||
FormRSCTL(std::string varName) {
|
FormRSCTL(std::string varName)
|
||||||
|
{
|
||||||
oper = RSCTL_PV;
|
oper = RSCTL_PV;
|
||||||
name = varName;
|
name = varName;
|
||||||
arg[0] = nullptr;
|
arg[0] = nullptr;
|
||||||
@@ -175,7 +183,8 @@ public:
|
|||||||
*
|
*
|
||||||
* @param val value of the logical constant
|
* @param val value of the logical constant
|
||||||
*/
|
*/
|
||||||
FormRSCTL(bool val) {
|
FormRSCTL(bool val)
|
||||||
|
{
|
||||||
oper = RSCTL_TF;
|
oper = RSCTL_TF;
|
||||||
tf = val;
|
tf = val;
|
||||||
arg[0] = nullptr;
|
arg[0] = nullptr;
|
||||||
@@ -189,7 +198,8 @@ public:
|
|||||||
/**
|
/**
|
||||||
* @brief Constructor for two-argument formula.
|
* @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_2ARG(op));
|
||||||
assert(!RSCTL_COND_ACT(op));
|
assert(!RSCTL_COND_ACT(op));
|
||||||
oper = op;
|
oper = op;
|
||||||
@@ -204,7 +214,8 @@ public:
|
|||||||
/**
|
/**
|
||||||
* @brief Constructor for two-argument formula with action restrictions.
|
* @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(acts != nullptr);
|
||||||
assert(RSCTL_COND_2ARG(op));
|
assert(RSCTL_COND_2ARG(op));
|
||||||
assert(RSCTL_COND_ACT(op));
|
assert(RSCTL_COND_ACT(op));
|
||||||
@@ -220,7 +231,8 @@ public:
|
|||||||
/**
|
/**
|
||||||
* @brief Constructor for two-argument formula with Boolean context restrictions.
|
* @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(bctx != nullptr);
|
||||||
assert(RSCTL_COND_2ARG(op));
|
assert(RSCTL_COND_2ARG(op));
|
||||||
assert(RSCTL_COND_ACT(op));
|
assert(RSCTL_COND_ACT(op));
|
||||||
@@ -236,7 +248,8 @@ public:
|
|||||||
/**
|
/**
|
||||||
* @brief Constructor for one-argument formula.
|
* @brief Constructor for one-argument formula.
|
||||||
*/
|
*/
|
||||||
FormRSCTL(Oper op, FormRSCTL *form1) {
|
FormRSCTL(Oper op, FormRSCTL *form1)
|
||||||
|
{
|
||||||
assert(RSCTL_COND_1ARG(op));
|
assert(RSCTL_COND_1ARG(op));
|
||||||
assert(!RSCTL_COND_ACT(op));
|
assert(!RSCTL_COND_ACT(op));
|
||||||
oper = op;
|
oper = op;
|
||||||
@@ -251,7 +264,8 @@ public:
|
|||||||
/**
|
/**
|
||||||
* @brief Constructor for one-argument formula with action restrictions.
|
* @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(acts != nullptr);
|
||||||
assert(RSCTL_COND_1ARG(op));
|
assert(RSCTL_COND_1ARG(op));
|
||||||
assert(RSCTL_COND_ACT(op));
|
assert(RSCTL_COND_ACT(op));
|
||||||
@@ -267,7 +281,8 @@ public:
|
|||||||
/**
|
/**
|
||||||
* @brief Constructor for one-argument formula with Boolean context restrictions.
|
* @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(bctx != nullptr);
|
||||||
assert(RSCTL_COND_1ARG(op));
|
assert(RSCTL_COND_1ARG(op));
|
||||||
assert(RSCTL_COND_ACT(op));
|
assert(RSCTL_COND_ACT(op));
|
||||||
@@ -283,7 +298,8 @@ public:
|
|||||||
/**
|
/**
|
||||||
* @brief Destructor.
|
* @brief Destructor.
|
||||||
*/
|
*/
|
||||||
~FormRSCTL() {
|
~FormRSCTL()
|
||||||
|
{
|
||||||
delete arg[0];
|
delete arg[0];
|
||||||
delete arg[1];
|
delete arg[1];
|
||||||
delete bdd;
|
delete bdd;
|
||||||
@@ -293,38 +309,47 @@ public:
|
|||||||
}
|
}
|
||||||
std::string toStr(void) const;
|
std::string toStr(void) const;
|
||||||
bool hasOper(Oper op) const;
|
bool hasOper(Oper op) const;
|
||||||
const BDD *getBDD(void) const {
|
const BDD *getBDD(void) const
|
||||||
|
{
|
||||||
assert(oper == RSCTL_PV);
|
assert(oper == RSCTL_PV);
|
||||||
assert(bdd != nullptr);
|
assert(bdd != nullptr);
|
||||||
return bdd;
|
return bdd;
|
||||||
}
|
}
|
||||||
const BDD *getActionsBDD(void) const {
|
const BDD *getActionsBDD(void) const
|
||||||
|
{
|
||||||
assert(RSCTL_COND_ACT(oper));
|
assert(RSCTL_COND_ACT(oper));
|
||||||
assert(actions_bdd != nullptr);
|
assert(actions_bdd != nullptr);
|
||||||
return actions_bdd;
|
return actions_bdd;
|
||||||
}
|
}
|
||||||
Oper getOper(void) const {
|
Oper getOper(void) const
|
||||||
|
{
|
||||||
assert(RSCTL_IS_VALID(oper));
|
assert(RSCTL_IS_VALID(oper));
|
||||||
return oper;
|
return oper;
|
||||||
}
|
}
|
||||||
FormRSCTL *getLeftSF(void) const {
|
FormRSCTL *getLeftSF(void) const
|
||||||
|
{
|
||||||
assert(arg[0] != nullptr);
|
assert(arg[0] != nullptr);
|
||||||
return arg[0];
|
return arg[0];
|
||||||
}
|
}
|
||||||
FormRSCTL *getRightSF(void) const {
|
FormRSCTL *getRightSF(void) const
|
||||||
|
{
|
||||||
assert(RSCTL_COND_2ARG(oper));
|
assert(RSCTL_COND_2ARG(oper));
|
||||||
assert(arg[1] != nullptr);
|
assert(arg[1] != nullptr);
|
||||||
return arg[1];
|
return arg[1];
|
||||||
}
|
}
|
||||||
std::string getActionsStr(void) const;
|
std::string getActionsStr(void) const;
|
||||||
bool getTF(void) const {
|
bool getTF(void) const
|
||||||
|
{
|
||||||
assert(oper == RSCTL_TF);
|
assert(oper == RSCTL_TF);
|
||||||
return tf;
|
return tf;
|
||||||
}
|
}
|
||||||
void encodeEntities(const SymRS *srs);
|
void encodeEntities(const SymRS *srs);
|
||||||
void encodeActions(const SymRS *srs);
|
void encodeActions(const SymRS *srs);
|
||||||
void forgetActionsBDD(void) {
|
void forgetActionsBDD(void)
|
||||||
if (actions_bdd != nullptr) delete actions_bdd;
|
{
|
||||||
|
if (actions_bdd != nullptr) {
|
||||||
|
delete actions_bdd;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
bool isERSCTL(void) const;
|
bool isERSCTL(void) const;
|
||||||
};
|
};
|
||||||
|
|||||||
93
main.cc
93
main.cc
@@ -24,8 +24,7 @@ int main(int argc, char **argv)
|
|||||||
bool usage_error = false;
|
bool usage_error = false;
|
||||||
bool print_parsed_sys = false;
|
bool print_parsed_sys = false;
|
||||||
|
|
||||||
static struct option long_options[] =
|
static struct option long_options[] = {
|
||||||
{
|
|
||||||
{"trace-parsing", no_argument, 0, 0 },
|
{"trace-parsing", no_argument, 0, 0 },
|
||||||
{"trace-scanning", no_argument, 0, 0 },
|
{"trace-scanning", no_argument, 0, 0 },
|
||||||
{0, 0, 0, 0 }
|
{0, 0, 0, 0 }
|
||||||
@@ -34,65 +33,84 @@ int main(int argc, char **argv)
|
|||||||
int c;
|
int c;
|
||||||
int option_index = 0;
|
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) {
|
switch (c) {
|
||||||
case 0:
|
case 0:
|
||||||
printf("option %s", long_options[option_index].name);
|
printf("option %s", long_options[option_index].name);
|
||||||
if (optarg)
|
|
||||||
|
if (optarg) {
|
||||||
printf(" with arg %s", optarg);
|
printf(" with arg %s", optarg);
|
||||||
|
}
|
||||||
|
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
|
||||||
if (strcmp(long_options[option_index].name, "trace-parsing"))
|
if (strcmp(long_options[option_index].name, "trace-parsing")) {
|
||||||
driver.trace_parsing = true;
|
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;
|
driver.trace_scanning = true;
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
//case 'b':
|
//case 'b':
|
||||||
// printf("-b with %s\n", optarg);
|
// printf("-b with %s\n", optarg);
|
||||||
// break;
|
// break;
|
||||||
case 'b':
|
case 'b':
|
||||||
bmc = false;
|
bmc = false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'p':
|
case 'p':
|
||||||
opts->show_progress = true;
|
opts->show_progress = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'P':
|
case 'P':
|
||||||
print_parsed_sys = true;
|
print_parsed_sys = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'r':
|
case 'r':
|
||||||
show_reactions = true;
|
show_reactions = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'c':
|
case 'c':
|
||||||
rstl_model_checking = true;
|
rstl_model_checking = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'm':
|
case 'm':
|
||||||
opts->measure = true;
|
opts->measure = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'B':
|
case 'B':
|
||||||
benchmarking = true;
|
benchmarking = true;
|
||||||
opts->measure = true;
|
opts->measure = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 's':
|
case 's':
|
||||||
reach_states = true;
|
reach_states = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 't':
|
case 't':
|
||||||
reach_states_succ = true;
|
reach_states_succ = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'v':
|
case 'v':
|
||||||
opts->verbose++;
|
opts->verbose++;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'x':
|
case 'x':
|
||||||
opts->part_tr_rel = true;
|
opts->part_tr_rel = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'z':
|
case 'z':
|
||||||
opts->reorder_reach = true;
|
opts->reorder_reach = true;
|
||||||
opts->reorder_trans = true;
|
opts->reorder_trans = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'h':
|
case 'h':
|
||||||
usage_error = true;
|
usage_error = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
usage_error = true;
|
usage_error = true;
|
||||||
break;
|
break;
|
||||||
@@ -100,36 +118,32 @@ int main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string inputfile;
|
std::string inputfile;
|
||||||
if (optind < argc)
|
|
||||||
{
|
if (optind < argc) {
|
||||||
inputfile = argv[optind];
|
inputfile = argv[optind];
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
cout << "Missing input file" << endl;
|
cout << "Missing input file" << endl;
|
||||||
usage_error = true;
|
usage_error = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (usage_error)
|
if (usage_error) {
|
||||||
{
|
|
||||||
print_help(std::string(argv[0]));
|
print_help(std::string(argv[0]));
|
||||||
return 100;
|
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");
|
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;
|
cout << "Verbose level: " << opts->verbose << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
VERB("Parsing " << inputfile);
|
VERB("Parsing " << inputfile);
|
||||||
|
|
||||||
if (driver.parse(inputfile))
|
if (driver.parse(inputfile)) {
|
||||||
{
|
|
||||||
FERROR("Parse error");
|
FERROR("Parse error");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -144,51 +158,47 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
rs.setOptions(opts); // these need to be passed to the driver
|
rs.setOptions(opts); // these need to be passed to the driver
|
||||||
|
|
||||||
if (show_reactions)
|
if (show_reactions) {
|
||||||
rs.showReactions();
|
rs.showReactions();
|
||||||
|
}
|
||||||
|
|
||||||
if (print_parsed_sys)
|
if (print_parsed_sys) {
|
||||||
rs.printSystem();
|
rs.printSystem();
|
||||||
|
}
|
||||||
|
|
||||||
if (reach_states || reach_states_succ || rstl_model_checking)
|
if (reach_states || reach_states_succ || rstl_model_checking) {
|
||||||
{
|
|
||||||
SymRS srs(&rs, opts);
|
SymRS srs(&rs, opts);
|
||||||
|
|
||||||
ModelChecker mc(&srs, opts);
|
ModelChecker mc(&srs, opts);
|
||||||
|
|
||||||
if (reach_states)
|
if (reach_states) {
|
||||||
{
|
|
||||||
mc.printReach();
|
mc.printReach();
|
||||||
}
|
}
|
||||||
if (reach_states_succ)
|
|
||||||
{
|
if (reach_states_succ) {
|
||||||
mc.printReachWithSucc();
|
mc.printReachWithSucc();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rstl_model_checking)
|
if (rstl_model_checking) {
|
||||||
{
|
if (bmc) {
|
||||||
if (bmc)
|
|
||||||
{
|
|
||||||
cout << "Using BDD-based Bounded Model Checking" << endl;
|
cout << "Using BDD-based Bounded Model Checking" << endl;
|
||||||
mc.checkRSCTL(driver.getFormRSCTL());
|
mc.checkRSCTL(driver.getFormRSCTL());
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
mc.checkRSCTLfull(driver.getFormRSCTL());
|
mc.checkRSCTLfull(driver.getFormRSCTL());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (opts->measure)
|
if (opts->measure) {
|
||||||
{
|
|
||||||
cout << endl << std::setprecision(4)
|
cout << endl << std::setprecision(4)
|
||||||
<< "Encoding time: " << opts->enc_time << " sec" << endl
|
<< "Encoding time: " << opts->enc_time << " sec" << endl
|
||||||
<< "Verification time: " << opts->ver_time << " sec" << endl
|
<< "Verification time: " << opts->ver_time << " sec" << endl
|
||||||
<< "Encoding memory: " << opts->enc_mem << " MB" << endl
|
<< "Encoding memory: " << opts->enc_mem << " MB" << endl
|
||||||
<< "Memory (total): " << opts->ver_mem << " MB" << endl
|
<< "Memory (total): " << opts->ver_mem << " MB" << endl
|
||||||
<< "TOTAL time: " << opts->enc_time + opts->ver_time << " sec" << endl;
|
<< "TOTAL time: " << opts->enc_time + opts->ver_time << " sec" << endl;
|
||||||
if (benchmarking)
|
|
||||||
{
|
if (benchmarking) {
|
||||||
cout << std::setprecision(4)
|
cout << std::setprecision(4)
|
||||||
<< "STAT; " << opts->enc_time
|
<< "STAT; " << opts->enc_time
|
||||||
<< " ; " << opts->ver_time
|
<< " ; " << opts->ver_time
|
||||||
@@ -228,12 +238,15 @@ void print_help(std::string path_str)
|
|||||||
<< " -P -- print parsed system" << endl
|
<< " -P -- print parsed system" << endl
|
||||||
<< " -r -- print reactions" << endl
|
<< " -r -- print reactions" << endl
|
||||||
<< " -s -- print the set of all the reachable states" << 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
|
<< endl << " OTHER:" << endl
|
||||||
<< " -b -- disable bounded model checking (BMC) heuristic" << 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
|
<< " -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
|
<< " -p -- show progress (where possible)" << endl
|
||||||
<< endl
|
<< endl
|
||||||
<< " Benchmarking options:" << endl
|
<< " Benchmarking options:" << endl
|
||||||
|
|||||||
271
mc.cc
271
mc.cc
@@ -27,22 +27,24 @@ ModelChecker::ModelChecker(SymRS *srs, Options *opts)
|
|||||||
// If we use trp, then trm is nullptr (same for trm)
|
// If we use trp, then trm is nullptr (same for trm)
|
||||||
//
|
//
|
||||||
trp = srs->getEncPartTrans();
|
trp = srs->getEncPartTrans();
|
||||||
if (trp == nullptr)
|
|
||||||
|
if (trp == nullptr) {
|
||||||
trp_size = 0;
|
trp_size = 0;
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
trp_size = trp->size();
|
trp_size = trp->size();
|
||||||
|
}
|
||||||
|
|
||||||
trm = srs->getEncMonoTrans();
|
trm = srs->getEncMonoTrans();
|
||||||
|
|
||||||
if (srs->usingContextAutomaton())
|
if (srs->usingContextAutomaton()) {
|
||||||
{
|
|
||||||
using_ctx_aut = true;
|
using_ctx_aut = true;
|
||||||
pv_ca = srs->getEncCtxAutPV();
|
pv_ca = srs->getEncCtxAutPV();
|
||||||
pv_ca_succ = srs->getEncCtxAutPVsucc();
|
pv_ca_succ = srs->getEncCtxAutPVsucc();
|
||||||
pv_ca_E = srs->getEncCtxAutPV_E();
|
pv_ca_E = srs->getEncCtxAutPV_E();
|
||||||
pv_ca_succ_E = srs->getEncCtxAutPVsucc_E();
|
pv_ca_succ_E = srs->getEncCtxAutPVsucc_E();
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
using_ctx_aut = false;
|
using_ctx_aut = false;
|
||||||
pv_ca = nullptr;
|
pv_ca = nullptr;
|
||||||
pv_ca_succ = nullptr;
|
pv_ca_succ = nullptr;
|
||||||
@@ -59,17 +61,16 @@ inline BDD ModelChecker::getSucc(const BDD &states)
|
|||||||
BDD q = BDD_TRUE;
|
BDD q = BDD_TRUE;
|
||||||
|
|
||||||
VERB_L2("Computing successors");
|
VERB_L2("Computing successors");
|
||||||
if (opts->part_tr_rel)
|
|
||||||
{
|
if (opts->part_tr_rel) {
|
||||||
for (unsigned int i = 0; i < trp_size; ++i)
|
for (unsigned int i = 0; i < trp_size; ++i) {
|
||||||
{
|
|
||||||
q *= states * (*trp)[i];
|
q *= states * (*trp)[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
q *= states * *trm;
|
q *= states * *trm;
|
||||||
}
|
}
|
||||||
|
|
||||||
q = (q.ExistAbstract(*pv_E)).SwapVariables(*pv_succ, *pv);
|
q = (q.ExistAbstract(*pv_E)).SwapVariables(*pv_succ, *pv);
|
||||||
q = q.ExistAbstract(*pv_act_E);
|
q = q.ExistAbstract(*pv_act_E);
|
||||||
|
|
||||||
@@ -81,15 +82,16 @@ inline BDD ModelChecker::getPreE(const BDD &states)
|
|||||||
BDD q = BDD_TRUE;
|
BDD q = BDD_TRUE;
|
||||||
VERB_L2("Computing preE");
|
VERB_L2("Computing preE");
|
||||||
BDD x = states.SwapVariables(*pv, *pv_succ);
|
BDD x = states.SwapVariables(*pv, *pv_succ);
|
||||||
if (opts->part_tr_rel)
|
|
||||||
{
|
if (opts->part_tr_rel) {
|
||||||
for (unsigned int i = 0; i < trp_size; ++i)
|
for (unsigned int i = 0; i < trp_size; ++i) {
|
||||||
q *= x * (*trp)[i];
|
q *= x * (*trp)[i];
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
{
|
else {
|
||||||
q *= x * *trm;
|
q *= x * *trm;
|
||||||
}
|
}
|
||||||
|
|
||||||
q = q.ExistAbstract(*pv_succ_E);
|
q = q.ExistAbstract(*pv_succ_E);
|
||||||
q = q.ExistAbstract(*pv_act_E);
|
q = q.ExistAbstract(*pv_act_E);
|
||||||
return q;
|
return q;
|
||||||
@@ -100,15 +102,16 @@ inline BDD ModelChecker::getPreEctx(const BDD &states, const BDD *contexts)
|
|||||||
BDD q = BDD_TRUE;
|
BDD q = BDD_TRUE;
|
||||||
VERB_L2("Computing (context-restricted) preE");
|
VERB_L2("Computing (context-restricted) preE");
|
||||||
BDD x = states.SwapVariables(*pv, *pv_succ);
|
BDD x = states.SwapVariables(*pv, *pv_succ);
|
||||||
if (opts->part_tr_rel)
|
|
||||||
{
|
if (opts->part_tr_rel) {
|
||||||
for (unsigned int i = 0; i < trp_size; ++i)
|
for (unsigned int i = 0; i < trp_size; ++i) {
|
||||||
q *= x * (*trp)[i] * *contexts;
|
q *= x * (*trp)[i] * *contexts;
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
{
|
else {
|
||||||
q *= x * *trm * *contexts;
|
q *= x * *trm * *contexts;
|
||||||
}
|
}
|
||||||
|
|
||||||
q = q.ExistAbstract(*pv_succ_E);
|
q = q.ExistAbstract(*pv_succ_E);
|
||||||
q = q.ExistAbstract(*pv_act_E);
|
q = q.ExistAbstract(*pv_act_E);
|
||||||
return q;
|
return q;
|
||||||
@@ -123,8 +126,9 @@ void ModelChecker::printReach(void)
|
|||||||
{
|
{
|
||||||
VERB_LN(2, "Printing/generating reachable states");
|
VERB_LN(2, "Printing/generating reachable states");
|
||||||
|
|
||||||
if (opts->measure)
|
if (opts->measure) {
|
||||||
opts->ver_time = cpuTime();
|
opts->ver_time = cpuTime();
|
||||||
|
}
|
||||||
|
|
||||||
assert(initStates != nullptr);
|
assert(initStates != nullptr);
|
||||||
|
|
||||||
@@ -133,12 +137,11 @@ void ModelChecker::printReach(void)
|
|||||||
|
|
||||||
unsigned int k = 0;
|
unsigned int k = 0;
|
||||||
|
|
||||||
while (*reach != reach_p)
|
while (*reach != reach_p) {
|
||||||
{
|
if (opts->show_progress) {
|
||||||
if (opts->show_progress)
|
|
||||||
{
|
|
||||||
cout << "\rIteration " << ++k << flush;
|
cout << "\rIteration " << ++k << flush;
|
||||||
}
|
}
|
||||||
|
|
||||||
reach_p = *reach;
|
reach_p = *reach;
|
||||||
*reach += getSucc(*reach);
|
*reach += getSucc(*reach);
|
||||||
}
|
}
|
||||||
@@ -149,8 +152,7 @@ void ModelChecker::printReach(void)
|
|||||||
|
|
||||||
cleanup();
|
cleanup();
|
||||||
|
|
||||||
if (opts->measure)
|
if (opts->measure) {
|
||||||
{
|
|
||||||
opts->ver_time = cpuTime() - opts->ver_time;
|
opts->ver_time = cpuTime() - opts->ver_time;
|
||||||
opts->ver_mem = memUsed();
|
opts->ver_mem = memUsed();
|
||||||
}
|
}
|
||||||
@@ -163,8 +165,7 @@ void ModelChecker::printReachWithSucc(void)
|
|||||||
BDD *reach = new BDD(*initStates);
|
BDD *reach = new BDD(*initStates);
|
||||||
BDD reach_p = cuddMgr->bddZero();
|
BDD reach_p = cuddMgr->bddZero();
|
||||||
|
|
||||||
while (*reach != reach_p)
|
while (*reach != reach_p) {
|
||||||
{
|
|
||||||
reach_p = *reach;
|
reach_p = *reach;
|
||||||
BDD newStates = getSucc(*reach) - *reach;
|
BDD newStates = getSucc(*reach) - *reach;
|
||||||
*reach += newStates;
|
*reach += newStates;
|
||||||
@@ -172,8 +173,8 @@ void ModelChecker::printReachWithSucc(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
BDD unproc = *reach;
|
BDD unproc = *reach;
|
||||||
while (!unproc.IsZero())
|
|
||||||
{
|
while (!unproc.IsZero()) {
|
||||||
BDD t;
|
BDD t;
|
||||||
t = unproc.PickOneMinterm(*pv);
|
t = unproc.PickOneMinterm(*pv);
|
||||||
cout << "Successors of " << srs->decodedRctSysStateToStr(t) << ":" << endl;
|
cout << "Successors of " << srs->decodedRctSysStateToStr(t) << ":" << endl;
|
||||||
@@ -186,29 +187,28 @@ void ModelChecker::printReachWithSucc(void)
|
|||||||
|
|
||||||
bool ModelChecker::checkReach(const Entities testState)
|
bool ModelChecker::checkReach(const Entities testState)
|
||||||
{
|
{
|
||||||
if (opts->measure)
|
if (opts->measure) {
|
||||||
opts->ver_time = cpuTime();
|
opts->ver_time = cpuTime();
|
||||||
|
}
|
||||||
|
|
||||||
BDD st = srs->getEncState(testState);
|
BDD st = srs->getEncState(testState);
|
||||||
|
|
||||||
BDD reach = *initStates;
|
BDD reach = *initStates;
|
||||||
BDD reach_p = cuddMgr->bddZero();
|
BDD reach_p = cuddMgr->bddZero();
|
||||||
|
|
||||||
while (reach != reach_p)
|
while (reach != reach_p) {
|
||||||
{
|
if (reach * st != cuddMgr->bddZero()) {
|
||||||
if (reach * st != cuddMgr->bddZero())
|
|
||||||
{
|
|
||||||
cleanup();
|
cleanup();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
reach_p = reach;
|
reach_p = reach;
|
||||||
reach += getSucc(reach);
|
reach += getSucc(reach);
|
||||||
}
|
}
|
||||||
|
|
||||||
cleanup();
|
cleanup();
|
||||||
|
|
||||||
if (opts->measure)
|
if (opts->measure) {
|
||||||
{
|
|
||||||
opts->ver_time = cpuTime() - opts->ver_time;
|
opts->ver_time = cpuTime() - opts->ver_time;
|
||||||
opts->ver_mem = memUsed();
|
opts->ver_mem = memUsed();
|
||||||
}
|
}
|
||||||
@@ -220,124 +220,112 @@ BDD ModelChecker::getStatesRSCTL(const FormRSCTL *form)
|
|||||||
{
|
{
|
||||||
assert(reach != nullptr);
|
assert(reach != nullptr);
|
||||||
Oper oper = form->getOper();
|
Oper oper = form->getOper();
|
||||||
if (oper == RSCTL_PV)
|
|
||||||
{
|
if (oper == RSCTL_PV) {
|
||||||
return *form->getBDD() * *reach;
|
return *form->getBDD() * *reach;
|
||||||
}
|
}
|
||||||
else if (oper == RSCTL_TF)
|
else if (oper == RSCTL_TF) {
|
||||||
{
|
if (form->getTF() == true) {
|
||||||
if (form->getTF() == true)
|
|
||||||
return *reach;
|
return *reach;
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
return cuddMgr->bddZero();
|
return cuddMgr->bddZero();
|
||||||
}
|
}
|
||||||
else if (oper == RSCTL_AND)
|
}
|
||||||
{
|
else if (oper == RSCTL_AND) {
|
||||||
return getStatesRSCTL(form->getLeftSF()) * getStatesRSCTL(form->getRightSF());
|
return getStatesRSCTL(form->getLeftSF()) * getStatesRSCTL(form->getRightSF());
|
||||||
}
|
}
|
||||||
else if (oper == RSCTL_OR)
|
else if (oper == RSCTL_OR) {
|
||||||
{
|
|
||||||
return getStatesRSCTL(form->getLeftSF()) + getStatesRSCTL(form->getRightSF());
|
return getStatesRSCTL(form->getLeftSF()) + getStatesRSCTL(form->getRightSF());
|
||||||
}
|
}
|
||||||
else if (oper == RSCTL_XOR)
|
else if (oper == RSCTL_XOR) {
|
||||||
{
|
|
||||||
return getStatesRSCTL(form->getLeftSF()) ^ getStatesRSCTL(form->getRightSF());
|
return getStatesRSCTL(form->getLeftSF()) ^ getStatesRSCTL(form->getRightSF());
|
||||||
}
|
}
|
||||||
else if (oper == RSCTL_IMPL)
|
else if (oper == RSCTL_IMPL) {
|
||||||
{
|
return (!getStatesRSCTL(form->getLeftSF()) * *reach) + getStatesRSCTL(
|
||||||
return (!getStatesRSCTL(form->getLeftSF()) * *reach) + getStatesRSCTL(form->getRightSF());
|
form->getRightSF());
|
||||||
}
|
}
|
||||||
else if (oper == RSCTL_NOT)
|
else if (oper == RSCTL_NOT) {
|
||||||
{
|
|
||||||
return !getStatesRSCTL(form->getLeftSF()) * *reach;
|
return !getStatesRSCTL(form->getLeftSF()) * *reach;
|
||||||
}
|
}
|
||||||
else if (oper == RSCTL_EX)
|
else if (oper == RSCTL_EX) {
|
||||||
{
|
|
||||||
return getPreE(getStatesRSCTL(form->getLeftSF())) * *reach;
|
return getPreE(getStatesRSCTL(form->getLeftSF())) * *reach;
|
||||||
}
|
}
|
||||||
else if (oper == RSCTL_EG)
|
else if (oper == RSCTL_EG) {
|
||||||
{
|
|
||||||
return statesEG(getStatesRSCTL(form->getLeftSF()));
|
return statesEG(getStatesRSCTL(form->getLeftSF()));
|
||||||
}
|
}
|
||||||
else if (oper == RSCTL_EU)
|
else if (oper == RSCTL_EU) {
|
||||||
{
|
|
||||||
return statesEU(
|
return statesEU(
|
||||||
getStatesRSCTL(form->getLeftSF()),
|
getStatesRSCTL(form->getLeftSF()),
|
||||||
getStatesRSCTL(form->getRightSF())
|
getStatesRSCTL(form->getRightSF())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else if (oper == RSCTL_EF)
|
else if (oper == RSCTL_EF) {
|
||||||
{
|
|
||||||
return statesEF(getStatesRSCTL(form->getLeftSF()));
|
return statesEF(getStatesRSCTL(form->getLeftSF()));
|
||||||
}
|
}
|
||||||
else if (oper == RSCTL_AX)
|
else if (oper == RSCTL_AX) {
|
||||||
{
|
|
||||||
return !getPreE(!getStatesRSCTL(form->getLeftSF()) * *reach) * *reach;
|
return !getPreE(!getStatesRSCTL(form->getLeftSF()) * *reach) * *reach;
|
||||||
}
|
}
|
||||||
else if (oper == RSCTL_AG)
|
else if (oper == RSCTL_AG) {
|
||||||
{
|
|
||||||
return !statesEF(
|
return !statesEF(
|
||||||
!getStatesRSCTL(form->getLeftSF()) * *reach) * *reach;
|
!getStatesRSCTL(form->getLeftSF()) * *reach) * *reach;
|
||||||
}
|
}
|
||||||
else if (oper == RSCTL_AU)
|
else if (oper == RSCTL_AU) {
|
||||||
{
|
|
||||||
BDD ng = !getStatesRSCTL(form->getRightSF()) * *reach;
|
BDD ng = !getStatesRSCTL(form->getRightSF()) * *reach;
|
||||||
BDD nf = !getStatesRSCTL(form->getLeftSF()) * *reach;
|
BDD nf = !getStatesRSCTL(form->getLeftSF()) * *reach;
|
||||||
|
|
||||||
BDD x = !statesEU(ng, ng * nf) * *reach;
|
BDD x = !statesEU(ng, ng * nf) * *reach;
|
||||||
if (!x.IsZero())
|
|
||||||
|
if (!x.IsZero()) {
|
||||||
x = x * !statesEG(ng) * *reach;
|
x = x * !statesEG(ng) * *reach;
|
||||||
|
}
|
||||||
|
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
else if (oper == RSCTL_AF)
|
else if (oper == RSCTL_AF) {
|
||||||
{
|
|
||||||
return !statesEG(
|
return !statesEG(
|
||||||
!getStatesRSCTL(form->getLeftSF()) * *reach) * *reach;
|
!getStatesRSCTL(form->getLeftSF()) * *reach) * *reach;
|
||||||
}
|
}
|
||||||
/***** CONTEXT RESTRICTIONS: ******/
|
/***** CONTEXT RESTRICTIONS: ******/
|
||||||
else if (oper == RSCTL_EX_ACT)
|
else if (oper == RSCTL_EX_ACT) {
|
||||||
{
|
return getPreEctx(getStatesRSCTL(form->getLeftSF()),
|
||||||
return getPreEctx(getStatesRSCTL(form->getLeftSF()), form->getActionsBDD()) * *reach;
|
form->getActionsBDD()) * *reach;
|
||||||
}
|
}
|
||||||
else if (oper == RSCTL_EG_ACT)
|
else if (oper == RSCTL_EG_ACT) {
|
||||||
{
|
return statesEGctx(form->getActionsBDD(),
|
||||||
return statesEGctx(form->getActionsBDD(), getStatesRSCTL(form->getLeftSF())); /***** EG? *****/
|
getStatesRSCTL(form->getLeftSF())); /***** EG? *****/
|
||||||
}
|
}
|
||||||
else if (oper == RSCTL_EU_ACT)
|
else if (oper == RSCTL_EU_ACT) {
|
||||||
{
|
|
||||||
return statesEUctx(
|
return statesEUctx(
|
||||||
form->getActionsBDD(),
|
form->getActionsBDD(),
|
||||||
getStatesRSCTL(form->getLeftSF()),
|
getStatesRSCTL(form->getLeftSF()),
|
||||||
getStatesRSCTL(form->getRightSF())
|
getStatesRSCTL(form->getRightSF())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else if (oper == RSCTL_EF_ACT)
|
else if (oper == RSCTL_EF_ACT) {
|
||||||
{
|
|
||||||
return statesEFctx(form->getActionsBDD(), getStatesRSCTL(form->getLeftSF()));
|
return statesEFctx(form->getActionsBDD(), getStatesRSCTL(form->getLeftSF()));
|
||||||
}
|
}
|
||||||
else if (oper == RSCTL_AX_ACT)
|
else if (oper == RSCTL_AX_ACT) {
|
||||||
{
|
return !getPreEctx(!getStatesRSCTL(form->getLeftSF()) * *reach,
|
||||||
return !getPreEctx(!getStatesRSCTL(form->getLeftSF()) * *reach, form->getActionsBDD()) * *reach;
|
form->getActionsBDD()) * *reach;
|
||||||
}
|
}
|
||||||
else if (oper == RSCTL_AG_ACT)
|
else if (oper == RSCTL_AG_ACT) {
|
||||||
{
|
|
||||||
return !statesEFctx(form->getActionsBDD(),
|
return !statesEFctx(form->getActionsBDD(),
|
||||||
!getStatesRSCTL(form->getLeftSF()) * *reach) * *reach;
|
!getStatesRSCTL(form->getLeftSF()) * *reach) * *reach;
|
||||||
}
|
}
|
||||||
else if (oper == RSCTL_AU_ACT)
|
else if (oper == RSCTL_AU_ACT) {
|
||||||
{
|
|
||||||
BDD ng = !getStatesRSCTL(form->getRightSF()) * *reach;
|
BDD ng = !getStatesRSCTL(form->getRightSF()) * *reach;
|
||||||
BDD nf = !getStatesRSCTL(form->getLeftSF()) * *reach;
|
BDD nf = !getStatesRSCTL(form->getLeftSF()) * *reach;
|
||||||
|
|
||||||
BDD x = !statesEUctx(form->getActionsBDD(), ng, ng * nf) * *reach;
|
BDD x = !statesEUctx(form->getActionsBDD(), ng, ng * nf) * *reach;
|
||||||
if (!x.IsZero())
|
|
||||||
|
if (!x.IsZero()) {
|
||||||
x = x * !statesEGctx(form->getActionsBDD(), ng) * *reach;
|
x = x * !statesEGctx(form->getActionsBDD(), ng) * *reach;
|
||||||
|
}
|
||||||
|
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
else if (oper == RSCTL_AF_ACT)
|
else if (oper == RSCTL_AF_ACT) {
|
||||||
{
|
|
||||||
return !statesEGctx(form->getActionsBDD(),
|
return !statesEGctx(form->getActionsBDD(),
|
||||||
!getStatesRSCTL(form->getLeftSF()) * *reach) * *reach;
|
!getStatesRSCTL(form->getLeftSF()) * *reach) * *reach;
|
||||||
}
|
}
|
||||||
@@ -350,11 +338,12 @@ BDD ModelChecker::statesEG(const BDD &states)
|
|||||||
{
|
{
|
||||||
BDD x = states;
|
BDD x = states;
|
||||||
BDD x_p = cuddMgr->bddZero();
|
BDD x_p = cuddMgr->bddZero();
|
||||||
while (x != x_p)
|
|
||||||
{
|
while (x != x_p) {
|
||||||
x_p = x;
|
x_p = x;
|
||||||
x = x * getPreE(x);
|
x = x * getPreE(x);
|
||||||
}
|
}
|
||||||
|
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -362,11 +351,12 @@ BDD ModelChecker::statesEU(const BDD &statesA, const BDD &statesB)
|
|||||||
{
|
{
|
||||||
BDD x = statesA;
|
BDD x = statesA;
|
||||||
BDD x_p = *reach;
|
BDD x_p = *reach;
|
||||||
while (x != x_p)
|
|
||||||
{
|
while (x != x_p) {
|
||||||
x_p = x;
|
x_p = x;
|
||||||
x = x + (statesA * getPreE(x));
|
x = x + (statesA * getPreE(x));
|
||||||
}
|
}
|
||||||
|
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -374,11 +364,12 @@ BDD ModelChecker::statesEF(const BDD &states)
|
|||||||
{
|
{
|
||||||
BDD x = states;
|
BDD x = states;
|
||||||
BDD x_p = *reach;
|
BDD x_p = *reach;
|
||||||
while (x != x_p)
|
|
||||||
{
|
while (x != x_p) {
|
||||||
x_p = x;
|
x_p = x;
|
||||||
x = x + (*reach * getPreE(x));
|
x = x + (*reach * getPreE(x));
|
||||||
}
|
}
|
||||||
|
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -386,23 +377,26 @@ BDD ModelChecker::statesEGctx(const BDD *contexts, const BDD &states)
|
|||||||
{
|
{
|
||||||
BDD x = states;
|
BDD x = states;
|
||||||
BDD x_p = cuddMgr->bddZero();
|
BDD x_p = cuddMgr->bddZero();
|
||||||
while (x != x_p)
|
|
||||||
{
|
while (x != x_p) {
|
||||||
x_p = x;
|
x_p = x;
|
||||||
x = x * getPreEctx(x, contexts);
|
x = x * getPreEctx(x, contexts);
|
||||||
}
|
}
|
||||||
|
|
||||||
return x;
|
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 = statesA;
|
||||||
BDD x_p = *reach;
|
BDD x_p = *reach;
|
||||||
while (x != x_p)
|
|
||||||
{
|
while (x != x_p) {
|
||||||
x_p = x;
|
x_p = x;
|
||||||
x = x + (statesA * getPreEctx(x, contexts));
|
x = x + (statesA * getPreEctx(x, contexts));
|
||||||
}
|
}
|
||||||
|
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -410,26 +404,30 @@ BDD ModelChecker::statesEFctx(const BDD *contexts, const BDD &states)
|
|||||||
{
|
{
|
||||||
BDD x = states;
|
BDD x = states;
|
||||||
BDD x_p = *reach;
|
BDD x_p = *reach;
|
||||||
while (x != x_p)
|
|
||||||
{
|
while (x != x_p) {
|
||||||
x_p = x;
|
x_p = x;
|
||||||
x = x + (*reach * getPreEctx(x, contexts));
|
x = x + (*reach * getPreEctx(x, contexts));
|
||||||
}
|
}
|
||||||
|
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ModelChecker::checkRSCTL(FormRSCTL *form)
|
bool ModelChecker::checkRSCTL(FormRSCTL *form)
|
||||||
{
|
{
|
||||||
if (form->isERSCTL())
|
if (form->isERSCTL()) {
|
||||||
return checkRSCTLbmc(form);
|
return checkRSCTLbmc(form);
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
return checkRSCTLfull(form);
|
return checkRSCTLfull(form);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool ModelChecker::checkRSCTLfull(FormRSCTL *form)
|
bool ModelChecker::checkRSCTLfull(FormRSCTL *form)
|
||||||
{
|
{
|
||||||
if (opts->measure)
|
if (opts->measure) {
|
||||||
opts->ver_time = cpuTime();
|
opts->ver_time = cpuTime();
|
||||||
|
}
|
||||||
|
|
||||||
assert(form != nullptr);
|
assert(form != nullptr);
|
||||||
|
|
||||||
@@ -454,16 +452,13 @@ bool ModelChecker::checkRSCTLfull(FormRSCTL *form)
|
|||||||
|
|
||||||
unsigned int k = 0;
|
unsigned int k = 0;
|
||||||
|
|
||||||
while (*reach != reach_p)
|
while (*reach != reach_p) {
|
||||||
{
|
|
||||||
|
|
||||||
if (opts->show_progress)
|
if (opts->show_progress) {
|
||||||
{
|
|
||||||
cout << "\rIteration " << ++k << flush;
|
cout << "\rIteration " << ++k << flush;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (opts->reorder_reach)
|
if (opts->reorder_reach) {
|
||||||
{
|
|
||||||
VERB_L2("Reordering")
|
VERB_L2("Reordering")
|
||||||
Cudd_ReduceHeap(cuddMgr->getManager(), CUDD_REORDER_SIFT, 10000);
|
Cudd_ReduceHeap(cuddMgr->getManager(), CUDD_REORDER_SIFT, 10000);
|
||||||
}
|
}
|
||||||
@@ -472,26 +467,26 @@ bool ModelChecker::checkRSCTLfull(FormRSCTL *form)
|
|||||||
*reach += getSucc(*reach);
|
*reach += getSucc(*reach);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (opts->show_progress) cout << endl;
|
if (opts->show_progress) {
|
||||||
|
cout << endl;
|
||||||
|
}
|
||||||
|
|
||||||
VERB("Checking the formula");
|
VERB("Checking the formula");
|
||||||
|
|
||||||
//if (*initStates * getStatesRSCTL(form) != cuddMgr->bddZero())
|
//if (*initStates * getStatesRSCTL(form) != cuddMgr->bddZero())
|
||||||
if (*initStates * getStatesRSCTL(form) == *initStates)
|
if (*initStates * getStatesRSCTL(form) == *initStates) {
|
||||||
{
|
|
||||||
result = true;
|
result = true;
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
result = false;
|
result = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
cleanup();
|
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_time = cpuTime() - opts->ver_time;
|
||||||
opts->ver_mem = memUsed();
|
opts->ver_mem = memUsed();
|
||||||
}
|
}
|
||||||
@@ -501,14 +496,15 @@ bool ModelChecker::checkRSCTLfull(FormRSCTL *form)
|
|||||||
|
|
||||||
bool ModelChecker::checkRSCTLbmc(FormRSCTL *form)
|
bool ModelChecker::checkRSCTLbmc(FormRSCTL *form)
|
||||||
{
|
{
|
||||||
if (opts->measure)
|
if (opts->measure) {
|
||||||
opts->ver_time = cpuTime();
|
opts->ver_time = cpuTime();
|
||||||
|
}
|
||||||
|
|
||||||
assert(form != nullptr);
|
assert(form != nullptr);
|
||||||
|
|
||||||
if (!form->isERSCTL())
|
if (!form->isERSCTL()) {
|
||||||
{
|
FERROR("Formula " << form->toStr() <<
|
||||||
FERROR("Formula " << form->toStr() << " is not syntactically an ERSCTL formula");
|
" is not syntactically an ERSCTL formula");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool result = false;
|
bool result = false;
|
||||||
@@ -530,16 +526,13 @@ bool ModelChecker::checkRSCTLbmc(FormRSCTL *form)
|
|||||||
|
|
||||||
unsigned int k = 0;
|
unsigned int k = 0;
|
||||||
|
|
||||||
while (*reach != reach_p)
|
while (*reach != reach_p) {
|
||||||
{
|
if (opts->show_progress) {
|
||||||
if (opts->show_progress)
|
|
||||||
{
|
|
||||||
cout << "\rIteration " << ++k << flush;
|
cout << "\rIteration " << ++k << flush;
|
||||||
}
|
}
|
||||||
|
|
||||||
//if (*initStates * getStatesRSCTL(form) != cuddMgr->bddZero())
|
//if (*initStates * getStatesRSCTL(form) != cuddMgr->bddZero())
|
||||||
if (*initStates * getStatesRSCTL(form) == *initStates)
|
if (*initStates * getStatesRSCTL(form) == *initStates) {
|
||||||
{
|
|
||||||
result = true;
|
result = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -548,14 +541,16 @@ bool ModelChecker::checkRSCTLbmc(FormRSCTL *form)
|
|||||||
*reach += getSucc(*reach);
|
*reach += getSucc(*reach);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (opts->show_progress) cout << endl;
|
if (opts->show_progress) {
|
||||||
|
cout << endl;
|
||||||
|
}
|
||||||
|
|
||||||
cleanup();
|
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_time = cpuTime() - opts->ver_time;
|
||||||
opts->ver_mem = memUsed();
|
opts->ver_mem = memUsed();
|
||||||
}
|
}
|
||||||
|
|||||||
13
memtime.hh
13
memtime.hh
@@ -40,16 +40,19 @@ static inline int memReadStat(void)
|
|||||||
pid_t pid = getpid();
|
pid_t pid = getpid();
|
||||||
sprintf(name, "/proc/%d/statm", pid);
|
sprintf(name, "/proc/%d/statm", pid);
|
||||||
FILE *in = fopen(name, "rb");
|
FILE *in = fopen(name, "rb");
|
||||||
if (in == nullptr)
|
|
||||||
{
|
if (in == nullptr) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int value;
|
int value;
|
||||||
for (int field = 0; field >= 0; --field)
|
|
||||||
{
|
for (int field = 0; field >= 0; --field) {
|
||||||
if (fscanf(in, "%d", &value) == EOF)
|
if (fscanf(in, "%d", &value) == EOF) {
|
||||||
FERROR("EOF");
|
FERROR("EOF");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fclose(in);
|
fclose(in);
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
#ifndef RS_OPTIONS_HH
|
#ifndef RS_OPTIONS_HH
|
||||||
#define RS_OPTIONS_HH
|
#define RS_OPTIONS_HH
|
||||||
|
|
||||||
class Options {
|
class Options
|
||||||
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
unsigned int verbose;
|
unsigned int verbose;
|
||||||
|
|||||||
121
rs.cc
121
rs.cc
@@ -16,16 +16,17 @@ RctSys::RctSys(void)
|
|||||||
|
|
||||||
bool RctSys::hasEntity(std::string name)
|
bool RctSys::hasEntity(std::string name)
|
||||||
{
|
{
|
||||||
if (entities_names.find(name) == entities_names.end())
|
if (entities_names.find(name) == entities_names.end()) {
|
||||||
return false;
|
return false;
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void RctSys::addEntity(std::string name)
|
void RctSys::addEntity(std::string name)
|
||||||
{
|
{
|
||||||
if (!hasEntity(name))
|
if (!hasEntity(name)) {
|
||||||
{
|
|
||||||
Entity new_entity_id = entities_ids.size();
|
Entity new_entity_id = entities_ids.size();
|
||||||
|
|
||||||
VERB_L2("Adding entity: " << name << " index=" << new_entity_id);
|
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)
|
std::string RctSys::getEntityName(Entity entityID)
|
||||||
{
|
{
|
||||||
if (entityID < entities_ids.size())
|
if (entityID < entities_ids.size()) {
|
||||||
return entities_ids[entityID];
|
return entities_ids[entityID];
|
||||||
else
|
}
|
||||||
{
|
else {
|
||||||
FERROR("No such entity ID: " << entityID);
|
FERROR("No such entity ID: " << entityID);
|
||||||
return "??";
|
return "??";
|
||||||
}
|
}
|
||||||
@@ -48,10 +49,10 @@ std::string RctSys::getEntityName(Entity entityID)
|
|||||||
|
|
||||||
Entity RctSys::getEntityID(std::string name)
|
Entity RctSys::getEntityID(std::string name)
|
||||||
{
|
{
|
||||||
if (!hasEntity(name))
|
if (!hasEntity(name)) {
|
||||||
{
|
|
||||||
FERROR("No such entity: " << name);
|
FERROR("No such entity: " << name);
|
||||||
}
|
}
|
||||||
|
|
||||||
return entities_names[name];
|
return entities_names[name];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,8 +60,7 @@ void RctSys::setCurrentProcess(std::string processName)
|
|||||||
{
|
{
|
||||||
VERB_LN(2, "Current Process: " << processName);
|
VERB_LN(2, "Current Process: " << processName);
|
||||||
|
|
||||||
if (!hasProcess(processName))
|
if (!hasProcess(processName)) {
|
||||||
{
|
|
||||||
addProcess(processName);
|
addProcess(processName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -70,8 +70,7 @@ void RctSys::setCurrentProcess(std::string processName)
|
|||||||
|
|
||||||
void RctSys::addProcess(std::string processName)
|
void RctSys::addProcess(std::string processName)
|
||||||
{
|
{
|
||||||
if (!hasProcess(processName))
|
if (!hasProcess(processName)) {
|
||||||
{
|
|
||||||
Process new_proc_id = processes_ids.size();
|
Process new_proc_id = processes_ids.size();
|
||||||
|
|
||||||
VERB_L2("Adding process: " << processName << " index=" << new_proc_id);
|
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)
|
bool RctSys::hasProcess(std::string processName)
|
||||||
{
|
{
|
||||||
if (processes_names.find(processName) == processes_names.end())
|
if (processes_names.find(processName) == processes_names.end()) {
|
||||||
return false;
|
return false;
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Process RctSys::getProcessID(std::string processName)
|
Process RctSys::getProcessID(std::string processName)
|
||||||
{
|
{
|
||||||
if (!hasProcess(processName))
|
if (!hasProcess(processName)) {
|
||||||
{
|
|
||||||
FERROR("No such process: " << processName);
|
FERROR("No such process: " << processName);
|
||||||
}
|
}
|
||||||
|
|
||||||
return processes_names[processName];
|
return processes_names[processName];
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string RctSys::getProcessName(Process processID)
|
std::string RctSys::getProcessName(Process processID)
|
||||||
{
|
{
|
||||||
if (processID < processes_ids.size())
|
if (processID < processes_ids.size()) {
|
||||||
return processes_ids[processID];
|
return processes_ids[processID];
|
||||||
else
|
}
|
||||||
{
|
else {
|
||||||
FERROR("No such process ID: " << processID);
|
FERROR("No such process ID: " << processID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RctSys::pushReactant(std::string entityName)
|
void RctSys::pushReactant(std::string entityName)
|
||||||
{
|
{
|
||||||
if (!hasEntity(entityName))
|
if (!hasEntity(entityName)) {
|
||||||
addEntity(entityName);
|
addEntity(entityName);
|
||||||
|
}
|
||||||
|
|
||||||
tmpReactants.insert(getEntityID(entityName));
|
tmpReactants.insert(getEntityID(entityName));
|
||||||
}
|
}
|
||||||
void RctSys::pushInhibitor(std::string entityName)
|
void RctSys::pushInhibitor(std::string entityName)
|
||||||
{
|
{
|
||||||
if (!hasEntity(entityName))
|
if (!hasEntity(entityName)) {
|
||||||
addEntity(entityName);
|
addEntity(entityName);
|
||||||
|
}
|
||||||
|
|
||||||
tmpInhibitors.insert(getEntityID(entityName));
|
tmpInhibitors.insert(getEntityID(entityName));
|
||||||
}
|
}
|
||||||
void RctSys::pushProduct(std::string entityName)
|
void RctSys::pushProduct(std::string entityName)
|
||||||
{
|
{
|
||||||
if (!hasEntity(entityName))
|
if (!hasEntity(entityName)) {
|
||||||
addEntity(entityName);
|
addEntity(entityName);
|
||||||
|
}
|
||||||
|
|
||||||
tmpProducts.insert(getEntityID(entityName));
|
tmpProducts.insert(getEntityID(entityName));
|
||||||
}
|
}
|
||||||
|
|
||||||
void RctSys::addReactionForCurrentProcess(Reaction reaction)
|
void RctSys::addReactionForCurrentProcess(Reaction reaction)
|
||||||
{
|
{
|
||||||
if (!current_process_defined)
|
if (!current_process_defined) {
|
||||||
{
|
|
||||||
FERROR("Internal error. Current process is not set!");
|
FERROR("Internal error. Current process is not set!");
|
||||||
}
|
}
|
||||||
|
|
||||||
proc_reactions[current_proc_id].push_back(reaction);
|
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 RctSys::entitiesToStr(const Entities &entities)
|
||||||
{
|
{
|
||||||
std::string s = " ";
|
std::string s = " ";
|
||||||
for (auto a = entities.begin(); a != entities.end(); ++a)
|
|
||||||
{
|
for (auto a = entities.begin(); a != entities.end(); ++a) {
|
||||||
s += entityToStr(*a) + " ";
|
s += entityToStr(*a) + " ";
|
||||||
}
|
}
|
||||||
|
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -171,101 +179,113 @@ void RctSys::showReactions(void)
|
|||||||
{
|
{
|
||||||
cout << "# Reactions:" << endl;
|
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 << endl;
|
||||||
cout << " . proc = \"" << getProcessName(proc_id) << "\":" << 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) << "},"
|
cout << " * (R={" << entitiesToStr(r.rctt) << "},"
|
||||||
<< "I={" << entitiesToStr(r.inhib) << "},"
|
<< "I={" << entitiesToStr(r.inhib) << "},"
|
||||||
<< "P={" << entitiesToStr(r.prod) << "})" << endl;
|
<< "P={" << entitiesToStr(r.prod) << "})" << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cout << endl;
|
cout << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RctSys::pushStateEntity(std::string entityName)
|
void RctSys::pushStateEntity(std::string entityName)
|
||||||
{
|
{
|
||||||
if (!hasEntity(entityName))
|
if (!hasEntity(entityName)) {
|
||||||
{
|
|
||||||
FERROR("No such entity: " << entityName);
|
FERROR("No such entity: " << entityName);
|
||||||
}
|
}
|
||||||
|
|
||||||
tmpState.insert(getEntityID(entityName));
|
tmpState.insert(getEntityID(entityName));
|
||||||
}
|
}
|
||||||
|
|
||||||
void RctSys::commitInitState(void)
|
void RctSys::commitInitState(void)
|
||||||
{
|
{
|
||||||
if (ctx_aut != nullptr)
|
if (ctx_aut != nullptr) {
|
||||||
{
|
|
||||||
FERROR("Initial RS states must not be used with context automaton");
|
FERROR("Initial RS states must not be used with context automaton");
|
||||||
}
|
}
|
||||||
|
|
||||||
initStates.insert(tmpState);
|
initStates.insert(tmpState);
|
||||||
tmpState.clear();
|
tmpState.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RctSys::addActionEntity(std::string entityName)
|
void RctSys::addActionEntity(std::string entityName)
|
||||||
{
|
{
|
||||||
if (!hasEntity(entityName))
|
if (!hasEntity(entityName)) {
|
||||||
addEntity(entityName);
|
addEntity(entityName);
|
||||||
|
}
|
||||||
|
|
||||||
actionEntities.insert(getEntityID(entityName));
|
actionEntities.insert(getEntityID(entityName));
|
||||||
}
|
}
|
||||||
|
|
||||||
void RctSys::addActionEntity(Entity entity)
|
void RctSys::addActionEntity(Entity entity)
|
||||||
{
|
{
|
||||||
if (!isActionEntity(entity))
|
if (!isActionEntity(entity)) {
|
||||||
actionEntities.insert(entity);
|
actionEntities.insert(entity);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool RctSys::isActionEntity(Entity entity)
|
bool RctSys::isActionEntity(Entity entity)
|
||||||
{
|
{
|
||||||
if (actionEntities.count(entity) > 0)
|
if (actionEntities.count(entity) > 0) {
|
||||||
return true;
|
return true;
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void RctSys::showActionEntities(void)
|
void RctSys::showActionEntities(void)
|
||||||
{
|
{
|
||||||
cout << "# Context entities:";
|
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 << " " << getEntityName(*a);
|
||||||
}
|
}
|
||||||
|
|
||||||
cout << endl;
|
cout << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RctSys::showInitialStates(void)
|
void RctSys::showInitialStates(void)
|
||||||
{
|
{
|
||||||
cout << "# Initial states:" << endl;
|
cout << "# Initial states:" << endl;
|
||||||
for (auto s = initStates.begin(); s != initStates.end(); ++s)
|
|
||||||
{
|
for (auto s = initStates.begin(); s != initStates.end(); ++s) {
|
||||||
cout << " *";
|
cout << " *";
|
||||||
for (auto a = s->begin(); a != s->end(); ++a)
|
|
||||||
{
|
for (auto a = s->begin(); a != s->end(); ++a) {
|
||||||
cout << " " << getEntityName(*a);
|
cout << " " << getEntityName(*a);
|
||||||
}
|
}
|
||||||
|
|
||||||
cout << endl;
|
cout << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RctSys::printSystem(void)
|
void RctSys::printSystem(void)
|
||||||
{
|
{
|
||||||
if (!usingContextAutomaton())
|
if (!usingContextAutomaton()) {
|
||||||
showInitialStates();
|
showInitialStates();
|
||||||
|
}
|
||||||
|
|
||||||
showActionEntities();
|
showActionEntities();
|
||||||
showReactions();
|
showReactions();
|
||||||
|
|
||||||
if (ctx_aut != nullptr) ctx_aut->printAutomaton();
|
if (ctx_aut != nullptr) {
|
||||||
|
ctx_aut->printAutomaton();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RctSys::ctxAutEnable(void)
|
void RctSys::ctxAutEnable(void)
|
||||||
{
|
{
|
||||||
assert(ctx_aut == nullptr);
|
assert(ctx_aut == nullptr);
|
||||||
if (initStatesDefined())
|
|
||||||
{
|
if (initStatesDefined()) {
|
||||||
FERROR("Initial states must not be defined if using context automaton");
|
FERROR("Initial states must not be defined if using context automaton");
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx_aut = new CtxAut(opts, this);
|
ctx_aut = new CtxAut(opts, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -281,7 +301,8 @@ void RctSys::ctxAutSetInitState(std::string stateName)
|
|||||||
ctx_aut->setInitState(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);
|
assert(ctx_aut != nullptr);
|
||||||
ctx_aut->addTransition(srcStateName, dstStateName);
|
ctx_aut->addTransition(srcStateName, dstStateName);
|
||||||
|
|||||||
40
rs.hh
40
rs.hh
@@ -34,7 +34,10 @@ class RctSys
|
|||||||
public:
|
public:
|
||||||
RctSys(void);
|
RctSys(void);
|
||||||
|
|
||||||
void setOptions(Options *opts) { this->opts = opts; }
|
void setOptions(Options *opts)
|
||||||
|
{
|
||||||
|
this->opts = opts;
|
||||||
|
}
|
||||||
bool hasEntity(std::string entityName);
|
bool hasEntity(std::string entityName);
|
||||||
void addEntity(std::string entityName);
|
void addEntity(std::string entityName);
|
||||||
std::string getEntityName(Entity entityID);
|
std::string getEntityName(Entity entityID);
|
||||||
@@ -51,7 +54,10 @@ class RctSys
|
|||||||
void pushInhibitor(std::string entityName);
|
void pushInhibitor(std::string entityName);
|
||||||
void pushProduct(std::string entityName);
|
void pushProduct(std::string entityName);
|
||||||
void commitReaction(void);
|
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);
|
std::string entitiesToStr(const Entities &entities);
|
||||||
void showReactions(void);
|
void showReactions(void);
|
||||||
void pushStateEntity(std::string entityName);
|
void pushStateEntity(std::string entityName);
|
||||||
@@ -59,10 +65,22 @@ class RctSys
|
|||||||
void addActionEntity(std::string entityName);
|
void addActionEntity(std::string entityName);
|
||||||
void addActionEntity(Entity entity);
|
void addActionEntity(Entity entity);
|
||||||
bool isActionEntity(Entity entity);
|
bool isActionEntity(Entity entity);
|
||||||
void resetInitStates(void) { initStates.clear(); }
|
void resetInitStates(void)
|
||||||
unsigned int getEntitiesSize(void) { return entities_ids.size(); }
|
{
|
||||||
unsigned int getReactionsSize(void) { return reactions.size(); }
|
initStates.clear();
|
||||||
unsigned int getActionsSize(void) { return actionEntities.size(); }
|
}
|
||||||
|
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 showInitialStates(void);
|
||||||
void showActionEntities(void);
|
void showActionEntities(void);
|
||||||
void printSystem(void);
|
void printSystem(void);
|
||||||
@@ -73,8 +91,14 @@ class RctSys
|
|||||||
void ctxAutAddTransition(std::string srcStateName, std::string dstStateName);
|
void ctxAutAddTransition(std::string srcStateName, std::string dstStateName);
|
||||||
void ctxAutPushNamedContextEntity(std::string entity_name);
|
void ctxAutPushNamedContextEntity(std::string entity_name);
|
||||||
|
|
||||||
bool initStatesDefined(void) { return initStates.size() != 0; }
|
bool initStatesDefined(void)
|
||||||
bool usingContextAutomaton(void) { return ctx_aut != nullptr; }
|
{
|
||||||
|
return initStates.size() != 0;
|
||||||
|
}
|
||||||
|
bool usingContextAutomaton(void)
|
||||||
|
{
|
||||||
|
return ctx_aut != nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Reactions reactions; // TODO: to be removed later
|
Reactions reactions; // TODO: to be removed later
|
||||||
|
|||||||
@@ -51,8 +51,7 @@ void rsin_driver::error(const std::string &m)
|
|||||||
|
|
||||||
FormRSCTL *rsin_driver::getFormRSCTL(void)
|
FormRSCTL *rsin_driver::getFormRSCTL(void)
|
||||||
{
|
{
|
||||||
if (rsctlform == nullptr)
|
if (rsctlform == nullptr) {
|
||||||
{
|
|
||||||
FERROR("RSCTL formula was not supplied!");
|
FERROR("RSCTL formula was not supplied!");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -64,17 +63,17 @@ FormRSCTL *rsin_driver::getFormRSCTL(void)
|
|||||||
//
|
//
|
||||||
void rsin_driver::ensureOptionsAllowed(void)
|
void rsin_driver::ensureOptionsAllowed(void)
|
||||||
{
|
{
|
||||||
if (rs != nullptr)
|
if (rs != nullptr) {
|
||||||
{
|
|
||||||
FERROR("Options cannot be set/modified after the reaction system is initialised")
|
FERROR("Options cannot be set/modified after the reaction system is initialised")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void rsin_driver::ensureReactionSystemReady(void)
|
void rsin_driver::ensureReactionSystemReady(void)
|
||||||
{
|
{
|
||||||
if (rs == nullptr)
|
if (rs == nullptr) {
|
||||||
setupReactionSystem();
|
setupReactionSystem();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void rsin_driver::setupReactionSystem(void)
|
void rsin_driver::setupReactionSystem(void)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -41,13 +41,23 @@ public:
|
|||||||
std::string file;
|
std::string file;
|
||||||
bool trace_parsing;
|
bool trace_parsing;
|
||||||
|
|
||||||
void setOptions(Options *opts) { this->opts = opts; };
|
void setOptions(Options *opts)
|
||||||
void addFormRSCTL(FormRSCTL *f) { rsctlform = f; };
|
{
|
||||||
|
this->opts = opts;
|
||||||
|
};
|
||||||
|
void addFormRSCTL(FormRSCTL *f)
|
||||||
|
{
|
||||||
|
rsctlform = f;
|
||||||
|
};
|
||||||
FormRSCTL *getFormRSCTL(void);
|
FormRSCTL *getFormRSCTL(void);
|
||||||
|
|
||||||
void ensureOptionsAllowed(void);
|
void ensureOptionsAllowed(void);
|
||||||
void useContextAutomaton(void);
|
void useContextAutomaton(void);
|
||||||
void useConcentrations(void) { ensureOptionsAllowed(); use_concentrations = true; };
|
void useConcentrations(void)
|
||||||
|
{
|
||||||
|
ensureOptionsAllowed();
|
||||||
|
use_concentrations = true;
|
||||||
|
};
|
||||||
|
|
||||||
void ensureReactionSystemReady(void);
|
void ensureReactionSystemReady(void);
|
||||||
void setupReactionSystem(void);
|
void setupReactionSystem(void);
|
||||||
|
|||||||
246
symrs.cc
246
symrs.cc
@@ -32,10 +32,12 @@ BDD SymRS::encEntity_raw(Entity entity, bool succ) const
|
|||||||
{
|
{
|
||||||
BDD r;
|
BDD r;
|
||||||
|
|
||||||
if (succ)
|
if (succ) {
|
||||||
r = (*pv_succ)[entity];
|
r = (*pv_succ)[entity];
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
r = (*pv)[entity];
|
r = (*pv)[entity];
|
||||||
|
}
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
@@ -44,10 +46,13 @@ BDD SymRS::encEntitiesConj_raw(const Entities &entities, bool succ)
|
|||||||
{
|
{
|
||||||
BDD r = BDD_TRUE;
|
BDD r = BDD_TRUE;
|
||||||
|
|
||||||
for (const auto &entity : entities)
|
for (const auto &entity : entities) {
|
||||||
{
|
if (succ) {
|
||||||
if (succ) r *= encEntitySucc(entity);
|
r *= encEntitySucc(entity);
|
||||||
else r *= encEntity(entity);
|
}
|
||||||
|
else {
|
||||||
|
r *= encEntity(entity);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
@@ -57,10 +62,13 @@ BDD SymRS::encEntitiesDisj_raw(const Entities &entities, bool succ)
|
|||||||
{
|
{
|
||||||
BDD r = BDD_FALSE;
|
BDD r = BDD_FALSE;
|
||||||
|
|
||||||
for (const auto &entity : entities)
|
for (const auto &entity : entities) {
|
||||||
{
|
if (succ) {
|
||||||
if (succ) r += encEntitySucc(entity);
|
r += encEntitySucc(entity);
|
||||||
else r += encEntity(entity);
|
}
|
||||||
|
else {
|
||||||
|
r += encEntity(entity);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
@@ -70,14 +78,14 @@ BDD SymRS::encStateActEntitiesConj(const Entities &entities)
|
|||||||
{
|
{
|
||||||
BDD r = BDD_TRUE;
|
BDD r = BDD_TRUE;
|
||||||
|
|
||||||
for (const auto &entity : entities)
|
for (const auto &entity : entities) {
|
||||||
{
|
|
||||||
BDD state_act = encEntity(entity);
|
BDD state_act = encEntity(entity);
|
||||||
int actEntity;
|
int actEntity;
|
||||||
|
|
||||||
// if entity is also an action entity, we include it in the encoding
|
// 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);
|
state_act += encActEntity(actEntity);
|
||||||
|
}
|
||||||
|
|
||||||
r *= state_act;
|
r *= state_act;
|
||||||
}
|
}
|
||||||
@@ -89,14 +97,14 @@ BDD SymRS::encStateActEntitiesDisj(const Entities &entities)
|
|||||||
{
|
{
|
||||||
BDD r = BDD_FALSE;
|
BDD r = BDD_FALSE;
|
||||||
|
|
||||||
for (const auto &entity : entities)
|
for (const auto &entity : entities) {
|
||||||
{
|
|
||||||
BDD state_act = encEntity(entity);
|
BDD state_act = encEntity(entity);
|
||||||
int actEntity;
|
int actEntity;
|
||||||
|
|
||||||
// if entity is also an aciton entity, we include it in the encoding
|
// 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);
|
state_act += encActEntity(actEntity);
|
||||||
|
}
|
||||||
|
|
||||||
r += state_act;
|
r += state_act;
|
||||||
}
|
}
|
||||||
@@ -108,8 +116,7 @@ BDD SymRS::encActEntitiesConj(const Entities &entities)
|
|||||||
{
|
{
|
||||||
BDD r = BDD_TRUE;
|
BDD r = BDD_TRUE;
|
||||||
|
|
||||||
for (const auto &entity : entities)
|
for (const auto &entity : entities) {
|
||||||
{
|
|
||||||
Entity actEntity = getMappedStateToActID(entity);
|
Entity actEntity = getMappedStateToActID(entity);
|
||||||
r *= encActEntity(actEntity);
|
r *= encActEntity(actEntity);
|
||||||
}
|
}
|
||||||
@@ -121,11 +128,11 @@ BDD SymRS::compState(const BDD &state) const
|
|||||||
{
|
{
|
||||||
BDD s = state;
|
BDD s = state;
|
||||||
|
|
||||||
for (unsigned int i = 0; i < totalRctSysStateVars; ++i)
|
for (unsigned int i = 0; i < totalRctSysStateVars; ++i) {
|
||||||
{
|
if (!(*pv)[i] * state != cuddMgr->bddZero()) {
|
||||||
if (!(*pv)[i] * state != cuddMgr->bddZero())
|
|
||||||
s *= !(*pv)[i];
|
s *= !(*pv)[i];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
@@ -134,11 +141,11 @@ BDD SymRS::compContext(const BDD &context) const
|
|||||||
{
|
{
|
||||||
BDD c = context;
|
BDD c = context;
|
||||||
|
|
||||||
for (unsigned int i = 0; i < totalActions; ++i)
|
for (unsigned int i = 0; i < totalActions; ++i) {
|
||||||
{
|
if (!(*pv_act)[i] * context != cuddMgr->bddZero()) {
|
||||||
if (!(*pv_act)[i] * context != cuddMgr->bddZero())
|
|
||||||
c *= !(*pv_act)[i];
|
c *= !(*pv_act)[i];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
@@ -146,13 +153,13 @@ BDD SymRS::compContext(const BDD &context) const
|
|||||||
std::string SymRS::decodedRctSysStateToStr(const BDD &state)
|
std::string SymRS::decodedRctSysStateToStr(const BDD &state)
|
||||||
{
|
{
|
||||||
std::string s = "{ ";
|
std::string s = "{ ";
|
||||||
for (unsigned int i = 0; i < totalRctSysStateVars; ++i)
|
|
||||||
{
|
for (unsigned int i = 0; i < totalRctSysStateVars; ++i) {
|
||||||
if (!(encEntity(i) * state).IsZero())
|
if (!(encEntity(i) * state).IsZero()) {
|
||||||
{
|
|
||||||
s += rs->entityToStr(i) + " ";
|
s += rs->entityToStr(i) + " ";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
s += "}";
|
s += "}";
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
@@ -160,14 +167,16 @@ std::string SymRS::decodedRctSysStateToStr(const BDD &state)
|
|||||||
void SymRS::printDecodedRctSysStates(const BDD &states)
|
void SymRS::printDecodedRctSysStates(const BDD &states)
|
||||||
{
|
{
|
||||||
BDD unproc = states;
|
BDD unproc = states;
|
||||||
while (!unproc.IsZero())
|
|
||||||
{
|
while (!unproc.IsZero()) {
|
||||||
BDD t = unproc.PickOneMinterm(*pv_rs);
|
BDD t = unproc.PickOneMinterm(*pv_rs);
|
||||||
cout << decodedRctSysStateToStr(t) << endl;
|
cout << decodedRctSysStateToStr(t) << endl;
|
||||||
|
|
||||||
if (opts->verbose > 9) {
|
if (opts->verbose > 9) {
|
||||||
t.PrintMinterm();
|
t.PrintMinterm();
|
||||||
cout << endl;
|
cout << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
unproc -= t;
|
unproc -= t;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -198,8 +207,7 @@ void SymRS::initBDDvars(void)
|
|||||||
pv_rs_E = new BDD(BDD_TRUE);
|
pv_rs_E = new BDD(BDD_TRUE);
|
||||||
pv_rs_succ_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)[i] = cuddMgr->bddVar(bdd_var_idx++);
|
||||||
(*pv_rs_succ)[i] = cuddMgr->bddVar(bdd_var_idx++);
|
(*pv_rs_succ)[i] = cuddMgr->bddVar(bdd_var_idx++);
|
||||||
*pv_rs_E *= (*pv_rs)[i];
|
*pv_rs_E *= (*pv_rs)[i];
|
||||||
@@ -211,8 +219,7 @@ void SymRS::initBDDvars(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// CA
|
// CA
|
||||||
if (usingContextAutomaton())
|
if (usingContextAutomaton()) {
|
||||||
{
|
|
||||||
VERB("Context automaton variables");
|
VERB("Context automaton variables");
|
||||||
|
|
||||||
pv_ca = new vector<BDD>(totalCtxAutStateVars);
|
pv_ca = new vector<BDD>(totalCtxAutStateVars);
|
||||||
@@ -220,8 +227,7 @@ void SymRS::initBDDvars(void)
|
|||||||
pv_ca_E = new BDD(BDD_TRUE);
|
pv_ca_E = new BDD(BDD_TRUE);
|
||||||
pv_ca_succ_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)[i] = cuddMgr->bddVar(bdd_var_idx++);
|
||||||
(*pv_ca_succ)[i] = cuddMgr->bddVar(bdd_var_idx++);
|
(*pv_ca_succ)[i] = cuddMgr->bddVar(bdd_var_idx++);
|
||||||
*pv_ca_E *= (*pv_ca)[i];
|
*pv_ca_E *= (*pv_ca)[i];
|
||||||
@@ -237,8 +243,7 @@ void SymRS::initBDDvars(void)
|
|||||||
pv_act = new vector<BDD>(totalActions);
|
pv_act = new vector<BDD>(totalActions);
|
||||||
pv_act_E = new BDD(BDD_TRUE);
|
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)[i] = cuddMgr->bddVar(bdd_var_idx++);
|
||||||
*pv_act_E *= (*pv_act)[i];
|
*pv_act_E *= (*pv_act)[i];
|
||||||
}
|
}
|
||||||
@@ -248,8 +253,7 @@ void SymRS::initBDDvars(void)
|
|||||||
*pv_E = *pv_rs_E;
|
*pv_E = *pv_rs_E;
|
||||||
*pv_succ_E = *pv_rs_succ_E;
|
*pv_succ_E = *pv_rs_succ_E;
|
||||||
|
|
||||||
if (usingContextAutomaton())
|
if (usingContextAutomaton()) {
|
||||||
{
|
|
||||||
*pv_E *= *pv_ca_E;
|
*pv_E *= *pv_ca_E;
|
||||||
*pv_succ_E *= *pv_ca_succ_E;
|
*pv_succ_E *= *pv_ca_succ_E;
|
||||||
}
|
}
|
||||||
@@ -262,73 +266,66 @@ void SymRS::encodeTransitions(void)
|
|||||||
DecompReactions dr;
|
DecompReactions dr;
|
||||||
|
|
||||||
VERB("Decomposing reactions");
|
VERB("Decomposing reactions");
|
||||||
for (unsigned int i = 0; i < totalReactions; ++i)
|
|
||||||
{
|
for (unsigned int i = 0; i < totalReactions; ++i) {
|
||||||
ReactionCond cond;
|
ReactionCond cond;
|
||||||
cond.rctt = rs->reactions[i].rctt;
|
cond.rctt = rs->reactions[i].rctt;
|
||||||
cond.inhib = rs->reactions[i].inhib;
|
cond.inhib = rs->reactions[i].inhib;
|
||||||
|
|
||||||
for (Entities::iterator p = rs->reactions[i].prod.begin();
|
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);
|
dr[*p].push_back(cond);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
VERB("Encoding reactions");
|
VERB("Encoding reactions");
|
||||||
|
|
||||||
if (opts->part_tr_rel)
|
if (opts->part_tr_rel) {
|
||||||
{
|
|
||||||
VERB("Using partitioned transition relation encoding");
|
VERB("Using partitioned transition relation encoding");
|
||||||
partTrans = new vector<BDD>(totalRctSysStateVars);
|
partTrans = new vector<BDD>(totalRctSysStateVars);
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
VERB("Using monolithic transition relation encoding");
|
VERB("Using monolithic transition relation encoding");
|
||||||
monoTrans = new BDD(BDD_TRUE);
|
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);
|
VERB_L3("Encoding for successor " << p);
|
||||||
|
|
||||||
DecompReactions::iterator di;
|
DecompReactions::iterator di;
|
||||||
|
|
||||||
if ((di = dr.find(p)) == dr.end())
|
if ((di = dr.find(p)) == dr.end()) {
|
||||||
{
|
|
||||||
// there is no reaction producing p:
|
// there is no reaction producing p:
|
||||||
if (opts->part_tr_rel)
|
if (opts->part_tr_rel) {
|
||||||
(*partTrans)[p] = !encEntitySucc(p);
|
(*partTrans)[p] = !encEntitySucc(p);
|
||||||
else
|
}
|
||||||
{
|
else {
|
||||||
*monoTrans *= !encEntitySucc(p);
|
*monoTrans *= !encEntitySucc(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
// di - reactions producing p
|
// di - reactions producing p
|
||||||
|
|
||||||
BDD conditions = BDD_FALSE;
|
BDD conditions = BDD_FALSE;
|
||||||
|
|
||||||
assert(di->second.size() > 0);
|
assert(di->second.size() > 0);
|
||||||
|
|
||||||
for (unsigned int j = 0; j < di->second.size(); ++j)
|
for (unsigned int j = 0; j < di->second.size(); ++j) {
|
||||||
{
|
conditions += encStateActEntitiesConj(di->second[j].rctt) *
|
||||||
conditions += encStateActEntitiesConj(di->second[j].rctt) * !encStateActEntitiesDisj(di->second[j].inhib);
|
!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);
|
||||||
(*partTrans)[p] += !conditions * !encEntitySucc(p);
|
(*partTrans)[p] += !conditions * !encEntitySucc(p);
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
*monoTrans *= (conditions * encEntitySucc(p)) + (!conditions * !encEntitySucc(
|
||||||
*monoTrans *= (conditions * encEntitySucc(p)) + (!conditions * !encEntitySucc(p));
|
p));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (opts->reorder_trans)
|
|
||||||
{
|
if (opts->reorder_trans) {
|
||||||
VERB_L2("Reordering");
|
VERB_L2("Reordering");
|
||||||
Cudd_ReduceHeap(cuddMgr->getManager(), CUDD_REORDER_SIFT, 10000);
|
Cudd_ReduceHeap(cuddMgr->getManager(), CUDD_REORDER_SIFT, 10000);
|
||||||
}
|
}
|
||||||
@@ -337,15 +334,13 @@ void SymRS::encodeTransitions(void)
|
|||||||
|
|
||||||
VERB("Reactions ready");
|
VERB("Reactions ready");
|
||||||
|
|
||||||
if (usingContextAutomaton())
|
if (usingContextAutomaton()) {
|
||||||
{
|
|
||||||
VERB("Augmenting transition relation encoding with the transition relation for context automaton");
|
VERB("Augmenting transition relation encoding with the transition relation for context automaton");
|
||||||
if (opts->part_tr_rel)
|
|
||||||
{
|
if (opts->part_tr_rel) {
|
||||||
assert(0);
|
assert(0);
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
assert(tr_ca != nullptr);
|
assert(tr_ca != nullptr);
|
||||||
*monoTrans *= *tr_ca;
|
*monoTrans *= *tr_ca;
|
||||||
}
|
}
|
||||||
@@ -369,8 +364,7 @@ BDD SymRS::encNoContext(void)
|
|||||||
{
|
{
|
||||||
BDD noContextBDD = BDD_TRUE;
|
BDD noContextBDD = BDD_TRUE;
|
||||||
|
|
||||||
for (unsigned int i = 0; i < totalActions; ++i)
|
for (unsigned int i = 0; i < totalActions; ++i) {
|
||||||
{
|
|
||||||
noContextBDD *= !(*pv_act)[i];
|
noContextBDD *= !(*pv_act)[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -379,16 +373,15 @@ BDD SymRS::encNoContext(void)
|
|||||||
|
|
||||||
void SymRS::encodeInitStates(void)
|
void SymRS::encodeInitStates(void)
|
||||||
{
|
{
|
||||||
if (usingContextAutomaton())
|
if (usingContextAutomaton()) {
|
||||||
{
|
|
||||||
VERB("Encoding initial states (using context automaton)");
|
VERB("Encoding initial states (using context automaton)");
|
||||||
encodeInitStatesForCtxAut();
|
encodeInitStatesForCtxAut();
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
VERB("Encoding initial states (for the action entities method -- no CA)");
|
VERB("Encoding initial states (for the action entities method -- no CA)");
|
||||||
encodeInitStatesNoCtxAut();
|
encodeInitStatesNoCtxAut();
|
||||||
}
|
}
|
||||||
|
|
||||||
VERB("Initial states encoded");
|
VERB("Initial states encoded");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -396,8 +389,7 @@ void SymRS::encodeInitStatesForCtxAut(void)
|
|||||||
{
|
{
|
||||||
initStates = new BDD(BDD_TRUE);
|
initStates = new BDD(BDD_TRUE);
|
||||||
|
|
||||||
for (unsigned int i = 0; i < totalRctSysStateVars; ++i)
|
for (unsigned int i = 0; i < totalRctSysStateVars; ++i) {
|
||||||
{
|
|
||||||
*initStates *= !(*pv)[i];
|
*initStates *= !(*pv)[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -407,28 +399,28 @@ void SymRS::encodeInitStatesForCtxAut(void)
|
|||||||
void SymRS::encodeInitStatesNoCtxAut(void)
|
void SymRS::encodeInitStatesNoCtxAut(void)
|
||||||
{
|
{
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
if (opts->part_tr_rel)
|
|
||||||
|
if (opts->part_tr_rel) {
|
||||||
assert(partTrans != nullptr);
|
assert(partTrans != nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
initStates = new BDD(BDD_FALSE);
|
initStates = new BDD(BDD_FALSE);
|
||||||
|
|
||||||
for (auto state = rs->initStates.begin();
|
for (auto state = rs->initStates.begin();
|
||||||
state != rs->initStates.end();
|
state != rs->initStates.end();
|
||||||
++state)
|
++state) {
|
||||||
{
|
|
||||||
VERB("Encoding a single inital state");
|
VERB("Encoding a single inital state");
|
||||||
BDD newInitState = compState(encEntitiesConj(*state));
|
BDD newInitState = compState(encEntitiesConj(*state));
|
||||||
BDD q = BDD_TRUE;
|
BDD q = BDD_TRUE;
|
||||||
if (opts->part_tr_rel)
|
|
||||||
{
|
if (opts->part_tr_rel) {
|
||||||
for (unsigned int i = 0; i < partTrans->size(); ++i)
|
for (unsigned int i = 0; i < partTrans->size(); ++i) {
|
||||||
{
|
|
||||||
q *= newInitState * (*partTrans)[i] * encNoContext();
|
q *= newInitState * (*partTrans)[i] * encNoContext();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
q *= newInitState * *monoTrans * encNoContext();
|
q *= newInitState * *monoTrans * encNoContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -443,22 +435,22 @@ void SymRS::mapStateToAct(void)
|
|||||||
{
|
{
|
||||||
VERB("Mapping state variables to action variables");
|
VERB("Mapping state variables to action variables");
|
||||||
unsigned int j = 0;
|
unsigned int j = 0;
|
||||||
for (unsigned int i = 0; i < totalRctSysStateVars; ++i)
|
|
||||||
{
|
for (unsigned int i = 0; i < totalRctSysStateVars; ++i) {
|
||||||
if (rs->isActionEntity(i)) {
|
if (rs->isActionEntity(i)) {
|
||||||
stateToAct.push_back(j++);
|
stateToAct.push_back(j++);
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
stateToAct.push_back(-1);
|
stateToAct.push_back(-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const unsigned int verbosity_level = 9;
|
const unsigned int verbosity_level = 9;
|
||||||
if (opts->verbose > verbosity_level)
|
|
||||||
{
|
if (opts->verbose > verbosity_level) {
|
||||||
for (unsigned int i = 0; i < stateToAct.size(); ++i)
|
for (unsigned int i = 0; i < stateToAct.size(); ++i) {
|
||||||
{
|
cout << "ii VERBOSE(" << verbosity_level << "): stateToAct[" << i << "] = " <<
|
||||||
cout << "ii VERBOSE(" << verbosity_level << "): stateToAct[" << i << "] = " << stateToAct[i] << endl;
|
stateToAct[i] << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -467,8 +459,7 @@ void SymRS::encode(void)
|
|||||||
{
|
{
|
||||||
VERB("Encoding...");
|
VERB("Encoding...");
|
||||||
|
|
||||||
if (opts->measure)
|
if (opts->measure) {
|
||||||
{
|
|
||||||
opts->enc_time = cpuTime();
|
opts->enc_time = cpuTime();
|
||||||
opts->enc_mem = memUsed();
|
opts->enc_mem = memUsed();
|
||||||
}
|
}
|
||||||
@@ -477,20 +468,17 @@ void SymRS::encode(void)
|
|||||||
|
|
||||||
initBDDvars();
|
initBDDvars();
|
||||||
|
|
||||||
if (usingContextAutomaton())
|
if (usingContextAutomaton()) {
|
||||||
{
|
|
||||||
encodeCtxAutTrans();
|
encodeCtxAutTrans();
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
VERB_LN(3, "Not using context automata, not encoding TR for CA")
|
VERB_LN(3, "Not using context automata, not encoding TR for CA")
|
||||||
}
|
}
|
||||||
|
|
||||||
encodeTransitions();
|
encodeTransitions();
|
||||||
encodeInitStates();
|
encodeInitStates();
|
||||||
|
|
||||||
if (opts->measure)
|
if (opts->measure) {
|
||||||
{
|
|
||||||
opts->enc_time = cpuTime() - opts->enc_time;
|
opts->enc_time = cpuTime() - opts->enc_time;
|
||||||
opts->enc_mem = memUsed() - opts->enc_mem;
|
opts->enc_mem = memUsed() - opts->enc_mem;
|
||||||
}
|
}
|
||||||
@@ -501,26 +489,29 @@ void SymRS::encode(void)
|
|||||||
BDD SymRS::encActStrEntity(std::string name) const
|
BDD SymRS::encActStrEntity(std::string name) const
|
||||||
{
|
{
|
||||||
int id = getMappedStateToActID(rs->getEntityID(name));
|
int id = getMappedStateToActID(rs->getEntityID(name));
|
||||||
if (id < 0)
|
|
||||||
{
|
if (id < 0) {
|
||||||
FERROR("Entity \"" << name << "\" not defined as context entity");
|
FERROR("Entity \"" << name << "\" not defined as context entity");
|
||||||
return BDD_FALSE;
|
return BDD_FALSE;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
return encActEntity(getMappedStateToActID(rs->getEntityID(name)));
|
return encActEntity(getMappedStateToActID(rs->getEntityID(name)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t SymRS::getCtxAutStateEncodingSize(void)
|
size_t SymRS::getCtxAutStateEncodingSize(void)
|
||||||
{
|
{
|
||||||
if (!usingContextAutomaton()) return 0;
|
if (!usingContextAutomaton()) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
assert(rs->ctx_aut != nullptr);
|
assert(rs->ctx_aut != nullptr);
|
||||||
|
|
||||||
size_t bitCount = 0;
|
size_t bitCount = 0;
|
||||||
size_t bitCountMaxVal = 1;
|
size_t bitCountMaxVal = 1;
|
||||||
size_t numStates = rs->ctx_aut->statesCount();
|
size_t numStates = rs->ctx_aut->statesCount();
|
||||||
while (bitCountMaxVal <= numStates)
|
|
||||||
{
|
while (bitCountMaxVal <= numStates) {
|
||||||
bitCount++;
|
bitCount++;
|
||||||
bitCountMaxVal *= 2;
|
bitCountMaxVal *= 2;
|
||||||
}
|
}
|
||||||
@@ -533,33 +524,34 @@ BDD SymRS::encCtxAutState_raw(State state_id, bool succ) const
|
|||||||
{
|
{
|
||||||
// select appropriate BDD vector
|
// select appropriate BDD vector
|
||||||
vector<BDD> *enc_vec;
|
vector<BDD> *enc_vec;
|
||||||
if (succ)
|
|
||||||
|
if (succ) {
|
||||||
enc_vec = pv_ca_succ;
|
enc_vec = pv_ca_succ;
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
enc_vec = pv_ca;
|
enc_vec = pv_ca;
|
||||||
|
}
|
||||||
|
|
||||||
assert(enc_vec != nullptr);
|
assert(enc_vec != nullptr);
|
||||||
|
|
||||||
BDD r = BDD_TRUE;
|
BDD r = BDD_TRUE;
|
||||||
State val = state_id;
|
State val = state_id;
|
||||||
|
|
||||||
for (unsigned int i = 0; i < totalCtxAutStateVars; ++i)
|
for (unsigned int i = 0; i < totalCtxAutStateVars; ++i) {
|
||||||
{
|
if (val != 0) {
|
||||||
if (val != 0)
|
if (val % 2 == 1) {
|
||||||
{
|
|
||||||
if (val % 2 == 1)
|
|
||||||
{
|
|
||||||
r *= (*enc_vec)[i];
|
r *= (*enc_vec)[i];
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
r *= !(*enc_vec)[i];
|
r *= !(*enc_vec)[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
val /= 2;
|
val /= 2;
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
r *= !(*enc_vec)[i];
|
r *= !(*enc_vec)[i];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
@@ -577,16 +569,14 @@ void SymRS::encodeCtxAutTrans(void)
|
|||||||
{
|
{
|
||||||
VERB_LN(2, "Encoding context automaton's transition relation");
|
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")
|
VERB_LN(1, "Encoding for context automaton already present, not replacing")
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
tr_ca = new BDD(BDD_FALSE);
|
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)
|
VERB_LN(2, "Encoding CA transition " << rs->ctx_aut->getStateName(t.src_state)
|
||||||
<< " -> " << rs->ctx_aut->getStateName(t.dst_state));
|
<< " -> " << rs->ctx_aut->getStateName(t.dst_state));
|
||||||
BDD enc_src = encCtxAutState(t.src_state);
|
BDD enc_src = encCtxAutState(t.src_state);
|
||||||
|
|||||||
129
symrs.hh
129
symrs.hh
@@ -72,28 +72,35 @@ class SymRS
|
|||||||
unsigned int totalCtxAutStateVars;
|
unsigned int totalCtxAutStateVars;
|
||||||
|
|
||||||
BDD encEntity_raw(Entity entity, bool succ) const;
|
BDD encEntity_raw(Entity entity, bool succ) const;
|
||||||
BDD encEntity(Entity entity) const {
|
BDD encEntity(Entity entity) const
|
||||||
|
{
|
||||||
return encEntity_raw(entity, false);
|
return encEntity_raw(entity, false);
|
||||||
}
|
}
|
||||||
BDD encActEntity(Entity entity) const {
|
BDD encActEntity(Entity entity) const
|
||||||
|
{
|
||||||
assert(entity < pv_act->size());
|
assert(entity < pv_act->size());
|
||||||
return (*pv_act)[entity];
|
return (*pv_act)[entity];
|
||||||
}
|
}
|
||||||
BDD encEntitySucc(Entity entity) const {
|
BDD encEntitySucc(Entity entity) const
|
||||||
|
{
|
||||||
return encEntity_raw(entity, true);
|
return encEntity_raw(entity, true);
|
||||||
}
|
}
|
||||||
BDD encEntitiesConj_raw(const Entities &entities, bool succ);
|
BDD encEntitiesConj_raw(const Entities &entities, bool succ);
|
||||||
BDD encEntitiesConj(const Entities &entities) {
|
BDD encEntitiesConj(const Entities &entities)
|
||||||
|
{
|
||||||
return encEntitiesConj_raw(entities, false);
|
return encEntitiesConj_raw(entities, false);
|
||||||
}
|
}
|
||||||
BDD encEntitiesConjSucc(const Entities &entities) {
|
BDD encEntitiesConjSucc(const Entities &entities)
|
||||||
|
{
|
||||||
return encEntitiesConj_raw(entities, true);
|
return encEntitiesConj_raw(entities, true);
|
||||||
}
|
}
|
||||||
BDD encEntitiesDisj_raw(const Entities &entities, bool succ);
|
BDD encEntitiesDisj_raw(const Entities &entities, bool succ);
|
||||||
BDD encEntitiesDisj(const Entities &entities) {
|
BDD encEntitiesDisj(const Entities &entities)
|
||||||
|
{
|
||||||
return encEntitiesDisj_raw(entities, false);
|
return encEntitiesDisj_raw(entities, false);
|
||||||
}
|
}
|
||||||
BDD encEntitiesDisjSucc(const Entities &entities) {
|
BDD encEntitiesDisjSucc(const Entities &entities)
|
||||||
|
{
|
||||||
return encEntitiesDisj_raw(entities, true);
|
return encEntitiesDisj_raw(entities, true);
|
||||||
}
|
}
|
||||||
BDD encStateActEntitiesConj(const Entities &entities);
|
BDD encStateActEntitiesConj(const Entities &entities);
|
||||||
@@ -135,32 +142,75 @@ class SymRS
|
|||||||
public:
|
public:
|
||||||
SymRS(RctSys *rs, Options *opts);
|
SymRS(RctSys *rs, Options *opts);
|
||||||
|
|
||||||
vector<BDD> *getEncPV(void) { return pv; }
|
vector<BDD> *getEncPV(void)
|
||||||
vector<BDD> *getEncPVsucc(void) { return pv_succ; }
|
{
|
||||||
BDD *getEncPV_E(void) { return pv_E; }
|
return pv;
|
||||||
BDD *getEncPVsucc_E(void) { return pv_succ_E; }
|
}
|
||||||
BDD *getEncPVact_E(void) { return pv_act_E; }
|
vector<BDD> *getEncPVsucc(void)
|
||||||
vector<BDD> *getEncPartTrans(void) { return partTrans; }
|
{
|
||||||
BDD *getEncMonoTrans(void) { return monoTrans; }
|
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 getEncState(const Entities &entities);
|
||||||
BDD *getEncInitStates(void) { return initStates; }
|
BDD *getEncInitStates(void)
|
||||||
Cudd *getCuddMgr(void) { return cuddMgr; }
|
{
|
||||||
unsigned int getTotalStateVars(void) { return totalStateVars; }
|
return initStates;
|
||||||
unsigned int getTotalRctSysStateVars(void) { return totalRctSysStateVars; }
|
}
|
||||||
BDD encEntity(std::string name) const {
|
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));
|
return encEntity(rs->getEntityID(name));
|
||||||
}
|
}
|
||||||
|
|
||||||
BDD encActStrEntity(std::string name) const;
|
BDD encActStrEntity(std::string name) const;
|
||||||
BDD getBDDtrue(void) const { return BDD_TRUE; }
|
BDD getBDDtrue(void) const
|
||||||
BDD getBDDfalse(void) const { return BDD_FALSE; }
|
{
|
||||||
|
return BDD_TRUE;
|
||||||
|
}
|
||||||
|
BDD getBDDfalse(void) const
|
||||||
|
{
|
||||||
|
return BDD_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Checks if context automaton is used
|
* @brief Checks if context automaton is used
|
||||||
*
|
*
|
||||||
* @return True if CA 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
|
* @brief Encodes a context automaton's state
|
||||||
@@ -174,14 +224,20 @@ public:
|
|||||||
*
|
*
|
||||||
* @return Returns the encoded state
|
* @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)
|
* @brief Encodes a context automaton's state (as successor/primed)
|
||||||
*
|
*
|
||||||
* @return Returns the encoded state
|
* @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
|
* @brief Encodes the initial state of context automaton
|
||||||
@@ -195,28 +251,40 @@ public:
|
|||||||
*
|
*
|
||||||
* @return Returns a vector of BDDs
|
* @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
|
* @brief Getter for context automaton's successor (primed) state variables
|
||||||
*
|
*
|
||||||
* @return Returns a vector of BDDs
|
* @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)
|
* @brief Getter for context automaton's quantification BDD (for non-primed vars)
|
||||||
*
|
*
|
||||||
* @return Returns a BDD for quantification
|
* @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)
|
* @brief Getter for context automaton's quantification BDD (for primed vars)
|
||||||
*
|
*
|
||||||
* @return Returns a BDD for quantification
|
* @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
|
* @brief Encodes the monolithic transition relation
|
||||||
@@ -228,7 +296,10 @@ public:
|
|||||||
*
|
*
|
||||||
* @return Returns a BDD encoding the transition relation
|
* @return Returns a BDD encoding the transition relation
|
||||||
*/
|
*/
|
||||||
BDD *getEncCtxAutTrans(void) { return tr_ca; }
|
BDD *getEncCtxAutTrans(void)
|
||||||
|
{
|
||||||
|
return tr_ca;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user