revamp the formula hierarchy (montro-patch)

Flatten the formula ltl::formula hiearchy into a single ltl::vnode that
has an enumerator to distinguish the types of node, and a common
interface to access children, update reference counts, etc.  The
ltl::formula class is now a thin wrapper around an ltl::vnode pointer to
keep track of reference counts automatically.  Visitor are not used
anymore; we now have map() and traversor() methods that are more
concise.

This basically fixes #43, but should be followed by some fine tuning
that should now be localized to the formula.hh and formula.cc files.

Some statistics about this patch.  I started working on it on Sep 9, had
a first compiling version two weeks later on Sep 22, and it then took 5
days to fixes the ~70 distincts bugs that were introduced during the
conversion.  About 13200 lines were modified, and one third of those
were removed.

* src/ltlast/formula.cc, src/ltlast/formula.hh: Complete rewrite,
including what was in separate nearby files.
* src/ltlast/allnodes.hh, src/ltlast/atomic_prop.cc,
src/ltlast/atomic_prop.hh, src/ltlast/binop.cc, src/ltlast/binop.hh,
src/ltlast/bunop.cc, src/ltlast/bunop.hh, src/ltlast/constant.cc,
src/ltlast/constant.hh, src/ltlast/multop.cc, src/ltlast/multop.hh,
src/ltlast/unop.cc, src/ltlast/unop.hh, src/ltlvisit/dump.cc,
src/ltlvisit/dump.hh, src/ltlast/predecl.hh: Delete these files.  Their
feature have been merged in formula.hh and formula.cc.
* src/ltlast/visitor.hh, src/ltlvisit/clone.cc, src/ltlvisit/clone.hh,
src/ltlvisit/dump.hh, src/ltlvisit/postfix.cc, src/ltlvisit/postfix.hh:
Delete these files, as we do not use visitors anymore.
* bench/stutter/stutter_invariance_formulas.cc,
bench/stutter/stutter_invariance_randomgraph.cc, doc/org/tut01.org,
doc/org/tut02.org, doc/org/tut10.org, doc/org/tut22.org,
iface/ltsmin/ltsmin.cc, iface/ltsmin/ltsmin.hh,
iface/ltsmin/modelcheck.cc, src/bin/autfilt.cc,
src/bin/common_aoutput.cc, src/bin/common_aoutput.hh,
src/bin/common_finput.cc, src/bin/common_finput.hh,
src/bin/common_output.cc, src/bin/common_output.hh,
src/bin/common_trans.cc, src/bin/common_trans.hh, src/bin/dstar2tgba.cc,
src/bin/genltl.cc, src/bin/ltl2tgba.cc, src/bin/ltl2tgta.cc,
src/bin/ltlcross.cc, src/bin/ltldo.cc, src/bin/ltlfilt.cc,
src/bin/ltlgrind.cc, src/bin/randaut.cc, src/bin/randltl.cc,
src/kripke/kripkeexplicit.cc, src/kripke/kripkeexplicit.hh,
src/kripkeparse/kripkeparse.yy, src/ltlast/Makefile.am,
src/ltlenv/declenv.cc, src/ltlenv/declenv.hh, src/ltlenv/defaultenv.cc,
src/ltlenv/defaultenv.hh, src/ltlenv/environment.hh,
src/ltlparse/ltlparse.yy, src/ltlparse/public.hh,
src/ltlvisit/Makefile.am, src/ltlvisit/apcollect.cc,
src/ltlvisit/apcollect.hh, src/ltlvisit/contain.cc,
src/ltlvisit/contain.hh, src/ltlvisit/dot.cc, src/ltlvisit/dot.hh,
src/ltlvisit/exclusive.cc, src/ltlvisit/exclusive.hh,
src/ltlvisit/length.cc, src/ltlvisit/length.hh, src/ltlvisit/mark.cc,
src/ltlvisit/mark.hh, src/ltlvisit/mutation.cc,
src/ltlvisit/mutation.hh, src/ltlvisit/nenoform.cc,
src/ltlvisit/nenoform.hh, src/ltlvisit/print.cc, src/ltlvisit/print.hh,
src/ltlvisit/randomltl.cc, src/ltlvisit/randomltl.hh,
src/ltlvisit/relabel.cc, src/ltlvisit/relabel.hh,
src/ltlvisit/remove_x.cc, src/ltlvisit/remove_x.hh,
src/ltlvisit/simpfg.cc, src/ltlvisit/simpfg.hh,
src/ltlvisit/simplify.cc, src/ltlvisit/simplify.hh, src/ltlvisit/snf.cc,
src/ltlvisit/snf.hh, src/ltlvisit/unabbrev.cc, src/ltlvisit/unabbrev.hh,
src/parseaut/parseaut.yy, src/ta/taexplicit.cc, src/ta/tgtaexplicit.cc,
src/taalgos/minimize.cc, src/taalgos/tgba2ta.cc, src/tests/bare.test,
src/tests/checkpsl.cc, src/tests/checkta.cc,
src/tests/complementation.cc, src/tests/consterm.cc,
src/tests/emptchk.cc, src/tests/equalsf.cc, src/tests/ikwiad.cc,
src/tests/isop.test, src/tests/kind.cc, src/tests/length.cc,
src/tests/ltldo.test, src/tests/ltlfilt.test, src/tests/ltlgrind.test,
src/tests/ltlprod.cc, src/tests/ltlrel.cc,
src/tests/parse_print_test.cc, src/tests/parseaut.test,
src/tests/parseerr.test, src/tests/randtgba.cc, src/tests/readltl.cc,
src/tests/reduc.cc, src/tests/syntimpl.cc, src/tests/taatgba.cc,
src/tests/tostring.cc, src/tests/twagraph.cc, src/tests/utf8.test,
src/twa/acc.cc, src/twa/bdddict.cc, src/twa/bdddict.hh,
src/twa/bddprint.cc, src/twa/formula2bdd.cc, src/twa/formula2bdd.hh,
src/twa/taatgba.cc, src/twa/taatgba.hh, src/twa/twa.cc, src/twa/twa.hh
src/twa/twagraph.cc, src/twa/twagraph.hh, src/twa/twasafracomplement.cc,
src/twaalgos/compsusp.cc, src/twaalgos/compsusp.hh,
src/twaalgos/dtgbasat.cc, src/twaalgos/hoa.cc, src/twaalgos/lbtt.cc,
src/twaalgos/ltl2taa.cc, src/twaalgos/ltl2taa.hh,
src/twaalgos/ltl2tgba_fm.cc, src/twaalgos/ltl2tgba_fm.hh,
src/twaalgos/minimize.cc, src/twaalgos/minimize.hh,
src/twaalgos/neverclaim.cc, src/twaalgos/postproc.cc,
src/twaalgos/postproc.hh, src/twaalgos/powerset.cc,
src/twaalgos/powerset.hh, src/twaalgos/randomgraph.cc,
src/twaalgos/remprop.cc, src/twaalgos/remprop.hh, src/twaalgos/stats.cc,
src/twaalgos/stats.hh, src/twaalgos/stutter.cc, src/twaalgos/stutter.hh,
src/twaalgos/translate.cc, src/twaalgos/translate.hh,
wrap/python/ajax/spotcgi.in, wrap/python/spot.py,
wrap/python/spot_impl.i, wrap/python/Makefile.am,
wrap/python/tests/automata-io.ipynb, wrap/python/tests/formulas.ipynb,
wrap/python/tests/ltl2tgba.py, wrap/python/tests/ltlparse.py,
wrap/python/tests/ltlsimple.py, wrap/python/tests/randltl.ipynb: Adjust
to use the new interface.
* src/sanity/style.test: Accept more C++11 patterns.
* NEWS: Mention the change.
This commit is contained in:
Alexandre Duret-Lutz 2015-09-24 19:44:00 +02:00
parent 1628b188fe
commit b77f7e24c3
177 changed files with 8295 additions and 13332 deletions

View file

@ -1,6 +1,6 @@
#!/bin/sh
# -*- coding: utf-8 -*-
# Copyright (C) 2012 Laboratoire de Recherche et Développement
# Copyright (C) 2012, 2015 Laboratoire de Recherche et Développement
# de l'Epita (LRDE).
#
# This file is part of Spot, a model checking library.
@ -21,10 +21,10 @@
. ./defs
set -e
test "`../../bin/ltlfilt -p -f 'GFP_0.b_c'`" = "(G(F(P_0.b_c)))"
test "`../../bin/ltlfilt -p -f 'GFP_0.b_c'`" = "G(F(P_0.b_c))"
test "`../../bin/ltlfilt -f 'GFP_0.b_c'`" = "GFP_0.b_c"
foo=`../../bin/ltlfilt -p -f 'GF"P_0.b_c"'`
test "$foo" = "(G(F(P_0.b_c)))"
test "$foo" = "G(F(P_0.b_c))"
foo=`../../bin/ltlfilt -p -f '"a.b" U c.d.e'`
test "$foo" = "(a.b) U (c.d.e)"

