Skip to content

Missing features and/or potential bugs (willing to fix) #360

@leventeBajczi

Description

@leventeBajczi

Hi!

I'm in the process (ftsrg/theta#258) of integrating JavaSMT with our Theta model checker. By doing so, I have discovered some pain points of the integration, which I'd like to both log as a potential issue and discuss in terms of what I can do to help these get resolved. I'm more than happy to try and create a PR about the changes, but wanted to discuss first.

I know that most of these problems are easily solved using some workarounds, but I think there is value in getting them implemented / fixed.

In no particular order the missing features (keep in mind that it is entirely possible that I just missed some :) ):

  1. The conversion between Rational and Integer sorts in this direction is given by the .floor() operation, but there is no inverse operation, despite Z3 having a .mkInt2Real, SMT-LIB defining a to_real, etc. I can see some signs of support for this operator (e.g., here), but I see no way of creating this formula otherwise.

  2. There is no support for rotating (either left or right) a bitvector. Some solvers (including Z3 and CVC4) have support for these operators, and for others, it can be (expensively) emulated. However, emulating it for supporting solvers is way too big of an overhead.

  3. fp.rem is not supported.

  4. I see no way of creating array literals, therefore I cannot translate the following assertion: (assert (= 0 (select ((as const (Array Int Int)) 0) 0))).

  5. I see no way of creating a floating point literal from a IEEE-754 bit pattern without first creating the bitvector literal, then using the fromIeeeBitvector. Consequently, I also miss a way of retrieving the bit pattern from a floating point literal.

And the (potential) bug:

  1. Modulo creates REM operator instead of MOD for bitvectors. See relevant code here. This is potentially dangerous, because (at least) I would think that a .modulo() function will use the bvsmod operator, and not one of the {s,u}rem operators. Consider the following as an example for why this matters:
(declare-fun a () (_ BitVec 2))
(declare-fun b () (_ BitVec 2))

(assert (not (= (bvsmod a b) (bvsrem a b))))

(declare-fun c () (_ BitVec 2))
(declare-fun d () (_ BitVec 2))

(assert (not (= (bvsmod c d) (bvurem c d))))

(check-sat)
(get-model)

There are satisfying assignments to all variables (meaning smod corresponds to neither urem nor srem) , and in those cases, a wrong result would have been created, should the user not look at the internals of JavaSMT. I think this should be changed.

Again, I'm more than happy to provide a fix for these as a PR. However, I would like to get some feedback on the points above, especially regarding which might be a misunderstanding on my part rather than a missing feature / bug. Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions