* src/tgbatest/emptinesscheckexplicit.test (acc): New file.
* src/tgbatest/emptinesscheckexplicit.cc (main): New file. * src/tgbatest/emptinesscheck.test: New file. * src/tgbatest/emptinesscheck.cc (main): New file. * src/tgbaalgos/emptinesscheck.cc (spot): New method. * src/tgbaalgos/emptinesscheck.hh: New interface.
This commit is contained in:
parent
83565fb659
commit
7f3c113130
9 changed files with 964 additions and 0 deletions
|
|
@ -6,6 +6,8 @@ check_SCRIPTS = defs
|
|||
check_PROGRAMS = \
|
||||
bddprod \
|
||||
explicit \
|
||||
emptinesscheck \
|
||||
emptinesscheckexplicit \
|
||||
explprod \
|
||||
ltl2tgba \
|
||||
ltlmagic \
|
||||
|
|
@ -18,6 +20,8 @@ check_PROGRAMS = \
|
|||
# Keep this sorted alphabetically.
|
||||
bddprod_SOURCES = ltlprod.cc
|
||||
bddprod_CXXFLAGS = -DBDD_CONCRETE_PRODUCT
|
||||
emptinesscheck_SOURCES = emptinesscheck.cc
|
||||
emptinesscheckexplicit_SOURCES = emptinesscheckexplicit.cc
|
||||
explicit_SOURCES = explicit.cc
|
||||
explprod_SOURCES = explprod.cc
|
||||
ltl2tgba_SOURCES = ltl2tgba.cc
|
||||
|
|
@ -42,6 +46,8 @@ TESTS = \
|
|||
explpro3.test \
|
||||
tripprod.test \
|
||||
mixprod.test \
|
||||
emptinesscheck.test \
|
||||
emptinesscheckexplicit.test \
|
||||
ltlmagic.test \
|
||||
spotlbtt.test
|
||||
|
||||
|
|
|
|||
145
src/tgbatest/emptinesscheck.cc
Normal file
145
src/tgbatest/emptinesscheck.cc
Normal file
|
|
@ -0,0 +1,145 @@
|
|||
|
||||
#include <iostream>
|
||||
#include <cassert>
|
||||
#include "ltlvisit/destroy.hh"
|
||||
#include "ltlast/allnodes.hh"
|
||||
#include "ltlparse/public.hh"
|
||||
#include "tgbaalgos/ltl2tgba_fm.hh"
|
||||
#include "tgbaalgos/emptinesscheck.hh"
|
||||
#include "tgba/bddprint.hh"
|
||||
//#include "tgba/tgbabddtranslatefactory.hh"
|
||||
#include "tgbaalgos/dotty.hh"
|
||||
|
||||
void
|
||||
syntax(char* prog)
|
||||
{ std::cerr << "Usage: "<< prog << " [OPTIONS...] formula" << std::endl
|
||||
<< std::endl
|
||||
<< "Options:" << std::endl
|
||||
<< " -a display the accepting_conditions BDD, not the reachability graph"
|
||||
<< std::endl
|
||||
<< " -A same as -a, but as a set" << std::endl
|
||||
<< " -d turn on traces during parsing" << std::endl
|
||||
<< " -c emptinesschecking + counter example" << std::endl
|
||||
<< " -e emptinesschecking for the automaton" << std::endl
|
||||
<< " -o re-order BDD variables in the automata" << std::endl
|
||||
<< std::endl
|
||||
<< " -r display the relation BDD, not the reachability graph"
|
||||
<< std::endl
|
||||
<< " -R same as -r, but as a set" << std::endl
|
||||
<< " -v display the BDD variables used by the automaton"
|
||||
<< std::endl;
|
||||
exit(2);
|
||||
}
|
||||
|
||||
std::string
|
||||
print_emptiness_check_ans (bool ans)
|
||||
{
|
||||
if (ans)
|
||||
{
|
||||
return "EMPTY-LANGAGE";
|
||||
}
|
||||
else
|
||||
{
|
||||
return "CONSISTENT-AUTOMATA";
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char** argv)
|
||||
{
|
||||
int exit_code = 0;
|
||||
|
||||
bool debug_opt = false;
|
||||
bool defrag_opt = false;
|
||||
spot::emptiness_check* empty_check = new spot::emptiness_check();
|
||||
bool emptiness = true;
|
||||
int output = 0;
|
||||
int formula_index = 0;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
if (argc < formula_index + 2)
|
||||
syntax(argv[0]);
|
||||
|
||||
++formula_index;
|
||||
|
||||
if (!strcmp(argv[formula_index], "-a"))
|
||||
{
|
||||
output = 2;
|
||||
}
|
||||
else if (!strcmp(argv[formula_index], "-A"))
|
||||
{
|
||||
output = 4;
|
||||
}
|
||||
else if (!strcmp(argv[formula_index], "-d"))
|
||||
{
|
||||
debug_opt = true;
|
||||
}
|
||||
else if (!strcmp(argv[formula_index], "-e"))
|
||||
{
|
||||
output = 6;
|
||||
}
|
||||
else if (!strcmp(argv[formula_index], "-c"))
|
||||
{
|
||||
output = 7;
|
||||
}
|
||||
else if (!strcmp(argv[formula_index], "-o"))
|
||||
{
|
||||
defrag_opt = true;
|
||||
}
|
||||
else if (!strcmp(argv[formula_index], "-r"))
|
||||
{
|
||||
output = 1;
|
||||
}
|
||||
else if (!strcmp(argv[formula_index], "-R"))
|
||||
{
|
||||
output = 3;
|
||||
}
|
||||
else if (!strcmp(argv[formula_index], "-v"))
|
||||
{
|
||||
output = 5;
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
spot::ltl::environment& env(spot::ltl::default_environment::instance());
|
||||
spot::ltl::parse_error_list pel;
|
||||
spot::ltl::formula* f = spot::ltl::parse(argv[formula_index],
|
||||
pel, env, debug_opt);
|
||||
|
||||
exit_code = spot::ltl::format_parse_errors(std::cerr, argv[formula_index], pel);
|
||||
spot::bdd_dict* dict = new spot::bdd_dict();
|
||||
if (f)
|
||||
{
|
||||
spot::tgba_explicit* a = spot::ltl_to_tgba_fm(f, dict);
|
||||
spot::ltl::destroy(f);
|
||||
switch (output)
|
||||
{
|
||||
case 6:
|
||||
emptiness = empty_check->tgba_emptiness_check(a);
|
||||
std::cout << print_emptiness_check_ans(emptiness) << std::endl;
|
||||
break;
|
||||
case 7:
|
||||
empty_check->counter_example(a);
|
||||
break;
|
||||
default:
|
||||
assert(!"unknown output option");
|
||||
}
|
||||
delete a;
|
||||
delete empty_check;
|
||||
}
|
||||
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::multop::instance_count() == 0);
|
||||
delete dict;
|
||||
return exit_code;
|
||||
}
|
||||
20
src/tgbatest/emptinesscheck.test
Executable file
20
src/tgbatest/emptinesscheck.test
Executable file
|
|
@ -0,0 +1,20 @@
|
|||
#!/bin/sh
|
||||
|
||||
. ./defs
|
||||
|
||||
set -e
|
||||
|
||||
# We don't check the output, but just running these might be enough to
|
||||
# trigger assertions.
|
||||
|
||||
./emptinesscheck -e 'a'
|
||||
./emptinesscheck -e 'a U b'
|
||||
./emptinesscheck -e 'X a'
|
||||
./emptinesscheck -e 'a & b & c'
|
||||
./emptinesscheck -e 'a | b | (c U (d & (g U (h ^ i))))'
|
||||
./emptinesscheck -e 'Xa & (b U !a) & (b U !a)'
|
||||
./emptinesscheck -e 'Fa & Xb & GFc & Gd'
|
||||
./emptinesscheck -e 'Fa & Xa & GFc & Gc'
|
||||
./emptinesscheck -e 'Fc & X(a | Xb) & GF(a | Xb) & Gc'
|
||||
./emptinesscheck -e '!((FF a) <=> (F x))'
|
||||
./emptinesscheck -e '!((FF a) <=> (F a))'
|
||||
46
src/tgbatest/emptinesscheckexplicit.cc
Normal file
46
src/tgbatest/emptinesscheckexplicit.cc
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
#include <iostream>
|
||||
#include "tgbaparse/public.hh"
|
||||
#include "tgba/tgbaexplicit.hh"
|
||||
#include "tgbaalgos/dotty.hh"
|
||||
#include "tgbaalgos/emptinesscheck.hh"
|
||||
|
||||
void
|
||||
syntax(char* prog)
|
||||
{
|
||||
std::cerr << prog << " [-d] filename" << std::endl;
|
||||
exit(2);
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char** argv)
|
||||
{
|
||||
int exit_code = 0;
|
||||
|
||||
if (argc < 2)
|
||||
syntax(argv[0]);
|
||||
|
||||
bool debug = false;
|
||||
int filename_index = 1;
|
||||
bool emptiness = false;
|
||||
|
||||
if (!strcmp(argv[1], "-d"))
|
||||
{
|
||||
debug = true;
|
||||
if (argc < 3)
|
||||
syntax(argv[0]);
|
||||
filename_index = 2;
|
||||
}
|
||||
|
||||
spot::ltl::environment& env(spot::ltl::default_environment::instance());
|
||||
spot::tgba_parse_error_list pel;
|
||||
spot::bdd_dict* dict = new spot::bdd_dict();
|
||||
spot::tgba_explicit* a = spot::tgba_parse(argv[filename_index],
|
||||
pel, dict, env, debug);
|
||||
spot::emptiness_check empty_check;
|
||||
|
||||
if (spot::format_tgba_parse_errors(std::cerr, pel))
|
||||
return 2;
|
||||
empty_check.counter_example(a);
|
||||
delete a;
|
||||
return 0;
|
||||
}
|
||||
14
src/tgbatest/emptinesscheckexplicit.test
Executable file
14
src/tgbatest/emptinesscheckexplicit.test
Executable file
|
|
@ -0,0 +1,14 @@
|
|||
#!/bin/sh
|
||||
|
||||
. ./defs
|
||||
|
||||
set -e
|
||||
|
||||
cat >input <<'EOF'
|
||||
acc = c d;
|
||||
s1, "s2", a!b, c d;
|
||||
"s2", "state 3", a, c;
|
||||
"state 3", s1,,;
|
||||
EOF
|
||||
|
||||
./emptinesscheckexplicit input > stdout
|
||||
Loading…
Add table
Add a link
Reference in a new issue