MCPcopy Create free account
hub / github.com/Z3Prover/z3 / quantifierExample3

Method quantifierExample3

examples/java/JavaExample.java:691–726  ·  view source on GitHub ↗
(Context ctx)

Source from the content-addressed store, hash-verified

689 // cref="inj_axiom"/>
690
691 public void quantifierExample3(Context ctx) throws TestFailedException
692 {
693 System.out.println("QuantifierExample3");
694 Log.append("QuantifierExample3");
695
696 /*
697 * If quantified formulas are asserted in a logical context, then the
698 * model produced by Z3 should be viewed as a potential model.
699 */
700
701 /* declare function f */
702 Sort I = ctx.getIntSort();
703 FuncDecl f = ctx.mkFuncDecl("f", new Sort[] { I, I }, I);
704
705 /* f is injective in the second argument. */
706 BoolExpr inj = injAxiom(ctx, f, 1);
707
708 /* create x, y, v, w, fxy, fwv */
709 Expr x = ctx.mkIntConst("x");
710 Expr y = ctx.mkIntConst("y");
711 Expr v = ctx.mkIntConst("v");
712 Expr w = ctx.mkIntConst("w");
713 Expr fxy = ctx.mkApp(f, x, y);
714 Expr fwv = ctx.mkApp(f, w, v);
715
716 /* f(x, y) = f(w, v) */
717 BoolExpr p1 = ctx.mkEq(fxy, fwv);
718
719 /* prove f(x, y) = f(w, v) implies y = v */
720 BoolExpr p2 = ctx.mkEq(y, v);
721 prove(ctx, p2, false, inj, p1);
722
723 /* disprove f(x, y) = f(w, v) implies x = w */
724 BoolExpr p3 = ctx.mkEq(x, w);
725 disprove(ctx, p3, false, inj, p1);
726 }
727
728 // / Prove that <tt>f(x, y) = f(w, v) implies y = v</tt> when
729 // / <code>f</code> is injective in the second argument. <seealso

Callers 1

mainMethod · 0.95

Calls 9

appendMethod · 0.95
injAxiomMethod · 0.95
proveMethod · 0.95
disproveMethod · 0.95
getIntSortMethod · 0.80
mkFuncDeclMethod · 0.80
mkIntConstMethod · 0.80
mkAppMethod · 0.80
mkEqMethod · 0.80

Tested by

no test coverage detected