(Context ctx)
| 1239 | // functions |
| 1240 | // / and arithmetic.</remarks> |
| 1241 | public void proveExample2(Context ctx) throws TestFailedException |
| 1242 | { |
| 1243 | System.out.println("ProveExample2"); |
| 1244 | Log.append("ProveExample2"); |
| 1245 | |
| 1246 | /* declare function g */ |
| 1247 | Sort I = ctx.getIntSort(); |
| 1248 | |
| 1249 | FuncDecl g = ctx.mkFuncDecl("g", I, I); |
| 1250 | |
| 1251 | /* create x, y, and z */ |
| 1252 | IntExpr x = ctx.mkIntConst("x"); |
| 1253 | IntExpr y = ctx.mkIntConst("y"); |
| 1254 | IntExpr z = ctx.mkIntConst("z"); |
| 1255 | |
| 1256 | /* create gx, gy, gz */ |
| 1257 | Expr gx = ctx.mkApp(g, x); |
| 1258 | Expr gy = ctx.mkApp(g, y); |
| 1259 | Expr gz = ctx.mkApp(g, z); |
| 1260 | |
| 1261 | /* create zero */ |
| 1262 | IntExpr zero = ctx.mkInt(0); |
| 1263 | |
| 1264 | /* assert not(g(g(x) - g(y)) = g(z)) */ |
| 1265 | ArithExpr gx_gy = ctx.mkSub((IntExpr) gx, (IntExpr) gy); |
| 1266 | Expr ggx_gy = ctx.mkApp(g, gx_gy); |
| 1267 | BoolExpr eq = ctx.mkEq(ggx_gy, gz); |
| 1268 | BoolExpr c1 = ctx.mkNot(eq); |
| 1269 | |
| 1270 | /* assert x + z <= y */ |
| 1271 | ArithExpr x_plus_z = ctx.mkAdd(x, z); |
| 1272 | BoolExpr c2 = ctx.mkLe(x_plus_z, y); |
| 1273 | |
| 1274 | /* assert y <= x */ |
| 1275 | BoolExpr c3 = ctx.mkLe(y, x); |
| 1276 | |
| 1277 | /* prove z < 0 */ |
| 1278 | BoolExpr f = ctx.mkLt(z, zero); |
| 1279 | System.out |
| 1280 | .println("prove: not(g(g(x) - g(y)) = g(z)), x + z <= y <= x implies z < 0"); |
| 1281 | prove(ctx, f, false, c1, c2, c3); |
| 1282 | |
| 1283 | /* disprove z < -1 */ |
| 1284 | IntExpr minus_one = ctx.mkInt(-1); |
| 1285 | f = ctx.mkLt(z, minus_one); |
| 1286 | System.out |
| 1287 | .println("disprove: not(g(g(x) - g(y)) = g(z)), x + z <= y <= x implies z < -1"); |
| 1288 | disprove(ctx, f, false, c1, c2, c3); |
| 1289 | } |
| 1290 | |
| 1291 | // / Show how push & pop can be used to create "backtracking" points. |
| 1292 |
no test coverage detected