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

Method quantifierExample4

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

Source from the content-addressed store, hash-verified

730 // cref="inj_axiom"/>
731
732 public void quantifierExample4(Context ctx) throws TestFailedException
733 {
734 System.out.println("QuantifierExample4");
735 Log.append("QuantifierExample4");
736
737 /*
738 * If quantified formulas are asserted in a logical context, then the
739 * model produced by Z3 should be viewed as a potential model.
740 */
741
742 /* declare function f */
743 Sort I = ctx.getIntSort();
744 FuncDecl f = ctx.mkFuncDecl("f", new Sort[] { I, I }, I);
745
746 /* f is injective in the second argument. */
747 BoolExpr inj = injAxiomAbs(ctx, f, 1);
748
749 /* create x, y, v, w, fxy, fwv */
750 Expr x = ctx.mkIntConst("x");
751 Expr y = ctx.mkIntConst("y");
752 Expr v = ctx.mkIntConst("v");
753 Expr w = ctx.mkIntConst("w");
754 Expr fxy = ctx.mkApp(f, x, y);
755 Expr fwv = ctx.mkApp(f, w, v);
756
757 /* f(x, y) = f(w, v) */
758 BoolExpr p1 = ctx.mkEq(fxy, fwv);
759
760 /* prove f(x, y) = f(w, v) implies y = v */
761 BoolExpr p2 = ctx.mkEq(y, v);
762 prove(ctx, p2, false, inj, p1);
763
764 /* disprove f(x, y) = f(w, v) implies x = w */
765 BoolExpr p3 = ctx.mkEq(x, w);
766 disprove(ctx, p3, false, inj, p1);
767 }
768
769 // / Some basic tests.
770

Callers 1

mainMethod · 0.95

Calls 9

appendMethod · 0.95
injAxiomAbsMethod · 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