33 std::vector<uint64_t>& acceptanceConditions) {
36 spot::twa_graph_ptr productAutomaton;
37 spot::bdd_dict_ptr dict = spot::make_bdd_dict();
38 uint64_t countAccept = 0;
40 for (
const std::shared_ptr<const storm::logic::Formula>& subFormula : formula.
getSubformulas()) {
42 STORM_LOG_ASSERT(subFormula->isProbabilityOperatorFormula(),
"subformula " << *subFormula <<
" has unexpected type.");
43 auto const& pathFormula = subFormula->asProbabilityOperatorFormula().getSubformula().asPathFormula();
49 std::string prefixLtl = ltlFormula1->toPrefixString();
50 spot::parsed_formula spotPrefixLtl = spot::parse_prefix_ltl(prefixLtl);
51 if (!spotPrefixLtl.errors.empty()) {
52 std::ostringstream errorMsg;
53 spotPrefixLtl.format_errors(errorMsg);
54 STORM_LOG_THROW(
false, storm::exceptions::ExpressionEvaluationException,
"Spot could not parse formula: " << prefixLtl <<
": " << errorMsg.str());
56 spot::formula spotFormula = spotPrefixLtl.f;
59 spot::translator trans = spot::translator(dict);
60 trans.set_type(spot::postprocessor::Parity);
61 trans.set_pref(spot::postprocessor::Deterministic | spot::postprocessor::SBAcc | spot::postprocessor::Complete | spot::postprocessor::Colored);
63 auto aut = trans.run(spotFormula);
65 acceptanceConditions.push_back(countAccept);
66 countAccept += aut->get_acceptance().top_conjuncts().size();
69 productAutomaton = aut;
74 spot::const_twa_graph_ptr left = aut;
75 spot::const_twa_graph_ptr right = productAutomaton;
76 unsigned left_state = left->get_init_state_number();
77 unsigned right_state = right->get_init_state_number();
79 auto res = spot::make_twa_graph(left->get_dict());
80 res->copy_ap_of(left);
81 res->copy_ap_of(right);
83 auto left_num = left->num_sets();
84 auto& left_acc = left->get_acceptance();
85 auto right_acc = right->get_acceptance() << left_num;
86 right_acc &= left_acc;
88 res->set_acceptance(left_num + right->num_sets(), right_acc);
90 auto merge_acc = [&](spot::acc_cond::mark_t ml, spot::acc_cond::mark_t mr) {
return ml | (mr << left_num); };
91 std::unordered_map<product_state, unsigned, product_state_hash> s2n;
92 std::deque<std::pair<product_state, unsigned>> todo;
95 res->set_named_prop(
"product-states", v);
97 auto new_state = [&](
unsigned left_state,
unsigned right_state) ->
unsigned {
99 auto p = s2n.emplace(x, 0);
102 p.first->second = res->new_state();
103 todo.emplace_back(x, p.first->second);
104 assert(p.first->second == v->size());
107 return p.first->second;
110 res->set_init_state(new_state(left_state, right_state));
111 while (!todo.empty()) {
112 auto top = todo.front();
114 for (
auto& l : left->out(top.first.first))
115 for (
auto& r : right->out(top.first.second)) {
116 auto cond = l.cond & r.cond;
117 if (cond == bddfalse)
119 auto dst = new_state(l.dst, r.dst);
120 res->new_edge(top.second, dst, cond, merge_acc(l.acc, r.acc));
125 if (res->acc().is_f()) {
126 assert(res->num_edges() == 0);
127 res->prop_universal(
true);
128 res->prop_complete(
false);
129 res->prop_stutter_invariant(
true);
130 res->prop_terminal(
true);
131 res->prop_state_acc(
true);
135 if (left->prop_universal() && right->prop_universal())
136 res->prop_universal(
true);
137 if (left->prop_complete() && right->prop_complete())
138 res->prop_complete(
true);
139 if (left->prop_stutter_invariant() && right->prop_stutter_invariant())
140 res->prop_stutter_invariant(
true);
141 if (left->prop_inherently_weak() && right->prop_inherently_weak())
142 res->prop_inherently_weak(
true);
143 if (left->prop_weak() && right->prop_weak())
144 res->prop_weak(
true);
145 if (left->prop_terminal() && right->prop_terminal())
146 res->prop_terminal(
true);
147 res->prop_state_acc(left->prop_state_acc() && right->prop_state_acc());
149 productAutomaton = res;
152 acceptanceConditions.push_back(countAccept);
154 if (!(productAutomaton->get_acceptance().is_cnf())) {
156 productAutomaton = to_generalized_streett(productAutomaton,
true);
158 std::stringstream autStream;
160 spot::print_hoa(autStream, productAutomaton,
"is");
167 STORM_LOG_THROW(
false, storm::exceptions::NotSupportedException,
"Storm is compiled without Spot support.");
170 (void)acceptanceConditions;