From 1f01dce3cc02aadf9ac04f49b336624f083d2608 Mon Sep 17 00:00:00 2001 From: Artur Meski Date: Mon, 26 Mar 2018 22:29:11 +0100 Subject: [PATCH] Formatting, initial state encoding --- mc.cc | 5 ++-- mc.hh | 6 ++-- symrs.cc | 37 +++++++++++++++++++------ symrs.hh | 84 +++++++++++++++++++++++++++++--------------------------- 4 files changed, 77 insertions(+), 55 deletions(-) diff --git a/mc.cc b/mc.cc index bcf74b0..081daeb 100644 --- a/mc.cc +++ b/mc.cc @@ -7,8 +7,7 @@ ModelChecker::ModelChecker(SymRS *srs, Options *opts) cuddMgr = srs->getCuddMgr(); - if (!srs->usingContextAutomaton()) - initStates = srs->getEncInitStates(); + initStates = srs->getEncInitStates(); totalStateVars = srs->getTotalStateVars(); @@ -35,7 +34,7 @@ ModelChecker::ModelChecker(SymRS *srs, Options *opts) if (srs->usingContextAutomaton()) { - ca_init_state = srs->getEncCtxAutInitState(); + // ca_init_state = srs->getEncCtxAutInitState(); pv_ca = srs->getEncCtxAutPV(); pv_ca_succ = srs->getEncCtxAutPVsucc(); ca_tr = srs->getEncCtxAutTrans(); diff --git a/mc.hh b/mc.hh index a09c68e..04868a0 100644 --- a/mc.hh +++ b/mc.hh @@ -31,11 +31,11 @@ class ModelChecker BDD *trm; // Context Automaton - BDD *ca_init_state; vector *pv_ca; vector *pv_ca_succ; - BDD *ca_tr; - + // BDD *ca_tr; + // BDD *ca_init_state; + unsigned int trp_size; unsigned int totalStateVars; diff --git a/symrs.cc b/symrs.cc index 268d2c6..a58ac66 100644 --- a/symrs.cc +++ b/symrs.cc @@ -337,8 +337,33 @@ BDD SymRS::encNoContext(void) void SymRS::encodeInitStates(void) { - VERB("Encoding initial states"); + if (usingContextAutomaton()) + { + VERB("Encoding initial states (using context automaton)"); + encodeInitStatesForCtxAut(); + } + else + { + VERB("Encoding initial states (for the action entities method -- no CA)"); + encodeInitStatesNoCtxAut(); + } + VERB("Initial states encoded"); +} +void SymRS::encodeInitStatesForCtxAut(void) +{ + initStates = new BDD(BDD_TRUE); + + for (unsigned int i = 0; i < totalStateVars; ++i) + { + *initStates *= !(*pv)[i]; + } + + *initStates *= getEncCtxAutInitState(); +} + +void SymRS::encodeInitStatesNoCtxAut(void) +{ #ifndef NDEBUG if (opts->part_tr_rel) assert(partTrans != nullptr); @@ -370,8 +395,6 @@ void SymRS::encodeInitStates(void) *initStates += q; } - - VERB("Initial states encoded"); } void SymRS::mapStateToAct(void) @@ -487,15 +510,13 @@ BDD SymRS::encCtxAutState_raw(State state_id, bool succ) const return r; } -BDD *SymRS::getEncCtxAutInitState(void) +BDD SymRS::getEncCtxAutInitState(void) { VERB_LN(2, "Encoding context automaton's initial state"); State state = rs->ctx_aut->getInitState(); - - BDD *r = new BDD(encCtxAutState(state)); - - return r; + + return encCtxAutState(state); } BDD *SymRS::getEncCtxAutTrans(void) diff --git a/symrs.hh b/symrs.hh index 4f9d5c7..c36624a 100644 --- a/symrs.hh +++ b/symrs.hh @@ -113,6 +113,8 @@ class SymRS void encodeTransitions(void); void encodeTransitions_old(void); void encodeInitStates(void); + void encodeInitStatesForCtxAut(void); + void encodeInitStatesNoCtxAut(void); void mapStateToAct(void); void encode(void); @@ -142,60 +144,60 @@ public: BDD getBDDtrue(void) const { return BDD_TRUE; } BDD getBDDfalse(void) const { return BDD_FALSE; } - /** - * @brief Checks if context automaton is used - * - * @return True if CA is used - */ + /** + * @brief Checks if context automaton is used + * + * @return True if CA is used + */ bool usingContextAutomaton(void) { return rs->ctx_aut != nullptr; } - /** - * @brief Encodes a context automaton's state - * - * @return Returns the encoded state - */ + /** + * @brief Encodes a context automaton's state + * + * @return Returns the encoded state + */ BDD encCtxAutState_raw(State state_id, bool succ) const; - /** - * @brief Encodes a context automaton's state (as predecessor/non-primed) - * - * @return Returns the encoded state - */ + /** + * @brief Encodes a context automaton's state (as predecessor/non-primed) + * + * @return Returns the encoded state + */ BDD encCtxAutState(State state_id) const { return encCtxAutState_raw(state_id, false); } - /** - * @brief Encodes a context automaton's state (as successor/primed) - * - * @return Returns the encoded state - */ + /** + * @brief Encodes a context automaton's state (as successor/primed) + * + * @return Returns the encoded state + */ BDD encCtxAutStateSucc(State state_id) const { return encCtxAutState_raw(state_id, true); } - /** - * @brief Encodes the initial state of context automaton - * - * @return Returns the encoded state(s) - */ - BDD *getEncCtxAutInitState(void); + /** + * @brief Encodes the initial state of context automaton + * + * @return Returns the encoded state(s) + */ + BDD getEncCtxAutInitState(void); - /** - * @brief Getter for context automaton's state variables (predecessor/non-primed) - * - * @return Returns a vector of BDDs - */ + /** + * @brief Getter for context automaton's state variables (predecessor/non-primed) + * + * @return Returns a vector of BDDs + */ vector *getEncCtxAutPV(void) { return pv_ca; } - /** - * @brief Getter for context automaton's successor (primed) state variables - * - * @return Returns a vector of BDDs - */ + /** + * @brief Getter for context automaton's successor (primed) state variables + * + * @return Returns a vector of BDDs + */ vector *getEncCtxAutPVsucc(void) { return pv_ca_succ; } - /** - * @brief Encodes the monolithic transition relation - * - * @return Returns a BDD encoding the transition relation - */ + /** + * @brief Encodes the monolithic transition relation + * + * @return Returns a BDD encoding the transition relation + */ BDD *getEncCtxAutTrans(void); };