32 std::vector<uint>& acceptanceConditions) {
35 spot::twa_graph_ptr productAutomaton;
36 spot::bdd_dict_ptr dict = spot::make_bdd_dict();
39 for (
const std::shared_ptr<const storm::logic::Formula>& subFormula : formula.
getSubformulas()) {
41 STORM_LOG_ASSERT(subFormula->isProbabilityOperatorFormula(),
"subformula " << *subFormula <<
" has unexpected type.");
42 auto const& pathFormula = subFormula->asProbabilityOperatorFormula().getSubformula().asPathFormula();
48 std::string prefixLtl = ltlFormula1->toPrefixString();
49 spot::parsed_formula spotPrefixLtl = spot::parse_prefix_ltl(prefixLtl);
50 if (!spotPrefixLtl.errors.empty()) {
51 std::ostringstream errorMsg;
52 spotPrefixLtl.format_errors(errorMsg);
53 STORM_LOG_THROW(
false, storm::exceptions::ExpressionEvaluationException,
"Spot could not parse formula: " << prefixLtl <<
": " << errorMsg.str());
55 spot::formula spotFormula = spotPrefixLtl.f;
58 spot::translator trans = spot::translator(dict);
59 trans.set_type(spot::postprocessor::Parity);
60 trans.set_pref(spot::postprocessor::Deterministic | spot::postprocessor::SBAcc | spot::postprocessor::Complete | spot::postprocessor::Colored);
62 auto aut = trans.run(spotFormula);
64 acceptanceConditions.push_back(countAccept);
65 countAccept += aut->get_acceptance().top_conjuncts().size();
68 productAutomaton = aut;
73 spot::const_twa_graph_ptr left = aut;
74 spot::const_twa_graph_ptr right = productAutomaton;
75 unsigned left_state = left->get_init_state_number();
76 unsigned right_state = right->get_init_state_number();
78 auto res = spot::make_twa_graph(left->get_dict());
79 res->copy_ap_of(left);
80 res->copy_ap_of(right);
82 auto left_num = left->num_sets();
83 auto& left_acc = left->get_acceptance();
84 auto right_acc = right->get_acceptance() << left_num;
85 right_acc &= left_acc;
87 res->set_acceptance(left_num + right->num_sets(), right_acc);
89 auto merge_acc = [&](spot::acc_cond::mark_t ml, spot::acc_cond::mark_t mr) {
return ml | (mr << left_num); };
90 std::unordered_map<product_state, unsigned, product_state_hash> s2n;
91 std::deque<std::pair<product_state, unsigned>> todo;
94 res->set_named_prop(
"product-states", v);
96 auto new_state = [&](
unsigned left_state,
unsigned right_state) ->
unsigned {
98 auto p = s2n.emplace(x, 0);
101 p.first->second = res->new_state();
102 todo.emplace_back(x, p.first->second);
103 assert(p.first->second == v->size());
106 return p.first->second;
109 res->set_init_state(new_state(left_state, right_state));
110 while (!todo.empty()) {
111 auto top = todo.front();
113 for (
auto& l : left->out(top.first.first))
114 for (
auto& r : right->out(top.first.second)) {
115 auto cond = l.cond & r.cond;
116 if (cond == bddfalse)
118 auto dst = new_state(l.dst, r.dst);
119 res->new_edge(top.second, dst, cond, merge_acc(l.acc, r.acc));
124 if (res->acc().is_f()) {
125 assert(res->num_edges() == 0);
126 res->prop_universal(
true);
127 res->prop_complete(
false);
128 res->prop_stutter_invariant(
true);
129 res->prop_terminal(
true);
130 res->prop_state_acc(
true);
134 if (left->prop_universal() && right->prop_universal())
135 res->prop_universal(
true);
136 if (left->prop_complete() && right->prop_complete())
137 res->prop_complete(
true);
138 if (left->prop_stutter_invariant() && right->prop_stutter_invariant())
139 res->prop_stutter_invariant(
true);
140 if (left->prop_inherently_weak() && right->prop_inherently_weak())
141 res->prop_inherently_weak(
true);
142 if (left->prop_weak() && right->prop_weak())
143 res->prop_weak(
true);
144 if (left->prop_terminal() && right->prop_terminal())
145 res->prop_terminal(
true);
146 res->prop_state_acc(left->prop_state_acc() && right->prop_state_acc());
148 productAutomaton = res;
151 acceptanceConditions.push_back(countAccept);
153 if (!(productAutomaton->get_acceptance().is_cnf())) {
155 productAutomaton = to_generalized_streett(productAutomaton,
true);
157 std::stringstream autStream;
159 spot::print_hoa(autStream, productAutomaton,
"is");
166 STORM_LOG_THROW(
false, storm::exceptions::NotSupportedException,
"Storm is compiled without Spot support.");
169 (void)acceptanceConditions;