Skip to content

Conversation

@Lysxia
Copy link
Collaborator

@Lysxia Lysxia commented Nov 26, 2025

No description provided.

Comment on lines +207 to +209
#[ensures(self >> $type::BITS - result == $zero)]
#[ensures((result != $type::BITS) == (self >> ($type::BITS - result - 1u32) == $one))]
#[ensures((result == $type::BITS) == (self == $zero))]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#[ensures(self >> $type::BITS - result == $zero)]
#[ensures((result != $type::BITS) == (self >> ($type::BITS - result - 1u32) == $one))]
#[ensures((result == $type::BITS) == (self == $zero))]
#[ensures((result != $type::BITS) == (self >> ($type::BITS - result - 1u32) == $one))]
#[ensures((result == $type::BITS) == (self == $zero))]

This clause is redundant (though it's unclear whether SMT solvers will be more comfortable with suc or such clause).

Comment on lines +213 to +215
#[ensures(self << $type::BITS - result == $zero)]
#[ensures((result != $type::BITS) == ((self >> $type::BITS) & $one == $one))]
#[ensures((result == $type::BITS) == (self == $zero))]
Copy link
Collaborator

@jhjourdan jhjourdan Nov 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#[ensures(self << $type::BITS - result == $zero)]
#[ensures((result != $type::BITS) == ((self >> $type::BITS) & $one == $one))]
#[ensures((result == $type::BITS) == (self == $zero))]
#[ensures((result != $type::BITS) == (self << ($type::BITS - result - 1u32) == $one << ($type::BITS - 1u32))]
#[ensures((result == $type::BITS) == (self == $zero))]

I see no reason we would have a different spec for both functions.

Comment on lines +219 to +221
#[ensures(!self >> $type::BITS - result == $zero)]
#[ensures((result != $type::BITS) == (!self >> ($type::BITS - result - 1u32) == $zero))]
#[ensures((result == $type::BITS) == (self == $type::MAX))]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#[ensures(!self >> $type::BITS - result == $zero)]
#[ensures((result != $type::BITS) == (!self >> ($type::BITS - result - 1u32) == $zero))]
#[ensures((result == $type::BITS) == (self == $type::MAX))]
#[ensures((result != $type::BITS) == (!self >> ($type::BITS - result - 1u32) == $zero))]
#[ensures((result == $type::BITS) == (self == $type::MAX))]

Comment on lines +225 to +227
#[ensures(!self << $type::BITS - result == $zero)]
#[ensures((result != $type::BITS) == ((!self >> $type::BITS) & $one == $one))]
#[ensures((result == $type::BITS) == (self == $type::MAX))]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#[ensures(!self << $type::BITS - result == $zero)]
#[ensures((result != $type::BITS) == ((!self >> $type::BITS) & $one == $one))]
#[ensures((result == $type::BITS) == (self == $type::MAX))]
#[ensures((result == $type::BITS) == (!self << ($type::BITS - result - 1u32) == $one << ($type::BITS - 1u32)))]
#[ensures((result == $type::BITS) == (self == $type::MAX))]

@jhjourdan
Copy link
Collaborator

Suggestion: have logic functions for trailing/leading_one/zeros, specified the same way, and use them to specify the program function.

@Lysxia
Copy link
Collaborator Author

Lysxia commented Dec 1, 2025

@mcoulmance the main todo is to fix the translation of << in logic to lsl_bv : t -> t -> t instead of lsl : t -> int -> t. The challenge is that << allows arguments of different types, so we need to cast the second argument accordingly. This also means deciding of a way to handle overflows, which we didn't need before when the second argument was cast to int.

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

Successfully merging this pull request may close these issues.

2 participants