(Context ctx)
| 1145 | // / <remarks>Check that the projection of a tuple |
| 1146 | // / returns the corresponding element.</remarks> |
| 1147 | public void tupleExample(Context ctx) throws TestFailedException |
| 1148 | { |
| 1149 | System.out.println("TupleExample"); |
| 1150 | Log.append("TupleExample"); |
| 1151 | |
| 1152 | IntSort int_type = ctx.getIntSort(); |
| 1153 | TupleSort tuple = ctx.mkTupleSort(ctx.mkSymbol("mk_tuple"), // name of |
| 1154 | // tuple |
| 1155 | // constructor |
| 1156 | new Symbol[] { ctx.mkSymbol("first"), ctx.mkSymbol("second") }, // names |
| 1157 | // of |
| 1158 | // projection |
| 1159 | // operators |
| 1160 | new Sort[] { int_type, int_type } // types of projection |
| 1161 | // operators |
| 1162 | ); |
| 1163 | // have to cast here because it is not possible to type a member of an array of mixed generics |
| 1164 | @SuppressWarnings("unchecked") |
| 1165 | FuncDecl<IntSort> first = (FuncDecl<IntSort>) tuple.getFieldDecls()[0]; // declarations are for |
| 1166 | // projections |
| 1167 | @SuppressWarnings("unused") |
| 1168 | FuncDecl<?> second = tuple.getFieldDecls()[1]; |
| 1169 | Expr<IntSort> x = ctx.mkConst("x", int_type); |
| 1170 | Expr<IntSort> y = ctx.mkConst("y", int_type); |
| 1171 | Expr<TupleSort> n1 = tuple.mkDecl().apply(x, y); |
| 1172 | Expr<IntSort> n2 = first.apply(n1); |
| 1173 | BoolExpr n3 = ctx.mkEq(x, n2); |
| 1174 | System.out.printf("Tuple example: %s%n", n3); |
| 1175 | prove(ctx, n3, false); |
| 1176 | } |
| 1177 | |
| 1178 | // / Simple bit-vector example. |
| 1179 |
no test coverage detected