This commit is contained in:
Artur Meski
2018-03-26 22:05:23 +01:00
parent 76ab891786
commit 03cbf26afa
4 changed files with 45 additions and 29 deletions

View File

@@ -186,9 +186,13 @@ int main(int argc, char **argv)
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)
{ {

13
mc.cc
View File

@@ -7,7 +7,7 @@ ModelChecker::ModelChecker(SymRS *srs, Options *opts)
cuddMgr = srs->getCuddMgr(); cuddMgr = srs->getCuddMgr();
if (srs->usingContextAutomaton()) if (!srs->usingContextAutomaton())
initStates = srs->getEncInitStates(); initStates = srs->getEncInitStates();
totalStateVars = srs->getTotalStateVars(); totalStateVars = srs->getTotalStateVars();
@@ -107,11 +107,15 @@ inline BDD ModelChecker::getPreEctx(const BDD &states, const BDD *contexts)
void ModelChecker::printReach(void) void ModelChecker::printReach(void)
{ {
VERB_LN(2, "Printing/generating reachable states");
if (opts->measure) if (opts->measure)
opts->ver_time = cpuTime(); opts->ver_time = cpuTime();
assert(initStates != nullptr);
BDD *reach = new BDD(*initStates); BDD *reach = new BDD(*initStates);
BDD reach_p = cuddMgr->bddZero(); BDD reach_p = BDD_FALSE;
unsigned int k = 0; unsigned int k = 0;
@@ -138,12 +142,13 @@ void ModelChecker::printReach(void)
void ModelChecker::printReachWithSucc(void) void ModelChecker::printReachWithSucc(void)
{ {
VERB_LN(2, "Printing/generating reachable states (with successors)");
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)
{ {
//cout << "==[ " << ++k << " ]===========================" << endl;
reach_p = *reach; reach_p = *reach;
BDD newStates = getSucc(*reach) - *reach; BDD newStates = getSucc(*reach) - *reach;
*reach += newStates; *reach += newStates;
@@ -530,7 +535,7 @@ bool ModelChecker::checkRSCTLbmc(FormRSCTL *form)
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)
{ {

View File

@@ -13,6 +13,7 @@ SymRS::SymRS(RctSys *rs, Options *opts)
totalStateVars = rs->getEntitiesSize(); totalStateVars = rs->getEntitiesSize();
totalReactions = rs->getReactionsSize(); totalReactions = rs->getReactionsSize();
totalActions = rs->getActionsSize(); totalActions = rs->getActionsSize();
totalCtxAutStateVars = getCtxAutStateEncodingSize(); totalCtxAutStateVars = getCtxAutStateEncodingSize();
partTrans = nullptr; partTrans = nullptr;
@@ -200,10 +201,12 @@ void SymRS::initBDDvars(void)
*pv_act_E *= (*pv_act)[i]; *pv_act_E *= (*pv_act)[i];
} }
offset += totalActions; if (usingContextAutomaton())
{
VERB("Context automaton variables"); VERB("Context automaton variables");
offset += totalActions;
pv_ca = new vector<BDD>(totalCtxAutStateVars); pv_ca = new vector<BDD>(totalCtxAutStateVars);
pv_ca_succ = new vector<BDD>(totalCtxAutStateVars); pv_ca_succ = new vector<BDD>(totalCtxAutStateVars);
pv_ca_E = new BDD(BDD_TRUE); pv_ca_E = new BDD(BDD_TRUE);
@@ -223,6 +226,7 @@ void SymRS::initBDDvars(void)
base_index += 2; base_index += 2;
} }
}
VERB("All BDD variables ready"); VERB("All BDD variables ready");
} }
@@ -433,6 +437,10 @@ BDD SymRS::encActStrEntity(std::string name) const
size_t SymRS::getCtxAutStateEncodingSize(void) size_t SymRS::getCtxAutStateEncodingSize(void)
{ {
if (!usingContextAutomaton()) return 0;
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();

View File

@@ -65,7 +65,6 @@ class SymRS
unsigned int totalActions; unsigned int totalActions;
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);