Refactor + tests (#6)
- Minor codebase clean-up - Slight reorganisation of examples + tests so that we don't break stuff by accident - CI tests
This commit was merged in pull request #6.
This commit is contained in:
@@ -13,12 +13,7 @@ CtxAut::CtxAut(Options *opts, RctSys *parent_rctsys)
|
||||
|
||||
bool CtxAut::hasState(std::string name)
|
||||
{
|
||||
if (states_names.find(name) == states_names.end()) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
return true;
|
||||
}
|
||||
return states_names.find(name) != states_names.end();
|
||||
}
|
||||
|
||||
State CtxAut::getStateID(std::string name)
|
||||
|
||||
@@ -12,10 +12,7 @@
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <cstdlib>
|
||||
// #include "rs.hh"
|
||||
#include "types.hh"
|
||||
// #include "options.hh"
|
||||
// #include "stateconstr.hh"
|
||||
|
||||
using std::cout;
|
||||
using std::endl;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/bin/sh
|
||||
|
||||
TMPINPUT="tmp_$RANDOM$RANDOM.rs"
|
||||
TMPINPUT="tmp_$RANDOM$RANDOM.drs"
|
||||
|
||||
CMD="./reactics -B"
|
||||
|
||||
|
||||
@@ -172,39 +172,6 @@ bool FormRSCTLK::isERSCTLK(void) const
|
||||
|
||||
std::string FormRSCTLK::getActionsStr(void) const
|
||||
{
|
||||
// if (actions != nullptr) {
|
||||
// std::string r = "[ ";
|
||||
// bool firstact = true;
|
||||
//
|
||||
// for (ActionsVec_f::iterator act = actions->begin(); act != actions->end();
|
||||
// ++act) {
|
||||
// if (!firstact) {
|
||||
// r += ",";
|
||||
// }
|
||||
// else {
|
||||
// firstact = false;
|
||||
// }
|
||||
//
|
||||
// r += "{";
|
||||
// bool firstent = true;
|
||||
//
|
||||
// for (Action_f::iterator ent = act->begin(); ent != act->end(); ++ent) {
|
||||
// if (!firstent) {
|
||||
// r += ",";
|
||||
// }
|
||||
// else {
|
||||
// firstent = false;
|
||||
// }
|
||||
//
|
||||
// r += *ent;
|
||||
// }
|
||||
//
|
||||
// r += "}";
|
||||
// }
|
||||
//
|
||||
// r += " ]";
|
||||
// return r;
|
||||
// }
|
||||
if (boolCtx != nullptr) {
|
||||
return "< " + boolCtx->toStr() + " >";
|
||||
}
|
||||
@@ -222,22 +189,6 @@ void FormRSCTLK::encodeActions(const SymRS *srs)
|
||||
|
||||
actions_bdd = new BDD(srs->getBDDfalse());
|
||||
assert(boolCtx != nullptr);
|
||||
// assert(actions != nullptr || boolCtx != nullptr);
|
||||
// assert(!(actions != nullptr && boolCtx != nullptr));
|
||||
|
||||
// if (actions != nullptr) {
|
||||
// for (ActionsVec_f::iterator act = actions->begin(); act != actions->end();
|
||||
// ++act) {
|
||||
// BDD single_action = srs->getBDDtrue();
|
||||
//
|
||||
// for (Action_f::iterator ent = act->begin(); ent != act->end(); ++ent) {
|
||||
// single_action *= srs->encActStrEntity(*ent);
|
||||
// }
|
||||
//
|
||||
// single_action = srs->compContext(single_action);
|
||||
// *actions_bdd += single_action;
|
||||
// }
|
||||
// }
|
||||
if (boolCtx != nullptr) {
|
||||
*actions_bdd = boolCtx->getBDDforContext(srs);
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
// #include "rs.hh"
|
||||
#include "symrs.hh"
|
||||
#include "cudd.hh"
|
||||
#include "types.hh"
|
||||
@@ -56,9 +55,6 @@
|
||||
using std::cout;
|
||||
using std::endl;
|
||||
|
||||
// typedef std::string Entity_f;
|
||||
// typedef std::set<Entity_f> Action_f;
|
||||
// typedef vector<Action_f> ActionsVec_f;
|
||||
typedef std::set<std::string> Agents_f;
|
||||
|
||||
class StateConstr;
|
||||
@@ -74,7 +70,6 @@ class FormRSCTLK
|
||||
std::string proc_name;
|
||||
bool tf;
|
||||
BDD *bdd;
|
||||
// ActionsVec_f *actions;
|
||||
BDD *actions_bdd;
|
||||
StateConstr *boolCtx;
|
||||
Agents_f agents;
|
||||
@@ -93,7 +88,6 @@ class FormRSCTLK
|
||||
arg[0] = nullptr;
|
||||
arg[1] = nullptr;
|
||||
bdd = nullptr;
|
||||
// actions = nullptr;
|
||||
actions_bdd = nullptr;
|
||||
boolCtx = nullptr;
|
||||
}
|
||||
@@ -110,7 +104,6 @@ class FormRSCTLK
|
||||
arg[0] = nullptr;
|
||||
arg[1] = nullptr;
|
||||
bdd = nullptr;
|
||||
// actions = nullptr;
|
||||
actions_bdd = nullptr;
|
||||
boolCtx = nullptr;
|
||||
}
|
||||
@@ -126,28 +119,10 @@ class FormRSCTLK
|
||||
arg[0] = form1;
|
||||
arg[1] = form2;
|
||||
bdd = nullptr;
|
||||
// actions = nullptr;
|
||||
actions_bdd = nullptr;
|
||||
boolCtx = nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Constructor for two-argument formula with action restrictions.
|
||||
*/
|
||||
// FormRSCTLK(Oper op, ActionsVec_f *acts, FormRSCTLK *form1, FormRSCTLK *form2)
|
||||
// {
|
||||
// assert(acts != nullptr);
|
||||
// assert(RSCTLK_COND_2ARG(op));
|
||||
// assert(RSCTLK_COND_ACT(op));
|
||||
// oper = op;
|
||||
// arg[0] = form1;
|
||||
// arg[1] = form2;
|
||||
// bdd = nullptr;
|
||||
// actions = acts;
|
||||
// actions_bdd = nullptr;
|
||||
// boolCtx = nullptr;
|
||||
// }
|
||||
|
||||
/**
|
||||
* @brief Constructor for two-argument formula with Boolean context restrictions.
|
||||
*/
|
||||
@@ -160,7 +135,6 @@ class FormRSCTLK
|
||||
arg[0] = form1;
|
||||
arg[1] = form2;
|
||||
bdd = nullptr;
|
||||
// actions = nullptr;
|
||||
actions_bdd = nullptr;
|
||||
boolCtx = bctx;
|
||||
}
|
||||
@@ -176,28 +150,10 @@ class FormRSCTLK
|
||||
arg[0] = form1;
|
||||
arg[1] = nullptr;
|
||||
bdd = nullptr;
|
||||
// actions = nullptr;
|
||||
actions_bdd = nullptr;
|
||||
boolCtx = nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Constructor for one-argument formula with action restrictions.
|
||||
*/
|
||||
// FormRSCTLK(Oper op, ActionsVec_f *acts, FormRSCTLK *form1)
|
||||
// {
|
||||
// assert(acts != nullptr);
|
||||
// assert(RSCTLK_COND_1ARG(op));
|
||||
// assert(RSCTLK_COND_ACT(op));
|
||||
// oper = op;
|
||||
// arg[0] = form1;
|
||||
// arg[1] = nullptr;
|
||||
// bdd = nullptr;
|
||||
// // actions = acts;
|
||||
// actions_bdd = nullptr;
|
||||
// boolCtx = nullptr;
|
||||
// }
|
||||
|
||||
/**
|
||||
* @brief Constructor for one-argument formula with Boolean context restrictions.
|
||||
*/
|
||||
@@ -210,7 +166,6 @@ class FormRSCTLK
|
||||
arg[0] = form1;
|
||||
arg[1] = nullptr;
|
||||
bdd = nullptr;
|
||||
// actions = nullptr;
|
||||
actions_bdd = nullptr;
|
||||
boolCtx = bctx;
|
||||
}
|
||||
@@ -234,7 +189,6 @@ class FormRSCTLK
|
||||
delete arg[0];
|
||||
delete arg[1];
|
||||
delete bdd;
|
||||
// delete actions;
|
||||
delete actions_bdd;
|
||||
delete boolCtx;
|
||||
}
|
||||
|
||||
@@ -42,10 +42,10 @@ for form in $forms; do
|
||||
|
||||
echo "$x" > $filename
|
||||
|
||||
./gen_bc.py $n $form > tmp.rs
|
||||
./gen_bc.py $n $form > tmp.drs
|
||||
|
||||
echo "EXEC: $tool $options $popt tmp.rs"
|
||||
$tool $options $popt tmp.rs >&1 >> $filename
|
||||
echo "EXEC: $tool $options $popt tmp.drs"
|
||||
$tool $options $popt tmp.drs >&1 >> $filename
|
||||
|
||||
result="$(tail -1 $filename | grep -E '.*;.*;.*;.*'| sed "s/STAT/$n /")"
|
||||
if [ "$result" = "" ];then
|
||||
|
||||
@@ -44,11 +44,11 @@ for form in $forms; do
|
||||
|
||||
echo "$x" > $filename
|
||||
|
||||
./gen_mutex.py $n $form > tmp.rs
|
||||
./gen_mutex.py $n $form > tmp.drs
|
||||
|
||||
echo "EXEC: $tool $options $popt tmp.rs"
|
||||
echo "EXEC: $tool $options $popt tmp.drs"
|
||||
|
||||
$tool $options $popt tmp.rs >&1 >> $filename
|
||||
$tool $options $popt tmp.drs >&1 >> $filename
|
||||
|
||||
result="$(tail -1 $filename | grep -E '.*;.*;.*;.*'| sed "s/STAT/$n /")"
|
||||
if [ "$result" = "" ];then
|
||||
|
||||
@@ -43,11 +43,11 @@ for form in $forms; do
|
||||
|
||||
echo "$x" > $filename
|
||||
|
||||
./gen_abstract1.py $n $form > tmp.rs
|
||||
./gen_abstract1.py $n $form > tmp.drs
|
||||
|
||||
echo "EXEC: $tool $options $popt tmp.rs"
|
||||
echo "EXEC: $tool $options $popt tmp.drs"
|
||||
|
||||
$tool $options $popt tmp.rs >&1 >> $filename
|
||||
$tool $options $popt tmp.drs >&1 >> $filename
|
||||
|
||||
result="$(tail -1 $filename | grep -E '.*;.*;.*;.*'| sed "s/STAT/$n /")"
|
||||
if [ "$result" = "" ];then
|
||||
|
||||
@@ -4,8 +4,8 @@ for x in `seq 2 1 24`;do
|
||||
echo $y $x
|
||||
filename="results/f${y}_n${x}.out"
|
||||
echo "$x" > $filename
|
||||
./gen_bc.py $x $y > tmp.rs
|
||||
../main -c -B tmp.rs >> $filename
|
||||
./gen_bc.py $x $y > tmp.drs
|
||||
../main -c -B tmp.drs >> $filename
|
||||
result="$(tail -1 $filename | sed "s/STAT/$x /")"
|
||||
echo $result >> results/summary_f${y}.out
|
||||
echo $result
|
||||
@@ -13,4 +13,4 @@ for x in `seq 2 1 24`;do
|
||||
done
|
||||
done
|
||||
|
||||
rm tmp.rs
|
||||
rm tmp.drs
|
||||
|
||||
@@ -4,8 +4,8 @@ for x in `seq 1 60`;do
|
||||
echo $x
|
||||
filename="results/abs_v${y}_f0_n${x}.out"
|
||||
echo "$x" > $filename
|
||||
./gen_abstract1.py $x $y > tmp.rs
|
||||
../main -z -c -p -v -B tmp.rs >&1 >> $filename
|
||||
./gen_abstract1.py $x $y > tmp.drs
|
||||
../main -z -c -p -v -B tmp.drs >&1 >> $filename
|
||||
result="$(tail -1 $filename | sed "s/STAT/$x /")"
|
||||
echo $result >> results/summary_v${y}_abs_f0.out
|
||||
echo $result
|
||||
@@ -13,4 +13,4 @@ for x in `seq 1 60`;do
|
||||
done
|
||||
done
|
||||
|
||||
rm tmp.rs
|
||||
rm tmp.drs
|
||||
|
||||
@@ -4,8 +4,8 @@ for x in `seq 1 60`;do
|
||||
echo $x
|
||||
filename="results/abs_v${y}_f0_n${x}_PT.out"
|
||||
echo "$x" > $filename
|
||||
./gen_abstract1.py $x $y > tmp.rs
|
||||
../main -z -x -c -p -v -B tmp.rs >&1 >> $filename
|
||||
./gen_abstract1.py $x $y > tmp.drs
|
||||
../main -z -x -c -p -v -B tmp.drs >&1 >> $filename
|
||||
result="$(tail -1 $filename | sed "s/STAT/$x /")"
|
||||
echo $result >> results/summary_v${y}_abs_f0_PT.out
|
||||
echo $result
|
||||
@@ -13,4 +13,4 @@ for x in `seq 1 60`;do
|
||||
done
|
||||
done
|
||||
|
||||
rm tmp.rs
|
||||
rm tmp.drs
|
||||
|
||||
@@ -4,8 +4,8 @@ for x in `seq 1 50`;do
|
||||
echo $x $y
|
||||
filename="results/bc_f${y}_n${x}.out"
|
||||
echo "$x" > $filename
|
||||
./gen_bc.py $x $y > tmp.rs
|
||||
../main -z -c -v -B tmp.rs >&1 >> $filename
|
||||
./gen_bc.py $x $y > tmp.drs
|
||||
../main -z -c -v -B tmp.drs >&1 >> $filename
|
||||
result="$(tail -1 $filename | sed "s/STAT/$x /")"
|
||||
echo $result >> results/summary_bc_f${y}.out
|
||||
echo $result
|
||||
@@ -13,4 +13,4 @@ for x in `seq 1 50`;do
|
||||
done
|
||||
done
|
||||
|
||||
rm tmp.rs
|
||||
rm tmp.drs
|
||||
|
||||
@@ -4,8 +4,8 @@ for x in `seq 2 40`;do
|
||||
echo $x $y
|
||||
filename="results/mutex_f${y}_n${x}.out"
|
||||
echo "$x" > $filename
|
||||
./gen_mutex.py $x $y > tmp.rs
|
||||
../main -z -c -p -v -B tmp.rs >&1 >> $filename
|
||||
./gen_mutex.py $x $y > tmp.drs
|
||||
../main -z -c -p -v -B tmp.drs >&1 >> $filename
|
||||
result="$(tail -1 $filename | sed "s/STAT/$x /")"
|
||||
echo $result >> results/summary_mutex_f${y}.out
|
||||
echo $result
|
||||
@@ -13,4 +13,4 @@ for x in `seq 2 40`;do
|
||||
done
|
||||
done
|
||||
|
||||
rm tmp.rs
|
||||
rm tmp.drs
|
||||
|
||||
@@ -4,8 +4,8 @@ for x in `seq 2 40`;do
|
||||
echo $x $y
|
||||
filename="results/mutex_f${y}_n${x}_PT.out"
|
||||
echo "$x" > $filename
|
||||
./gen_mutex.py $x $y > tmp.rs
|
||||
../main -zcpxvB tmp.rs >&1 >> $filename
|
||||
./gen_mutex.py $x $y > tmp.drs
|
||||
../main -zcpxvB tmp.drs >&1 >> $filename
|
||||
result="$(tail -1 $filename | sed "s/STAT/$x /")"
|
||||
echo $result >> results/summary_mutex_f${y}_PT.out
|
||||
echo $result
|
||||
@@ -13,4 +13,4 @@ for x in `seq 2 40`;do
|
||||
done
|
||||
done
|
||||
|
||||
rm tmp.rs
|
||||
rm tmp.drs
|
||||
|
||||
@@ -1,47 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
from sys import argv,exit
|
||||
|
||||
if len(argv) < 3:
|
||||
print "Usage:", argv[0], "<number of modules> <variant>"
|
||||
exit(100)
|
||||
|
||||
n = int(argv[1])
|
||||
v = int(argv[2])
|
||||
|
||||
if not ( v > 0 and v < 3 ):
|
||||
print "unsupported variant"
|
||||
exit(100)
|
||||
|
||||
print "reactions {"
|
||||
s = "\t{ {x},{s} -> {a1} };\n"
|
||||
print s
|
||||
|
||||
for i in range(1,n+1):
|
||||
s = "\t{ {a" + str(i) + "},{s} -> {y" + str(i) + "} };\n"
|
||||
s += "\t{ {a" + str(i) + "},{s} -> {b" + str(i) + "} };\n"
|
||||
s += "\t{ {b" + str(i) + "},{s} -> {c" + str(i) + "} };\n"
|
||||
s += "\t{ {c" + str(i) + "},{s} -> {d" + str(i) + "} };\n"
|
||||
s += "\t{ {d" + str(i) + ",y" + str(i) + "},{s} -> {a" + str(i+1) + "} };\n"
|
||||
s += "\t{ {y" + str(i) + "},{s} -> {y" + str(i) + "} };\n"
|
||||
print s
|
||||
|
||||
s = "\t{ {a" + str(n+1)
|
||||
for i in range(1,n+1):
|
||||
s += ",y" + str(i)
|
||||
s += "},{s} -> {r} };\n"
|
||||
print s
|
||||
print "}"
|
||||
|
||||
if v == 1:
|
||||
print "context-entities { s }"
|
||||
elif v == 2:
|
||||
s = "context-entities { s"
|
||||
for i in range(1,n+1):
|
||||
if i % 2 == 0:
|
||||
s += ",a" + str(i)
|
||||
s += " }"
|
||||
print s
|
||||
|
||||
print "initial-contexts { {x} }"
|
||||
print "rsctl-property { E[{}]F(r) }"
|
||||
@@ -1,93 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
from sys import argv,exit
|
||||
|
||||
OPTIONS_STR = """
|
||||
options { use-context-automaton; make-progressive; };
|
||||
"""
|
||||
|
||||
PROC_STR = """
|
||||
proc{:d} {{
|
||||
{{{{a}}, {{s}} -> {{y}}}};
|
||||
{{{{y}}, {{s}} -> {{y}}}};
|
||||
{{{{a}}, {{s}} -> {{b}}}};
|
||||
{{{{b}}, {{s}} -> {{c}}}};
|
||||
{{{{c}}, {{s}} -> {{d}}}};
|
||||
{{{{d,y}}, {{s}} -> {{dy}}}};
|
||||
}};
|
||||
"""
|
||||
|
||||
FINAL_PROC = """
|
||||
procFinal {
|
||||
{{done}, {s} -> {done}};
|
||||
};
|
||||
"""
|
||||
|
||||
CA_STR = """
|
||||
context-automaton {{
|
||||
states {{ init, act }};
|
||||
init-state {{ init }};
|
||||
transitions {{
|
||||
{:s}
|
||||
}};
|
||||
}};
|
||||
"""
|
||||
|
||||
PROPERTY_STR = """
|
||||
rsctlk-property {{ {:s} : {:s} }};
|
||||
"""
|
||||
|
||||
|
||||
#################################################################
|
||||
|
||||
if len(argv) < 1:
|
||||
print("Usage: {:s} <number of processes>".format(argv[0]))
|
||||
exit(100)
|
||||
|
||||
n = int(argv[1])
|
||||
|
||||
assert n > 1, "number of proc must be > 1"
|
||||
|
||||
out = ""
|
||||
|
||||
out += OPTIONS_STR
|
||||
out += "reactions {\n"
|
||||
for i in range(1, n+1):
|
||||
out += PROC_STR.format(i)
|
||||
|
||||
out += FINAL_PROC
|
||||
out += "};\n"
|
||||
|
||||
transitions = ""
|
||||
|
||||
init_trans = 8*" " + "{ proc1={a} }: init -> act;\n"
|
||||
transitions += init_trans
|
||||
|
||||
for i in range(1, n+1):
|
||||
transitions += "{:s}{{ proc{:d}={{}} }}: act -> act : ~proc{:d}.dy;\n".format(8*" ", i, i, i)
|
||||
|
||||
for i in range(2, n+1):
|
||||
transitions += "{:s}{{ proc{:d}={{a}} }}: act -> act : proc{:d}.dy;\n".format(8*" ", i, i-1)
|
||||
|
||||
final_cond = "proc1.dy"
|
||||
for i in range(2, n+1):
|
||||
final_cond += " AND proc{:d}.dy".format(i)
|
||||
|
||||
transitions += "{:s}{{ procFinal={{done}} }}: act -> act : {:s};\n".format(8*" ", final_cond)
|
||||
|
||||
out += CA_STR.format(transitions)
|
||||
|
||||
# f1
|
||||
formula = "EF( procFinal.done )"
|
||||
out += PROPERTY_STR.format("f1",formula)
|
||||
|
||||
# f2
|
||||
formula = "AG( proc{:d}.d IMPLIES K[proc{:d}]( proc{:d}.y ) )".format(n, n, n-1)
|
||||
out += PROPERTY_STR.format("f2",formula)
|
||||
|
||||
# x1
|
||||
formula = "EF( ~procFinal.done )"
|
||||
out += PROPERTY_STR.format("x1",formula)
|
||||
|
||||
print(out)
|
||||
|
||||
@@ -1,118 +0,0 @@
|
||||
#!/usr/bin/env python2.7
|
||||
|
||||
from sys import argv,exit
|
||||
|
||||
|
||||
if len(argv) < 3:
|
||||
print "Usage:", argv[0], "<number of bits> <property>"
|
||||
exit(100)
|
||||
|
||||
n = int(argv[1])
|
||||
property = int(argv[2])
|
||||
|
||||
K = 8
|
||||
if property == 3:
|
||||
if n < K+1:
|
||||
print "too small n"
|
||||
exit(100)
|
||||
|
||||
if not ( property >= 1 and property < 5 ):
|
||||
print "property: 1-4"
|
||||
exit(101)
|
||||
|
||||
print "reactions {"
|
||||
|
||||
# (1) no dec, no inc
|
||||
print "\t# (1) no decrement, no increment"
|
||||
for j in range(0,n):
|
||||
print "\t{{p" + str(j) + "},{dec,inc} -> {p" + str(j) + "}};"
|
||||
|
||||
# (2) increment
|
||||
s = "\n\t# (2) increment operation\n"
|
||||
s += "\t{{inc},{dec,p0} -> {p0}};\n"
|
||||
for j in range(1,n):
|
||||
s += "\t{{inc,"
|
||||
for k in range(0,j):
|
||||
s += "p" + str(k)
|
||||
if k < j-1:
|
||||
s += ","
|
||||
s += "},{dec,p" + str(j) + "} -> {p" + str(j) + "}};\n"
|
||||
|
||||
print s
|
||||
|
||||
print "\t# the more significant bits remain (inc)"
|
||||
s = ""
|
||||
for j in range(0,n):
|
||||
for k in range(j+1,n):
|
||||
s += "\t{{inc,p" + str(k) + "},{dec,p" + str(j) + "} -> {p" + str(k) + "}};\n"
|
||||
|
||||
print s
|
||||
|
||||
print "\t# (3) decrement operation"
|
||||
s = ""
|
||||
for j in range(0,n):
|
||||
s += "\t{{dec},{inc,"
|
||||
for k in range(0,j+1):
|
||||
s += "p" + str(k)
|
||||
if k < j:
|
||||
s += ","
|
||||
s += "} -> {p" + str(j) + "}};\n"
|
||||
print s
|
||||
|
||||
print "\t# the more significant bits remain (dec)"
|
||||
s = ""
|
||||
for j in range(0,n):
|
||||
for k in range(j+1,n):
|
||||
s += "\t{{dec,p" + str(j) + ",p" + str(k) + "},{inc} -> {p" + str(k) + "}};\n"
|
||||
|
||||
s += "}\n"
|
||||
print s
|
||||
|
||||
print "context-entities { inc,dec }"
|
||||
print "initial-contexts { {} }"
|
||||
|
||||
if property == 4:
|
||||
print "rsctl-property { AG( p" + str(n-1) + " IMPLIES EF ~p" + str(n-1) + " ) }"
|
||||
elif property == 1:
|
||||
s = "rsctl-property { AG(("
|
||||
for i in range(0,n):
|
||||
s += "~p" + str(i)
|
||||
if i < n-1:
|
||||
s += " AND "
|
||||
s += ") IMPLIES E[{inc},{dec}]F("
|
||||
for i in range(0,n):
|
||||
s += "p" + str(i)
|
||||
if i < n-1:
|
||||
s += " AND "
|
||||
|
||||
s += ")) }"
|
||||
print s
|
||||
elif property == 2:
|
||||
s = "rsctl-property { AG(("
|
||||
for i in range(0,n):
|
||||
s += "p" + str(i)
|
||||
if i < n-1:
|
||||
s += " AND "
|
||||
s += ") IMPLIES A[{inc}]X("
|
||||
for i in range(0,n):
|
||||
s += "~p" + str(i)
|
||||
if i < n-1:
|
||||
s += " AND "
|
||||
|
||||
s += ")) }"
|
||||
print s
|
||||
|
||||
elif property == 3:
|
||||
s = "rsctl-property { E[{inc}]F("
|
||||
for i in range(0,n-K):
|
||||
s += "p" + str(i)
|
||||
if i < n-1:
|
||||
s += " AND "
|
||||
for i in range(n-K,n):
|
||||
s += "~p" + str(i)
|
||||
if i < n-1:
|
||||
s += " AND "
|
||||
s += ") }"
|
||||
print s
|
||||
|
||||
|
||||
@@ -1,76 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
from sys import argv,exit
|
||||
|
||||
|
||||
if len(argv) < 3:
|
||||
print "Usage:", argv[0], "<number of processes> <formula>"
|
||||
exit(100)
|
||||
|
||||
n = int(argv[1])
|
||||
f = int(argv[2])
|
||||
|
||||
if not ( f>0 and f<4 ):
|
||||
print "unsupported formula"
|
||||
exit(100)
|
||||
|
||||
print "reactions {"
|
||||
for i in range(0,n):
|
||||
s = "\t{{out" + str(i) + ",act" + str(i) + "},{} -> {request" + str(i) + "}};\n"
|
||||
s += "\t{{out" + str(i) + "},{act" + str(i) + "} -> {out" + str(i) + "}};\n"
|
||||
for j in range(0,n):
|
||||
if i != j:
|
||||
s += "\t{{request" + str(i) + ",act" + str(i) + ",act" + str(j) + "},{} -> {request" + str(i) + "}};\n"
|
||||
#s += "\t{{request" + str(i) + "},{"
|
||||
#for j in range(0,n):
|
||||
# s += "act" + str(j)
|
||||
# if j < n-1:
|
||||
# s += ","
|
||||
#s += "} -> {request" + str(i) + "}};\n"
|
||||
s += "\t{{request" + str(i) + "},{act" + str(i) + "} -> {request" + str(i) + "}};\n"
|
||||
s += "\t{{request" + str(i) + ",act" + str(i) + "},{"
|
||||
for j in range(0,n):
|
||||
if i != j:
|
||||
s += "act" + str(j) + ","
|
||||
s += "lock} -> {in" + str(i) + ",lock}};\n"
|
||||
s += "\t{{in" + str(i) + ",act" + str(i) + "},{} -> {out" + str(i) + ",done}};\n"
|
||||
s += "\t{{in" + str(i) + "},{act" + str(i) + "} -> {in" + str(i) + "}};\n"
|
||||
print s
|
||||
|
||||
print "\t{{lock},{done} -> {lock}};"
|
||||
|
||||
print "}"
|
||||
|
||||
s = "context-entities {"
|
||||
for i in range(0,n):
|
||||
s += "act" + str(i)
|
||||
if i < n-1:
|
||||
s += ","
|
||||
s += "}\n"
|
||||
print s
|
||||
|
||||
s = "initial-contexts { {"
|
||||
for i in range(0,n):
|
||||
s += "out" + str(i)
|
||||
if i < n-1:
|
||||
s += ","
|
||||
s += "} }\n"
|
||||
print s
|
||||
|
||||
#print "rsctl-property { A[{act1}]G(A[{act1}]F(in1)) }"
|
||||
if f == 1:
|
||||
print "rsctl-property { A[{act1}]F(in1) }"
|
||||
elif f == 2:
|
||||
print "rsctl-property { E[{act1}]F(in1) }"
|
||||
elif f == 3:
|
||||
s = "rsctl-property { AG("
|
||||
for i in range(0,n):
|
||||
for j in range(i+1,n):
|
||||
s += "~(in" + str(i) + " AND in" + str(j) + ")"
|
||||
if i < n-2:
|
||||
s += " AND "
|
||||
s += ") }"
|
||||
print s
|
||||
else:
|
||||
exit(111)
|
||||
|
||||
@@ -1,117 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
from sys import argv,exit
|
||||
|
||||
OPTIONS_STR = """
|
||||
options { use-context-automaton; make-progressive; };
|
||||
"""
|
||||
|
||||
PROC_STR = """
|
||||
proc{:d} {{
|
||||
{{{{out}}, {{}} -> {{approach}}}};
|
||||
{{{{approach}}, {{req}} -> {{req}}}};
|
||||
{{{{allowed}}, {{}} -> {{in}}}};
|
||||
{{{{in}}, {{}} -> {{out,leave}}}};
|
||||
{{{{req}}, {{in}} -> {{req}}}};
|
||||
}};
|
||||
"""
|
||||
|
||||
CA_STR = """
|
||||
context-automaton {{
|
||||
states {{ init, green, red }};
|
||||
init-state {{ init }};
|
||||
transitions {{
|
||||
{:s}
|
||||
}};
|
||||
}};
|
||||
"""
|
||||
|
||||
PROPERTY_STR = """
|
||||
rsctlk-property {{ {:s} : {:s} }};
|
||||
"""
|
||||
|
||||
|
||||
#################################################################
|
||||
|
||||
if len(argv) < 1:
|
||||
print("Usage: {:s} <number of processes>".format(argv[0]))
|
||||
exit(100)
|
||||
|
||||
n = int(argv[1])
|
||||
|
||||
assert n > 1, "number of proc must be > 1"
|
||||
|
||||
out = ""
|
||||
|
||||
out += OPTIONS_STR
|
||||
out += "reactions {\n"
|
||||
for i in range(n):
|
||||
out += PROC_STR.format(i)
|
||||
out += "};\n"
|
||||
|
||||
transitions = ""
|
||||
|
||||
init_trans = 8*" " + "{ "
|
||||
for i in range(n):
|
||||
init_trans += "proc{:d}={{out}} ".format(i)
|
||||
init_trans += "}: init -> green;\n"
|
||||
transitions += init_trans
|
||||
|
||||
for i in range(n):
|
||||
transitions += "{:s}{{ proc{:d}={{allowed}} }}: green -> red : proc{:d}.req;\n".format(8*" ", i, i)
|
||||
|
||||
no_req_cond = "~proc0.req"
|
||||
for i in range(1, n):
|
||||
no_req_cond += " AND ~proc{:d}.req".format(i)
|
||||
|
||||
for i in range(n):
|
||||
transitions += "{:s}{{ proc{:d}={{}} }}: green -> green : {:s};\n".format(8*" ", i, no_req_cond)
|
||||
|
||||
for i in range(n):
|
||||
transitions += "{:s}{{ proc{:d}={{}} }}: red -> green : proc{:d}.leave;\n".format(8*" ", i, i)
|
||||
|
||||
no_leave_cond = "~proc0.leave"
|
||||
for i in range(1, n):
|
||||
no_leave_cond += " AND ~proc{:d}.leave".format(i)
|
||||
|
||||
for i in range(n):
|
||||
transitions += "{:s}{{ proc{:d}={{}} }}: red -> red : {:s};\n".format(8*" ", i, no_leave_cond)
|
||||
|
||||
out += CA_STR.format(transitions)
|
||||
|
||||
## f1
|
||||
#formula = "EF( proc0.in )"
|
||||
#out += PROPERTY_STR.format("f1",formula)
|
||||
|
||||
# f1
|
||||
formula = "EF( E<proc0.allowed>X( proc0.in ) )"
|
||||
for i in range(1, n):
|
||||
formula += " AND EF( E<proc{:d}.allowed>X( proc{:d}.in ) )".format(i, i)
|
||||
out += PROPERTY_STR.format("f1",formula)
|
||||
|
||||
# f2
|
||||
formula = "EF( proc0.approach"
|
||||
for i in range(1, n):
|
||||
formula += " AND proc{:d}.approach".format(i)
|
||||
formula += " )"
|
||||
out += PROPERTY_STR.format("f2",formula)
|
||||
|
||||
# f3
|
||||
subf = "~proc1.in"
|
||||
for i in range(2, n):
|
||||
subf += " AND ~proc{:d}.in".format(i)
|
||||
formula = "AG( proc0.in IMPLIES K[proc0]({:s}) )".format(subf)
|
||||
out += PROPERTY_STR.format("f3",formula)
|
||||
|
||||
# f4
|
||||
subf = "~proc1.in"
|
||||
for i in range(2, n):
|
||||
subf += " AND ~proc{:d}.in".format(i)
|
||||
all_agents = "proc0"
|
||||
for i in range(1, n):
|
||||
all_agents += ",proc{:d}".format(i)
|
||||
formula = "AG( proc0.in IMPLIES C[{:s}]({:s}) )".format(all_agents,subf)
|
||||
out += PROPERTY_STR.format("f4",formula)
|
||||
|
||||
print(out)
|
||||
|
||||
@@ -517,9 +517,9 @@ BDD ModelChecker::getIthOnly(Process proc_id)
|
||||
/* nothing has been found in the cache */
|
||||
BDD bdd = BDD_TRUE;
|
||||
|
||||
for (auto i = 0; i < pv_drs_E->size(); ++i) {
|
||||
for (size_t i = 0; i < pv_drs_E->size(); ++i) {
|
||||
|
||||
if (i == proc_id) {
|
||||
if (i == static_cast<size_t>(proc_id)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -591,13 +591,7 @@ bool ModelChecker::checkRSCTLKfull(FormRSCTLK *form)
|
||||
|
||||
VERB("Checking the formula");
|
||||
|
||||
//if (*initStates * getStatesRSCTLK(form) != cuddMgr->bddZero())
|
||||
if (*initStates * getStatesRSCTLK(form) == *initStates) {
|
||||
result = true;
|
||||
}
|
||||
else {
|
||||
result = false;
|
||||
}
|
||||
result = (*initStates * getStatesRSCTLK(form) == *initStates);
|
||||
|
||||
cleanup();
|
||||
|
||||
|
||||
@@ -37,13 +37,13 @@ int main(int argc, char **argv)
|
||||
&option_index)) != -1) {
|
||||
switch (c) {
|
||||
case 0:
|
||||
printf("option %s", long_options[option_index].name);
|
||||
cout << "option " << long_options[option_index].name;
|
||||
|
||||
if (optarg) {
|
||||
printf(" with arg %s", optarg);
|
||||
cout << " with arg " << optarg;
|
||||
}
|
||||
|
||||
printf("\n");
|
||||
cout << endl;
|
||||
|
||||
if (strcmp(long_options[option_index].name, "trace-parsing")) {
|
||||
driver.trace_parsing = true;
|
||||
@@ -236,16 +236,7 @@ int main(int argc, char **argv)
|
||||
|
||||
delete opts;
|
||||
|
||||
int ret_val;
|
||||
|
||||
if (result) {
|
||||
ret_val = 0;
|
||||
}
|
||||
else {
|
||||
ret_val = 1;
|
||||
}
|
||||
|
||||
return ret_val;
|
||||
return result ? 0 : 1;
|
||||
}
|
||||
|
||||
void print_help(std::string path_str)
|
||||
|
||||
@@ -14,12 +14,7 @@ RctSys::RctSys(void)
|
||||
|
||||
bool RctSys::hasEntity(std::string name)
|
||||
{
|
||||
if (entities_names.find(name) == entities_names.end()) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
return true;
|
||||
}
|
||||
return entities_names.find(name) != entities_names.end();
|
||||
}
|
||||
|
||||
void RctSys::addEntity(std::string name)
|
||||
@@ -84,21 +79,12 @@ void RctSys::addProcess(std::string processName)
|
||||
|
||||
bool RctSys::hasProcess(std::string processName)
|
||||
{
|
||||
if (processes_names.find(processName) == processes_names.end()) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
return true;
|
||||
}
|
||||
return processes_names.find(processName) != processes_names.end();
|
||||
}
|
||||
|
||||
bool RctSys::hasProcess(Process processID)
|
||||
{
|
||||
if (processID >= processes_ids.size()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return processID < processes_ids.size();
|
||||
}
|
||||
|
||||
Process RctSys::getProcessID(std::string processName)
|
||||
@@ -120,28 +106,26 @@ std::string RctSys::getProcessName(Process processID)
|
||||
}
|
||||
}
|
||||
|
||||
void RctSys::pushReactant(std::string entityName)
|
||||
void RctSys::ensureEntity(std::string entityName)
|
||||
{
|
||||
if (!hasEntity(entityName)) {
|
||||
addEntity(entityName);
|
||||
}
|
||||
}
|
||||
|
||||
void RctSys::pushReactant(std::string entityName)
|
||||
{
|
||||
ensureEntity(entityName);
|
||||
tmpReactants.insert(getEntityID(entityName));
|
||||
}
|
||||
void RctSys::pushInhibitor(std::string entityName)
|
||||
{
|
||||
if (!hasEntity(entityName)) {
|
||||
addEntity(entityName);
|
||||
}
|
||||
|
||||
ensureEntity(entityName);
|
||||
tmpInhibitors.insert(getEntityID(entityName));
|
||||
}
|
||||
void RctSys::pushProduct(std::string entityName)
|
||||
{
|
||||
if (!hasEntity(entityName)) {
|
||||
addEntity(entityName);
|
||||
}
|
||||
|
||||
ensureEntity(entityName);
|
||||
tmpProducts.insert(getEntityID(entityName));
|
||||
}
|
||||
|
||||
@@ -232,10 +216,7 @@ void RctSys::commitInitState(void)
|
||||
|
||||
void RctSys::addActionEntity(std::string entityName)
|
||||
{
|
||||
if (!hasEntity(entityName)) {
|
||||
addEntity(entityName);
|
||||
}
|
||||
|
||||
ensureEntity(entityName);
|
||||
actionEntities.insert(getEntityID(entityName));
|
||||
}
|
||||
|
||||
@@ -248,12 +229,7 @@ void RctSys::addActionEntity(Entity entity)
|
||||
|
||||
bool RctSys::isActionEntity(Entity entity)
|
||||
{
|
||||
if (actionEntities.count(entity) > 0) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
return actionEntities.count(entity) > 0;
|
||||
}
|
||||
|
||||
void RctSys::showActionEntities(void)
|
||||
|
||||
@@ -50,6 +50,7 @@ class RctSys
|
||||
|
||||
void addReactionForCurrentProcess(Reaction reaction);
|
||||
|
||||
void ensureEntity(std::string entityName);
|
||||
void pushReactant(std::string entityName);
|
||||
void pushInhibitor(std::string entityName);
|
||||
void pushProduct(std::string entityName);
|
||||
|
||||
@@ -17,9 +17,6 @@ SymRS::SymRS(RctSys *rs, Options *opts)
|
||||
|
||||
totalEntities = rs->getEntitiesSize();
|
||||
|
||||
// TODO: remove
|
||||
totalActions = 0;
|
||||
|
||||
totalRctSysStateVars = getTotalProductVariables();
|
||||
totalCtxEntities = getTotalCtxEntitiesVariables();
|
||||
|
||||
@@ -404,39 +401,19 @@ BDD SymRS::encCtxEntity(Process proc_id, Entity entity) const
|
||||
|
||||
bool SymRS::productEntityExists(Process proc_id, Entity entity) const
|
||||
{
|
||||
if (prod_ent_local_idx.count(proc_id) == 0) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
if (prod_ent_local_idx.at(proc_id).count(entity) == 1) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
return prod_ent_local_idx.count(proc_id) != 0 &&
|
||||
prod_ent_local_idx.at(proc_id).count(entity) == 1;
|
||||
}
|
||||
|
||||
bool SymRS::ctxEntityExists(Process proc_id, Entity entity) const
|
||||
{
|
||||
if (ctx_ent_local_idx.count(proc_id) == 0) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
if (ctx_ent_local_idx.at(proc_id).count(entity) == 1) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
return ctx_ent_local_idx.count(proc_id) != 0 &&
|
||||
ctx_ent_local_idx.at(proc_id).count(entity) == 1;
|
||||
}
|
||||
|
||||
bool SymRS::processUsesEntity(Process proc_id, Entity entity_id) const
|
||||
{
|
||||
if (productEntityExists(proc_id, entity_id) || ctxEntityExists(proc_id, entity_id)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return productEntityExists(proc_id, entity_id) || ctxEntityExists(proc_id, entity_id);
|
||||
}
|
||||
|
||||
BDD SymRS::encEntitiesConj_raw(Process proc_id, const Entities &entities, bool succ)
|
||||
@@ -511,20 +488,6 @@ BDD SymRS::encContext(const EntitiesForProc &proc_entities)
|
||||
return r;
|
||||
}
|
||||
|
||||
BDD SymRS::compState(const BDD &state) const
|
||||
{
|
||||
assert(0);
|
||||
BDD s = state;
|
||||
|
||||
for (unsigned int i = 0; i < totalRctSysStateVars; ++i) {
|
||||
if (!(*pv)[i] * state != cuddMgr->bddZero()) {
|
||||
s *= !(*pv)[i];
|
||||
}
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
BDD SymRS::compContext(const BDD &context) const
|
||||
{
|
||||
BDD c = context;
|
||||
@@ -725,65 +688,6 @@ BDD SymRS::encEnabledness(Process prod_proc_id, Entity entity_id)
|
||||
return enab;
|
||||
}
|
||||
|
||||
// BDD SymRS::encEnabledness(Process prod_proc_id, Entity entity_id)
|
||||
// {
|
||||
// assert(prod_conds.size() > prod_proc_id);
|
||||
|
||||
// BDD enab = BDD_FALSE;
|
||||
|
||||
// auto production_conditions = prod_conds[prod_proc_id][entity_id];
|
||||
|
||||
// VERB_LN(5, "| Produce " << rs->getEntityName(entity_id) << " in " << rs->getProcessName(prod_proc_id) << ":");
|
||||
|
||||
// for (const auto &cond : production_conditions) {
|
||||
|
||||
// BDD reactants = BDD_TRUE;
|
||||
// BDD inhibitors = BDD_TRUE;
|
||||
|
||||
// for (const auto &reactant : cond.rctt) {
|
||||
// BDD proc_reactants = BDD_FALSE;
|
||||
|
||||
// for (unsigned int proc_id = 0; proc_id < numberOfProc; ++proc_id) {
|
||||
// if (processUsesEntity(proc_id, reactant)) {
|
||||
// proc_reactants += encProcEnabled(proc_id) * encEntityCondition(proc_id, reactant);
|
||||
|
||||
// VERB_LN(5, "| - if process " << rs->getProcessName(proc_id) << " is enabled and has " << rs->getEntityName(reactant));
|
||||
|
||||
// }
|
||||
// } // END FOR: prod_id
|
||||
|
||||
// reactants *= proc_reactants;
|
||||
// } // END FOR: reactant
|
||||
|
||||
// // For inhibitors, we take all the processes first and then we iterate over the inhibitors
|
||||
// for (unsigned int proc_id = 0; proc_id < numberOfProc; ++proc_id) {
|
||||
// BDD proc_inhibitors = BDD_TRUE;
|
||||
|
||||
// for (const auto &inhibitor : cond.inhib) {
|
||||
// if (processUsesEntity(proc_id, inhibitor)) {
|
||||
// proc_inhibitors *= !encEntityCondition(proc_id, inhibitor);
|
||||
// }
|
||||
// }
|
||||
|
||||
// if (proc_inhibitors != BDD_TRUE) { // just an optimisation
|
||||
// proc_inhibitors += !encProcEnabled(proc_id);
|
||||
// inhibitors *= proc_inhibitors;
|
||||
// }
|
||||
// }
|
||||
|
||||
// enab += reactants * inhibitors;
|
||||
|
||||
// } // END FOR: cond
|
||||
|
||||
// if (opts->reorder_trans) {
|
||||
// VERB_L2("Reordering");
|
||||
// Cudd_ReduceHeap(cuddMgr->getManager(), CUDD_REORDER_SIFT, 10000);
|
||||
// }
|
||||
|
||||
// return enab;
|
||||
// }
|
||||
|
||||
|
||||
BDD SymRS::encEntitySameSuccessor(Process proc_id, Entity entity_id)
|
||||
{
|
||||
return BDD_IFF(encEntity(proc_id, entity_id), encEntitySucc(proc_id, entity_id));
|
||||
@@ -810,7 +714,7 @@ void SymRS::encodeTransitions(void)
|
||||
|
||||
prod_conds.resize(numberOfProc);
|
||||
|
||||
for (auto proc_id = 0; proc_id < numberOfProc; ++proc_id) {
|
||||
for (unsigned int proc_id = 0; proc_id < numberOfProc; ++proc_id) {
|
||||
prod_conds[proc_id] = getProductionConditions(proc_id);
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
#include "types.hh"
|
||||
#include "macro.hh"
|
||||
#include "bdd_macro.hh"
|
||||
// #include "rs.hh"
|
||||
#include "options.hh"
|
||||
#include "memtime.hh"
|
||||
|
||||
@@ -240,16 +239,11 @@ class SymRS
|
||||
vector<BDDvec> *pv_proc_ctx;
|
||||
BDDvec *pv_proc_ctx_E;
|
||||
|
||||
// TODO: remove
|
||||
BDDvec *pv_act;
|
||||
BDD *pv_act_E;
|
||||
|
||||
unsigned int totalEntities;
|
||||
unsigned int numberOfProc; /*!< The number of DRS processes */
|
||||
unsigned int totalStateVars;
|
||||
unsigned int totalRctSysStateVars; /*!< Total number of different entities produced by reactions */
|
||||
unsigned int totalCtxEntities; /*!< Total number of different (process,context) entities used */
|
||||
unsigned int totalActions;
|
||||
unsigned int totalCtxAutStateVars;
|
||||
|
||||
EntitiesForProc usedProducts; /*!< Entities used in products (per process) */
|
||||
@@ -309,13 +303,6 @@ class SymRS
|
||||
|
||||
BDD encContext(const EntitiesForProc &proc_entities);
|
||||
|
||||
/**
|
||||
* @brief Complements an encoding of a given state by negating all the variables that are not set to true
|
||||
*
|
||||
* @return Returns the encoded state
|
||||
*/
|
||||
BDD compState(const BDD &state) const;
|
||||
|
||||
BDD compContext(const BDD &context) const;
|
||||
|
||||
std::string decodedRctSysStateToStr(const BDD &state);
|
||||
|
||||
Reference in New Issue
Block a user