Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use logical shift right for BV '>>' operator #243

Open
JPaja opened this issue Jul 18, 2023 · 2 comments
Open

Use logical shift right for BV '>>' operator #243

JPaja opened this issue Jul 18, 2023 · 2 comments

Comments

@JPaja
Copy link

JPaja commented Jul 18, 2023

I think operator >> should be implemented to use bvlshr as default since BitVectors dont have sign.

impl_binary_op!(
    BV<'ctx>,
    Shr,
    ShrAssign,
    shr,
    shr_assign,
    bvlshr,
    mk_const_bv
);
@waywardmonkeys
Copy link
Contributor

@Pat-Lafon What do you think?

@Pat-Lafon
Copy link
Contributor

The original comment might need a little bit more elaboration. The original pr #88 which added these operations specifically called out shr as the BV operation not to be added because of sign issues.

While BVs don't have a sign, the documentation I've read suggests that the theory relies on special operations that change whether the BV should be treated as having a sign.

If we are looking to have consistency with the python implementation, https://z3prover.github.io/api/html/classz3py_1_1_bit_vec_ref.html#a5977ca600992dbeda4a98b38c372133a shows >> as mapping to bvashr instead(the arithmetic version).

I'm not sure how surprising/unexpected this mapping is for users. For example https://stackoverflow.com/questions/13955385/z3py-do-a-roll#comment19249416_13955593 shows there is confusion... but if it makes sense for the python bindings then maybe not having >> implemented at all would be more confusing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants