MCPcopy Create free account
hub / github.com/Z3Prover/z3 / tupleExample

Method tupleExample

examples/java/JavaGenericExample.java:1147–1176  ·  view source on GitHub ↗
(Context ctx)

Source from the content-addressed store, hash-verified

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

Callers 1

mainMethod · 0.95

Calls 10

appendMethod · 0.95
getFieldDeclsMethod · 0.95
mkDeclMethod · 0.95
proveMethod · 0.95
getIntSortMethod · 0.80
mkTupleSortMethod · 0.80
mkSymbolMethod · 0.80
mkConstMethod · 0.80
mkEqMethod · 0.80
applyMethod · 0.65

Tested by

no test coverage detected