0

In one of my SMT program, I use a real term. I need to bound the precision of the real number for increasing the efficiency, as there are almost infinite number of solutions are possible for this number, although only 5/6 digits after the decimal point is necessary. For example, the possible valuation of the real numbers can be the following, though all are the same if we take the first seven digits after the decimal point.

1197325/13631488 = 0.087835238530......

19157213/218103808 = 0.087835298134......

153257613/1744830464 = 0.087835245980......

1226060865/13958643712 = 0.087835243186......

I want that the SMT solver considers all these four number as a single number (so that the search space reduces). Is there any way to control the precision of the real number?

I tried programmatically (using Z3 Dot Net API) to solve this above problem, which is shown in the following. Here DelBP[j] is a real term.

{
    BoolExpr[] _Exprs = new BoolExpr[nBuses];
    for (j = 1; j <= nBuses; j++)
    {
        _Exprs[j - 1] = z3.MkEq(DelBP[j], z3.MkDiv(z3.MkInt2Real(DelBP_A[j]), z3.MkInt2Real(DelBP_B[j])));
    }

    BoolExpr Expr = z3.MkAnd(_Exprs);
    s.Assert(Expr);
    tw.WriteLine("(assert {0})", Expr.ToString());
}

{
    BoolExpr[] _Exprs = new BoolExpr[nBuses];
    for (j = 1; j <= nBuses; j++)
    {
        _Exprs[j - 1] = z3.MkAnd(z3.MkGe(DelBP_A[j], z3.MkInt(1)),
            z3.MkLe(DelBP_A[j], z3.MkInt(10000)));
    }

    BoolExpr Expr = z3.MkAnd(_Exprs);
    s.Assert(Expr);
    tw.WriteLine("(assert {0})", Expr.ToString());
}

{
    BoolExpr[] _Exprs = new BoolExpr[nBuses];
    for (j = 1; j <= nBuses; j++)
    {
        _Exprs[j - 1] = z3.MkAnd(z3.MkGe(DelBP_B[j], z3.MkInt(1)),
            z3.MkLe(DelBP_B[j], z3.MkInt(10000)));
    }

    BoolExpr Expr = z3.MkAnd(_Exprs);
    s.Assert(Expr);
    tw.WriteLine("(assert {0})", Expr.ToString());
}

However, it did not work. Can anyone help me to solve this problem? Thank you in advance.

Ashiq
  • 307
  • 2
  • 10

1 Answers1

1

If you feel the need to control the "precision" of real-numbers, then that strongly suggests Real is not the correct domain for your problem. Some ideas, depending on what you're really trying to do:

  • If 6 digits past the decimal point is all you care, then you might get away with using plain Integers, multiplying everything by 1e6 and restricting all variables to be less than 1e6; or some other similar transformation.

  • Keep in mind that Z3 has support for IEEE-floating point numbers these days, which are by definition of limited precision. So you can use those if your domain is truly the floating-point numbers as prescribed by IEEE-754.

  • If you're trying to generate "successive" results, i.e., by solving the problem, then adding the constraint that the result should be different than the previous one, and calling Z3 again; then you can consider adding a constraint that says the new result should differ from the old by more than 1e6 in absolute value.

Whether any of this applies depends on the precise problem you're trying to solve. If you can share some more of your problem, people might be able to come up with other ideas. But the first choice should be figuring out if Real is really the domain you want to work with.

alias
  • 28,120
  • 2
  • 23
  • 40
  • Thanks for your reply. I cannot use Integer terms, as my actual problem needs floating points values. I have already applied the third to see how many different results I can get by adding constraints for the precision. However, my program includes a second part, that depends on these potential values. I do not want to segregate these two parts and combine them programmatically (i.e., external to the model). I think your second suggestion may work. Can you provide me any link or elaborated suggestion that can help me know more about this? – Ashiq Aug 29 '13 at 21:00
  • I think Z3 Dot Net API does not support IEEE floating point numbers. Does it? – Ashiq Aug 30 '13 at 03:01
  • FP support is pretty new, it wouldn't surprise me if only SMT-Lib was supported for the time being. But one of the Z3 folks need to confirm that. See http://stackoverflow.com/questions/15181211/qf-fpa-does-z3-support-ieee-754-arithmetic for some more info. – alias Aug 30 '13 at 22:09
  • Yes, currently we have FPA support in SMTlib format and through the API in a new branch of Z3 called fpa-api: http://z3.codeplex.com/SourceControl/latest?branch=fpa-api – Christoph Wintersteiger Sep 13 '13 at 12:12