(Context ctx)
| 430 | // / <remarks>This example also shows how to use the <code>distinct</code> |
| 431 | // construct.</remarks> |
| 432 | @SuppressWarnings("unchecked") |
| 433 | public void arrayExample3(Context ctx) throws TestFailedException |
| 434 | { |
| 435 | System.out.println("ArrayExample3"); |
| 436 | Log.append("ArrayExample2"); |
| 437 | |
| 438 | for (int n = 2; n <= 5; n++) |
| 439 | { |
| 440 | System.out.printf("n = %d%n", n); |
| 441 | |
| 442 | BoolSort bool_type = ctx.mkBoolSort(); |
| 443 | ArraySort<BoolSort, BoolSort> array_type = ctx.mkArraySort(bool_type, bool_type); |
| 444 | List<Expr<ArraySort<BoolSort, BoolSort>>> a = IntStream.range(0, n).mapToObj(i -> ctx.mkConst(String.format("array_%d", i), array_type)).collect(Collectors.toList()); |
| 445 | |
| 446 | /* create arrays */ |
| 447 | |
| 448 | /* assert distinct(a[0], ..., a[n]) */ |
| 449 | BoolExpr d = ctx.mkDistinct(a.toArray(new Expr[0])); |
| 450 | System.out.println(d); |
| 451 | |
| 452 | /* context is satisfiable if n < 5 */ |
| 453 | Model model = check(ctx, d, n < 5 ? Status.SATISFIABLE : Status.UNSATISFIABLE); |
| 454 | if (n < 5) |
| 455 | { |
| 456 | for (int i = 0; i < n; i++) |
| 457 | { |
| 458 | System.out.printf("%s = %s%n", a.get(i), model.evaluate(a.get(i), false)); |
| 459 | } |
| 460 | } |
| 461 | } |
| 462 | } |
| 463 | |
| 464 | // / Sudoku solving example. |
| 465 |
no test coverage detected