Commit 8939e0dd authored by Alexandre Duret-Lutz's avatar Alexandre Duret-Lutz
Browse files

genltl: move all formula generation code to spot/gen/

Fixes #254.

* spot/gen/formulas.cc, spot/gen/formulas.hh: New files.
* spot/gen/Makefile.am: Add them.
* spot/Makefile.am: Fix build order.
* bin/genltl.cc: Move most code to the above files and adjust.
* bin/Makefile.am: Link genltl with libspotgen.
* doc/org/arch.tex: Adjust picture to show that genltl uses
libspotgen.
* python/spot/gen.i: Include formulas.hh.
* tests/python/gen.py: Make sure genltl() and ltl_pattern_name()
can be called.
parent 52af3948
## -*- coding: utf-8 -*-
## Copyright (C) 2012, 2013, 2014, 2015, 2016-2017 Laboratoire de Recherche
## et Développement de l'Epita (LRDE).
## Copyright (C) 2012-2017 Laboratoire de Recherche et Développement
## de l'Epita (LRDE).
##
## This file is part of Spot, a model checking library.
##
......@@ -79,6 +79,7 @@ ltlfilt_SOURCES = ltlfilt.cc
genaut_SOURCES = genaut.cc
genaut_LDADD = $(top_builddir)/spot/gen/libspotgen.la $(LDADD)
genltl_SOURCES = genltl.cc
genltl_LDADD = $(top_builddir)/spot/gen/libspotgen.la $(LDADD)
randaut_SOURCES = randaut.cc
randltl_SOURCES = randltl.cc
ltl2tgba_SOURCES = ltl2tgba.cc
......
// -*- coding: utf-8 -*-
// Copyright (C) 2012, 2013, 2015, 2016, 2017 Laboratoire de Recherche et
// Copyright (C) 2012, 2013, 2015-2017 Laboratoire de Recherche et
// Développement de l'Epita (LRDE).
//
// This file is part of Spot, a model checking library.
......@@ -17,145 +17,6 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// Families defined here come from the following papers:
//
// @InProceedings{cichon.09.depcos,
// author = {Jacek Cicho{\'n} and Adam Czubak and Andrzej Jasi{\'n}ski},
// title = {Minimal {B\"uchi} Automata for Certain Classes of {LTL} Formulas},
// booktitle = {Proceedings of the Fourth International Conference on
// Dependability of Computer Systems},
// pages = {17--24},
// year = 2009,
// publisher = {IEEE Computer Society},
// }
//
// @InProceedings{geldenhuys.06.spin,
// author = {Jaco Geldenhuys and Henri Hansen},
// title = {Larger Automata and Less Work for LTL Model Checking},
// booktitle = {Proceedings of the 13th International SPIN Workshop},
// year = {2006},
// pages = {53--70},
// series = {Lecture Notes in Computer Science},
// volume = {3925},
// publisher = {Springer}
// }
//
// @InProceedings{gastin.01.cav,
// author = {Paul Gastin and Denis Oddoux},
// title = {Fast {LTL} to {B\"u}chi Automata Translation},
// booktitle = {Proceedings of the 13th International Conference on
// Computer Aided Verification (CAV'01)},
// pages = {53--65},
// year = 2001,
// editor = {G. Berry and H. Comon and A. Finkel},
// volume = {2102},
// series = {Lecture Notes in Computer Science},
// address = {Paris, France},
// publisher = {Springer-Verlag}
// }
//
// @InProceedings{rozier.07.spin,
// author = {Kristin Y. Rozier and Moshe Y. Vardi},
// title = {LTL Satisfiability Checking},
// booktitle = {Proceedings of the 12th International SPIN Workshop on
// Model Checking of Software (SPIN'07)},
// pages = {149--167},
// year = {2007},
// volume = {4595},
// series = {Lecture Notes in Computer Science},
// publisher = {Springer-Verlag}
// }
//
// @InProceedings{dwyer.98.fmsp,
// author = {Matthew B. Dwyer and George S. Avrunin and James C. Corbett},
// title = {Property Specification Patterns for Finite-state
// Verification},
// booktitle = {Proceedings of the 2nd Workshop on Formal Methods in
// Software Practice (FMSP'98)},
// publisher = {ACM Press},
// address = {New York},
// editor = {Mark Ardis},
// month = mar,
// year = {1998},
// pages = {7--15}
// }
//
// @InProceedings{etessami.00.concur,
// author = {Kousha Etessami and Gerard J. Holzmann},
// title = {Optimizing {B\"u}chi Automata},
// booktitle = {Proceedings of the 11th International Conference on
// Concurrency Theory (Concur'00)},
// pages = {153--167},
// year = {2000},
// editor = {C. Palamidessi},
// volume = {1877},
// series = {Lecture Notes in Computer Science},
// address = {Pennsylvania, USA},
// publisher = {Springer-Verlag}
// }
//
// @InProceedings{somenzi.00.cav,
// author = {Fabio Somenzi and Roderick Bloem},
// title = {Efficient {B\"u}chi Automata for {LTL} Formul{\ae}},
// booktitle = {Proceedings of the 12th International Conference on
// Computer Aided Verification (CAV'00)},
// pages = {247--263},
// year = {2000},
// volume = {1855},
// series = {Lecture Notes in Computer Science},
// address = {Chicago, Illinois, USA},
// publisher = {Springer-Verlag}
// }
//
// @InProceedings{tabakov.10.rv,
// author = {Deian Tabakov and Moshe Y. Vardi},
// title = {Optimized Temporal Monitors for {SystemC}},
// booktitle = {Proceedings of the 1st International Conference on Runtime
// Verification (RV'10)},
// pages = {436--451},
// year = 2010,
// volume = {6418},
// series = {Lecture Notes in Computer Science},
// month = nov,
// publisher = {Springer}
// }
//
// @InProceedings{kupferman.10.mochart,
// author = {Orna Kupferman and And Rosenberg},
// title = {The Blow-Up in Translating LTL do Deterministic Automata},
// booktitle = {Proceedings of the 6th International Workshop on Model
// Checking and Artificial Intelligence (MoChArt 2010)},
// pages = {85--94},
// year = 2011,
// volume = {6572},
// series = {Lecture Notes in Artificial Intelligence},
// month = nov,
// publisher = {Springer}
// }
//
// @techreport{holevek.04.tr,
// title = {Verification Results in {Liberouter} Project},
// author = {J. Hole\v{c}ek and T. Kratochv\'ila and V. \v{R}eh\'ak
// and D. \v{S}afr\'anek and P. \v{S}ime\v{c}ek},
// month = {September},
// year = 2004,
// number = 03,
// institution = {CESNET}
// }
//
// @InProceedings{pelanek.07.spin,
// author = {Radek Pel\'{a}nek},
// title = {{BEEM}: benchmarks for explicit model checkers},
// booktitle = {Proceedings of the 14th international SPIN conference on
// Model checking software},
// year = 2007,
// pages = {263--267},
// numpages = {5},
// volume = {4595},
// series = {Lecture Notes in Computer Science},
// publisher = {Springer-Verlag}
// }
#include "common_sys.hh"
......@@ -176,96 +37,25 @@
#include <sstream>
#include <set>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <spot/tl/formula.hh>
#include <spot/tl/relabel.hh>
#include <spot/tl/parse.hh>
#include <spot/tl/exclusive.hh>
#include <spot/gen/formulas.hh>
using namespace spot;
const char argp_program_doc[] ="\
Generate temporal logic formulas from predefined patterns.";
// We reuse the values from spot::gen::ltl_patterns as option keys.
// Additional options should therefore start after
// spot::gen::LAST_CLASS.
enum {
FIRST_CLASS = 256,
OPT_AND_F = FIRST_CLASS,
OPT_AND_FG,
OPT_AND_GF,
OPT_CCJ_ALPHA,
OPT_CCJ_BETA,
OPT_CCJ_BETA_PRIME,
OPT_DAC_PATTERNS,
OPT_EH_PATTERNS,
OPT_GH_Q,
OPT_GH_R,
OPT_GO_THETA,
OPT_HKRSS_PATTERNS,
OPT_KR_N,
OPT_KR_NLOGN,
OPT_KV_PSI,
OPT_OR_FG,
OPT_OR_G,
OPT_OR_GF,
OPT_P_PATTERNS,
OPT_R_LEFT,
OPT_R_RIGHT,
OPT_RV_COUNTER,
OPT_RV_COUNTER_CARRY,
OPT_RV_COUNTER_CARRY_LINEAR,
OPT_RV_COUNTER_LINEAR,
OPT_SB_PATTERNS,
OPT_TV_F1,
OPT_TV_F2,
OPT_TV_G1,
OPT_TV_G2,
OPT_TV_UU,
OPT_U_LEFT,
OPT_U_RIGHT,
LAST_CLASS,
OPT_POSITIVE,
OPT_POSITIVE = spot::gen::LAST_CLASS + 1,
OPT_NEGATIVE,
};
const char* const class_name[LAST_CLASS - FIRST_CLASS] =
{
"and-f",
"and-fg",
"and-gf",
"ccj-alpha",
"ccj-beta",
"ccj-beta-prime",
"dac-patterns",
"eh-patterns",
"gh-q",
"gh-r",
"go-theta",
"hkrss-patterns",
"kr-n",
"kr-nlogn",
"kv-psi",
"or-fg",
"or-g",
"or-gf",
"p-patterns",
"r-left",
"r-right",
"rv-counter",
"rv-counter-carry",
"rv-counter-carry-linear",
"rv-counter-linear",
"sb-patterns",
"tv-f1",
"tv-f2",
"tv-g1",
"tv-g2",
"tv-uu",
"u-left",
"u-right",
};
#define OPT_ALIAS(o) { #o, 0, nullptr, OPTION_ALIAS, nullptr, 0 }
......@@ -276,75 +66,83 @@ static const argp_option options[] =
{ nullptr, 0, nullptr, 0, "Pattern selection:", 1},
// J. Geldenhuys and H. Hansen (Spin'06): Larger automata and less
// work for LTL model checking.
{ "and-f", OPT_AND_F, "RANGE", 0, "F(p1)&F(p2)&...&F(pn)", 0 },
{ "and-f", spot::gen::AND_F, "RANGE", 0, "F(p1)&F(p2)&...&F(pn)", 0 },
OPT_ALIAS(gh-e),
{ "and-fg", OPT_AND_FG, "RANGE", 0, "FG(p1)&FG(p2)&...&FG(pn)", 0 },
{ "and-gf", OPT_AND_GF, "RANGE", 0, "GF(p1)&GF(p2)&...&GF(pn)", 0 },
{ "and-fg", spot::gen::AND_FG, "RANGE", 0, "FG(p1)&FG(p2)&...&FG(pn)", 0 },
{ "and-gf", spot::gen::AND_GF, "RANGE", 0, "GF(p1)&GF(p2)&...&GF(pn)", 0 },
OPT_ALIAS(ccj-phi),
OPT_ALIAS(gh-c2),
{ "ccj-alpha", OPT_CCJ_ALPHA, "RANGE", 0,
{ "ccj-alpha", spot::gen::CCJ_ALPHA, "RANGE", 0,
"F(p1&F(p2&F(p3&...F(pn)))) & F(q1&F(q2&F(q3&...F(qn))))", 0 },
{ "ccj-beta", OPT_CCJ_BETA, "RANGE", 0,
{ "ccj-beta", spot::gen::CCJ_BETA, "RANGE", 0,
"F(p&X(p&X(p&...X(p)))) & F(q&X(q&X(q&...X(q))))", 0 },
{ "ccj-beta-prime", OPT_CCJ_BETA_PRIME, "RANGE", 0,
{ "ccj-beta-prime", spot::gen::CCJ_BETA_PRIME, "RANGE", 0,
"F(p&(Xp)&(XXp)&...(X...X(p))) & F(q&(Xq)&(XXq)&...(X...X(q)))", 0 },
{ "dac-patterns", OPT_DAC_PATTERNS, "RANGE", OPTION_ARG_OPTIONAL,
{ "dac-patterns", spot::gen::DAC_PATTERNS, "RANGE", OPTION_ARG_OPTIONAL,
"Dwyer et al. [FMSP'98] Spec. Patterns for LTL "
"(range should be included in 1..55)", 0 },
OPT_ALIAS(spec-patterns),
{ "eh-patterns", OPT_EH_PATTERNS, "RANGE", OPTION_ARG_OPTIONAL,
{ "eh-patterns", spot::gen::EH_PATTERNS, "RANGE", OPTION_ARG_OPTIONAL,
"Etessami and Holzmann [Concur'00] patterns "
"(range should be included in 1..12)", 0 },
{ "gh-q", OPT_GH_Q, "RANGE", 0,
{ "gh-q", spot::gen::GH_Q, "RANGE", 0,
"(F(p1)|G(p2))&(F(p2)|G(p3))&...&(F(pn)|G(p{n+1}))", 0 },
{ "gh-r", OPT_GH_R, "RANGE", 0,
{ "gh-r", spot::gen::GH_R, "RANGE", 0,
"(GF(p1)|FG(p2))&(GF(p2)|FG(p3))&... &(GF(pn)|FG(p{n+1}))", 0 },
{ "go-theta", OPT_GO_THETA, "RANGE", 0,
{ "go-theta", spot::gen::GO_THETA, "RANGE", 0,
"!((GF(p1)&GF(p2)&...&GF(pn)) -> G(q->F(r)))", 0 },
{ "hkrss-patterns", OPT_HKRSS_PATTERNS, "RANGE", OPTION_ARG_OPTIONAL,
{ "hkrss-patterns", spot::gen::HKRSS_PATTERNS, "RANGE", OPTION_ARG_OPTIONAL,
"Holeček et al. patterns from the Liberouter project "
"(range should be included in 1..55)", 0 },
OPT_ALIAS(liberouter-patterns),
{ "kr-n", OPT_KR_N, "RANGE", 0,
{ "kr-n", spot::gen::KR_N, "RANGE", 0,
"linear formula with doubly exponential DBA", 0 },
{ "kr-nlogn", OPT_KR_NLOGN, "RANGE", 0,
{ "kr-nlogn", spot::gen::KR_NLOGN, "RANGE", 0,
"quasilinear formula with doubly exponential DBA", 0 },
{ "kv-psi", OPT_KV_PSI, "RANGE", 0,
{ "kv-psi", spot::gen::KV_PSI, "RANGE", 0,
"quadratic formula with doubly exponential DBA", 0 },
OPT_ALIAS(kr-n2),
{ "or-fg", OPT_OR_FG, "RANGE", 0, "FG(p1)|FG(p2)|...|FG(pn)", 0 },
{ "or-fg", spot::gen::OR_FG, "RANGE", 0, "FG(p1)|FG(p2)|...|FG(pn)", 0 },
OPT_ALIAS(ccj-xi),
{ "or-g", OPT_OR_G, "RANGE", 0, "G(p1)|G(p2)|...|G(pn)", 0 },
{ "or-g", spot::gen::OR_G, "RANGE", 0, "G(p1)|G(p2)|...|G(pn)", 0 },
OPT_ALIAS(gh-s),
{ "or-gf", OPT_OR_GF, "RANGE", 0, "GF(p1)|GF(p2)|...|GF(pn)", 0 },
{ "or-gf", spot::gen::OR_GF, "RANGE", 0, "GF(p1)|GF(p2)|...|GF(pn)", 0 },
OPT_ALIAS(gh-c1),
{ "p-patterns", OPT_P_PATTERNS, "RANGE", OPTION_ARG_OPTIONAL,
{ "p-patterns", spot::gen::P_PATTERNS, "RANGE", OPTION_ARG_OPTIONAL,
"Pelánek [Spin'07] patterns from BEEM "
"(range should be included in 1..20)", 0 },
OPT_ALIAS(beem-patterns),
OPT_ALIAS(p),
{ "r-left", OPT_R_LEFT, "RANGE", 0, "(((p1 R p2) R p3) ... R pn)", 0 },
{ "r-right", OPT_R_RIGHT, "RANGE", 0, "(p1 R (p2 R (... R pn)))", 0 },
{ "rv-counter", OPT_RV_COUNTER, "RANGE", 0,
{ "r-left", spot::gen::R_LEFT, "RANGE", 0,
"(((p1 R p2) R p3) ... R pn)", 0 },
{ "r-right", spot::gen::R_RIGHT, "RANGE", 0,
"(p1 R (p2 R (... R pn)))", 0 },
{ "rv-counter", spot::gen::RV_COUNTER, "RANGE", 0,
"n-bit counter", 0 },
{ "rv-counter-carry", OPT_RV_COUNTER_CARRY, "RANGE", 0,
{ "rv-counter-carry", spot::gen::RV_COUNTER_CARRY, "RANGE", 0,
"n-bit counter w/ carry", 0 },
{ "rv-counter-carry-linear", OPT_RV_COUNTER_CARRY_LINEAR, "RANGE", 0,
{ "rv-counter-carry-linear", spot::gen::RV_COUNTER_CARRY_LINEAR, "RANGE", 0,
"n-bit counter w/ carry (linear size)", 0 },
{ "rv-counter-linear", OPT_RV_COUNTER_LINEAR, "RANGE", 0,
{ "rv-counter-linear", spot::gen::RV_COUNTER_LINEAR, "RANGE", 0,
"n-bit counter (linear size)", 0 },
{ "sb-patterns", OPT_SB_PATTERNS, "RANGE", OPTION_ARG_OPTIONAL,
{ "sb-patterns", spot::gen::SB_PATTERNS, "RANGE", OPTION_ARG_OPTIONAL,
"Somenzi and Bloem [CAV'00] patterns "
"(range should be included in 1..27)", 0 },
{ "tv-f1", OPT_TV_F1, "RANGE", 0, "G(p -> (q | Xq | ... | XX...Xq)", 0 },
{ "tv-f2", OPT_TV_F2, "RANGE", 0, "G(p -> (q | X(q | X(... | Xq)))", 0 },
{ "tv-g1", OPT_TV_G1, "RANGE", 0, "G(p -> (q & Xq & ... & XX...Xq)", 0 },
{ "tv-g2", OPT_TV_G2, "RANGE", 0, "G(p -> (q & X(q & X(... & Xq)))", 0 },
{ "tv-uu", OPT_TV_UU, "RANGE", 0,
{ "tv-f1", spot::gen::TV_F1, "RANGE", 0,
"G(p -> (q | Xq | ... | XX...Xq)", 0 },
{ "tv-f2", spot::gen::TV_F2, "RANGE", 0,
"G(p -> (q | X(q | X(... | Xq)))", 0 },
{ "tv-g1", spot::gen::TV_G1, "RANGE", 0,
"G(p -> (q & Xq & ... & XX...Xq)", 0 },
{ "tv-g2", spot::gen::TV_G2, "RANGE", 0,
"G(p -> (q & X(q & X(... & Xq)))", 0 },
{ "tv-uu", spot::gen::TV_UU, "RANGE", 0,
"G(p1 -> (p1 U (p2 & (p2 U (p3 & (p3 U ...))))))", 0 },
{ "u-left", OPT_U_LEFT, "RANGE", 0, "(((p1 U p2) U p3) ... U pn)", 0 },
{ "u-left", spot::gen::U_LEFT, "RANGE", 0,
"(((p1 U p2) U p3) ... U pn)", 0 },
OPT_ALIAS(gh-u),
{ "u-right", OPT_U_RIGHT, "RANGE", 0, "(p1 U (p2 U (... U pn)))", 0 },
{ "u-right", spot::gen::U_RIGHT, "RANGE", 0,
"(p1 U (p2 U (... U pn)))", 0 },
OPT_ALIAS(gh-u2),
OPT_ALIAS(go-phi),
RANGE_DOC,
......@@ -373,7 +171,7 @@ static const argp_option options[] =
struct job
{
int pattern;
spot::gen::ltl_pattern pattern;
struct range range;
};
......@@ -393,7 +191,7 @@ static void
enqueue_job(int pattern, const char* range_str)
{
job j;
j.pattern = pattern;
j.pattern = static_cast<spot::gen::ltl_pattern>(pattern);
j.range = parse_range(range_str);
jobs.push_back(j);
}
......@@ -402,7 +200,7 @@ static void
enqueue_job(int pattern, int min, int max)
{
job j;
j.pattern = pattern;
j.pattern = static_cast<spot::gen::ltl_pattern>(pattern);
j.range = {min, max};
jobs.push_back(j);
}
......@@ -413,56 +211,26 @@ parse_opt(int key, char* arg, struct argp_state*)
// This switch is alphabetically-ordered.
switch (key)
{
case OPT_AND_F:
case OPT_AND_FG:
case OPT_AND_GF:
case OPT_CCJ_ALPHA:
case OPT_CCJ_BETA:
case OPT_CCJ_BETA_PRIME:
case OPT_GH_Q:
case OPT_GH_R:
case OPT_GO_THETA:
case OPT_KR_N:
case OPT_KR_NLOGN:
case OPT_KV_PSI:
case OPT_OR_FG:
case OPT_OR_G:
case OPT_OR_GF:
case OPT_R_LEFT:
case OPT_R_RIGHT:
case OPT_RV_COUNTER:
case OPT_RV_COUNTER_CARRY:
case OPT_RV_COUNTER_CARRY_LINEAR:
case OPT_RV_COUNTER_LINEAR:
case OPT_TV_F1:
case OPT_TV_F2:
case OPT_TV_G1:
case OPT_TV_G2:
case OPT_TV_UU:
case OPT_U_LEFT:
case OPT_U_RIGHT:
enqueue_job(key, arg);
break;
case OPT_DAC_PATTERNS:
case OPT_HKRSS_PATTERNS:
case spot::gen::DAC_PATTERNS:
case spot::gen::HKRSS_PATTERNS:
if (arg)
enqueue_job(key, arg);
else
enqueue_job(key, 1, 55);
break;
case OPT_EH_PATTERNS:
case spot::gen::EH_PATTERNS:
if (arg)
enqueue_job(key, arg);
else
enqueue_job(key, 1, 12);
break;
case OPT_P_PATTERNS:
case spot::gen::P_PATTERNS:
if (arg)
enqueue_job(key, arg);
else
enqueue_job(key, 1, 20);
break;
case OPT_SB_PATTERNS:
case spot::gen::SB_PATTERNS:
if (arg)
enqueue_job(key, arg);
else
......@@ -475,1125 +243,21 @@ parse_opt(int key, char* arg, struct argp_state*)
opt_negative = true;
break;
default:
return ARGP_ERR_UNKNOWN;
}
return 0;
}
#define G_(x) formula::G(x)
#define F_(x) formula::F(x)
#define X_(x) formula::X(x)
#define Not_(x) formula::Not(x)
#define Implies_(x, y) formula::Implies((x), (y))
#define Equiv_(x, y) formula::Equiv((x), (y))
#define And_(x, y) formula::And({(x), (y)})
#define Or_(x, y) formula::Or({(x), (y)})
#define U_(x, y) formula::U((x), (y))
// F(p_1 & F(p_2 & F(p_3 & ... F(p_n))))
static formula
E_n(std::string name, int n)
{
if (n <= 0)
return formula::tt();
formula result = nullptr;
for (; n > 0; --n)
{
std::ostringstream p;
p << name << n;
formula f = formula::ap(p.str());
if (result)
result = And_(f, result);
else
result = f;
result = F_(result);
}
return result;
}
// p & X(p & X(p & ... X(p)))
static formula
phi_n(std::string name, int n,
op oper = op::And)
{
if (n <= 0)
return formula::tt();
formula result = nullptr;
formula p = formula::ap(name);
for (; n > 0; --n)
{
if (result)
result = formula::multop(oper, {p, X_(result)});
else
result = p;
}
return result;
}
static formula
N_n(std::string name, int n)
{
return formula::F(phi_n(name, n));
}
// p & X(p) & XX(p) & XXX(p) & ... X^n(p)
static formula
phi_prime_n(std::string name, int n,
op oper = op::And)
{
if (n <= 0)
return formula::tt();
formula result = nullptr;
formula p = formula::ap(name);
for (; n > 0; --n)
{
if (result)
if (key >= spot::gen::FIRST_CLASS && key < spot::gen::LAST_CLASS)
{
p = X_(p);
result = formula::multop(oper, {result, p});
enqueue_job(key, arg);
break;
}
else
{
result = p;
}
}
return result;
}
static formula
N_prime_n(std::string name, int n)
{
return F_(phi_prime_n(name, n));
}
// GF(p_1) & GF(p_2) & ... & GF(p_n) if conj == true
// GF(p_1) | GF(p_2) | ... | GF(p_n) if conj == false
static formula
GF_n(std::string name, int n, bool conj = true)
{
if (n <= 0)
return conj ? formula::tt() : formula::ff();
formula result = nullptr;
op o = conj ? op::And : op::Or;
for (int i = 1; i <= n; ++i)
{
std::ostringstream p;
p << name << i;
formula f = G_(F_(formula::ap(p.str())));
if (result)
result = formula::multop(o, {f, result});
else
result = f;
}
return result;
}
// FG(p_1) | FG(p_2) | ... | FG(p_n) if conj == false
// FG(p_1) & FG(p_2) & ... & FG(p_n) if conj == true
static formula
FG_n(std::string name, int n, bool conj = false)
{
if (n <= 0)
return conj ? formula::tt() : formula::ff();
formula result = nullptr;
op o = conj ? op::And : op::Or;
for (int i = 1; i <= n; ++i)
{
std::ostringstream p;
p << name << i;
formula f = F_(G_(formula::ap(p.str())));
if (result)
result = formula::multop(o, {f, result});
else
result = f;
}
return result;