View file

@ -23,7 +23,6 @@
#include <cstdlib>
#include <cstring>
#include "ltlparse/public.hh"
#include "ltlast/allnodes.hh"
#include "twaalgos/ltl2tgba_fm.hh"
#include "twaalgos/ltl2taa.hh"
#include "twaalgos/sccfilter.hh"
@ -67,8 +66,7 @@ main(int argc, char** argv)
if (spot::ltl::format_parse_errors(std::cerr, s, pe))
return 2;
auto fneg =
spot::ltl::unop::instance(spot::ltl::unop::Not, fpos->clone());
auto fneg = spot::ltl::formula::Not(fpos);
{
auto apos = scc_filter(ltl_to_tgba_fm(fpos, d));
@ -90,7 +88,7 @@ main(int argc, char** argv)
}
}
if (fpos->is_ltl_formula())
if (fpos.is_ltl_formula())
{
auto apos =
scc_filter(make_twa_graph(ltl_to_taa(fpos, d),
@ -104,17 +102,8 @@ main(int argc, char** argv)
exit(2);
}
}
fpos->destroy();
fneg->destroy();
}
spot::ltl::atomic_prop::dump_instances(std::cerr);
spot::ltl::unop::dump_instances(std::cerr);
spot::ltl::binop::dump_instances(std::cerr);
spot::ltl::multop::dump_instances(std::cerr);
assert(spot::ltl::atomic_prop::instance_count() == 0);
assert(spot::ltl::unop::instance_count() == 0);
assert(spot::ltl::binop::instance_count() == 0);
assert(spot::ltl::multop::instance_count() == 0);
assert(spot::ltl::fnode::instances_check());
return 0;
}

View file

@ -24,7 +24,6 @@
#include <cstdlib>
#include <cstring>
#include "ltlparse/public.hh"
#include "ltlast/allnodes.hh"
#include "twaalgos/ltl2tgba_fm.hh"
#include "twaalgos/sccfilter.hh"
#include "twaalgos/degen.hh"
@ -219,17 +218,8 @@ main(int argc, char** argv)
}
}
f->destroy();
}
spot::ltl::atomic_prop::dump_instances(std::cerr);
spot::ltl::unop::dump_instances(std::cerr);
spot::ltl::binop::dump_instances(std::cerr);
spot::ltl::multop::dump_instances(std::cerr);
assert(spot::ltl::atomic_prop::instance_count() == 0);
assert(spot::ltl::unop::instance_count() == 0);
assert(spot::ltl::binop::instance_count() == 0);
assert(spot::ltl::multop::instance_count() == 0);
assert(spot::ltl::fnode::instances_check());
return 0;
}

View file

@ -28,7 +28,6 @@
#include "ltlparse/public.hh"
#include "twaalgos/stats.hh"
#include "twaalgos/emptiness.hh"
#include "ltlast/unop.hh"
#include "twaalgos/stats.hh"
#include "twaalgos/emptiness_stats.hh"
#include "twaalgos/degen.hh"
@ -149,7 +148,7 @@ int main(int argc, char* argv[])
else if (print_formula)
{
spot::ltl::parse_error_list p1;
auto* f1 = spot::ltl::parse_infix_psl(file, p1);
auto f1 = spot::ltl::parse_infix_psl(file, p1);
if (spot::ltl::format_parse_errors(std::cerr, file, p1))
return 2;
@ -159,12 +158,11 @@ int main(int argc, char* argv[])
complement = spot::make_safra_complement(a);
spot::print_dot(std::cout, complement);
f1->destroy();
}
else if (stats)
{
spot::twa_graph_ptr a;
const spot::ltl::formula* f1 = 0;
spot::ltl::formula f1 = nullptr;
if (formula)
{
@ -211,29 +209,25 @@ int main(int argc, char* argv[])
if (formula)
{
auto nf1 = spot::ltl::unop::instance(spot::ltl::unop::Not, f1->clone());
auto a2 = spot::ltl_to_tgba_fm(nf1, dict);
spot::tgba_statistics a_size = spot::stats_reachable(a2);
auto a2 = spot::ltl_to_tgba_fm(spot::ltl::formula::Not(f1), dict);
spot::tgba_statistics a_size = spot::stats_reachable(a2);
std::cout << "Not Formula: "
<< a_size.states << ", "
<< a_size.transitions << ", "
<< a2->acc().num_sets()
<< std::endl;
f1->destroy();
nf1->destroy();
}
}
else
{
spot::ltl::parse_error_list p1;
auto* f1 = spot::ltl::parse_infix_psl(file, p1);
auto f1 = spot::ltl::parse_infix_psl(file, p1);
if (spot::ltl::format_parse_errors(std::cerr, file, p1))
return 2;
auto Af = spot::ltl_to_tgba_fm(f1, dict);
auto nf1 = spot::ltl::unop::instance(spot::ltl::unop::Not, f1->clone());
auto nf1 = spot::ltl::formula::Not(f1);
auto Anf = spot::ltl_to_tgba_fm(nf1, dict);
auto nAf = spot::make_safra_complement(Af);
auto nAnf = spot::make_safra_complement(Anf);
@ -261,8 +255,6 @@ int main(int argc, char* argv[])
{
std::cout << "OK\n";
}
nf1->destroy();
f1->destroy();
}
return return_value;

View file

@ -23,7 +23,6 @@
#include <cassert>
#include <cstdlib>
#include "ltlparse/public.hh"
#include "ltlast/allnodes.hh"
void
syntax(char *prog)
@ -60,11 +59,11 @@ main(int argc, char **argv)
ss >> expected;
spot::ltl::parse_error_list p1;
auto* f1 = spot::ltl::parse_infix_sere(form, p1);
auto f1 = spot::ltl::parse_infix_sere(form, p1);
if (spot::ltl::format_parse_errors(std::cerr, form, p1))
return 2;
bool b = f1->accepts_eword();
bool b = f1.accepts_eword();
std::cout << form << ',' << b << '\n';
if (b != expected)
{
@ -72,13 +71,8 @@ main(int argc, char **argv)
<< "' but expected '" << expected << "'\n";
return 2;
}
f1->destroy();
}
assert(spot::ltl::atomic_prop::instance_count() == 0);
assert(spot::ltl::unop::instance_count() == 0);
assert(spot::ltl::binop::instance_count() == 0);
assert(spot::ltl::bunop::instance_count() == 0);
assert(spot::ltl::multop::instance_count() == 0);
assert(spot::ltl::fnode::instances_check());
return 0;
}

View file

@ -23,7 +23,6 @@
#include <cstdlib>
#include <cstring>
#include "ltlparse/public.hh"
#include "ltlast/allnodes.hh"
#include "twaalgos/ltl2tgba_fm.hh"
#include "twaalgos/ltl2taa.hh"
#include "twaalgos/sccfilter.hh"
@ -198,16 +197,8 @@ main(int argc, char** argv)
}
}
}
f->destroy();
}
spot::ltl::atomic_prop::dump_instances(std::cerr);
spot::ltl::unop::dump_instances(std::cerr);
spot::ltl::binop::dump_instances(std::cerr);
spot::ltl::multop::dump_instances(std::cerr);
assert(spot::ltl::atomic_prop::instance_count() == 0);
assert(spot::ltl::unop::instance_count() == 0);
assert(spot::ltl::binop::instance_count() == 0);
assert(spot::ltl::multop::instance_count() == 0);
assert(spot::ltl::fnode::instances_check());
return 0;
}

View file

