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);
if (reach_states)
mc.printReach();
{
mc.printReach();
}
if (reach_states_succ)
mc.printReachWithSucc();
{
mc.printReachWithSucc();
}
if (rstl_model_checking)
{

13
mc.cc
View File

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

View File

@@ -13,15 +13,16 @@ SymRS::SymRS(RctSys *rs, Options *opts)
totalStateVars = rs->getEntitiesSize();
totalReactions = rs->getReactionsSize();
totalActions = rs->getActionsSize();
totalCtxAutStateVars = getCtxAutStateEncodingSize();
partTrans = nullptr;
monoTrans = nullptr;
pv_ca = nullptr;
pv_ca_succ = nullptr;
encode();
encode();
}
BDD SymRS::encEntity_raw(Entity entity, bool succ) const
@@ -200,28 +201,31 @@ void SymRS::initBDDvars(void)
*pv_act_E *= (*pv_act)[i];
}
offset += totalActions;
VERB("Context automaton variables");
pv_ca = new vector<BDD>(totalCtxAutStateVars);
pv_ca_succ = new vector<BDD>(totalCtxAutStateVars);
pv_ca_E = new BDD(BDD_TRUE);
pv_ca_succ_E = new BDD(BDD_TRUE);
//
// BDD variables for encoding local states of context automaton
//
unsigned int base_index = offset;
for (unsigned int i = 0; i < totalCtxAutStateVars; ++i)
if (usingContextAutomaton())
{
(*pv_ca)[i] = cuddMgr->bddVar(base_index);
(*pv_ca_succ)[i] = cuddMgr->bddVar(base_index+1);
VERB("Context automaton variables");
offset += totalActions;
pv_ca = new vector<BDD>(totalCtxAutStateVars);
pv_ca_succ = new vector<BDD>(totalCtxAutStateVars);
pv_ca_E = new BDD(BDD_TRUE);
pv_ca_succ_E = new BDD(BDD_TRUE);
*pv_ca_E *= (*pv_ca)[i];
*pv_ca_succ_E *= (*pv_ca_succ)[i];
base_index += 2;
//
// BDD variables for encoding local states of context automaton
//
unsigned int base_index = offset;
for (unsigned int i = 0; i < totalCtxAutStateVars; ++i)
{
(*pv_ca)[i] = cuddMgr->bddVar(base_index);
(*pv_ca_succ)[i] = cuddMgr->bddVar(base_index+1);
*pv_ca_E *= (*pv_ca)[i];
*pv_ca_succ_E *= (*pv_ca_succ)[i];
base_index += 2;
}
}
VERB("All BDD variables ready");
@@ -433,6 +437,10 @@ BDD SymRS::encActStrEntity(std::string name) const
size_t SymRS::getCtxAutStateEncodingSize(void)
{
if (!usingContextAutomaton()) return 0;
assert(rs->ctx_aut != nullptr);
size_t bitCount = 0;
size_t bitCountMaxVal = 1;
size_t numStates = rs->ctx_aut->statesCount();

View File

@@ -65,7 +65,6 @@ class SymRS
unsigned int totalActions;
unsigned int totalCtxAutStateVars;
BDD encEntity_raw(Entity entity, bool succ) const;
BDD encEntity(Entity entity) const {
return encEntity_raw(entity, false);