Add an ltl2tgba option to read Kripke structure.
Also offers two ways to output Kripke structures. * src/kripketest/parse_print_test.cc, src/kripke/kripkeexplicit.cc : Simplify includes. * src/kripke/kripkeprint.hh (kripke_save_reachable, kripke_save_reachable_renumbered): New declarations. (KripkePrinter): Move and rename... * src/kripke/kripkeprint.cc (kripke_printer): ... here. (kripke_printer_renumbered): New class. (kripke_save_reachable, kripke_save_reachable_renumbered): New function. * src/tgbatest/ltl2tgba.cc: Add an option to read Kripke structures. * iface/dve2/dve2check.cc: Use kripke_save_reachable_renumbered. * iface/dve2/defs.in (run2): Remove. * iface/dve2/kripke.test: Adjust tests.
This commit is contained in:
parent
172ce2d7fd
commit
ba3108f98d
9 changed files with 188 additions and 118 deletions
|
|
@ -21,46 +21,120 @@
|
|||
|
||||
#include "kripkeprint.hh"
|
||||
#include "kripkeexplicit.hh"
|
||||
#include "../tgba/bddprint.hh"
|
||||
#include "tgba/bddprint.hh"
|
||||
#include "misc/escape.hh"
|
||||
#include "tgbaalgos/reachiter.hh"
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
namespace spot
|
||||
{
|
||||
KripkePrinter::KripkePrinter(const kripke* automata,
|
||||
std::ostream& os)
|
||||
: tgba_reachable_iterator_breadth_first(automata), os_(os)
|
||||
namespace
|
||||
{
|
||||
}
|
||||
|
||||
void KripkePrinter::start()
|
||||
{
|
||||
}
|
||||
|
||||
void KripkePrinter::process_state(const state* s,
|
||||
int,
|
||||
tgba_succ_iterator* si)
|
||||
{
|
||||
const bdd_dict* d = automata_->get_dict();
|
||||
std::string cur = automata_->format_state(s);
|
||||
os_ << "\"";
|
||||
escape_str(os_, automata_->format_state(s));
|
||||
os_ << "\", \"";
|
||||
const kripke* automata = down_cast<const kripke*>
|
||||
(automata_);
|
||||
assert(automata);
|
||||
escape_str(os_, bdd_format_formula(d,
|
||||
automata->state_condition(s)));
|
||||
|
||||
os_ << "\",";
|
||||
for (si->first(); !si->done(); si->next())
|
||||
class kripke_printer : public tgba_reachable_iterator_breadth_first
|
||||
{
|
||||
state* dest = si->current_state();
|
||||
os_ << " \"";
|
||||
escape_str(os_, automata_->format_state(dest));
|
||||
os_ << "\"";
|
||||
}
|
||||
os_ << ";" << std::endl;
|
||||
public:
|
||||
kripke_printer(const kripke* a, std::ostream& os)
|
||||
: tgba_reachable_iterator_breadth_first(a), os_(os)
|
||||
{
|
||||
}
|
||||
|
||||
void process_state(const state* s, int, tgba_succ_iterator* si)
|
||||
{
|
||||
const bdd_dict* d = automata_->get_dict();
|
||||
os_ << "\"";
|
||||
escape_str(os_, automata_->format_state(s));
|
||||
os_ << "\", \"";
|
||||
const kripke* automata = down_cast<const kripke*> (automata_);
|
||||
assert(automata);
|
||||
escape_str(os_, bdd_format_formula(d,
|
||||
automata->state_condition(s)));
|
||||
|
||||
os_ << "\",";
|
||||
for (si->first(); !si->done(); si->next())
|
||||
{
|
||||
state* dest = si->current_state();
|
||||
os_ << " \"";
|
||||
escape_str(os_, automata_->format_state(dest));
|
||||
os_ << "\"";
|
||||
}
|
||||
os_ << ";\n";
|
||||
}
|
||||
|
||||
private:
|
||||
std::ostream& os_;
|
||||
};
|
||||
|
||||
class kripke_printer_renumbered :
|
||||
public tgba_reachable_iterator_breadth_first
|
||||
{
|
||||
public:
|
||||
kripke_printer_renumbered(const kripke* a, std::ostream& os)
|
||||
: tgba_reachable_iterator_breadth_first(a), os_(os),
|
||||
notfirst(false)
|
||||
{
|
||||
}
|
||||
|
||||
void finish_state()
|
||||
{
|
||||
os_ << lastsuccs.str() << ";\n";
|
||||
lastsuccs.str("");
|
||||
}
|
||||
|
||||
void process_state(const state* s, int in_s, tgba_succ_iterator*)
|
||||
{
|
||||
if (notfirst)
|
||||
finish_state();
|
||||
else
|
||||
notfirst = true;
|
||||
|
||||
const bdd_dict* d = automata_->get_dict();
|
||||
std::string cur = automata_->format_state(s);
|
||||
os_ << "S" << in_s << ", \"";
|
||||
const kripke* automata = down_cast<const kripke*>(automata_);
|
||||
assert(automata);
|
||||
escape_str(os_, bdd_format_formula(d,
|
||||
automata->state_condition(s)));
|
||||
os_ << "\",";
|
||||
}
|
||||
|
||||
void
|
||||
process_link(const state*, int, const state*, int d,
|
||||
const tgba_succ_iterator*)
|
||||
{
|
||||
lastsuccs << " S" << d;
|
||||
}
|
||||
|
||||
void
|
||||
end()
|
||||
{
|
||||
finish_state();
|
||||
}
|
||||
|
||||
private:
|
||||
std::ostream& os_;
|
||||
std::ostringstream lastsuccs;
|
||||
bool notfirst;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
std::ostream&
|
||||
kripke_save_reachable(std::ostream& os, const kripke* k)
|
||||
{
|
||||
kripke_printer p(k, os);
|
||||
p.run();
|
||||
return os;
|
||||
}
|
||||
|
||||
std::ostream&
|
||||
kripke_save_reachable_renumbered(std::ostream& os, const kripke* k)
|
||||
{
|
||||
kripke_printer_renumbered p(k, os);
|
||||
p.run();
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
} // End namespace Spot
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue