(Context ctx)
| 595 | // / A basic example of how to use quantifiers. |
| 596 | |
| 597 | void quantifierExample1(Context ctx) |
| 598 | { |
| 599 | System.out.println("QuantifierExample"); |
| 600 | Log.append("QuantifierExample"); |
| 601 | |
| 602 | IntSort[] types = new IntSort[3]; |
| 603 | IntExpr[] xs = new IntExpr[3]; |
| 604 | Symbol[] names = new Symbol[3]; |
| 605 | IntExpr[] vars = new IntExpr[3]; |
| 606 | |
| 607 | for (int j = 0; j < 3; j++) |
| 608 | { |
| 609 | types[j] = ctx.getIntSort(); |
| 610 | names[j] = ctx.mkSymbol("x_" + Integer.toString(j)); |
| 611 | xs[j] = (IntExpr) ctx.mkConst(names[j], types[j]); |
| 612 | vars[j] = (IntExpr) ctx.mkBound(2 - j, types[j]); // <-- vars |
| 613 | // reversed! |
| 614 | } |
| 615 | |
| 616 | Expr body_vars = ctx.mkAnd( |
| 617 | ctx.mkEq(ctx.mkAdd(vars[0], ctx.mkInt(1)), ctx.mkInt(2)), |
| 618 | ctx.mkEq(ctx.mkAdd(vars[1], ctx.mkInt(2)), |
| 619 | ctx.mkAdd(vars[2], ctx.mkInt(3)))); |
| 620 | |
| 621 | Expr body_const = ctx.mkAnd( |
| 622 | ctx.mkEq(ctx.mkAdd(xs[0], ctx.mkInt(1)), ctx.mkInt(2)), |
| 623 | ctx.mkEq(ctx.mkAdd(xs[1], ctx.mkInt(2)), |
| 624 | ctx.mkAdd(xs[2], ctx.mkInt(3)))); |
| 625 | |
| 626 | Expr x = ctx.mkForall(types, names, body_vars, 1, null, null, |
| 627 | ctx.mkSymbol("Q1"), ctx.mkSymbol("skid1")); |
| 628 | System.out.println("Quantifier X: " + x.toString()); |
| 629 | |
| 630 | Expr y = ctx.mkForall(xs, body_const, 1, null, null, |
| 631 | ctx.mkSymbol("Q2"), ctx.mkSymbol("skid2")); |
| 632 | System.out.println("Quantifier Y: " + y.toString()); |
| 633 | } |
| 634 | |
| 635 | void quantifierExample2(Context ctx) |
| 636 | { |
no test coverage detected