@ -28,9 +28,7 @@
#include <cstring>
#include "ltlparse/public.hh"
#include "ltlvisit/unabbrev.hh"
#include "ltlvisit/dump.hh"
#include "ltlvisit/nenoform.hh"
#include "ltlast/allnodes.hh"
#include "ltlvisit/simplify.hh"
#include "ltlvisit/print.hh"
@ -98,7 +96,7 @@ main(int argc, char** argv)
}
spot::ltl::parse_error_list p2;
auto* f2 = spot::ltl::parse_infix_psl(formulas[size - 1], p2);
auto f2 = spot::ltl::parse_infix_psl(formulas[size - 1], p2);
if (spot::ltl::format_parse_errors(std::cerr, formulas[size - 1], p2))
return 2;
@ -107,7 +105,7 @@ main(int argc, char** argv)
{
spot::ltl::parse_error_list p1;
auto* f1 = spot::ltl::parse_infix_psl(formulas[n], p1);
auto f1 = spot::ltl::parse_infix_psl(formulas[n], p1);
if (check_first &&
spot::ltl::format_parse_errors(std::cerr, formulas[n], p1))
@ -117,21 +115,17 @@ main(int argc, char** argv)
{
#if defined UNABBREV || defined NENOFORM
const spot::ltl::formula* tmp;
spot::ltl::formula tmp;
#endif
#ifdef UNABBREV
tmp = f1;
f1 = spot::ltl::unabbreviate(f1, UNABBREV);
tmp->destroy();
spot::ltl::dump(std::cout, f1);
std::cout << std::endl;
f1.dump(std::cout) << std::endl;
#endif
#ifdef NENOFORM
tmp = f1;
f1 = spot::ltl::negative_normal_form(f1);
tmp->destroy();
spot::ltl::dump(std::cout, f1);
std::cout << std::endl;
f1.dump(std::cout) << std::endl;
#endif
#ifdef REDUC
spot::ltl::ltl_simplifier_options opt(true, true, true,
@ -141,7 +135,7 @@ main(int argc, char** argv)
# endif
spot::ltl::ltl_simplifier simp(opt);
{
const spot::ltl::formula* tmp;
spot::ltl::formula tmp;
tmp = f1;
f1 = simp.simplify(f1);
@ -152,18 +146,15 @@ main(int argc, char** argv)
spot::ltl::print_psl(std::cerr << "Simplified: ", f1) << '\n';
exit_code = 1;
}
tmp->destroy();
}
spot::ltl::dump(std::cout, f1);
std::cout << std::endl;
f1.dump(std::cout) << std::endl;
#endif
#ifdef REDUC_TAU
spot::ltl::ltl_simplifier_options opt(false, false, false,
true, false);
spot::ltl::ltl_simplifier simp(opt);
{
const spot::ltl::formula* tmp;
spot::ltl::formula tmp;
tmp = f1;
f1 = simp.simplify(f1);
@ -174,18 +165,15 @@ main(int argc, char** argv)
spot::ltl::print_psl(std::cerr << "Simplified: ", f1) << '\n';
exit_code = 1;
}
tmp->destroy();
}
spot::ltl::dump(std::cout, f1);
std::cout << std::endl;
f1.dump(std::cout) << std::endl;
#endif
#ifdef REDUC_TAUSTR
spot::ltl::ltl_simplifier_options opt(false, false, false,
true, true);
spot::ltl::ltl_simplifier simp(opt);
{
const spot::ltl::formula* tmp;
spot::ltl::formula tmp;
tmp = f1;
f1 = simp.simplify(f1);
@ -196,11 +184,8 @@ main(int argc, char** argv)
spot::ltl::print_psl(std::cerr << "Simplified: ", f1) << '\n';
exit_code = 1;
}
tmp->destroy();
}
spot::ltl::dump(std::cout, f1);
std::cout << std::endl;
f1.dump(std::cout) << std::endl;
#endif
exit_code |= f1 != f2;
@ -225,25 +210,11 @@ main(int argc, char** argv)
exit_code ^= 1;
#endif
if (exit_code)
{
spot::ltl::dump(std::cerr, f1) << std::endl;
spot::ltl::dump(std::cerr, f2) << std::endl;
return exit_code;
}
return exit_code;
}
f1->destroy();
}
f2->destroy();
}
spot::ltl::atomic_prop::dump_instances(std::cerr);
spot::ltl::unop::dump_instances(std::cerr);
spot::ltl::binop::dump_instances(std::cerr);
spot::ltl::multop::dump_instances(std::cerr);
assert(spot::ltl::atomic_prop::instance_count() == 0);
assert(spot::ltl::unop::instance_count() == 0);
assert(spot::ltl::binop::instance_count() == 0);
assert(spot::ltl::multop::instance_count() == 0);
assert(spot::ltl::fnode::instances_check());
return 0;
}

View file

@ -28,7 +28,7 @@
#include <cstdlib>
#include "ltlvisit/print.hh"
#include "ltlvisit/apcollect.hh"
#include "ltlast/allnodes.hh"
#include "ltlast/formula.hh"
#include "ltlparse/public.hh"
#include "twaalgos/ltl2tgba_fm.hh"
#include "twaalgos/ltl2taa.hh"
@ -923,7 +923,7 @@ checked_main(int argc, char** argv)
input = argv[formula_index];
}
const spot::ltl::formula* f = 0;
spot::ltl::formula f = nullptr;
if (!from_file) // Reading a formula, not reading an automaton from a file.
{
switch (translation)
@ -971,8 +971,7 @@ checked_main(int argc, char** argv)
if (simp)
{
tm.start("reducing formula");
const spot::ltl::formula* t = simp->simplify(f);
f->destroy();
spot::ltl::formula t = simp->simplify(f);
tm.stop("reducing formula");
f = t;
if (display_reduced_form)
@ -987,8 +986,8 @@ checked_main(int argc, char** argv)
simp->clear_as_bdd_cache();
}
if (f->is_psl_formula()
&& !f->is_ltl_formula()
if (f.is_psl_formula()
&& !f.is_ltl_formula()
&& (translation != TransFM && translation != TransCompo))
{
std::cerr << "Only the FM algorithm can translate PSL formulae;"
@ -1152,7 +1151,7 @@ checked_main(int argc, char** argv)
}
if (opt_determinize && a->acc().num_sets() <= 1
&& (!f || f->is_syntactic_recurrence()))
&& (!f || f.is_syntactic_recurrence()))
{
tm.start("determinization 2");
auto determinized = tba_determinize(ensure_digraph(a), 0,
@ -1642,8 +1641,6 @@ checked_main(int argc, char** argv)
}
while (search_many);
}
if (f)
f->destroy();
}
else
{
@ -1653,14 +1650,7 @@ checked_main(int argc, char** argv)
if (use_timer)
tm.print(std::cout);
if (unobservables)
{
for (spot::ltl::atomic_prop_set::iterator i =
unobservables->begin(); i != unobservables->end(); ++i)
(*i)->destroy();
delete unobservables;
}
delete unobservables;
return exit_code;
}
@ -1669,13 +1659,6 @@ int
main(int argc, char** argv)
{
int exit_code = checked_main(argc, argv);
spot::ltl::atomic_prop::dump_instances(std::cerr);
spot::ltl::unop::dump_instances(std::cerr);
spot::ltl::binop::dump_instances(std::cerr);
spot::ltl::multop::dump_instances(std::cerr);
assert(spot::ltl::atomic_prop::instance_count() == 0);
assert(spot::ltl::unop::instance_count() == 0);
assert(spot::ltl::binop::instance_count() == 0);
assert(spot::ltl::multop::instance_count() == 0);
assert(spot::ltl::fnode::instances_check());
return exit_code;
}

View file

@ -1,6 +1,6 @@
#!/bin/sh
# -*- coding: utf-8 -*-
# Copyright (C) 2013 Laboratoire de Recherche et Développement
# Copyright (C) 2013, 2015 Laboratoire de Recherche et Développement
# de l'Epita (LRDE).
#
# This file is part of Spot, a model checking library.
@ -35,7 +35,7 @@ cat> expected<<EOF
(!a & !b) | (b & d)
(!a | b) & (!b | d) & Xc
GF(b | (a & d))
{{{{!a && !b} | {b && d}}}[*];a[*]}<>-> ((!a & b) | (a & !b))
{{{!a && !b} | {b && d}}[*];a[*]}<>-> ((!a & b) | (a & !b))
EOF
cat output
@ -48,7 +48,7 @@ cat> expected<<EOF
(a -> b) & (b -> d)
(a -> b) & (b -> d) & Xc
GF((a | b) & (b | d))
{{{{a -> b} && {b -> d}}}[*];a[*]}<>-> ((a | b) & (!a | !b))
{{{a -> b} && {b -> d}}[*];a[*]}<>-> ((a | b) & (!a | !b))
EOF
cat output

View file

@ -23,7 +23,6 @@
#include <cassert>
#include <cstdlib>
#include "ltlparse/public.hh"
#include "ltlast/allnodes.hh"
void
syntax(char *prog)
@ -60,7 +59,7 @@ main(int argc, char **argv)
std::getline(ss, expected);
spot::ltl::parse_error_list p1;
auto* f1 = spot::ltl::parse_infix_psl(form, p1);
auto f1 = spot::ltl::parse_infix_psl(form, p1);
if (spot::ltl::format_parse_errors(std::cerr, form, p1))
return 2;
@ -74,11 +73,7 @@ main(int argc, char **argv)
<< "' but expected '" << expected << "'\n";
return 2;
}
f1->destroy();
}
assert(spot::ltl::atomic_prop::instance_count() == 0);
assert(spot::ltl::unop::instance_count() == 0);
assert(spot::ltl::binop::instance_count() == 0);
assert(spot::ltl::multop::instance_count() == 0);
assert(spot::ltl::fnode::instances_check());
return 0;
}

