@@ -152,6 +152,7 @@ void qe_project_z3(ast_manager &m, app_ref_vector &vars, expr_ref &fml,
152
152
params_ref p;
153
153
p.set_bool (" reduce_all_selects" , reduce_all_selects);
154
154
p.set_bool (" dont_sub" , dont_sub);
155
+ TRACE (" qe" , tout << " qe-project-z3\n " );
155
156
156
157
qe::mbproj mbp (m, p);
157
158
mbp.spacer (vars, mdl, fml);
@@ -167,8 +168,7 @@ void qe_project_spacer(ast_manager &m, app_ref_vector &vars, expr_ref &fml,
167
168
bool dont_sub) {
168
169
th_rewriter rw (m);
169
170
TRACE (" spacer_mbp" , tout << " Before projection:\n " ; tout << fml << " \n " ;
170
- tout << " Vars:\n "
171
- << vars;);
171
+ tout << " Vars:" << vars << " \n " ;);
172
172
173
173
{
174
174
// Ensure that top-level AND of fml is flat
@@ -182,6 +182,7 @@ void qe_project_spacer(ast_manager &m, app_ref_vector &vars, expr_ref &fml,
182
182
183
183
app_ref_vector arith_vars (m);
184
184
app_ref_vector array_vars (m);
185
+ app_ref_vector other_vars (m);
185
186
array_util arr_u (m);
186
187
arith_util ari_u (m);
187
188
expr_safe_replace bool_sub (m);
@@ -194,8 +195,7 @@ void qe_project_spacer(ast_manager &m, app_ref_vector &vars, expr_ref &fml,
194
195
rw (fml);
195
196
196
197
TRACE (" spacer_mbp" , tout << " After qe_lite:\n " ;
197
- tout << mk_pp (fml, m) << " \n " ; tout << " Vars:\n "
198
- << vars;);
198
+ tout << mk_pp (fml, m) << " \n Vars:" << vars << " \n " ;);
199
199
200
200
SASSERT (!m.is_false (fml));
201
201
@@ -206,12 +206,13 @@ void qe_project_spacer(ast_manager &m, app_ref_vector &vars, expr_ref &fml,
206
206
// using model completion
207
207
model::scoped_model_completion _sc_ (mdl, true );
208
208
bool_sub.insert (v, mdl (v));
209
- } else if (arr_u.is_array (v)) {
209
+ }
210
+ else if (arr_u.is_array (v))
210
211
array_vars.push_back (v);
211
- } else {
212
- SASSERT (ari_u.is_int (v) || ari_u.is_real (v));
212
+ else if (ari_u.is_int (v) || ari_u.is_real (v))
213
213
arith_vars.push_back (v);
214
- }
214
+ else
215
+ other_vars.push_back (v);
215
216
}
216
217
217
218
// substitute Booleans
@@ -220,8 +221,7 @@ void qe_project_spacer(ast_manager &m, app_ref_vector &vars, expr_ref &fml,
220
221
// -- bool_sub is not simplifying
221
222
rw (fml);
222
223
SASSERT (!m.is_false (fml));
223
- TRACE (" spacer_mbp" , tout << " Projected Booleans:\n "
224
- << fml << " \n " ;);
224
+ TRACE (" spacer_mbp" , tout << " Projected Booleans:\n " << fml << " \n " ;);
225
225
bool_sub.reset ();
226
226
}
227
227
@@ -230,7 +230,7 @@ void qe_project_spacer(ast_manager &m, app_ref_vector &vars, expr_ref &fml,
230
230
vars.reset ();
231
231
232
232
// project arrays
233
- {
233
+ if (!array_vars. empty ()) {
234
234
scoped_no_proof _sp (m);
235
235
// -- local rewriter that is aware of current proof mode
236
236
th_rewriter srw (m);
@@ -243,14 +243,15 @@ void qe_project_spacer(ast_manager &m, app_ref_vector &vars, expr_ref &fml,
243
243
244
244
TRACE (" spacer_mbp" , tout << " extended model:\n " ; model_pp (tout, mdl);
245
245
tout << " Auxiliary variables of index and value sorts:\n " ;
246
- tout << vars;);
246
+ tout << vars << " \n " ;);
247
247
248
- if (vars.empty ()) { break ; }
248
+ if (vars.empty ())
249
+ break ;
249
250
}
250
251
251
252
// project reals and ints
252
253
if (!arith_vars.empty ()) {
253
- TRACE (" spacer_mbp" , tout << " Arith vars:\n " << arith_vars;);
254
+ TRACE (" spacer_mbp" , tout << " Arith vars:" << arith_vars << " \n " ;);
254
255
255
256
if (use_native_mbp) {
256
257
qe::mbproj mbp (m);
@@ -260,19 +261,19 @@ void qe_project_spacer(ast_manager &m, app_ref_vector &vars, expr_ref &fml,
260
261
mbp (true , arith_vars, mdl, fmls);
261
262
fml = mk_and (fmls);
262
263
SASSERT (arith_vars.empty ());
263
- } else {
264
+ }
265
+ else {
264
266
scoped_no_proof _sp (m);
265
267
spacer_qe::arith_project (mdl, arith_vars, fml);
266
268
}
267
269
268
- TRACE (" spacer_mbp" , tout << " Projected arith vars:\n "
269
- << fml << " \n " ;
270
- tout << " Remaining arith vars:\n "
271
- << arith_vars << " \n " ;);
270
+ TRACE (" spacer_mbp" , tout << " Projected arith vars: " << fml << " \n " ;
271
+ tout << " Remaining arith vars:" << arith_vars << " \n " ;);
272
272
SASSERT (!m.is_false (fml));
273
273
}
274
274
275
- if (!arith_vars.empty ()) { mbqi_project (mdl, arith_vars, fml); }
275
+ if (!arith_vars.empty ())
276
+ mbqi_project (mdl, arith_vars, fml);
276
277
277
278
// substitute any remaining arith vars
278
279
if (!dont_sub && !arith_vars.empty ()) {
@@ -289,26 +290,30 @@ void qe_project_spacer(ast_manager &m, app_ref_vector &vars, expr_ref &fml,
289
290
SASSERT (mev.is_true (fml)););
290
291
291
292
vars.reset ();
292
- if (dont_sub && !arith_vars.empty ()) { vars.append (arith_vars); }
293
+ vars.append (other_vars);
294
+ if (dont_sub && !arith_vars.empty ())
295
+ vars.append (arith_vars);
296
+ TRACE (" qe" , tout << " after projection: " << fml << " : " << vars << " \n " );
293
297
}
294
298
295
299
static expr *apply_accessor (ast_manager &m, ptr_vector<func_decl> const &acc,
296
300
unsigned j, func_decl *f, expr *c) {
297
- if (is_app (c) && to_app (c)->get_decl () == f) {
301
+ if (is_app (c) && to_app (c)->get_decl () == f)
298
302
return to_app (c)->get_arg (j);
299
- } else {
303
+ else
300
304
return m.mk_app (acc[j], c);
301
- }
302
305
}
303
306
304
307
void qe_project (ast_manager &m, app_ref_vector &vars, expr_ref &fml, model &mdl,
305
308
bool reduce_all_selects, bool use_native_mbp, bool dont_sub) {
306
- if (use_native_mbp)
307
- qe_project_z3 (m, vars, fml, mdl, reduce_all_selects, use_native_mbp,
308
- dont_sub);
309
- else
309
+ if (!use_native_mbp)
310
310
qe_project_spacer (m, vars, fml, mdl, reduce_all_selects, use_native_mbp,
311
311
dont_sub);
312
+
313
+ if (!vars.empty ())
314
+ qe_project_z3 (m, vars, fml, mdl, reduce_all_selects, use_native_mbp,
315
+ dont_sub);
316
+
312
317
}
313
318
314
319
void expand_literals (ast_manager &m, expr_ref_vector &conjs) {
@@ -329,12 +334,14 @@ void expand_literals(ast_manager &m, expr_ref_vector &conjs) {
329
334
conjs[i] = arith.mk_le (e1 , e2 );
330
335
if (i + 1 == conjs.size ()) {
331
336
conjs.push_back (arith.mk_ge (e1 , e2 ));
332
- } else {
337
+ }
338
+ else {
333
339
conjs.push_back (conjs[i + 1 ].get ());
334
340
conjs[i + 1 ] = arith.mk_ge (e1 , e2 );
335
341
}
336
342
++i;
337
- } else if ((m.is_eq (e, c, val) && is_app (val) &&
343
+ }
344
+ else if ((m.is_eq (e, c, val) && is_app (val) &&
338
345
dt.is_constructor (to_app (val))) ||
339
346
(m.is_eq (e, val, c) && is_app (val) &&
340
347
dt.is_constructor (to_app (val)))) {
@@ -346,20 +353,20 @@ void expand_literals(ast_manager &m, expr_ref_vector &conjs) {
346
353
conjs.push_back (m.mk_eq (apply_accessor (m, acc, j, f, c),
347
354
to_app (val)->get_arg (j)));
348
355
}
349
- } else if ((m.is_eq (e, c, val) && bv.is_numeral (val, r, bv_size)) ||
350
- (m.is_eq (e, val, c) && bv.is_numeral (val, r, bv_size))) {
356
+ }
357
+ else if ((m.is_eq (e, c, val) && bv.is_numeral (val, r, bv_size)) ||
358
+ (m.is_eq (e, val, c) && bv.is_numeral (val, r, bv_size))) {
351
359
rational two (2 );
352
360
for (unsigned j = 0 ; j < bv_size; ++j) {
353
361
parameter p (j);
354
362
expr *e = m.mk_eq (m.mk_app (bv.get_family_id (), OP_BIT1),
355
363
bv.mk_extract (j, j, c));
356
364
if ((r % two).is_zero ()) { e = m.mk_not (e); }
357
365
r = div (r, two);
358
- if (j == 0 ) {
366
+ if (j == 0 )
359
367
conjs[i] = e;
360
- } else {
368
+ else
361
369
conjs.push_back (e);
362
- }
363
370
}
364
371
}
365
372
}
0 commit comments