genltl: add --gf-equiv-xn, --gf-implies-xn

* spot/gen/formulas.cc, spot/gen/formulas.hh: Here.
* bin/genltl.cc: Add options.
* tests/core/genltl.test: Test them.
* NEWS: Mention them.
This commit is contained in:
Alexandre Duret-Lutz 2018-06-08 15:51:11 +02:00
parent 7e9325866f
commit 1341c656be
5 changed files with 55 additions and 18 deletions

View file

@ -256,9 +256,20 @@ namespace spot
return result;
}
// Builds X(X(...X(p))) with n occurrences of X.
static formula
LTL_GF_equiv_implies(int n, const std::string& a, const std::string& z,
bool equiv)
X_n(formula p, int n)
{
assert(n >= 0);
formula res = p;
while (n--)
res = X_(res);
return res;
}
static formula
GF_equiv_implies(int n, const std::string& a, const std::string& z,
bool equiv)
{
formula left = GF_n(a, n);
formula right = formula::G(formula::F(formula::ap(z)));
@ -268,6 +279,19 @@ namespace spot
return formula::Implies(left, right);
}
static formula
GF_equiv_implies_xn(int n, const std::string& a, bool equiv)
{
formula ap = formula::ap(a);
formula xn = X_n(ap, n);
formula in;
if (equiv)
in = formula::Equiv(ap, xn);
else
in = formula::Implies(ap, xn);
return G_(F_(in));
}
// (((p1 OP p2) OP p3)...OP pn) if right_assoc == false
// (p1 OP (p2 OP (p3 OP (... pn) if right_assoc == true
static formula
@ -402,17 +426,6 @@ namespace spot
return Not_(Implies_(fair, resp));
}
// Builds X(X(...X(p))) with n occurrences of X.
static formula
X_n(formula p, int n)
{
assert(n >= 0);
formula res = p;
while (n--)
res = X_(res);
return res;
}
// Based on LTLcounter.pl from Kristin Rozier.
// http://shemesh.larc.nasa.gov/people/kyr/benchmarking_scripts/
static formula
@ -1224,9 +1237,13 @@ namespace spot
case LTL_FXG_OR:
return FXG_or_n("p", n);
case LTL_GF_EQUIV:
return LTL_GF_equiv_implies(n, "a", "z", true);
return GF_equiv_implies(n, "a", "z", true);
case LTL_GF_EQUIV_XN:
return GF_equiv_implies_xn(n, "a", true);
case LTL_GF_IMPLIES:
return LTL_GF_equiv_implies(n, "a", "z", false);
return GF_equiv_implies(n, "a", "z", false);
case LTL_GF_IMPLIES_XN:
return GF_equiv_implies_xn(n, "a", false);
case LTL_GH_Q:
return Q_n("p", n);
case LTL_GH_R:
@ -1316,7 +1333,9 @@ namespace spot
"eh-patterns",
"fxg-or",
"gf-equiv",
"gf-equiv-xn",
"gf-implies",
"gf-implies-xn",
"gh-q",
"gh-r",
"go-theta",
@ -1379,7 +1398,9 @@ namespace spot
return 12;
case LTL_FXG_OR:
case LTL_GF_EQUIV:
case LTL_GF_EQUIV_XN:
case LTL_GF_IMPLIES:
case LTL_GF_IMPLIES_XN:
case LTL_GH_Q:
case LTL_GH_R:
case LTL_GO_THETA:
@ -1444,7 +1465,9 @@ namespace spot
case LTL_EH_PATTERNS:
case LTL_FXG_OR:
case LTL_GF_EQUIV:
case LTL_GF_EQUIV_XN:
case LTL_GF_IMPLIES:
case LTL_GF_IMPLIES_XN:
case LTL_GH_Q:
case LTL_GH_R:
case LTL_GO_THETA:

View file

@ -220,7 +220,9 @@ namespace spot
LTL_EH_PATTERNS,
LTL_FXG_OR,
LTL_GF_EQUIV,
LTL_GF_EQUIV_XN,
LTL_GF_IMPLIES,
LTL_GF_IMPLIES_XN,
LTL_GH_Q,
LTL_GH_R,
LTL_GO_THETA,