(Context ctx)
| 450 | // / <remarks>This example also shows how to use the <code>distinct</code> |
| 451 | // construct.</remarks> |
| 452 | public void arrayExample3(Context ctx) throws TestFailedException |
| 453 | { |
| 454 | System.out.println("ArrayExample3"); |
| 455 | Log.append("ArrayExample2"); |
| 456 | |
| 457 | for (int n = 2; n <= 5; n++) |
| 458 | { |
| 459 | System.out.println("n = " + Integer.toString(n)); |
| 460 | |
| 461 | Sort bool_type = ctx.mkBoolSort(); |
| 462 | Sort array_type = ctx.mkArraySort(bool_type, bool_type); |
| 463 | Expr[] a = new Expr[n]; |
| 464 | |
| 465 | /* create arrays */ |
| 466 | for (int i = 0; i < n; i++) |
| 467 | { |
| 468 | a[i] = ctx.mkConst("array_" + Integer.toString(i), array_type); |
| 469 | } |
| 470 | |
| 471 | /* assert distinct(a[0], ..., a[n]) */ |
| 472 | BoolExpr d = ctx.mkDistinct(a); |
| 473 | System.out.println(d); |
| 474 | |
| 475 | /* context is satisfiable if n < 5 */ |
| 476 | Model model = check(ctx, d, n < 5 ? Status.SATISFIABLE |
| 477 | : Status.UNSATISFIABLE); |
| 478 | if (n < 5) |
| 479 | { |
| 480 | for (int i = 0; i < n; i++) |
| 481 | { |
| 482 | System.out.println(a[i].toString() + " = " |
| 483 | + model.evaluate(a[i], false)); |
| 484 | } |
| 485 | } |
| 486 | } |
| 487 | } |
| 488 | |
| 489 | // / Sudoku solving example. |
| 490 |
no test coverage detected