View file

@ -23,7 +23,6 @@
#include <cstring>
#include "ltlparse/public.hh"
#include "ltlvisit/length.hh"
#include "ltlast/allnodes.hh"
void
syntax(char *prog)
@ -45,21 +44,19 @@ main(int argc, char **argv)
++argv;
}
spot::ltl::parse_error_list p1;
auto* f1 = spot::ltl::parse_infix_psl(argv[1], p1);
{
spot::ltl::parse_error_list p1;
auto f1 = spot::ltl::parse_infix_psl(argv[1], p1);
if (spot::ltl::format_parse_errors(std::cerr, argv[1], p1))
return 2;
if (spot::ltl::format_parse_errors(std::cerr, argv[1], p1))
return 2;
if (boolone)
std::cout << spot::ltl::length_boolone(f1) << std::endl;
else
std::cout << spot::ltl::length(f1) << std::endl;
if (boolone)
std::cout << spot::ltl::length_boolone(f1) << std::endl;
else
std::cout << spot::ltl::length(f1) << std::endl;
}
f1->destroy();
assert(spot::ltl::atomic_prop::instance_count() == 0);
assert(spot::ltl::unop::instance_count() == 0);
assert(spot::ltl::binop::instance_count() == 0);
assert(spot::ltl::multop::instance_count() == 0);
assert(spot::ltl::fnode::instances_check());
return 0;
}

View file

@ -27,7 +27,7 @@ genltl=../../bin/genltl
run 0 $ltldo -f a -f 'a&b' -t 'echo %f,%s' >output
cat >expected <<EOF
(a),(a)
a,a
(a) & (b),(a) && (b)
EOF
diff output expected
@ -35,7 +35,7 @@ diff output expected
# Renaming
run 0 $ltldo -f a -f 'a&_b' -t 'echo %f,%s' >output
cat >expected <<EOF
(a),(a)
a,a
(p0) & (p1),(p0) && (p1)
EOF
diff output expected

View file

@ -240,35 +240,35 @@ diff exp out
toolong='((p2=0) * (p3=1))' # work around the 80-col check
cat >exp <<EOF
#define p0 ((a=1))
#define p1 ((c=1))
#define p2 ((b=1))
#define p0 (a=1)
#define p1 (c=1)
#define p2 (b=1)
(p0=1) * (p1=1) * (X(p2=1))
#define p0 ((a=1))
#define p1 ((b=1))
#define p2 ((c=1))
#define p0 (a=1)
#define p1 (b=1)
#define p2 (c=1)
(p0=1) * (p1=1) * (G(F((p0=1) + (p2=1)))) * (F(G((p0=1) + (p2=1))))
#define p0 ((b=1))
#define p1 ((a=1))
#define p2 ((c=1))
#define p0 (b=1)
#define p1 (a=1)
#define p2 (c=1)
(p0=1) * (G(F((p1=1) + (p2=1)))) * (F(G((p1=1) + (p2=1))))
#define p0 ((h=1))
#define p1 ((i=1))
#define p2 ((d=1))
#define p3 ((e=1))
#define p4 ((c=1))
#define p5 ((f=1))
#define p0 (h=1)
#define p1 (i=1)
#define p2 (d=1)
#define p3 (e=1)
#define p4 (c=1)
#define p5 (f=1)
(p0=1) + (p1=1) + (G((p2=1) * (p3=1))) + (F(G((p4=0) + (X(p5=1)))))
#define p0 ((b=1))
#define p1 ((e=1))
#define p2 ((f=1))
#define p3 ((g=1))
#define p4 ((c=1))
#define p0 (b=1)
#define p1 (e=1)
#define p2 (f=1)
#define p3 (g=1)
#define p4 (c=1)
(p0=1) * (p1=1) * ((p2=1) + (p3=1)) * (X(p4=0))
#define p0 ((c=1))
#define p1 ((d=1))
#define p2 ((a=1))
#define p3 ((b=1))
#define p0 (c=1)
#define p1 (d=1)
#define p2 (a=1)
#define p3 (b=1)
((p0=1) * (p1=0)) + ((p0=0) * (p1=1)) + (G(((p2=1) * (p3=0)) + $toolong))
EOF
run 0 $ltlfilt -p --wring -u --nnf --relabel=pnn --define in >out

View file

