(Context ctx)
| 401 | // / <remarks>This example demonstrates how to use the array |
| 402 | // theory.</remarks> |
| 403 | public void arrayExample2(Context ctx) throws TestFailedException |
| 404 | { |
| 405 | System.out.println("ArrayExample2"); |
| 406 | Log.append("ArrayExample2"); |
| 407 | |
| 408 | Sort int_type = ctx.getIntSort(); |
| 409 | Sort array_type = ctx.mkArraySort(int_type, int_type); |
| 410 | |
| 411 | ArrayExpr a1 = (ArrayExpr) ctx.mkConst("a1", array_type); |
| 412 | ArrayExpr a2 = ctx.mkArrayConst("a2", int_type, int_type); |
| 413 | Expr i1 = ctx.mkConst("i1", int_type); |
| 414 | Expr i2 = ctx.mkConst("i2", int_type); |
| 415 | Expr i3 = ctx.mkConst("i3", int_type); |
| 416 | Expr v1 = ctx.mkConst("v1", int_type); |
| 417 | Expr v2 = ctx.mkConst("v2", int_type); |
| 418 | |
| 419 | Expr st1 = ctx.mkStore(a1, i1, v1); |
| 420 | Expr st2 = ctx.mkStore(a2, i2, v2); |
| 421 | |
| 422 | Expr sel1 = ctx.mkSelect(a1, i3); |
| 423 | Expr sel2 = ctx.mkSelect(a2, i3); |
| 424 | |
| 425 | /* create antecedent */ |
| 426 | BoolExpr antecedent = ctx.mkEq(st1, st2); |
| 427 | |
| 428 | /* |
| 429 | * create consequent: i1 = i3 or i2 = i3 or select(a1, i3) = select(a2, |
| 430 | * i3) |
| 431 | */ |
| 432 | BoolExpr consequent = ctx.mkOr(ctx.mkEq(i1, i3), ctx.mkEq(i2, i3), |
| 433 | ctx.mkEq(sel1, sel2)); |
| 434 | |
| 435 | /* |
| 436 | * prove store(a1, i1, v1) = store(a2, i2, v2) implies (i1 = i3 or i2 = |
| 437 | * i3 or select(a1, i3) = select(a2, i3)) |
| 438 | */ |
| 439 | BoolExpr thm = ctx.mkImplies(antecedent, consequent); |
| 440 | System.out |
| 441 | .println("prove: store(a1, i1, v1) = store(a2, i2, v2) implies (i1 = i3 or i2 = i3 or select(a1, i3) = select(a2, i3))"); |
| 442 | System.out.println(thm); |
| 443 | prove(ctx, thm, false); |
| 444 | } |
| 445 | |
| 446 | // / Show that <code>distinct(a_0, ... , a_n)</code> is |
| 447 | // / unsatisfiable when <code>a_i</code>'s are arrays from boolean to |
no test coverage detected