|
15 | 15 | import static scala.collection.JavaConverters.asJava;
|
16 | 16 | import static scala.collection.JavaConverters.asJavaCollection;
|
17 | 17 |
|
18 |
| -import ap.basetypes.IdealInt; |
19 | 18 | import ap.parser.IAtom;
|
20 | 19 | import ap.parser.IBinFormula;
|
21 | 20 | import ap.parser.IBinJunctor;
|
@@ -364,30 +363,38 @@ private String getName(IExpression input) {
|
364 | 363 | }
|
365 | 364 |
|
366 | 365 | /** Returns true if the expression is a constant value. */
|
367 |
| - private static boolean isValue(IFunApp pExpr) { |
368 |
| - if (!pExpr.fun().equals(Rationals.frac()) && !pExpr.fun().equals(Rationals.fromRing())) { |
369 |
| - return false; |
370 |
| - } |
371 |
| - for (IExpression sub : asJava(pExpr.args())) { |
372 |
| - if (!(sub instanceof IIntLit)) { |
373 |
| - return false; |
| 366 | + private static boolean isValue(IExpression input) { |
| 367 | + if (input instanceof IBoolLit || input instanceof IIntLit) { |
| 368 | + // Boolean or integer literal |
| 369 | + return true; |
| 370 | + } else if (input instanceof IFunApp) { |
| 371 | + IFunApp app = (IFunApp) input; |
| 372 | + IFunction fun = app.fun(); |
| 373 | + if (fun.equals(Rationals.fromRing()) || fun.equals(Rationals.frac())) { |
| 374 | + // Rational number literal |
| 375 | + for (IExpression sub : asJava(app.args())) { |
| 376 | + if (!(sub instanceof IIntLit)) { |
| 377 | + return false; |
| 378 | + } |
| 379 | + } |
| 380 | + return true; |
| 381 | + } |
| 382 | + if (fun.equals(ModuloArithmetic.mod_cast()) && input.apply(2) instanceof IIntLit) { |
| 383 | + // Bitvector literal |
| 384 | + return true; |
| 385 | + } |
| 386 | + if (CONSTANT_UFS.contains(fun.name())) { |
| 387 | + // Nil, Cons from String theory |
| 388 | + return true; |
374 | 389 | }
|
375 | 390 | }
|
376 |
| - return true; |
| 391 | + return false; |
377 | 392 | }
|
378 | 393 |
|
379 | 394 | @SuppressWarnings("deprecation")
|
380 | 395 | @Override
|
381 | 396 | public <R> R visit(FormulaVisitor<R> visitor, final Formula f, final IExpression input) {
|
382 |
| - if (input instanceof IIntLit) { |
383 |
| - IdealInt value = ((IIntLit) input).value(); |
384 |
| - return visitor.visitConstant(f, value.bigIntValue()); |
385 |
| - |
386 |
| - } else if (input instanceof IBoolLit) { |
387 |
| - IBoolLit literal = (IBoolLit) input; |
388 |
| - return visitor.visitConstant(f, literal.value()); |
389 |
| - |
390 |
| - } else if (input instanceof IFunApp && isValue((IFunApp) input)) { |
| 397 | + if (isValue(input)) { |
391 | 398 | return visitor.visitConstant(f, convertValue(input));
|
392 | 399 |
|
393 | 400 | } else if (input instanceof IQuantified) {
|
@@ -462,20 +469,6 @@ public <R> R visit(FormulaVisitor<R> visitor, final Formula f, final IExpression
|
462 | 469 | return visit(visitor, f, ((IIntFormula) input).t());
|
463 | 470 | }
|
464 | 471 |
|
465 |
| - if (kind == FunctionDeclarationKind.OTHER && input instanceof IFunApp) { |
466 |
| - if (ModuloArithmetic.mod_cast().equals(((IFunApp) input).fun()) |
467 |
| - && ((IFunApp) input).apply(2) instanceof IIntLit) { |
468 |
| - // mod_cast(0, 256, 7) -> BV=7 with bitsize=8 |
469 |
| - return visitor.visitConstant(f, convertValue(input)); |
470 |
| - } |
471 |
| - } |
472 |
| - |
473 |
| - if (kind == FunctionDeclarationKind.UF && input instanceof IFunApp) { |
474 |
| - if (CONSTANT_UFS.contains(((IFunApp) input).fun().name())) { |
475 |
| - return visitor.visitConstant(f, convertValue(input)); |
476 |
| - } |
477 |
| - } |
478 |
| - |
479 | 472 | ImmutableList.Builder<Formula> args = ImmutableList.builder();
|
480 | 473 | ImmutableList.Builder<FormulaType<?>> argTypes = ImmutableList.builder();
|
481 | 474 | int arity = input.length();
|
|
0 commit comments