(Context ctx)
| 1534 | // / Create an enumeration data type. |
| 1535 | |
| 1536 | public void enumExample(Context ctx) throws TestFailedException |
| 1537 | { |
| 1538 | System.out.println("EnumExample"); |
| 1539 | Log.append("EnumExample"); |
| 1540 | |
| 1541 | Symbol name = ctx.mkSymbol("fruit"); |
| 1542 | |
| 1543 | EnumSort fruit = ctx.mkEnumSort(name, ctx.mkSymbol("apple"), |
| 1544 | ctx.mkSymbol("banana"), ctx.mkSymbol("orange")); |
| 1545 | |
| 1546 | System.out.println((fruit.getConsts()[0])); |
| 1547 | System.out.println((fruit.getConsts()[1])); |
| 1548 | System.out.println((fruit.getConsts()[2])); |
| 1549 | |
| 1550 | System.out.println((fruit.getTesterDecls()[0])); |
| 1551 | System.out.println((fruit.getTesterDecls()[1])); |
| 1552 | System.out.println((fruit.getTesterDecls()[2])); |
| 1553 | |
| 1554 | Expr apple = fruit.getConsts()[0]; |
| 1555 | Expr banana = fruit.getConsts()[1]; |
| 1556 | Expr orange = fruit.getConsts()[2]; |
| 1557 | |
| 1558 | /* Apples are different from oranges */ |
| 1559 | prove(ctx, ctx.mkNot(ctx.mkEq(apple, orange)), false); |
| 1560 | |
| 1561 | /* Apples pass the apple test */ |
| 1562 | prove(ctx, (BoolExpr) ctx.mkApp(fruit.getTesterDecls()[0], apple), |
| 1563 | false); |
| 1564 | |
| 1565 | /* Oranges fail the apple test */ |
| 1566 | disprove(ctx, (BoolExpr) ctx.mkApp(fruit.getTesterDecls()[0], orange), |
| 1567 | false); |
| 1568 | prove(ctx, |
| 1569 | (BoolExpr) ctx.mkNot((BoolExpr) ctx.mkApp( |
| 1570 | fruit.getTesterDecls()[0], orange)), false); |
| 1571 | |
| 1572 | Expr fruity = ctx.mkConst("fruity", fruit); |
| 1573 | |
| 1574 | /* If something is fruity, then it is an apple, banana, or orange */ |
| 1575 | |
| 1576 | prove(ctx, |
| 1577 | ctx.mkOr(ctx.mkEq(fruity, apple), ctx.mkEq(fruity, banana), |
| 1578 | ctx.mkEq(fruity, orange)), false); |
| 1579 | } |
| 1580 | |
| 1581 | // / Create a list datatype. |
| 1582 |
no test coverage detected