spot/bench/stutter/stutter_invariance_formulas.cc
Thibaud Michaud 37bcb5d959 Adding tgba-based stutter-invariance checking
* src/tgbaalgos/closure.cc, src/tgbaalgos/closure.hh:
Add closure function.
* src/tgbaalgos/stutterize.cc, src/tgbaalgos/stutterize.hh:
Add two implementations of "self-loopize" function.
* src/tgbaalgos/Makefile.am: Add them.
* src/tgba/tgbasl.cc, src/tgba/tgbasl.hh: On-the-fly implementation of
self-loopize.
* src/tgba/Makefile.am: Add it.
* src/tgbatest/ltl2tgba.cc, src/tgbatest/stutter_invariant.test: Test
closure and sl.
* src/tgbatest/Makefile.am: Adjust.
* src/bin/ltlfilt.cc: Modify stutter-invariant option to use
automaton-based checking rather than syntactic-based checking.
* src/ltlvisit/remove_x.cc, src/ltlvisit/remove_x.hh:
Remove is_stutter_insensitive function.
* src/tgbaalgos/stutter_invariance.cc,
src/tgbaalgos/stutter_invariance.hh: Check if a formula is
stutter-invariant using closure and sl.
* wrap/python/spot.i: Add closure and sl bindings.
* bench/stutter/stutter_invariance_formulas.cc: Generate benchmarks from
given formulas.
* bench/stutter/stutter_invariance_randomgraph.cc: Generate benchmarks
from random automata.
* bench/stutter/Makefile.am: Add them.
* configure.ac: Add bench/stutter/Makefile.
* bench/Makefile.am: Add stutter subdirectory.
* README: Document bench/stutter directory.
2014-11-14 11:11:39 +01:00

128 lines
3.4 KiB
C++

// -*- coding: utf-8 -*-
// Copyright (C) 2014 Laboratoire de Recherche et
// Développement de l'Epita (LRDE).
//
// This file is part of Spot, a model checking library.
//
// Spot is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3 of the License, or
// (at your option) any later version.
//
// Spot is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
// License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "bin/common_sys.hh"
#include "bin/common_setup.hh"
#include "bin/common_finput.hh"
#include "bin/common_output.hh"
#include "tgbaalgos/translate.hh"
#include "tgbaalgos/stutter_invariance.hh"
#include "ltlast/allnodes.hh"
#include "ltlvisit/apcollect.hh"
#include "ltlvisit/length.hh"
#include "misc/timer.hh"
#include <argp.h>
#include "error.h"
#include "tgbaalgos/closure.hh"
#include "tgbaalgos/stutterize.hh"
#include "tgbaalgos/dotty.hh"
#include "tgba/tgbaproduct.hh"
static unsigned n = 10;
const char argp_program_doc[] ="";
const struct argp_child children[] =
{
{ &finput_argp, 0, 0, 1 },
{ &output_argp, 0, 0, -20 },
{ &misc_argp, 0, 0, -1 },
{ 0, 0, 0, 0 }
};
namespace
{
class stut_processor: public job_processor
{
public:
spot::translator& trans;
std::string formula;
stut_processor(spot::translator& trans) : trans(trans)
{
}
int
process_string(const std::string& input,
const char* filename, int linenum)
{
formula = input;
return job_processor::process_string(input, filename, linenum);
}
int
process_formula(const spot::ltl::formula* f,
const char*, int)
{
const spot::ltl::formula* nf =
spot::ltl::unop::instance(spot::ltl::unop::Not,
f->clone());
spot::const_tgba_digraph_ptr a = trans.run(f);
spot::const_tgba_digraph_ptr na = trans.run(nf);
spot::ltl::atomic_prop_set* ap = spot::ltl::atomic_prop_collect(f);
bdd apdict = spot::ltl::atomic_prop_collect_as_bdd(f, a);
bool res;
bool prev = true;
for (char algo = '1'; algo <= '8'; ++algo)
{
// set SPOT_STUTTER_CHECK environment variable
char algostr[2] = { 0 };
algostr[0] = algo;
setenv("SPOT_STUTTER_CHECK", algostr, true);
spot::stopwatch sw;
sw.start();
for (unsigned i = 0; i < n; ++i)
res = spot::is_stutter_invariant(a, na, apdict);
const double time = sw.stop();
std::cout << formula << ", " << algo << ", " << ap->size() << ", "
<< a->num_states() << ", " << res << ", " << time << std::endl;
if (algo > '1')
assert(res == prev);
prev = res;
}
f->destroy();
nf->destroy();
delete(ap);
return 0;
}
};
}
int
main(int argc, char** argv)
{
setup(argv);
const argp ap = { 0, 0, "[FILENAME[/COL]...]",
argp_program_doc, children, 0, 0 };
if (int err = argp_parse(&ap, argc, argv, ARGP_NO_HELP, 0, 0))
exit(err);
spot::translator trans;
stut_processor processor(trans);
if (processor.run())
return 2;
return 0;
}