@ -25,7 +25,7 @@ set -e
checkopt()
{
cat >exp
run 0 ../../bin/ltlgrind "$@" > out
run 0 ../../bin/ltlgrind --sort "$@" > out
# The result must be parsable
../../bin/ltlfilt out
diff exp out
@ -34,44 +34,44 @@ checkopt()
checkopt -f 'Xp1 U (p4 | (p3 xor (p4 W p0)))' <<EOF
1
Xp1
p4 | (p3 xor (p4 W p0))
Xp1 W (p4 | (p3 xor (p4 W p0)))
Xp1 U (p3 xor (p4 W p0))
Xp1 U p4
Xp1 U (p3 | p4)
p4 | (p3 xor (p4 W p0))
Xp1 U (!p3 | p4)
Xp1 U (p3 xor (p4 W p0))
Xp1 U (p4 | (p4 W p0))
Xp1 U (p4 | (p3 & !(p4 W p0)))
Xp1 U (p4 | (!p3 & (p4 W p0)))
Xp1 U (p4 | (p3 xor p4))
Xp1 U (p4 | (p0 xor p3))
Xp1 U (!p3 | p4)
Xp1 U (p4 | (p3 xor (p4 W 0)))
Xp1 U (p4 | !(p4 W p0))
Xp1 U (p0 | (p0 xor p3))
p1 U (p4 | (p3 xor (p4 W p0)))
1 U (p4 | (p3 xor (p4 W p0)))
Xp1 U (p4 | !(p4 W p0))
Xp1 W (p4 | (p3 xor (p4 W p0)))
Xp1 U (p4 | (p3 xor (p4 W 0)))
Xp4 U (p4 | (p3 xor (p4 W p0)))
Xp3 U (p4 | (p3 xor (p4 W p0)))
Xp0 U (p4 | (p3 xor (p4 W p0)))
Xp1 U (p1 | (p3 xor (p1 W p0)))
Xp1 U (p3 | (p3 xor (p3 W p0)))
Xp1 U (p0 | (p0 xor p3))
Xp1 U (p4 | (p1 xor (p4 W p0)))
Xp1 U (p4 | (p4 xor (p4 W p0)))
Xp1 U (p4 | (p0 xor (p4 W p0)))
Xp1 U (p4 | (p3 xor (p4 W p1)))
Xp1 U (p4 | (p3 xor (p4 W p3)))
Xp1 U (p4 | (p3 & !(p4 W p0)))
Xp1 U (p4 | (!p3 & (p4 W p0)))
EOF
checkopt -f '(Xp4 R p3) W !p0' --sort <<EOF
checkopt -f '(Xp4 R p3) W !p0' <<EOF
1
!p0
Xp4 R p3
p3 W !p0
Xp4 W !p0
(Xp4 R p3) W p0
(Xp4 R p3) W 0
(p4 R p3) W !p0
(0 R p3) W !p0
(Xp4 R p3) W p0
(Xp4 R p3) W 0
(p3 W Xp4) W !p0
(Xp3 R p3) W !p0
(Xp0 R p3) W !p0
@ -82,22 +82,22 @@ Xp4 W !p0
EOF
checkopt -f 'F(!p2 & p3) | Fp0' -n 4 <<EOF
F(!p2 & p3)
Fp0
(!p2 & p3) | Fp0
F(!p2 & p3)
Fp0 | Fp3
(!p2 & p3) | Fp0
EOF
checkopt -f '{(a | b)[*4] & ((a | b)*; c)} <>-> G(d <-> e) xor f' --split-ops \
<<EOF
{{{a | b}}[*4] & {{{a | b}}[*];c}}<>-> (f & !G(d <-> e))
{{{a | b}}[*4] & {{{a | b}}[*];c}}<>-> (!f & G(d <-> e))
{{{a | b}}[*4] & {{{a | b}}[*];c}}<>-> (f xor G(d -> e))
{{{a | b}}[*4] & {{{a | b}}[*];c}}<>-> (f xor G(e -> d))
{{{a | b}}[*4] & {{{a | b}}[*];c}}<>-> (f xor G(d & e))
{{{a | b}}[*4] & {{{a | b}}[*];c}}<>-> (f xor G(!d & !e))
{{{{a | b}}[*];c} && {{{a | b}}[*4];[*]}}<>-> (f xor G(d <-> e))
{{{a | b}}[*4] && {{{a | b}}[*];c;[*]}}<>-> (f xor G(d <-> e))
{{a | b}[*4] & {{a | b}[*];c}}<>-> (f xor G(d -> e))
{{a | b}[*4] & {{a | b}[*];c}}<>-> (f xor G(e -> d))
{{a | b}[*4] & {{a | b}[*];c}}<>-> (f xor G(d & e))
{{a | b}[*4] & {{a | b}[*];c}}<>-> (f & !G(d <-> e))
{{a | b}[*4] & {{a | b}[*];c}}<>-> (!f & G(d <-> e))
{{a | b}[*4] & {{a | b}[*];c}}<>-> (f xor G(!d & !e))
{{{a | b}[*];c} && {{a | b}[*4];[*]}}<>-> (f xor G(d <-> e))
{{a | b}[*4] && {{a | b}[*];c;[*]}}<>-> (f xor G(d <-> e))
EOF
@ -108,9 +108,9 @@ checkopt -f '!(!XXp1 M X(p4 U p2))' --rewrite-ops <<EOF
EOF
checkopt -f '!(p0 & !p2 & (p1 W 0))' --remove-multop-operands <<EOF
!(!p2 & (p1 W 0))
!(p0 & (p1 W 0))
!(p0 & !p2)
!(p0 & (p1 W 0))
!(!p2 & (p1 W 0))
EOF
checkopt -f '{p1[*..2] | p2[*3..5] | p3[*6..]}[]-> 0' --simplify-bounds <<EOF
@ -136,9 +136,9 @@ EOF
checkopt -f '!p4 & (p2 | {{!p1}[*]})' --ap-to-const <<EOF
0
!p4
p2 & !p4
p2 | {{!p1}[*]}
!p4 & {{!p1}[*]}
p2 & !p4
!p4 & (p2 | {[*]})
EOF
@ -150,34 +150,34 @@ F((p0 & p4) | XXp0)
EOF
checkopt -f '1 U (p3 <-> p4)' -m 2 <<EOF
1
0
1
p3
p4
!p4
!p3
p3 -> p4
p4 -> p3
p3 & p4
!p4
!p3
!p3 & !p4
1 U p3
1 U p4
1 U !p3
1 U !p4
!p3 & !p4
1 U (p3 & !p4)
1 U (!p3 & p4)
EOF
checkopt -f 'F({{p2;p0}[:*]}[]-> Xp0)' <<EOF
1
{{p2;p0}[:*]}[]-> Xp0
F!{{p2;p0}[:*]}
FXp0
F!{{p2;p0}[:*]}
{{p2;p0}[:*]}[]-> Xp0
F({p2;p0}[]-> Xp0)
F({{p2;p0}[:*]}[]-> p0)
F({{p2;p0}[:*]}[]-> 0)
F({p2;p0}[]-> Xp0)
F({{1;p0}[:*]}[]-> Xp0)
F({{p2;1}[:*]}[]-> Xp0)
F({p0[*2][:*]}[]-> Xp0)
F({p2[*2][:*]}[]-> Xp2)
F({{1;p0}[:*]}[]-> Xp0)
F({{p2;1}[:*]}[]-> Xp0)
EOF

View file

@ -23,7 +23,6 @@
#include <iostream>
#include <cassert>
#include <cstdlib>
#include "ltlast/allnodes.hh"
#include "ltlparse/public.hh"
#include "twaalgos/product.hh"
#include "twaalgos/ltl2tgba_fm.hh"
@ -48,13 +47,13 @@ main(int argc, char** argv)
spot::ltl::environment& env(spot::ltl::default_environment::instance());
spot::ltl::parse_error_list pel1;
auto* f1 = spot::ltl::parse_infix_psl(argv[1], pel1, env);
auto f1 = spot::ltl::parse_infix_psl(argv[1], pel1, env);
if (spot::ltl::format_parse_errors(std::cerr, argv[1], pel1))
return 2;
spot::ltl::parse_error_list pel2;
auto* f2 = spot::ltl::parse_infix_psl(argv[2], pel2, env);
auto f2 = spot::ltl::parse_infix_psl(argv[2], pel2, env);
if (spot::ltl::format_parse_errors(std::cerr, argv[2], pel2))
return 2;
@ -63,14 +62,9 @@ main(int argc, char** argv)
{
auto a1 = spot::ltl_to_tgba_fm(f1, dict);
auto a2 = spot::ltl_to_tgba_fm(f2, dict);
f1->destroy();
f2->destroy();
spot::print_dot(std::cout, product(a1, a2));
}
}
assert(spot::ltl::atomic_prop::instance_count() == 0);
assert(spot::ltl::unop::instance_count() == 0);
assert(spot::ltl::binop::instance_count() == 0);
assert(spot::ltl::multop::instance_count() == 0);
assert(spot::ltl::fnode::instances_check());
return exit_code;
}

View file

@ -22,7 +22,6 @@
#include <cstdlib>
#include "ltlparse/public.hh"
#include "ltlvisit/relabel.hh"
#include "ltlast/allnodes.hh"
#include "ltlvisit/print.hh"
void
@ -38,38 +37,30 @@ main(int argc, char **argv)
if (argc != 2)
syntax(argv[0]);
spot::ltl::parse_error_list p1;
auto* f1 = spot::ltl::parse_infix_psl(argv[1], p1);
{
spot::ltl::parse_error_list p1;
auto f1 = spot::ltl::parse_infix_psl(argv[1], p1);
if (spot::ltl::format_parse_errors(std::cerr, argv[1], p1))
return 2;
if (spot::ltl::format_parse_errors(std::cerr, argv[1], p1))
return 2;
spot::ltl::relabeling_map* m = new spot::ltl::relabeling_map;
const spot::ltl::formula* f2 = spot::ltl::relabel_bse(f1, spot::ltl::Pnn, m);
f1->destroy();
spot::ltl::print_psl(std::cout, f2) << '\n';
spot::ltl::relabeling_map* m = new spot::ltl::relabeling_map;
auto f2 = spot::ltl::relabel_bse(f1, spot::ltl::Pnn, m);
spot::ltl::print_psl(std::cout, f2) << '\n';
typedef std::map<std::string, std::string> map_t;
map_t sorted_map;
for (spot::ltl::relabeling_map::const_iterator i = m->begin();
i != m->end(); ++i)
sorted_map[spot::ltl::str_psl(i->first)] =
spot::ltl::str_psl(i->second);
for (map_t::const_iterator i = sorted_map.begin();
i != sorted_map.end(); ++i)
std::cout << " " << i->first << " -> "
<< i->second << '\n';
f2->destroy();
delete m;
spot::ltl::atomic_prop::dump_instances(std::cerr);
spot::ltl::unop::dump_instances(std::cerr);
spot::ltl::binop::dump_instances(std::cerr);
spot::ltl::multop::dump_instances(std::cerr);
assert(spot::ltl::atomic_prop::instance_count() == 0);
assert(spot::ltl::unop::instance_count() == 0);
assert(spot::ltl::binop::instance_count() == 0);
assert(spot::ltl::multop::instance_count() == 0);
typedef std::map<std::string, std::string> map_t;
map_t sorted_map;
for (spot::ltl::relabeling_map::const_iterator i = m->begin();
i != m->end(); ++i)
sorted_map[spot::ltl::str_psl(i->first)] =
spot::ltl::str_psl(i->second);
for (map_t::const_iterator i = sorted_map.begin();
i != sorted_map.end(); ++i)
std::cout << " " << i->first << " -> "
<< i->second << '\n';
delete m;
}
assert(spot::ltl::fnode::instances_check());
return 0;
}

View file

@ -20,8 +20,6 @@
#include "kripkeparse/public.hh"
#include "kripke/kripkeprint.hh"
#include "ltlast/allnodes.hh"
using namespace spot;
@ -44,9 +42,6 @@ int main(int argc, char** argv)
kripke_save_reachable(std::cout, k);
}
assert(ltl::atomic_prop::instance_count() == 0);
assert(ltl::unop::instance_count() == 0);
assert(ltl::binop::instance_count() == 0);
assert(ltl::multop::instance_count() == 0);
assert(spot::ltl::fnode::instances_check());
return return_value;
}

View file

