(Context ctx)
| 1028 | // functions |
| 1029 | // / and arithmetic.</remarks> |
| 1030 | public void proveExample2(Context ctx) throws TestFailedException |
| 1031 | { |
| 1032 | System.out.println("ProveExample2"); |
| 1033 | Log.append("ProveExample2"); |
| 1034 | |
| 1035 | /* declare function g */ |
| 1036 | IntSort I = ctx.getIntSort(); |
| 1037 | |
| 1038 | FuncDecl<IntSort> g = ctx.mkFuncDecl("g", I, I); |
| 1039 | |
| 1040 | /* create x, y, and z */ |
| 1041 | IntExpr x = ctx.mkIntConst("x"); |
| 1042 | IntExpr y = ctx.mkIntConst("y"); |
| 1043 | IntExpr z = ctx.mkIntConst("z"); |
| 1044 | |
| 1045 | /* create gx, gy, gz */ |
| 1046 | Expr<IntSort> gx = ctx.mkApp(g, x); |
| 1047 | Expr<IntSort> gy = ctx.mkApp(g, y); |
| 1048 | Expr<IntSort> gz = ctx.mkApp(g, z); |
| 1049 | |
| 1050 | /* create zero */ |
| 1051 | IntNum zero = ctx.mkInt(0); |
| 1052 | |
| 1053 | /* assert not(g(g(x) - g(y)) = g(z)) */ |
| 1054 | ArithExpr<IntSort> gx_gy = ctx.mkSub(gx, gy); |
| 1055 | Expr<IntSort> ggx_gy = ctx.mkApp(g, gx_gy); |
| 1056 | BoolExpr eq = ctx.mkEq(ggx_gy, gz); |
| 1057 | BoolExpr c1 = ctx.mkNot(eq); |
| 1058 | |
| 1059 | /* assert x + z <= y */ |
| 1060 | ArithExpr<IntSort> x_plus_z = ctx.mkAdd(x, z); |
| 1061 | BoolExpr c2 = ctx.mkLe(x_plus_z, y); |
| 1062 | |
| 1063 | /* assert y <= x */ |
| 1064 | BoolExpr c3 = ctx.mkLe(y, x); |
| 1065 | |
| 1066 | /* prove z < 0 */ |
| 1067 | BoolExpr f = ctx.mkLt(z, zero); |
| 1068 | System.out.println("prove: not(g(g(x) - g(y)) = g(z)), x + z <= y <= x implies z < 0"); |
| 1069 | prove(ctx, f, false, c1, c2, c3); |
| 1070 | |
| 1071 | /* disprove z < -1 */ |
| 1072 | IntNum minus_one = ctx.mkInt(-1); |
| 1073 | f = ctx.mkLt(z, minus_one); |
| 1074 | System.out.println("disprove: not(g(g(x) - g(y)) = g(z)), x + z <= y <= x implies z < -1"); |
| 1075 | disprove(ctx, f, false, c1, c2, c3); |
| 1076 | } |
| 1077 | |
| 1078 | // / Show how push & pop can be used to create "backtracking" points. |
| 1079 |
no test coverage detected