@@ -84,98 +84,109 @@ exprt hoa_label_to_expr(
84
84
buechi_transt
85
85
ltl_to_buechi (const exprt &property, message_handlert &message_handler)
86
86
{
87
- // Turn the skeleton of the property into a string
88
87
ltl_sva_to_stringt ltl_sva_to_string;
89
- auto string = ltl_sva_to_string (property);
90
88
91
- // Run Spot's ltl2tgba
92
- std::ostringstream hoa_stream;
89
+ try
90
+ {
91
+ // Turn the skeleton of the property into a string
92
+ auto string = ltl_sva_to_string (property);
93
93
94
- messaget message (message_handler);
94
+ // Run Spot's ltl2tgba
95
+ std::ostringstream hoa_stream;
95
96
96
- message. debug () << " ltl2tgba property: " << string << messaget::eom ;
97
+ messaget message (message_handler) ;
97
98
98
- // State-based Buchi acceptance. Should compare with transition-based
99
- // acceptance.
100
- // Use --complete to be able to have multiple properties in one
101
- // model.
102
- auto run_result = run (
103
- " ltl2tgba" ,
104
- {" ltl2tgba" , " --sba" , " --complete" , " --hoaf=1.1" , string},
105
- " " ,
106
- hoa_stream,
107
- " " );
99
+ message.debug () << " ltl2tgba property: " << string << messaget::eom;
108
100
109
- if (run_result != 0 )
110
- throw ebmc_errort{} << " failed to run ltl2tgba" ;
101
+ // State-based Buchi acceptance. Should compare with transition-based
102
+ // acceptance.
103
+ // Use --complete to be able to have multiple properties in one
104
+ // model.
105
+ auto run_result = run (
106
+ " ltl2tgba" ,
107
+ {" ltl2tgba" , " --sba" , " --complete" , " --hoaf=1.1" , string},
108
+ " " ,
109
+ hoa_stream,
110
+ " " );
111
111
112
- auto hoa = hoat::from_string (hoa_stream.str ());
112
+ if (run_result != 0 )
113
+ throw ebmc_errort{} << " failed to run ltl2tgba" ;
113
114
114
- message. debug () << hoa << messaget::eom ;
115
+ auto hoa = hoat::from_string (hoa_stream. str ()) ;
115
116
116
- auto max_state_number = hoa.max_state_number ();
117
- auto state_type = range_typet{0 , max_state_number};
118
- const auto buechi_state = symbol_exprt{" buechi::state" , state_type};
119
- const auto buechi_next_state = next_symbol_exprt{" buechi::state" , state_type};
117
+ message.debug () << hoa << messaget::eom;
120
118
121
- // construct the initial state constraint
122
- std::vector<exprt> init_disjuncts;
119
+ auto max_state_number = hoa.max_state_number ();
120
+ auto state_type = range_typet{0 , max_state_number};
121
+ const auto buechi_state = symbol_exprt{" buechi::state" , state_type};
122
+ const auto buechi_next_state =
123
+ next_symbol_exprt{" buechi::state" , state_type};
123
124
124
- for (auto &item : hoa.header )
125
- if (item.first == " Start:" )
126
- {
127
- if (item.second .size () != 1 )
128
- throw ebmc_errort () << " Start header must have one token" ;
129
- auto state_number = string2integer (item.second .front ());
130
- init_disjuncts.push_back (
131
- equal_exprt{buechi_state, from_integer (state_number, state_type)});
132
- }
125
+ // construct the initial state constraint
126
+ std::vector<exprt> init_disjuncts;
133
127
134
- auto init = disjunction (init_disjuncts);
128
+ for (auto &item : hoa.header )
129
+ if (item.first == " Start:" )
130
+ {
131
+ if (item.second .size () != 1 )
132
+ throw ebmc_errort () << " Start header must have one token" ;
133
+ auto state_number = string2integer (item.second .front ());
134
+ init_disjuncts.push_back (
135
+ equal_exprt{buechi_state, from_integer (state_number, state_type)});
136
+ }
135
137
136
- message. debug () << " Buechi initial state: " << format (init) << messaget::eom ;
138
+ auto init = disjunction (init_disjuncts) ;
137
139
138
- // construct the liveness signal
139
- std::vector<exprt> liveness_disjuncts ;
140
+ message. debug () << " Buechi initial state: " << format (init)
141
+ << messaget::eom ;
140
142
141
- for (auto &state : hoa.body )
142
- if (!state.first .acc_sig .empty ())
143
- {
144
- liveness_disjuncts.push_back (equal_exprt{
145
- buechi_state, from_integer (state.first .number , state_type)});
146
- }
143
+ // construct the liveness signal
144
+ std::vector<exprt> liveness_disjuncts;
147
145
148
- auto liveness_signal = disjunction (liveness_disjuncts);
146
+ for (auto &state : hoa.body )
147
+ if (!state.first .acc_sig .empty ())
148
+ {
149
+ liveness_disjuncts.push_back (equal_exprt{
150
+ buechi_state, from_integer (state.first .number , state_type)});
151
+ }
149
152
150
- message.debug () << " Buechi liveness signal: " << format (liveness_signal)
151
- << messaget::eom;
153
+ auto liveness_signal = disjunction (liveness_disjuncts);
152
154
153
- // construct the transition relation
154
- std::vector<exprt> trans_disjuncts ;
155
+ message. debug () << " Buechi liveness signal: " << format (liveness_signal)
156
+ << messaget::eom ;
155
157
156
- for (auto &state : hoa.body )
157
- {
158
- auto pre =
159
- equal_exprt{buechi_state, from_integer (state.first .number , state_type)};
160
- for (auto &edge : state.second )
158
+ // construct the transition relation
159
+ std::vector<exprt> trans_disjuncts;
160
+
161
+ for (auto &state : hoa.body )
161
162
{
162
- if (edge.dest_states .size () != 1 )
163
- throw ebmc_errort () << " edge must have one destination state" ;
164
- auto cond = hoa_label_to_expr (edge.label , ltl_sva_to_string);
165
- auto post = equal_exprt{
166
- buechi_next_state, from_integer (edge.dest_states .front (), state_type)};
167
- trans_disjuncts.push_back (and_exprt{pre, cond, post});
163
+ auto pre =
164
+ equal_exprt{buechi_state, from_integer (state.first .number , state_type)};
165
+ for (auto &edge : state.second )
166
+ {
167
+ if (edge.dest_states .size () != 1 )
168
+ throw ebmc_errort () << " edge must have one destination state" ;
169
+ auto cond = hoa_label_to_expr (edge.label , ltl_sva_to_string);
170
+ auto post = equal_exprt{
171
+ buechi_next_state,
172
+ from_integer (edge.dest_states .front (), state_type)};
173
+ trans_disjuncts.push_back (and_exprt{pre, cond, post});
174
+ }
168
175
}
169
- }
170
176
171
- auto trans = disjunction (trans_disjuncts);
177
+ auto trans = disjunction (trans_disjuncts);
172
178
173
- message.debug () << " Buechi transition constraint: " << format (trans)
174
- << messaget::eom;
179
+ message.debug () << " Buechi transition constraint: " << format (trans)
180
+ << messaget::eom;
175
181
176
- return {
177
- buechi_state,
178
- std::move (init),
179
- std::move (trans),
180
- std::move (liveness_signal)};
182
+ return {
183
+ buechi_state,
184
+ std::move (init),
185
+ std::move (trans),
186
+ std::move (liveness_signal)};
187
+ }
188
+ catch (ltl_sva_to_string_unsupportedt error)
189
+ {
190
+ throw ebmc_errort{} << " failed to convert " << error.expr .id ();
191
+ }
181
192
}
0 commit comments