@ -690,8 +690,8 @@ State: 1
never { /* a U b */
T0_init:
if
:: ((b)) -> goto accept_all
:: ((a)) -> goto T0_init
:: (b) -> goto accept_all
:: (a) -> goto T0_init
fi;
accept_all:
skip
@ -1452,7 +1452,7 @@ expectok input --spin=c <<EOF
never { /* a U b */
T0_init: /* s1 */
if
:: ((b)) -> goto accept_all
:: (b) -> goto accept_all
:: ((a) && (!(b))) -> goto T0_init
fi;
accept_all: /* s0 */

View file

@ -1,7 +1,7 @@
#! /bin/sh
# -*- coding: utf-8 -*-
# Copyright (C) 2009, 2010, 2011, 2013, 2014 Laboratoire de Recherche et
# Développement de l'Epita (LRDE).
# Copyright (C) 2009, 2010, 2011, 2013, 2014, 2015 Laboratoire de
# Recherche et Développement de l'Epita (LRDE).
# Copyright (C) 2003, 2004 Laboratoire d'Informatique de Paris 6 (LIP6),
# département Systèmes Répartis Coopératifs (SRC), Université Pierre
# et Marie Curie.
@ -96,7 +96,7 @@ a & (, a & 0
EOF
run 0 ../equals -E recover.txt
check 'a - b' 'AP(a)' '>>> a - b
check 'a - b' 'AP(@3 #0 "a")' '>>> a - b
^
syntax error, unexpected $undefined
@ -105,7 +105,7 @@ syntax error, unexpected $undefined
ignoring trailing garbage
'
check '{a[*9999999999]}' 'unop(Closure, bunop(Star, AP(a), 0, unbounded))' \
check '{a[*9999999999]}' 'Closure(@5 #0 [Star(@4 #0 0.. [AP(@3 #0 "a")])])' \
'>>> {a[*9999999999]}
^^^^^^^^^^
value too large ignored

View file

@ -486,7 +486,7 @@ print_ar_stats(ar_stats_type& ar_stats, const std::string& s)
std::cout << std::setiosflags(old);
}
const spot::ltl::formula*
spot::ltl::formula
generate_formula(const spot::ltl::random_ltl& rl,
spot::ltl::ltl_simplifier& simp,
int opt_f, int opt_s,
@ -498,21 +498,16 @@ generate_formula(const spot::ltl::random_ltl& rl,
while (max_tries_u--)
{
spot::srand(opt_s++);
const spot::ltl::formula* f;
spot::ltl::formula f;
int max_tries_l = 1000;
while (max_tries_l--)
{
f = rl.generate(opt_f);
if (opt_l)
{
const spot::ltl::formula* g = simp.simplify(f);
f->destroy();
if (spot::ltl::length(g) < opt_l)
{
g->destroy();
continue;
}
f = g;
f = simp.simplify(f);
if (spot::ltl::length(f) < opt_l)
continue;
}
else
{
@ -529,10 +524,7 @@ generate_formula(const spot::ltl::random_ltl& rl,
}
std::string txt = spot::ltl::str_psl(f);
if (!opt_u || unique.insert(txt).second)
{
return f;
}
f->destroy();
return f;
}
assert(opt_u);
std::cerr << "Failed to generate another unique formula."
@ -855,12 +847,11 @@ main(int argc, char** argv)
{
if (opt_F)
{
const spot::ltl::formula* f =
spot::ltl::formula f =
generate_formula(rl, simp, opt_f, opt_ec_seed, opt_l, opt_u);
if (!f)
exit(1);
formula = spot::ltl_to_tgba_fm(f, dict, true);
f->destroy();
}
else if (opt_i)
{
@ -872,20 +863,16 @@ main(int argc, char** argv)
else if (input == "")
break;
spot::ltl::parse_error_list pel;
auto* f = spot::ltl::parse_infix_psl(input, pel, env);
auto f = spot::ltl::parse_infix_psl(input, pel, env);
if (spot::ltl::format_parse_errors(std::cerr, input, pel))
{
exit_code = 1;
break;
}
formula = spot::ltl_to_tgba_fm(f, dict, true);
spot::ltl::atomic_prop_set* tmp =
spot::ltl::atomic_prop_collect(f);
for (spot::ltl::atomic_prop_set::iterator i = tmp->begin();
i != tmp->end(); ++i)
apf->insert(down_cast<const spot::ltl::atomic_prop*>
((*i)->clone()));
f->destroy();
auto* tmp = spot::ltl::atomic_prop_collect(f);
for (auto i: *tmp)
apf->insert(i);
delete tmp;
}
else
@ -896,9 +883,8 @@ main(int argc, char** argv)
}
}
for (spot::ltl::atomic_prop_set::iterator i = ap->begin();
i != ap->end(); ++i)
apf->insert(static_cast<const spot::ltl::atomic_prop*>((*i)->clone()));
for (auto i: *ap)
apf->insert(i);
if (!opt_S)
{
@ -1147,9 +1133,6 @@ main(int argc, char** argv)
if (opt_F)
--opt_F;
opt_ec = init_opt_ec;
for (spot::ltl::atomic_prop_set::iterator i = apf->begin();
i != apf->end(); ++i)
(*i)->destroy();
apf->clear();
}
while (opt_F || opt_i);
@ -1294,10 +1277,6 @@ main(int argc, char** argv)
std::cout << std::endl;
}
for (spot::ltl::atomic_prop_set::iterator i = ap->begin();
i != ap->end(); ++i)
(*i)->destroy();
if (opt_i && strcmp(opt_i, "-"))
{
dynamic_cast<std::ifstream*>(formula_file)->close();

View file

@ -25,9 +25,7 @@
#include <cstdlib>
#include <cstring>
#include "ltlparse/public.hh"
#include "ltlvisit/dump.hh"
#include "ltlvisit/dot.hh"
#include "ltlast/allnodes.hh"
void
syntax(char* prog)
@ -36,16 +34,6 @@ syntax(char* prog)
exit(2);
}
void
dump_instances(const std::string& label)
{
std::cerr << "=== " << label << " ===" << std::endl;
spot::ltl::atomic_prop::dump_instances(std::cerr);
spot::ltl::unop::dump_instances(std::cerr);
spot::ltl::binop::dump_instances(std::cerr);
spot::ltl::multop::dump_instances(std::cerr);
}
int
main(int argc, char** argv)
{
@ -55,7 +43,6 @@ main(int argc, char** argv)
syntax(argv[0]);
bool debug = false;
bool debug_ref = false;
int formula_index = 1;
if (!strcmp(argv[1], "-d"))
@ -65,47 +52,30 @@ main(int argc, char** argv)
syntax(argv[0]);
formula_index = 2;
}
else if (!strcmp(argv[1], "-r"))
{
debug_ref = true;
if (argc < 3)
syntax(argv[0]);
formula_index = 2;
}
spot::ltl::environment& env(spot::ltl::default_environment::instance());
spot::ltl::parse_error_list pel;
auto* f = spot::ltl::parse_infix_psl(argv[formula_index], pel, env, debug);
{
spot::ltl::environment& env(spot::ltl::default_environment::instance());
spot::ltl::parse_error_list pel;
auto f = spot::ltl::parse_infix_psl(argv[formula_index], pel, env, debug);
exit_code =
spot::ltl::format_parse_errors(std::cerr, argv[formula_index], pel);
exit_code =
spot::ltl::format_parse_errors(std::cerr, argv[formula_index], pel);
if (f)
{
if (debug_ref)
dump_instances("before");
if (f)
{
#ifdef DOTTY
spot::ltl::print_dot_psl(std::cout, f);
spot::ltl::print_dot_psl(std::cout, f);
#else
spot::ltl::dump(std::cout, f);
std::cout << std::endl;
f.dump(std::cout) << std::endl;
#endif
f->destroy();
}
else
{
exit_code = 1;
}
if (debug_ref)
dump_instances("after");
}
else
{
exit_code = 1;
}
assert(spot::ltl::atomic_prop::instance_count() == 0);
assert(spot::ltl::unop::instance_count() == 0);
assert(spot::ltl::binop::instance_count() == 0);
assert(spot::ltl::bunop::instance_count() == 0);
assert(spot::ltl::multop::instance_count() == 0);
}
assert(spot::ltl::fnode::instances_check());
return exit_code;
}

View file

@ -27,11 +27,9 @@
#include <string>
#include <cstring>
#include "ltlparse/public.hh"
#include "ltlvisit/dump.hh"
#include "ltlvisit/print.hh"
#include "ltlvisit/simplify.hh"
#include "ltlvisit/length.hh"
#include "ltlast/allnodes.hh"
void
syntax(char* prog)
@ -146,183 +144,170 @@ main(int argc, char** argv)
return 2;
}
spot::ltl::ltl_simplifier* simp = new spot::ltl::ltl_simplifier(o);
o.reduce_size_strictly = true;
spot::ltl::ltl_simplifier* simp_size = new spot::ltl::ltl_simplifier(o);
const spot::ltl::formula* f1 = 0;
const spot::ltl::formula* f2 = 0;
std::ifstream* fin = 0;
if (readfile)
{
fin = new std::ifstream(argv[2]);
if (!*fin)
{
std::cerr << "Cannot open " << argv[2] << std::endl;
exit(2);
}
}
int exit_code = 0;
next_line:
if (fin)
{
std::string input;
do
{
if (!std::getline(*fin, input))
goto end;
}
while (input == "");
spot::ltl::parse_error_list p1;
f1 = spot::ltl::parse_infix_psl(input, p1);
if (spot::ltl::format_parse_errors(std::cerr, input, p1))
return 2;
}
else
{
spot::ltl::parse_error_list p1;
f1 = spot::ltl::parse_infix_psl(argv[2], p1);
if (spot::ltl::format_parse_errors(std::cerr, argv[2], p1))
return 2;
}
if (argc == 4)
{
if (readfile)
{
std::cerr << "Cannot read from file and check result." << std::endl;
exit(2);
}
spot::ltl::parse_error_list p2;
f2 = spot::ltl::parse_infix_psl(argv[3], p2);
if (spot::ltl::format_parse_errors(std::cerr, argv[3], p2))
return 2;
}
{
const spot::ltl::formula* ftmp1;
spot::ltl::ltl_simplifier* simp = new spot::ltl::ltl_simplifier(o);
o.reduce_size_strictly = true;
spot::ltl::ltl_simplifier* simp_size = new spot::ltl::ltl_simplifier(o);
ftmp1 = f1;
f1 = simp_size->negative_normal_form(f1, false);
ftmp1->destroy();
spot::ltl::formula f1 = nullptr;
spot::ltl::formula f2 = nullptr;
int length_f1_before = spot::ltl::length(f1);
std::string f1s_before = spot::ltl::str_psl(f1);
std::string f1l;
std::ifstream* fin = 0;
const spot::ltl::formula* input_f = f1;
f1 = simp_size->simplify(input_f);
if (!simp_size->are_equivalent(input_f, f1))
if (readfile)
{
std::cerr << "Incorrect reduction from `" << f1s_before
<< "' to `";
print_psl(std::cerr, f1) << "'.\n";
exit_code = 3;
}
else
{
const spot::ltl::formula* maybe_larger = simp->simplify(input_f);
f1l = spot::ltl::str_psl(maybe_larger);
if (!simp->are_equivalent(input_f, maybe_larger))
fin = new std::ifstream(argv[2]);
if (!*fin)
{
std::cerr << "Incorrect reduction (reduce_size_strictly=0) from `"
<< f1s_before << "' to `" << f1l << "'." << std::endl;
exit_code = 3;
}
maybe_larger->destroy();
}
input_f->destroy();
int length_f1_after = spot::ltl::length(f1);
std::string f1s_after = spot::ltl::str_psl(f1);
std::string f2s = "";
if (f2)
{
ftmp1 = f2;
f2 = simp_size->negative_normal_form(f2, false);
ftmp1->destroy();
f2s = spot::ltl::str_psl(f2);
}
sum_before += length_f1_before;
sum_after += length_f1_after;
// If -h is set, we want to print only formulae that have become larger.
if (!f2 && (!hidereduc || (length_f1_after > length_f1_before)))
{
std::cout << length_f1_before << ' ' << length_f1_after
<< " '" << f1s_before << "' reduce to '" << f1s_after << '\'';
if (f1l != "" && f1l != f1s_after)
std::cout << " or (w/o rss) to '" << f1l << '\'';
std::cout << '\n';
}
if (f2)
{
if (f1 != f2)
{
if (length_f1_after < length_f1_before)
std::cout << f1s_before << " ** " << f2s << " ** " << f1s_after
<< " KOREDUC " << std::endl;
else
std::cout << f1s_before << " ** " << f2s << " ** " << f1s_after
<< " KOIDEM " << std::endl;
exit_code = 1;
}
else
{
if (f1s_before != f1s_after)
std::cout << f1s_before << " ** " << f2s << " ** " << f1s_after
<< " OKREDUC " << std::endl;
else
std::cout << f1s_before << " ** " << f2s << " ** " << f1s_after
<< " OKIDEM" << std::endl;
exit_code = 0;
std::cerr << "Cannot open " << argv[2] << std::endl;
exit(2);
}
}
else
{
if (length_f1_after > length_f1_before)
exit_code = 1;
}
f1->destroy();
if (f2)
f2->destroy();
next_line:
if (fin)
goto next_line;
}
end:
{
std::string input;
do
{
if (!std::getline(*fin, input))
goto end;
}
while (input == "");
delete simp_size;
delete simp;
spot::ltl::parse_error_list p1;
f1 = spot::ltl::parse_infix_psl(input, p1);
if (spot::ltl::format_parse_errors(std::cerr, input, p1))
return 2;
}
else
{
spot::ltl::parse_error_list p1;
f1 = spot::ltl::parse_infix_psl(argv[2], p1);
if (spot::ltl::format_parse_errors(std::cerr, argv[2], p1))
return 2;
}
if (argc == 4)
{
if (readfile)
{
std::cerr << "Cannot read from file and check result." << std::endl;
exit(2);
}
spot::ltl::parse_error_list p2;
f2 = spot::ltl::parse_infix_psl(argv[3], p2);
if (spot::ltl::format_parse_errors(std::cerr, argv[3], p2))
return 2;
}
if (fin)
{
float before = sum_before;
float after = sum_after;
std::cout << "gain: "
<< (1 - (after / before)) * 100 << '%' << std::endl;
delete fin;
}
spot::ltl::formula ftmp1;
spot::ltl::atomic_prop::dump_instances(std::cerr);
spot::ltl::unop::dump_instances(std::cerr);
spot::ltl::binop::dump_instances(std::cerr);
spot::ltl::multop::dump_instances(std::cerr);
assert(spot::ltl::atomic_prop::instance_count() == 0);
assert(spot::ltl::unop::instance_count() == 0);
assert(spot::ltl::binop::instance_count() == 0);
assert(spot::ltl::multop::instance_count() == 0);
ftmp1 = f1;
f1 = simp_size->negative_normal_form(f1, false);
int length_f1_before = spot::ltl::length(f1);
std::string f1s_before = spot::ltl::str_psl(f1);
std::string f1l;
spot::ltl::formula input_f = f1;
f1 = simp_size->simplify(input_f);
if (!simp_size->are_equivalent(input_f, f1))
{
std::cerr << "Incorrect reduction from `" << f1s_before
<< "' to `";
print_psl(std::cerr, f1) << "'.\n";
exit_code = 3;
}
else
{
spot::ltl::formula maybe_larger = simp->simplify(input_f);
f1l = spot::ltl::str_psl(maybe_larger);
if (!simp->are_equivalent(input_f, maybe_larger))
{
std::cerr << "Incorrect reduction (reduce_size_strictly=0) from `"
<< f1s_before << "' to `" << f1l << "'." << std::endl;
exit_code = 3;
}
}
int length_f1_after = spot::ltl::length(f1);
std::string f1s_after = spot::ltl::str_psl(f1);
std::string f2s = "";
if (f2)
{
ftmp1 = f2;
f2 = simp_size->negative_normal_form(f2, false);
f2s = spot::ltl::str_psl(f2);
}
sum_before += length_f1_before;
sum_after += length_f1_after;
// If -h is set, we want to print only formulae that have become larger.
if (!f2 && (!hidereduc || (length_f1_after > length_f1_before)))
{
std::cout << length_f1_before << ' ' << length_f1_after
<< " '" << f1s_before << "' reduce to '"
<< f1s_after << '\'';
if (f1l != "" && f1l != f1s_after)
std::cout << " or (w/o rss) to '" << f1l << '\'';
std::cout << '\n';
}
if (f2)
{
if (f1 != f2)
{
if (length_f1_after < length_f1_before)
std::cout << f1s_before << " ** " << f2s << " ** " << f1s_after
<< " KOREDUC " << std::endl;
else
std::cout << f1s_before << " ** " << f2s << " ** " << f1s_after
<< " KOIDEM " << std::endl;
exit_code = 1;
}
else
{
if (f1s_before != f1s_after)
std::cout << f1s_before << " ** " << f2s << " ** " << f1s_after
<< " OKREDUC " << std::endl;
else
std::cout << f1s_before << " ** " << f2s << " ** " << f1s_after
<< " OKIDEM" << std::endl;
exit_code = 0;
}
}
else
{
if (length_f1_after > length_f1_before)
exit_code = 1;
}
if (fin)
goto next_line;
}
end:
delete simp_size;
delete simp;
if (fin)
{
float before = sum_before;
float after = sum_after;
std::cout << "gain: "
<< (1 - (after / before)) * 100 << '%' << std::endl;
delete fin;
}
}
assert(spot::ltl::fnode::instances_check());
return exit_code;
}

