(Context ctx)
| 554 | // / A basic example of how to use quantifiers. |
| 555 | |
| 556 | @SuppressWarnings("unchecked") |
| 557 | void quantifierExample1(Context ctx) |
| 558 | { |
| 559 | System.out.println("QuantifierExample"); |
| 560 | Log.append("QuantifierExample"); |
| 561 | |
| 562 | IntSort[] types = new IntSort[3]; |
| 563 | Arrays.fill(types, ctx.getIntSort()); |
| 564 | Symbol[] names = IntStream.range(0, 3).mapToObj(j -> ctx.mkSymbol(String.format("x_%d", j))).toArray(Symbol[]::new); |
| 565 | List<Expr<IntSort>> xs = IntStream.range(0, 3).mapToObj(j -> ctx.mkConst(names[j], types[j])).collect(Collectors.toList()); |
| 566 | List<Expr<IntSort>> vars = IntStream.range(0, 3).mapToObj(j -> ctx.mkBound(2 - j, types[j])).collect(Collectors.toList()); |
| 567 | |
| 568 | BoolExpr body_vars = ctx.mkAnd( |
| 569 | ctx.mkEq(ctx.mkAdd(vars.get(0), ctx.mkInt(1)), ctx.mkInt(2)), |
| 570 | ctx.mkEq(ctx.mkAdd(vars.get(1), ctx.mkInt(2)), |
| 571 | ctx.mkAdd(vars.get(2), ctx.mkInt(3)))); |
| 572 | |
| 573 | BoolExpr body_const = ctx.mkAnd( |
| 574 | ctx.mkEq(ctx.mkAdd(xs.get(0), ctx.mkInt(1)), ctx.mkInt(2)), |
| 575 | ctx.mkEq(ctx.mkAdd(xs.get(1), ctx.mkInt(2)), |
| 576 | ctx.mkAdd(xs.get(2), ctx.mkInt(3)))); |
| 577 | |
| 578 | Quantifier x = ctx.mkForall(types, names, body_vars, 1, null, null, |
| 579 | ctx.mkSymbol("Q1"), ctx.mkSymbol("skid1")); |
| 580 | System.out.printf("Quantifier X: %s%n", x.toString()); |
| 581 | |
| 582 | Quantifier y = ctx.mkForall(xs.toArray(new Expr[0]), body_const, 1, null, null, |
| 583 | ctx.mkSymbol("Q2"), ctx.mkSymbol("skid2")); |
| 584 | System.out.printf("Quantifier Y: %s%n", y.toString()); |
| 585 | } |
| 586 | |
| 587 | void quantifierExample2(Context ctx) |
| 588 | { |
no test coverage detected