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

Method tupleExample

examples/java/JavaExample.java:1361–1388  ·  view source on GitHub ↗
(Context ctx)

Source from the content-addressed store, hash-verified

1359 // / <remarks>Check that the projection of a tuple
1360 // / returns the corresponding element.</remarks>
1361 public void tupleExample(Context ctx) throws TestFailedException
1362 {
1363 System.out.println("TupleExample");
1364 Log.append("TupleExample");
1365
1366 Sort int_type = ctx.getIntSort();
1367 TupleSort tuple = ctx.mkTupleSort(ctx.mkSymbol("mk_tuple"), // name of
1368 // tuple
1369 // constructor
1370 new Symbol[] { ctx.mkSymbol("first"), ctx.mkSymbol("second") }, // names
1371 // of
1372 // projection
1373 // operators
1374 new Sort[] { int_type, int_type } // types of projection
1375 // operators
1376 );
1377 FuncDecl first = tuple.getFieldDecls()[0]; // declarations are for
1378 // projections
1379 @SuppressWarnings("unused")
1380 FuncDecl second = tuple.getFieldDecls()[1];
1381 Expr x = ctx.mkConst("x", int_type);
1382 Expr y = ctx.mkConst("y", int_type);
1383 Expr n1 = tuple.mkDecl().apply(x, y);
1384 Expr n2 = first.apply(n1);
1385 BoolExpr n3 = ctx.mkEq(x, n2);
1386 System.out.println("Tuple example: " + n3);
1387 prove(ctx, n3, false);
1388 }
1389
1390 // / Simple bit-vector example.
1391

Callers 1

mainMethod · 0.95

Calls 11

appendMethod · 0.95
getFieldDeclsMethod · 0.95
mkDeclMethod · 0.95
applyMethod · 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