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

Method floatingPointExample2

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

Source from the content-addressed store, hash-verified

1989 }
1990
1991 public void floatingPointExample2(Context ctx) throws TestFailedException
1992 {
1993 System.out.println("FloatingPointExample2");
1994 Log.append("FloatingPointExample2");
1995 FPSort double_sort = ctx.mkFPSort(11, 53);
1996 FPRMSort rm_sort = ctx.mkFPRoundingModeSort();
1997
1998 FPRMExpr rm = (FPRMExpr)ctx.mkConst(ctx.mkSymbol("rm"), rm_sort);
1999 BitVecExpr x = (BitVecExpr)ctx.mkConst(ctx.mkSymbol("x"), ctx.mkBitVecSort(64));
2000 FPExpr y = (FPExpr)ctx.mkConst(ctx.mkSymbol("y"), double_sort);
2001 FPExpr fp_val = ctx.mkFP(42, double_sort);
2002
2003 BoolExpr c1 = ctx.mkEq(y, fp_val);
2004 BoolExpr c2 = ctx.mkEq(x, ctx.mkFPToBV(rm, y, 64, false));
2005 BoolExpr c3 = ctx.mkEq(x, ctx.mkBV(42, 64));
2006 BoolExpr c4 = ctx.mkEq(ctx.mkNumeral(42, ctx.getRealSort()), ctx.mkFPToReal(fp_val));
2007 BoolExpr c5 = ctx.mkAnd(c1, c2, c3, c4);
2008 System.out.printf("c5 = %s%n", c5);
2009
2010 /* Generic solver */
2011 Solver s = ctx.mkSolver();
2012 s.add(c5);
2013
2014 if (s.check() != Status.SATISFIABLE)
2015 throw new TestFailedException();
2016
2017 System.out.printf("OK, model: %s%n", s.getModel());
2018 }
2019
2020 @SuppressWarnings("unchecked")
2021 public void optimizeExample(Context ctx)

Callers

nothing calls this directly

Calls 15

appendMethod · 0.95
addMethod · 0.95
checkMethod · 0.95
getModelMethod · 0.95
mkFPSortMethod · 0.80
mkFPRoundingModeSortMethod · 0.80
mkConstMethod · 0.80
mkSymbolMethod · 0.80
mkBitVecSortMethod · 0.80
mkFPMethod · 0.80
mkEqMethod · 0.80
mkFPToBVMethod · 0.80

Tested by

no test coverage detected