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

Method proveExample1

examples/java/JavaGenericExample.java:984–1021  ·  view source on GitHub ↗
(Context ctx)

Source from the content-addressed store, hash-verified

982 // / <remarks>This function demonstrates how to create uninterpreted
983 // / types and functions.</remarks>
984 public void proveExample1(Context ctx) throws TestFailedException
985 {
986 System.out.println("ProveExample1");
987 Log.append("ProveExample1");
988
989 /* create uninterpreted type. */
990 UninterpretedSort U = ctx.mkUninterpretedSort(ctx.mkSymbol("U"));
991
992 /* declare function g */
993 FuncDecl<UninterpretedSort> g = ctx.mkFuncDecl("g", U, U);
994
995 /* create x and y */
996 Expr<UninterpretedSort> x = ctx.mkConst("x", U);
997 Expr<UninterpretedSort> y = ctx.mkConst("y", U);
998 /* create g(x), g(y) */
999 Expr<UninterpretedSort> gx = g.apply(x);
1000 Expr<UninterpretedSort> gy = g.apply(y);
1001
1002 /* assert x = y */
1003 BoolExpr eq = ctx.mkEq(x, y);
1004
1005 /* prove g(x) = g(y) */
1006 BoolExpr f = ctx.mkEq(gx, gy);
1007 System.out.println("prove: x = y implies g(x) = g(y)");
1008 prove(ctx, ctx.mkImplies(eq, f), false);
1009
1010 /* create g(g(x)) */
1011 Expr<UninterpretedSort> ggx = g.apply(gx);
1012
1013 /* disprove g(g(x)) = g(y) */
1014 f = ctx.mkEq(ggx, gy);
1015 System.out.println("disprove: x = y implies g(g(x)) = g(y)");
1016 disprove(ctx, ctx.mkImplies(eq, f), false);
1017
1018 /* Print the model using the custom model printer */
1019 Model m = check(ctx, ctx.mkNot(f), Status.SATISFIABLE);
1020 System.out.println(m);
1021 }
1022
1023 // / Prove <tt>not(g(g(x) - g(y)) = g(z)), x + z <= y <= x implies z < 0
1024 // </tt>.

Callers 1

mainMethod · 0.95

Calls 12

appendMethod · 0.95
proveMethod · 0.95
disproveMethod · 0.95
checkMethod · 0.95
mkUninterpretedSortMethod · 0.80
mkSymbolMethod · 0.80
mkFuncDeclMethod · 0.80
mkConstMethod · 0.80
mkEqMethod · 0.80
mkImpliesMethod · 0.80
mkNotMethod · 0.80
applyMethod · 0.65

Tested by

no test coverage detected