Commit 788ed772 authored by martinez's avatar martinez
Browse files

* src/ltlvisit/basereduc.cc (spot): 80 columns.

* src/ltlvisit/reducform.cc (spot), src/ltltest/inf.cc,
src/ltltest/reduc.cc (main), src/ltlvisit/reducform.hh,
src/tgbatest/ltl2tgba.cc (main): More option.
* src/ltltest/inf.test: More test.
parent 41589e28
2004-05-17 Thomas Martinez <martinez@src.lip6.fr>
* src/ltlvisit/basereduc.cc (spot): 80 columns.
* src/ltlvisit/reducform.cc (spot), src/ltltest/inf.cc,
src/ltltest/reduc.cc (main), src/ltlvisit/reducform.hh,
src/tgbatest/ltl2tgba.cc (main): More option.
* src/ltltest/inf.test: More test.
2004-05-17 Alexandre Duret-Lutz <adl@src.lip6.fr>
* wrap/python/buddy.i: Define typemap for input_buf and use it
......
......@@ -41,21 +41,22 @@ syntax(char* prog)
int
main(int argc, char** argv)
{
if (argc < 3)
if (argc < 4)
syntax(argv[0]);
int opt = atoi(argv[1]);
spot::ltl::parse_error_list p1;
spot::ltl::formula* f1 = spot::ltl::parse(argv[1], p1);
spot::ltl::formula* f1 = spot::ltl::parse(argv[2], p1);
spot::ltl::formula* f2 = NULL;
if (spot::ltl::format_parse_errors(std::cerr, argv[1], p1))
if (spot::ltl::format_parse_errors(std::cerr, argv[2], p1))
return 2;
spot::ltl::parse_error_list p2;
f2 = spot::ltl::parse(argv[2], p2);
f2 = spot::ltl::parse(argv[3], p2);
if (spot::ltl::format_parse_errors(std::cerr, argv[2], p2))
if (spot::ltl::format_parse_errors(std::cerr, argv[3], p2))
return 2;
std::string f1s = spot::ltl::to_string(f1);
......@@ -63,29 +64,37 @@ main(int argc, char** argv)
int exit_return = 0;
std::cout << "Test f1 < f2" << std::endl;
if (spot::ltl::inf_form(f1, f2))
switch (opt)
{
std::cout << f1s << " < " << f2s << std::endl;
exit_return = 1;
case 0:
std::cout << "Test f1 < f2" << std::endl;
if (spot::ltl::inf_form(f1, f2))
{
std::cout << f1s << " < " << f2s << std::endl;
exit_return = 1;
}
break;
case 1:
std::cout << "Test !f1 < f2" << std::endl;
if (spot::ltl::infneg_form(f1, f2, 0))
{
std::cout << "!(" << f1s << ") < " << f2s << std::endl;
exit_return = 1;
}
break;
case 2:
std::cout << "Test f1 < !f2" << std::endl;
if (spot::ltl::infneg_form(f1, f2, 1))
{
std::cout << f1s << " < !(" << f2s << ")" << std::endl;
exit_return = 1;
}
break;
default: break;
}
/*
std::cout << "Test !f1 < f2" << std::endl;
if (spot::ltl::infneg_form(f1, f2, 0))
{
std::cout << "!(" << f1s << ") < " << f2s << std::endl;
exit_return = 2;
}
std::cout << "Test f1 < !f2" << std::endl;
if (spot::ltl::infneg_form(f1, f2, 1))
{
std::cout << f1s << " < !(" << f2s << ")" << std::endl;
exit_return = 3;
}
*/
spot::ltl::dump(std::cout, f1); std::cout << std::endl;
spot::ltl::dump(std::cout, f2); std::cout << std::endl;
......
......@@ -26,67 +26,67 @@
. ./defs || exit 1
#
run 1 ./inf 'Xa' 'X(b U a)'
run 1 ./inf 'XXa' 'XX(b U a)'
run 1 ./inf 0 'Xa' 'X(b U a)'
run 1 ./inf 0 'XXa' 'XX(b U a)'
run 1 ./inf '(e R f)' '(g U f)'
run 1 ./inf '( X(a + b))' '( X((a + b)+(c)+(d)))'
run 1 ./inf '( X(a + b)) U (e R f)' '( X((a + b)+(c)+(d))) U (g U f)'
run 1 ./inf 0 '(e R f)' '(g U f)'
run 1 ./inf 0 '( X(a + b))' '( X((a + b)+(c)+(d)))'
run 1 ./inf 0 '( X(a + b)) U (e R f)' '( X((a + b)+(c)+(d))) U (g U f)'
run 0 ./inf 'Xa' 'XX(b U a)'
run 0 ./inf 'XXa' 'X(b U a)'
run 0 ./inf 0 'Xa' 'XX(b U a)'
run 0 ./inf 0 'XXa' 'X(b U a)'
run 0 ./inf '( X(a + b))' '( X(X(a + b)+(c)+(d)))'
run 0 ./inf '( X(a + b)) U (e R f)' '( X(X(a + b)+(c)+(d))) U (g U f)'
run 0 ./inf 0 '( X(a + b))' '( X(X(a + b)+(c)+(d)))'
run 0 ./inf 0 '( X(a + b)) U (e R f)' '( X(X(a + b)+(c)+(d))) U (g U f)'
run 0 ./inf 'a' 'b'
run 0 ./inf 'a' 'b + c'
run 0 ./inf 'a + b' 'a'
run 0 ./inf 'a' 'a * c'
run 0 ./inf 'a * b' 'c'
run 0 ./inf 'a' 'a U b'
run 0 ./inf 'a' 'a R b'
run 0 ./inf 'a R b' 'a'
run 0 ./inf 0 'a' 'b'
run 0 ./inf 0 'a' 'b + c'
run 0 ./inf 0 'a + b' 'a'
run 0 ./inf 0 'a' 'a * c'
run 0 ./inf 0 'a * b' 'c'
run 0 ./inf 0 'a' 'a U b'
run 0 ./inf 0 'a' 'a R b'
run 0 ./inf 0 'a R b' 'a'
run 1 ./inf '1' '1'
run 1 ./inf '0' '0'
run 1 ./inf 0 '1' '1'
run 1 ./inf 0 '0' '0'
run 1 ./inf 'a' '1'
run 1 ./inf 'a' 'a'
run 1 ./inf 0 'a' '1'
run 1 ./inf 0 'a' 'a'
run 1 ./inf 'a' 'a * 1'
run 1 ./inf 0 'a' 'a * 1'
run 1 ./inf 'a * b' 'b'
run 1 ./inf 'a * b' 'a'
run 1 ./inf 0 'a * b' 'b'
run 1 ./inf 0 'a * b' 'a'
run 1 ./inf 'a' 'a + b'
run 1 ./inf 'b' 'a + b'
run 1 ./inf 0 'a' 'a + b'
run 1 ./inf 0 'b' 'a + b'
run 1 ./inf 'a + b' '1'
run 1 ./inf 0 'a + b' '1'
run 1 ./inf 'a' 'b U a'
run 1 ./inf 'a' 'b U 1'
run 1 ./inf 'a U b' '1'
run 1 ./inf 0 'a' 'b U a'
run 1 ./inf 0 'a' 'b U 1'
run 1 ./inf 0 'a U b' '1'
run 1 ./inf 'a' '1 R a'
run 1 ./inf 'a' 'a R 1'
run 1 ./inf 'a R b' 'b'
run 1 ./inf 'a R b' '1'
run 1 ./inf 0 'a' '1 R a'
run 1 ./inf 0 'a' 'a R 1'
run 1 ./inf 0 'a R b' 'b'
run 1 ./inf 0 'a R b' '1'
run 1 ./inf 'Xa' 'X(b U a)'
run 1 ./inf 'X(a R b)' 'Xb'
run 1 ./inf 0 'Xa' 'X(b U a)'
run 1 ./inf 0 'X(a R b)' 'Xb'
run 1 ./inf 'a U b' '1 U b'
run 1 ./inf 'a R b' '1 R b'
run 1 ./inf 0 'a U b' '1 U b'
run 1 ./inf 0 'a R b' '1 R b'
run 1 ./inf 'b * (a U b)' 'a U b'
run 1 ./inf 'a U b' 'c + (a U b)'
run 1 ./inf 0 'b * (a U b)' 'a U b'
run 1 ./inf 0 'a U b' 'c + (a U b)'
exit 0
#
#run 1 ./inf '(a U b) U ((a U b) U (a U b))' 'a U b'
#run 1 ./inf '(a U b) && (a U b)' 'a U b'
#run 1 ./inf 0 '(a U b) U ((a U b) U (a U b))' 'a U b'
#run 1 ./inf 0 '(a U b) && (a U b)' 'a U b'
'X1' '1'
'a U 0' '0'
......
......@@ -59,6 +59,15 @@ main(int argc, char** argv)
case 3:
o = spot::ltl::BRI;
break;
case 4:
o = spot::ltl::InfBase;
break;
case 5:
o = spot::ltl::EventualUniversalBase;
break;
case 6:
o = spot::ltl::InfEventualUniversal;
break;
default:
return 2;
}
......
This diff is collapsed.
......@@ -91,13 +91,13 @@ namespace spot
case unop::F:
/* If f is class of eventuality then F(f)=f. */
if (!is_eventual(result_) || (o == Inf))
if (!is_eventual(result_) || o == Inf || o == InfBase)
result_ = unop::instance(unop::F, result_);
return;
case unop::G:
/* If f is class of universality then G(f)=f. */
if (!is_universal(result_) || (o == Inf))
if (!is_universal(result_) || o == Inf || o == InfBase)
result_ = unop::instance(unop::G, result_);
return;
}
......@@ -112,7 +112,7 @@ namespace spot
/* If b is of class eventuality then a U b = b.
If b is of class universality then a R b = b. */
if ((o != Inf)
if ((o != Inf) && (o != InfBase)
&& ((is_eventual(f2) && ((bo->op()) == binop::U))
|| (is_universal(f2) && ((bo->op()) == binop::R))))
{
......@@ -122,7 +122,7 @@ namespace spot
/* case of implies */
formula* f1 = recurse(bo->first());
if (o != EventualUniversal)
if (o != EventualUniversal && o != EventualUniversalBase)
{
bool inf = inf_form(f1, f2);
bool infinv = inf_form(f2, f1);
......@@ -206,7 +206,7 @@ namespace spot
for (unsigned i = 0; i < mos; ++i)
res->push_back(recurse(mo->nth(i)));
if (o != EventualUniversal)
if (o != EventualUniversal && o != EventualUniversalBase)
{
switch (mo->op())
{
......@@ -312,7 +312,8 @@ namespace spot
spot::ltl::formula* ftmp2 = NULL;
reduce_form_visitor v(o);
if (o == BRI)
if (o == BRI || o == InfBase ||
o == EventualUniversalBase)
{
ftmp1 = spot::ltl::basic_reduce_form(f);
const_cast<formula*>(ftmp1)->accept(v);
......@@ -350,11 +351,20 @@ namespace spot
case Inf:
ftmp3 = spot::ltl::reduce_form(ftmp2, o);
break;
case InfBase:
ftmp3 = spot::ltl::reduce_form(ftmp2, o);
break;
case EventualUniversal:
ftmp3 = spot::ltl::reduce_form(ftmp2, o);
break;
case EventualUniversalBase:
ftmp3 = spot::ltl::reduce_form(ftmp2, o);
break;
case InfEventualUniversal:
ftmp3 = spot::ltl::reduce_form(ftmp2, o);
break;
case BRI:
ftmp3 = spot::ltl::reduce_form(ftmp2);
ftmp3 = spot::ltl::reduce_form(ftmp2, o);
break;
default:
assert(0);
......
......@@ -42,7 +42,13 @@ namespace spot
/// EventualUniversal for spot::ltl::reduce_eventuality_universality_form,
/// BRI for spot::ltl::reduce_form.
enum option {Base, Inf, EventualUniversal, BRI};
enum option {Base,
Inf,
InfBase,
EventualUniversal,
EventualUniversalBase,
InfEventualUniversal,
BRI};
formula* reduce(const formula* f, option o = BRI);
/// Implement basic rewriting.
......
......@@ -352,12 +352,19 @@ main(int argc, char** argv)
else if (reduc_r1 | reduc_r2 | reduc_r3)
{
spot::ltl::option o = spot::ltl::BRI;
if (reduc_r1)
if (reduc_r1 & !reduc_r2 & !reduc_r3)
o = spot::ltl::Base;
if (reduc_r2)
if (!reduc_r1 & reduc_r2 & !reduc_r3)
o = spot::ltl::EventualUniversal;
if (reduc_r3)
if (reduc_r1 & reduc_r2 & !reduc_r3)
o = spot::ltl::EventualUniversalBase;
if (!reduc_r1 & !reduc_r2 & reduc_r3)
o = spot::ltl::Inf;
if (reduc_r1 & !reduc_r2 & reduc_r3)
o = spot::ltl::InfBase;
if (!reduc_r1 & reduc_r2 & reduc_r3)
o = spot::ltl::InfEventualUniversal;
f = spot::ltl::reduce(f, o);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment