Removed action sets in formulae

This commit is contained in:
Artur Meski
2018-04-15 12:25:57 +01:00
parent 30b62c88c6
commit c4c3af0300
3 changed files with 152 additions and 149 deletions

View File

@@ -226,40 +226,40 @@ 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(); // for (ActionsVec_f::iterator act = actions->begin(); act != actions->end();
++act) { // ++act) {
if (!firstact) { // if (!firstact) {
r += ","; // r += ",";
} // }
else { // else {
firstact = false; // 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) { // if (!firstent) {
r += ","; // r += ",";
} // }
else { // else {
firstent = false; // firstent = false;
} // }
//
r += *ent; // r += *ent;
} // }
//
r += "}"; // r += "}";
} // }
//
r += " ]"; // r += " ]";
return r; // return r;
} // }
else if (boolCtx != nullptr) { if (boolCtx != nullptr) {
return "< " + boolCtx->toStr() + " >"; return "< " + boolCtx->toStr() + " >";
} }
else { else {
@@ -275,23 +275,24 @@ void FormRSCTL::encodeActions(const SymRS *srs)
} }
actions_bdd = new BDD(srs->getBDDfalse()); actions_bdd = new BDD(srs->getBDDfalse());
assert(actions != nullptr || boolCtx != nullptr); assert(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(); // for (ActionsVec_f::iterator act = actions->begin(); act != actions->end();
++act) { // ++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) { if (boolCtx != nullptr) {
*actions_bdd = boolCtx->getBDD(srs); *actions_bdd = boolCtx->getBDD(srs);
} }
else { else {

View File

@@ -65,9 +65,9 @@ using std::endl;
typedef unsigned char Oper; typedef unsigned char Oper;
typedef std::string Entity_f; // typedef std::string Entity_f;
typedef std::set<Entity_f> Action_f; // typedef std::set<Entity_f> Action_f;
typedef vector<Action_f> ActionsVec_f; // typedef vector<Action_f> ActionsVec_f;
class BoolContexts class BoolContexts
{ {
@@ -159,7 +159,7 @@ class FormRSCTL
std::string proc_name; std::string proc_name;
bool tf; bool tf;
BDD *bdd; BDD *bdd;
ActionsVec_f *actions; // ActionsVec_f *actions;
BDD *actions_bdd; BDD *actions_bdd;
BoolContexts *boolCtx; BoolContexts *boolCtx;
public: public:
@@ -177,7 +177,7 @@ class FormRSCTL
arg[0] = nullptr; arg[0] = nullptr;
arg[1] = nullptr; arg[1] = nullptr;
bdd = nullptr; bdd = nullptr;
actions = nullptr; // actions = nullptr;
actions_bdd = nullptr; actions_bdd = nullptr;
boolCtx = nullptr; boolCtx = nullptr;
} }
@@ -194,7 +194,7 @@ class FormRSCTL
arg[0] = nullptr; arg[0] = nullptr;
arg[1] = nullptr; arg[1] = nullptr;
bdd = nullptr; bdd = nullptr;
actions = nullptr; // actions = nullptr;
actions_bdd = nullptr; actions_bdd = nullptr;
boolCtx = nullptr; boolCtx = nullptr;
} }
@@ -210,7 +210,7 @@ class FormRSCTL
arg[0] = form1; arg[0] = form1;
arg[1] = form2; arg[1] = form2;
bdd = nullptr; bdd = nullptr;
actions = nullptr; // actions = nullptr;
actions_bdd = nullptr; actions_bdd = nullptr;
boolCtx = nullptr; boolCtx = nullptr;
} }
@@ -218,19 +218,19 @@ class FormRSCTL
/** /**
* @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));
oper = op; // oper = op;
arg[0] = form1; // arg[0] = form1;
arg[1] = form2; // arg[1] = form2;
bdd = nullptr; // bdd = nullptr;
actions = acts; // actions = acts;
actions_bdd = nullptr; // actions_bdd = nullptr;
boolCtx = nullptr; // boolCtx = nullptr;
} // }
/** /**
* @brief Constructor for two-argument formula with Boolean context restrictions. * @brief Constructor for two-argument formula with Boolean context restrictions.
@@ -244,7 +244,7 @@ class FormRSCTL
arg[0] = form1; arg[0] = form1;
arg[1] = form2; arg[1] = form2;
bdd = nullptr; bdd = nullptr;
actions = nullptr; // actions = nullptr;
actions_bdd = nullptr; actions_bdd = nullptr;
boolCtx = bctx; boolCtx = bctx;
} }
@@ -260,7 +260,7 @@ class FormRSCTL
arg[0] = form1; arg[0] = form1;
arg[1] = nullptr; arg[1] = nullptr;
bdd = nullptr; bdd = nullptr;
actions = nullptr; // actions = nullptr;
actions_bdd = nullptr; actions_bdd = nullptr;
boolCtx = nullptr; boolCtx = nullptr;
} }
@@ -268,19 +268,19 @@ class FormRSCTL
/** /**
* @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));
oper = op; // oper = op;
arg[0] = form1; // arg[0] = form1;
arg[1] = nullptr; // arg[1] = nullptr;
bdd = nullptr; // bdd = nullptr;
actions = acts; // // actions = acts;
actions_bdd = nullptr; // actions_bdd = nullptr;
boolCtx = nullptr; // boolCtx = nullptr;
} // }
/** /**
* @brief Constructor for one-argument formula with Boolean context restrictions. * @brief Constructor for one-argument formula with Boolean context restrictions.
@@ -294,7 +294,7 @@ class FormRSCTL
arg[0] = form1; arg[0] = form1;
arg[1] = nullptr; arg[1] = nullptr;
bdd = nullptr; bdd = nullptr;
actions = nullptr; // actions = nullptr;
actions_bdd = nullptr; actions_bdd = nullptr;
boolCtx = bctx; boolCtx = bctx;
} }
@@ -307,7 +307,7 @@ class FormRSCTL
delete arg[0]; delete arg[0];
delete arg[1]; delete arg[1];
delete bdd; delete bdd;
delete actions; // delete actions;
delete actions_bdd; delete actions_bdd;
delete boolCtx; delete boolCtx;
} }

View File

@@ -34,9 +34,9 @@ class rsin_driver;
int ival; int ival;
std::string *sval; std::string *sval;
FormRSCTL *frsctl; FormRSCTL *frsctl;
Entity_f *ent; // Entity_f *ent;
Action_f *act; // Action_f *act;
ActionsVec_f *actionsVec; // ActionsVec_f *actionsVec;
BoolContexts *fboolctx; BoolContexts *fboolctx;
}; };
@@ -61,9 +61,9 @@ class rsin_driver;
//%right SRB //%right SRB
%type <frsctl> rsctl_form %type <frsctl> rsctl_form
%type <ent> f_entity // %type <ent> f_entity
%type <act> action // %type <act> action
%type <actionsVec> actions // %type <actionsVec> actions
%type <fboolctx> bool_contexts %type <fboolctx> bool_contexts
//%printer { yyoutput << *$$; } "identifier" //%printer { yyoutput << *$$; } "identifier"
@@ -281,40 +281,40 @@ bool_contexts: IDENTIFIER DOT IDENTIFIER {
} }
; ;
actions: // actions:
LCB action RCB { // LCB action RCB {
$$ = new ActionsVec_f; // $$ = new ActionsVec_f;
$$->push_back(*$2); // $$->push_back(*$2);
free($2); // free($2);
} // }
| actions COMMA LCB action RCB { // | actions COMMA LCB action RCB {
$$ = $1; // $$ = $1;
$$->push_back(*$4); // $$->push_back(*$4);
free($4); // free($4);
} // }
; // ;
action: // action:
{ // {
$$ = new Action_f; // $$ = new Action_f;
} // }
| f_entity { // | f_entity {
$$ = new Action_f; // $$ = new Action_f;
$$->insert(*$1); // $$->insert(*$1);
free($1); // free($1);
} // }
| action COMMA f_entity { // | action COMMA f_entity {
$$ = $1; // $$ = $1;
$$->insert(*$3); // $$->insert(*$3);
free($3); // free($3);
} // }
; // ;
f_entity: IDENTIFIER { // f_entity: IDENTIFIER {
$$ = new Entity_f(*$1); // $$ = new Entity_f(*$1);
free($1); // free($1);
} // }
; // ;
rsctl_form: IDENTIFIER DOT IDENTIFIER { rsctl_form: IDENTIFIER DOT IDENTIFIER {
$$ = new FormRSCTL(*$1, *$3); $$ = new FormRSCTL(*$1, *$3);
@@ -363,30 +363,32 @@ rsctl_form: IDENTIFIER DOT IDENTIFIER {
| AG rsctl_form { | AG rsctl_form {
$$ = new FormRSCTL(RSCTL_AG, $2); $$ = new FormRSCTL(RSCTL_AG, $2);
} }
| E LSB actions RSB X rsctl_form {
$$ = new FormRSCTL(RSCTL_EX_ACT, $3, $6); // | E LSB actions RSB X rsctl_form {
} // $$ = new FormRSCTL(RSCTL_EX_ACT, $3, $6);
| E LSB actions RSB U LRB rsctl_form COMMA rsctl_form RRB { // }
$$ = new FormRSCTL(RSCTL_EU_ACT, $3, $7, $9); // | E LSB actions RSB U LRB rsctl_form COMMA rsctl_form RRB {
} // $$ = new FormRSCTL(RSCTL_EU_ACT, $3, $7, $9);
| E LSB actions RSB F rsctl_form { // }
$$ = new FormRSCTL(RSCTL_EF_ACT, $3, $6); // | E LSB actions RSB F rsctl_form {
} // $$ = new FormRSCTL(RSCTL_EF_ACT, $3, $6);
| E LSB actions RSB G rsctl_form { // }
$$ = new FormRSCTL(RSCTL_EG_ACT, $3, $6); // | E LSB actions RSB G rsctl_form {
} // $$ = new FormRSCTL(RSCTL_EG_ACT, $3, $6);
| A LSB actions RSB X rsctl_form { // }
$$ = new FormRSCTL(RSCTL_AX_ACT, $3, $6); // | A LSB actions RSB X rsctl_form {
} // $$ = new FormRSCTL(RSCTL_AX_ACT, $3, $6);
| A LSB actions RSB U LRB rsctl_form COMMA rsctl_form RRB { // }
$$ = new FormRSCTL(RSCTL_AU_ACT, $3, $7, $9); // | A LSB actions RSB U LRB rsctl_form COMMA rsctl_form RRB {
} // $$ = new FormRSCTL(RSCTL_AU_ACT, $3, $7, $9);
| A LSB actions RSB F rsctl_form { // }
$$ = new FormRSCTL(RSCTL_AF_ACT, $3, $6); // | A LSB actions RSB F rsctl_form {
} // $$ = new FormRSCTL(RSCTL_AF_ACT, $3, $6);
| A LSB actions RSB G rsctl_form { // }
$$ = new FormRSCTL(RSCTL_AG_ACT, $3, $6); // | A LSB actions RSB G rsctl_form {
} // $$ = new FormRSCTL(RSCTL_AG_ACT, $3, $6);
// }
/* contexts as boolean formulae */ /* contexts as boolean formulae */
| E LAB bool_contexts RAB X rsctl_form { | E LAB bool_contexts RAB X rsctl_form {
$$ = new FormRSCTL(RSCTL_EX_ACT, $3, $6); $$ = new FormRSCTL(RSCTL_EX_ACT, $3, $6);