34 std::vector<uint64_t>& acceptanceConditions) {
37 spot::twa_graph_ptr productAutomaton;
38 spot::bdd_dict_ptr dict = spot::make_bdd_dict();
39 uint64_t countAccept = 0;
41 for (
const std::shared_ptr<const storm::logic::Formula>& subFormula : formula.
getSubformulas()) {
43 STORM_LOG_ASSERT(subFormula->isProbabilityOperatorFormula(),
"subformula " << *subFormula <<
" has unexpected type.");
44 auto const& pathFormula = subFormula->asProbabilityOperatorFormula().getSubformula().asPathFormula();
50 std::string prefixLtl = ltlFormula1->toPrefixString();
51 spot::parsed_formula spotPrefixLtl = spot::parse_prefix_ltl(prefixLtl);
52 if (!spotPrefixLtl.errors.empty()) {
53 std::ostringstream errorMsg;
54 spotPrefixLtl.format_errors(errorMsg);
55 STORM_LOG_THROW(
false, storm::exceptions::ExpressionEvaluationException,
"Spot could not parse formula: " << prefixLtl <<
": " << errorMsg.str());
57 spot::formula spotFormula = spotPrefixLtl.f;
60 spot::translator trans = spot::translator(dict);
61 trans.set_type(spot::postprocessor::Parity);
62 trans.set_pref(spot::postprocessor::Deterministic | spot::postprocessor::SBAcc | spot::postprocessor::Complete | spot::postprocessor::Colored);
64 auto aut = trans.run(spotFormula);
66 acceptanceConditions.push_back(countAccept);
67 countAccept += aut->get_acceptance().top_conjuncts().size();
70 productAutomaton = aut;
75 spot::const_twa_graph_ptr left = aut;
76 spot::const_twa_graph_ptr right = productAutomaton;
77 unsigned left_state = left->get_init_state_number();
78 unsigned right_state = right->get_init_state_number();
80 auto res = spot::make_twa_graph(left->get_dict());
81 res->copy_ap_of(left);
82 res->copy_ap_of(right);
84 auto left_num = left->num_sets();
85 auto& left_acc = left->get_acceptance();
86 auto right_acc = right->get_acceptance() << left_num;
87 right_acc &= left_acc;
89 res->set_acceptance(left_num + right->num_sets(), right_acc);
91 auto merge_acc = [&](spot::acc_cond::mark_t ml, spot::acc_cond::mark_t mr) {
return ml | (mr << left_num); };
92 std::unordered_map<product_state, unsigned, product_state_hash> s2n;
93 std::deque<std::pair<product_state, unsigned>> todo;
96 res->set_named_prop(
"product-states", v);
98 auto new_state = [&](
unsigned left_state,
unsigned right_state) ->
unsigned {
100 auto p = s2n.emplace(x, 0);
103 p.first->second = res->new_state();
104 todo.emplace_back(x, p.first->second);
105 assert(p.first->second == v->size());
108 return p.first->second;
111 res->set_init_state(new_state(left_state, right_state));
112 while (!todo.empty()) {
113 auto top = todo.front();
115 for (
auto& l : left->out(top.first.first))
116 for (
auto& r : right->out(top.first.second)) {
117 auto cond = l.cond & r.cond;
118 if (cond == bddfalse)
120 auto dst = new_state(l.dst, r.dst);
121 res->new_edge(top.second, dst, cond, merge_acc(l.acc, r.acc));
126 if (res->acc().is_f()) {
127 assert(res->num_edges() == 0);
128 res->prop_universal(
true);
129 res->prop_complete(
false);
130 res->prop_stutter_invariant(
true);
131 res->prop_terminal(
true);
132 res->prop_state_acc(
true);
136 if (left->prop_universal() && right->prop_universal())
137 res->prop_universal(
true);
138 if (left->prop_complete() && right->prop_complete())
139 res->prop_complete(
true);
140 if (left->prop_stutter_invariant() && right->prop_stutter_invariant())
141 res->prop_stutter_invariant(
true);
142 if (left->prop_inherently_weak() && right->prop_inherently_weak())
143 res->prop_inherently_weak(
true);
144 if (left->prop_weak() && right->prop_weak())
145 res->prop_weak(
true);
146 if (left->prop_terminal() && right->prop_terminal())
147 res->prop_terminal(
true);
148 res->prop_state_acc(left->prop_state_acc() && right->prop_state_acc());
150 productAutomaton = res;
153 acceptanceConditions.push_back(countAccept);
155 if (!(productAutomaton->get_acceptance().is_cnf())) {
157 productAutomaton = to_generalized_streett(productAutomaton,
true);
159 std::stringstream autStream;
161 spot::print_hoa(autStream, productAutomaton,
"is");
168 STORM_LOG_THROW(
false, storm::exceptions::NotSupportedException,
"Storm is compiled without Spot support.");
171 (void)acceptanceConditions;