View file

@ -24,10 +24,8 @@
#include <cassert>
#include <cstdlib>
#include "ltlparse/public.hh"
#include "ltlvisit/dump.hh"
#include "ltlvisit/print.hh"
#include "ltlvisit/simplify.hh"
#include "ltlast/allnodes.hh"
#include "ltlvisit/nenoform.hh"
void
@ -44,74 +42,66 @@ main(int argc, char** argv)
syntax(argv[0]);
int opt = atoi(argv[1]);
spot::ltl::parse_error_list p1;
auto* ftmp1 = spot::ltl::parse_infix_psl(argv[2], p1);
if (spot::ltl::format_parse_errors(std::cerr, argv[2], p1))
return 2;
spot::ltl::parse_error_list p2;
auto* ftmp2 = spot::ltl::parse_infix_psl(argv[3], p2);
if (spot::ltl::format_parse_errors(std::cerr, argv[3], p2))
return 2;
const spot::ltl::formula* f1 = spot::ltl::negative_normal_form(ftmp1);
const spot::ltl::formula* f2 = spot::ltl::negative_normal_form(ftmp2);
std::string f1s = spot::ltl::str_psl(f1);
std::string f2s = spot::ltl::str_psl(f2);
int exit_return = 0;
spot::ltl::ltl_simplifier* c = new spot::ltl::ltl_simplifier;
switch (opt)
{
case 0:
std::cout << "Test f1 < f2" << std::endl;
if (c->syntactic_implication(f1, f2))
{
std::cout << f1s << " < " << f2s << '\n';
exit_return = 1;
}
break;
{
spot::ltl::parse_error_list p1;
auto ftmp1 = spot::ltl::parse_infix_psl(argv[2], p1);
case 1:
std::cout << "Test !f1 < f2" << std::endl;
if (c->syntactic_implication_neg(f1, f2, false))
{
std::cout << "!(" << f1s << ") < " << f2s << '\n';
exit_return = 1;
}
break;
if (spot::ltl::format_parse_errors(std::cerr, argv[2], p1))
return 2;
case 2:
std::cout << "Test f1 < !f2" << std::endl;
if (c->syntactic_implication_neg(f1, f2, true))
{
std::cout << f1s << " < !(" << f2s << ")\n";
exit_return = 1;
}
break;
default:
break;
}
spot::ltl::parse_error_list p2;
auto ftmp2 = spot::ltl::parse_infix_psl(argv[3], p2);
spot::ltl::dump(std::cout, f1) << '\n';
spot::ltl::dump(std::cout, f2) << '\n';
if (spot::ltl::format_parse_errors(std::cerr, argv[3], p2))
return 2;
f1->destroy();
f2->destroy();
ftmp1->destroy();
ftmp2->destroy();
spot::ltl::formula f1 = spot::ltl::negative_normal_form(ftmp1);
spot::ltl::formula f2 = spot::ltl::negative_normal_form(ftmp2);
delete c;
std::string f1s = spot::ltl::str_psl(f1);
std::string f2s = spot::ltl::str_psl(f2);
assert(spot::ltl::atomic_prop::instance_count() == 0);
assert(spot::ltl::unop::instance_count() == 0);
assert(spot::ltl::binop::instance_count() == 0);
assert(spot::ltl::multop::instance_count() == 0);
spot::ltl::ltl_simplifier* c = new spot::ltl::ltl_simplifier;
switch (opt)
{
case 0:
std::cout << "Test f1 < f2" << std::endl;
if (c->syntactic_implication(f1, f2))
{
std::cout << f1s << " < " << f2s << '\n';
exit_return = 1;
}
break;
case 1:
std::cout << "Test !f1 < f2" << std::endl;
if (c->syntactic_implication_neg(f1, f2, false))
{
std::cout << "!(" << f1s << ") < " << f2s << '\n';
exit_return = 1;
}
break;
case 2:
std::cout << "Test f1 < !f2" << std::endl;
if (c->syntactic_implication_neg(f1, f2, true))
{
std::cout << f1s << " < !(" << f2s << ")\n";
exit_return = 1;
}
break;
default:
break;
}
f1.dump(std::cout) << '\n';
f2.dump(std::cout) << '\n';
delete c;
}
assert(spot::ltl::fnode::instances_check());
return exit_return;
}

