(Context ctx)
| 585 | } |
| 586 | |
| 587 | void quantifierExample2(Context ctx) |
| 588 | { |
| 589 | |
| 590 | System.out.println("QuantifierExample2"); |
| 591 | Log.append("QuantifierExample2"); |
| 592 | |
| 593 | Quantifier q1, q2; |
| 594 | FuncDecl<IntSort> f = ctx.mkFuncDecl("f", ctx.getIntSort(), ctx.getIntSort()); |
| 595 | FuncDecl<IntSort> g = ctx.mkFuncDecl("g", ctx.getIntSort(), ctx.getIntSort()); |
| 596 | |
| 597 | // Quantifier with Exprs as the bound variables. |
| 598 | { |
| 599 | Expr<IntSort> x = ctx.mkConst("x", ctx.getIntSort()); |
| 600 | Expr<IntSort> y = ctx.mkConst("y", ctx.getIntSort()); |
| 601 | Expr<IntSort> f_x = ctx.mkApp(f, x); |
| 602 | Expr<IntSort> f_y = ctx.mkApp(f, y); |
| 603 | Expr<IntSort> g_y = ctx.mkApp(g, y); |
| 604 | @SuppressWarnings("unused") |
| 605 | Pattern[] pats = new Pattern[] { ctx.mkPattern(f_x, g_y) }; |
| 606 | Expr[] no_pats = new Expr[] { f_y }; |
| 607 | Expr[] bound = new Expr[] { x, y }; |
| 608 | BoolExpr body = ctx.mkAnd(ctx.mkEq(f_x, f_y), ctx.mkEq(f_y, g_y)); |
| 609 | |
| 610 | q1 = ctx.mkForall(bound, body, 1, null, no_pats, ctx.mkSymbol("q"), |
| 611 | ctx.mkSymbol("sk")); |
| 612 | |
| 613 | System.out.println(q1); |
| 614 | } |
| 615 | |
| 616 | // Quantifier with de-Bruijn indices. |
| 617 | { |
| 618 | Expr<IntSort> x = ctx.mkBound(1, ctx.getIntSort()); |
| 619 | Expr<IntSort> y = ctx.mkBound(0, ctx.getIntSort()); |
| 620 | Expr<IntSort> f_x = ctx.mkApp(f, x); |
| 621 | Expr<IntSort> f_y = ctx.mkApp(f, y); |
| 622 | Expr<IntSort> g_y = ctx.mkApp(g, y); |
| 623 | @SuppressWarnings("unused") |
| 624 | Pattern[] pats = new Pattern[] { ctx.mkPattern(f_x, g_y) }; |
| 625 | Expr[] no_pats = new Expr[] { f_y }; |
| 626 | Symbol[] names = new Symbol[] { ctx.mkSymbol("x"), |
| 627 | ctx.mkSymbol("y") }; |
| 628 | Sort[] sorts = new Sort[] { ctx.getIntSort(), ctx.getIntSort() }; |
| 629 | BoolExpr body = ctx.mkAnd(ctx.mkEq(f_x, f_y), ctx.mkEq(f_y, g_y)); |
| 630 | |
| 631 | q2 = ctx.mkForall(sorts, names, body, 1, null, // pats, |
| 632 | no_pats, ctx.mkSymbol("q"), ctx.mkSymbol("sk")); |
| 633 | System.out.println(q2); |
| 634 | } |
| 635 | |
| 636 | System.out.println(q1.equals(q2)); |
| 637 | } |
| 638 | |
| 639 | // / Prove that <tt>f(x, y) = f(w, v) implies y = v</tt> when |
| 640 | // / <code>f</code> is injective in the second argument. <seealso |
no test coverage detected