View file

@ -1,5 +1,5 @@
// -*- coding: utf-8 -*-
// Copyright (C) 2009, 2014 Laboratoire de Recherche et Développement
// Copyright (C) 2009, 2014, 2015 Laboratoire de Recherche et Développement
// de l'Epita (LRDE).
//
// This file is part of Spot, a model checking library.
@ -21,7 +21,6 @@
#include <cassert>
#include "misc/hash.hh"
#include "ltlenv/defaultenv.hh"
#include "ltlast/allnodes.hh"
#include "twaalgos/dot.hh"
#include "twa/taatgba.hh"
@ -49,8 +48,6 @@ main()
spot::print_dot(std::cout, a);
}
assert(spot::ltl::atomic_prop::instance_count() == 0);
assert(spot::ltl::unop::instance_count() == 0);
assert(spot::ltl::binop::instance_count() == 0);
assert(spot::ltl::multop::instance_count() == 0);
assert(spot::ltl::fnode::instances_check());
return 0;
}

View file

@ -25,7 +25,6 @@
#include <cstdlib>
#include "ltlparse/public.hh"
#include "ltlvisit/print.hh"
#include "ltlast/allnodes.hh"
void
syntax(char *prog)
@ -40,42 +39,38 @@ main(int argc, char **argv)
if (argc != 2)
syntax(argv[0]);
spot::ltl::parse_error_list p1;
auto* f1 = spot::ltl::parse_infix_psl(argv[1], p1);
{
spot::ltl::parse_error_list p1;
auto f1 = spot::ltl::parse_infix_psl(argv[1], p1);
if (spot::ltl::format_parse_errors(std::cerr, argv[1], p1))
return 2;
if (spot::ltl::format_parse_errors(std::cerr, argv[1], p1))
return 2;
// The string generated from an abstract tree should be parsable
// again.
// The string generated from an abstract tree should be parsable
// again.
std::string f1s = spot::ltl::str_psl(f1);
std::cout << f1s << '\n';
std::string f1s = spot::ltl::str_psl(f1);
std::cout << f1s << '\n';
auto* f2 = spot::ltl::parse_infix_psl(f1s, p1);
auto f2 = spot::ltl::parse_infix_psl(f1s, p1);
if (spot::ltl::format_parse_errors(std::cerr, f1s, p1))
return 2;
if (spot::ltl::format_parse_errors(std::cerr, f1s, p1))
return 2;
// This second abstract tree should be equal to the first.
// This second abstract tree should be equal to the first.
if (f1 != f2)
return 1;
if (f1 != f2)
return 1;
// It should also map to the same string.
// It should also map to the same string.
std::string f2s = spot::ltl::str_psl(f2);
std::cout << f2s << '\n';
std::string f2s = spot::ltl::str_psl(f2);
std::cout << f2s << '\n';
if (f2s != f1s)
return 1;
if (f2s != f1s)
return 1;
}
f1->destroy();
f2->destroy();
assert(spot::ltl::atomic_prop::instance_count() == 0);
assert(spot::ltl::unop::instance_count() == 0);
assert(spot::ltl::binop::instance_count() == 0);
assert(spot::ltl::multop::instance_count() == 0);
assert(spot::ltl::bunop::instance_count() == 0);
assert(spot::ltl::fnode::instances_check());
return 0;
}

View file

@ -31,8 +31,8 @@ void f1()
bdd p2 = bdd_ithvar(tg->register_ap("p2"));
tg->acc().add_sets(2);
for (auto *f: tg->ap())
std::cout << f->name() << '\n';
for (auto f: tg->ap())
std::cout << f.ap_name() << '\n';
auto s1 = tg->new_state();
auto s2 = tg->new_state();

View file

@ -26,12 +26,12 @@ set -e
# ----
run 0 ../ltl2text '□◯a' >out
echo 'unop(G, unop(X, AP(a)))' > exp
echo 'G(@5 #0 [X(@4 #0 [AP(@3 #0 "a")])])' > exp
cmp out exp
# ----
run 0 ../ltl2text '□◯"αβγ"' >out
echo 'unop(G, unop(X, AP(αβγ)))' > exp
echo 'G(@5 #0 [X(@4 #0 [AP(@3 #0 "αβγ")])])' > exp
cmp out exp