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

Improving reasoning for the BV theory #903

Open
3 of 4 tasks
Halbaroth opened this issue Oct 18, 2023 · 7 comments
Open
3 of 4 tasks

Improving reasoning for the BV theory #903

Halbaroth opened this issue Oct 18, 2023 · 7 comments
Assignees
Labels
reasoning This issue is about improving reasoning capabilities. umbrella
Milestone

Comments

@Halbaroth
Copy link
Collaborator

Halbaroth commented Oct 18, 2023

This umbrella issue tracks the progression of the BV theory reasoning. Please add related issue here and what we plan to improve in the future.

@Halbaroth Halbaroth added reasoning This issue is about improving reasoning capabilities. umbrella labels Oct 18, 2023
@bclement-ocp bclement-ocp self-assigned this Nov 13, 2023
@bclement-ocp bclement-ocp added this to the 2.6.0 milestone Nov 13, 2023
bclement-ocp added a commit to bclement-ocp/alt-ergo that referenced this issue Jan 26, 2024
This patch rewrites the `Constraints_make` module in order to make it
more flexible (this is preparatory step for dealing with arithmetic
bit-vector constraints, see OCamlPro#903).

More precisely:

 - Constraints no longer need to keep track of their own explanations,
   this is now entirely done by the `Constraints_make` functor. This
   makes it simpler to write `Constraint` modules, and avoid repeating
   boilerplate code to deal with explanation storage. Instead, the
   explanations are provided to the `Constraint` module in its
   `propagate` function.

 - The `Constraints_make` functor no longer need to know about
   constraint propagation. Instead, it simply keeps track of constraints
   that need to be propagated (pending constraints), and provides an API
   to flush the set of constraints to be propagated, letting the user
   take care of propagation proper.

 - The `Constraints_make` functor now tracks separately the constraint
   arguments and the leaves of said arguments. The leaves are used to
   know which constraints need to be updated during a substitution, and
   the arguments are used to mark as pending all constraints that apply
   to a given representative when its domain is updated (note that, for
   the bit-list domains, we actually store the domains at the leaves, so
   the arguments mapping is not used -- but this still makes the module
   more flexible in general, and in particular will allow to introduce
   arithmetic domains that need to be stored for all values, not only
   leaves, for the purpose of OCamlPro#903 in a future PR)

The new design should make it easier to write `Constraint` modules. It
also fixes a bug in the contract between the `Constraint` and `Domain`
modules regarding substitution: the `Domain` modules was written under
the assumption that constraints applying to `changed` domains would
always be marked as pending upon substitution, but that is not true
because we use functional representations where such updates are
delayed, and hence the `changed` flag needs to be propagated after
substitution (if appropriate).
bclement-ocp added a commit to bclement-ocp/alt-ergo that referenced this issue Jan 26, 2024
This patch rewrites the `Constraints_make` module in order to make it
more flexible (this is preparatory step for dealing with arithmetic
bit-vector constraints, see OCamlPro#903).

More precisely:

 - Constraints no longer need to keep track of their own explanations,
   this is now entirely done by the `Constraints_make` functor. This
   makes it simpler to write `Constraint` modules, and avoid repeating
   boilerplate code to deal with explanation storage. Instead, the
   explanations are provided to the `Constraint` module in its
   `propagate` function.

 - The `Constraints_make` functor no longer need to know about
   constraint propagation. Instead, it simply keeps track of constraints
   that need to be propagated (pending constraints), and provides an API
   to iterate (and remove) the set of constraints to be propagated,
   letting the user take care of propagation proper.

 - The `Constraints_make` functor now tracks separately the constraint
   arguments and the leaves of said arguments. The leaves are used to
   know which constraints need to be updated during a substitution, and
   the arguments are used to mark as pending all constraints that apply
   to a given representative when its domain is updated (note that, for
   the bit-list domains, we actually store the domains at the leaves, so
   the arguments mapping is not used -- but this still makes the module
   more flexible in general, and in particular will allow to introduce
   arithmetic domains that need to be stored for all values, not only
   leaves, for the purpose of OCamlPro#903 in a future PR)

The new design should make it easier to write `Constraint` modules. It
also fixes a bug in the contract between the `Constraint` and `Domain`
modules regarding substitution: the `Domain` modules was written under
the assumption that constraints applying to `changed` domains would
always be marked as pending upon substitution, but that is not true
because we use functional representations where such updates are
delayed, and hence the `changed` flag needs to be propagated after
substitution (if appropriate).
bclement-ocp added a commit to bclement-ocp/alt-ergo that referenced this issue Feb 8, 2024
This patch rewrites the `Constraints_make` module in order to make it
more flexible (this is preparatory step for dealing with arithmetic
bit-vector constraints, see OCamlPro#903).

More precisely:

 - Constraints no longer need to keep track of their own explanations,
   this is now entirely done by the `Constraints_make` functor. This
   makes it simpler to write `Constraint` modules, and avoid repeating
   boilerplate code to deal with explanation storage. Instead, the
   explanations are provided to the `Constraint` module in its
   `propagate` function.

 - The `Constraints_make` functor no longer need to know about
   constraint propagation. Instead, it simply keeps track of constraints
   that need to be propagated (pending constraints), and provides an API
   to iterate (and remove) the set of constraints to be propagated,
   letting the user take care of propagation proper.

 - The `Constraints_make` functor now tracks separately the constraint
   arguments and the leaves of said arguments. The leaves are used to
   know which constraints need to be updated during a substitution, and
   the arguments are used to mark as pending all constraints that apply
   to a given representative when its domain is updated (note that, for
   the bit-list domains, we actually store the domains at the leaves, so
   the arguments mapping is not used -- but this still makes the module
   more flexible in general, and in particular will allow to introduce
   arithmetic domains that need to be stored for all values, not only
   leaves, for the purpose of OCamlPro#903 in a future PR)

The new design should make it easier to write `Constraint` modules. It
also fixes a bug in the contract between the `Constraint` and `Domain`
modules regarding substitution: the `Domain` modules was written under
the assumption that constraints applying to `changed` domains would
always be marked as pending upon substitution, but that is not true
because we use functional representations where such updates are
delayed, and hence the `changed` flag needs to be propagated after
substitution (if appropriate).
bclement-ocp added a commit to bclement-ocp/alt-ergo that referenced this issue Feb 9, 2024
This patch rewrites the `Constraints_make` module in order to make it
more flexible (this is preparatory step for dealing with arithmetic
bit-vector constraints, see OCamlPro#903).

More precisely:

 - Constraints no longer need to keep track of their own explanations,
   this is now entirely done by the `Constraints_make` functor. This
   makes it simpler to write `Constraint` modules, and avoid repeating
   boilerplate code to deal with explanation storage. Instead, the
   explanations are provided to the `Constraint` module in its
   `propagate` function.

 - The `Constraints_make` functor no longer need to know about
   constraint propagation. Instead, it simply keeps track of constraints
   that need to be propagated (pending constraints), and provides an API
   to iterate (and remove) the set of constraints to be propagated,
   letting the user take care of propagation proper.

 - The `Constraints_make` functor now tracks separately the constraint
   arguments and the leaves of said arguments. The leaves are used to
   know which constraints need to be updated during a substitution, and
   the arguments are used to mark as pending all constraints that apply
   to a given representative when its domain is updated (note that, for
   the bit-list domains, we actually store the domains at the leaves, so
   the arguments mapping is not used -- but this still makes the module
   more flexible in general, and in particular will allow to introduce
   arithmetic domains that need to be stored for all values, not only
   leaves, for the purpose of OCamlPro#903 in a future PR)

The new design should make it easier to write `Constraint` modules. It
also fixes a bug in the contract between the `Constraint` and `Domain`
modules regarding substitution: the `Domain` modules was written under
the assumption that constraints applying to `changed` domains would
always be marked as pending upon substitution, but that is not true
because we use functional representations where such updates are
delayed, and hence the `changed` flag needs to be propagated after
substitution (if appropriate).
bclement-ocp added a commit to bclement-ocp/alt-ergo that referenced this issue Feb 12, 2024
This patch rewrites the `Constraints_make` module in order to make it
more flexible (this is preparatory step for dealing with arithmetic
bit-vector constraints, see OCamlPro#903).

More precisely:

 - Constraints no longer need to keep track of their own explanations,
   this is now entirely done by the `Constraints_make` functor. This
   makes it simpler to write `Constraint` modules, and avoid repeating
   boilerplate code to deal with explanation storage. Instead, the
   explanations are provided to the `Constraint` module in its
   `propagate` function.

 - The `Constraints_make` functor no longer need to know about
   constraint propagation. Instead, it simply keeps track of constraints
   that need to be propagated (pending constraints), and provides an API
   to iterate (and remove) the set of constraints to be propagated,
   letting the user take care of propagation proper.

 - The `Constraints_make` functor now tracks separately the constraint
   arguments and the leaves of said arguments. The leaves are used to
   know which constraints need to be updated during a substitution, and
   the arguments are used to mark as pending all constraints that apply
   to a given representative when its domain is updated (note that, for
   the bit-list domains, we actually store the domains at the leaves, so
   the arguments mapping is not used -- but this still makes the module
   more flexible in general, and in particular will allow to introduce
   arithmetic domains that need to be stored for all values, not only
   leaves, for the purpose of OCamlPro#903 in a future PR)

The new design should make it easier to write `Constraint` modules. It
also fixes a bug in the contract between the `Constraint` and `Domain`
modules regarding substitution: the `Domain` modules was written under
the assumption that constraints applying to `changed` domains would
always be marked as pending upon substitution, but that is not true
because we use functional representations where such updates are
delayed, and hence the `changed` flag needs to be propagated after
substitution (if appropriate).
bclement-ocp added a commit to bclement-ocp/alt-ergo that referenced this issue Mar 4, 2024
This patch rewrites the `Constraints_make` module in order to make it
more flexible (this is preparatory step for dealing with arithmetic
bit-vector constraints, see OCamlPro#903).

More precisely:

 - Constraints no longer need to keep track of their own explanations,
   this is now entirely done by the `Constraints_make` functor. This
   makes it simpler to write `Constraint` modules, and avoid repeating
   boilerplate code to deal with explanation storage. Instead, the
   explanations are provided to the `Constraint` module in its
   `propagate` function.

 - The `Constraints_make` functor no longer need to know about
   constraint propagation. Instead, it simply keeps track of constraints
   that need to be propagated (pending constraints), and provides an API
   to iterate (and remove) the set of constraints to be propagated,
   letting the user take care of propagation proper.

 - The `Constraints_make` functor now tracks separately the constraint
   arguments and the leaves of said arguments. The leaves are used to
   know which constraints need to be updated during a substitution, and
   the arguments are used to mark as pending all constraints that apply
   to a given representative when its domain is updated (note that, for
   the bit-list domains, we actually store the domains at the leaves, so
   the arguments mapping is not used -- but this still makes the module
   more flexible in general, and in particular will allow to introduce
   arithmetic domains that need to be stored for all values, not only
   leaves, for the purpose of OCamlPro#903 in a future PR)

The new design should make it easier to write `Constraint` modules. It
also fixes a bug in the contract between the `Constraint` and `Domain`
modules regarding substitution: the `Domain` modules was written under
the assumption that constraints applying to `changed` domains would
always be marked as pending upon substitution, but that is not true
because we use functional representations where such updates are
delayed, and hence the `changed` flag needs to be propagated after
substitution (if appropriate).
bclement-ocp added a commit to bclement-ocp/alt-ergo that referenced this issue Mar 4, 2024
This patch rewrites the `Constraints_make` module in order to make it
more flexible (this is preparatory step for dealing with arithmetic
bit-vector constraints, see OCamlPro#903).

More precisely:

 - Constraints no longer need to keep track of their own explanations,
   this is now entirely done by the `Constraints_make` functor. This
   makes it simpler to write `Constraint` modules, and avoid repeating
   boilerplate code to deal with explanation storage. Instead, the
   explanations are provided to the `Constraint` module in its
   `propagate` function.

 - The `Constraints_make` functor no longer need to know about
   constraint propagation. Instead, it simply keeps track of constraints
   that need to be propagated (pending constraints), and provides an API
   to iterate (and remove) the set of constraints to be propagated,
   letting the user take care of propagation proper.

 - The `Constraints_make` functor now tracks separately the constraint
   arguments and the leaves of said arguments. The leaves are used to
   know which constraints need to be updated during a substitution, and
   the arguments are used to mark as pending all constraints that apply
   to a given representative when its domain is updated (note that, for
   the bit-list domains, we actually store the domains at the leaves, so
   the arguments mapping is not used -- but this still makes the module
   more flexible in general, and in particular will allow to introduce
   arithmetic domains that need to be stored for all values, not only
   leaves, for the purpose of OCamlPro#903 in a future PR)

The new design should make it easier to write `Constraint` modules. It
also fixes a bug in the contract between the `Constraint` and `Domain`
modules regarding substitution: the `Domain` modules was written under
the assumption that constraints applying to `changed` domains would
always be marked as pending upon substitution, but that is not true
because we use functional representations where such updates are
delayed, and hence the `changed` flag needs to be propagated after
substitution (if appropriate).
bclement-ocp added a commit to bclement-ocp/alt-ergo that referenced this issue Mar 12, 2024
This patch rewrites the `Constraints_make` module in order to make it
more flexible (this is preparatory step for dealing with arithmetic
bit-vector constraints, see OCamlPro#903).

More precisely:

 - Constraints no longer need to keep track of their own explanations,
   this is now entirely done by the `Constraints_make` functor. This
   makes it simpler to write `Constraint` modules, and avoid repeating
   boilerplate code to deal with explanation storage. Instead, the
   explanations are provided to the `Constraint` module in its
   `propagate` function.

 - The `Constraints_make` functor no longer need to know about
   constraint propagation. Instead, it simply keeps track of constraints
   that need to be propagated (pending constraints), and provides an API
   to iterate (and remove) the set of constraints to be propagated,
   letting the user take care of propagation proper.

 - The `Constraints_make` functor now tracks separately the constraint
   arguments and the leaves of said arguments. The leaves are used to
   know which constraints need to be updated during a substitution, and
   the arguments are used to mark as pending all constraints that apply
   to a given representative when its domain is updated (note that, for
   the bit-list domains, we actually store the domains at the leaves, so
   the arguments mapping is not used -- but this still makes the module
   more flexible in general, and in particular will allow to introduce
   arithmetic domains that need to be stored for all values, not only
   leaves, for the purpose of OCamlPro#903 in a future PR)

The new design should make it easier to write `Constraint` modules. It
also fixes a bug in the contract between the `Constraint` and `Domain`
modules regarding substitution: the `Domain` modules was written under
the assumption that constraints applying to `changed` domains would
always be marked as pending upon substitution, but that is not true
because we use functional representations where such updates are
delayed, and hence the `changed` flag needs to be propagated after
substitution (if appropriate).
@bclement-ocp
Copy link
Collaborator

Some updates here:

bclement-ocp added a commit that referenced this issue Mar 14, 2024
This patch rewrites the `Constraints_make` module in order to make it
more flexible (this is preparatory step for dealing with arithmetic
bit-vector constraints, see #903).

More precisely:

 - Constraints no longer need to keep track of their own explanations,
   this is now entirely done by the `Constraints_make` functor. This
   makes it simpler to write `Constraint` modules, and avoid repeating
   boilerplate code to deal with explanation storage. Instead, the
   explanations are provided to the `Constraint` module in its
   `propagate` function.

 - The `Constraints_make` functor no longer need to know about
   constraint propagation. Instead, it simply keeps track of constraints
   that need to be propagated (pending constraints), and provides an API
   to iterate (and remove) the set of constraints to be propagated,
   letting the user take care of propagation proper.

 - The `Constraints_make` functor now tracks separately the constraint
   arguments and the leaves of said arguments. The leaves are used to
   know which constraints need to be updated during a substitution, and
   the arguments are used to mark as pending all constraints that apply
   to a given representative when its domain is updated (note that, for
   the bit-list domains, we actually store the domains at the leaves, so
   the arguments mapping is not used -- but this still makes the module
   more flexible in general, and in particular will allow to introduce
   arithmetic domains that need to be stored for all values, not only
   leaves, for the purpose of #903 in a future PR)

The new design should make it easier to write `Constraint` modules. It
also fixes a bug in the contract between the `Constraint` and `Domain`
modules regarding substitution: the `Domain` modules was written under
the assumption that constraints applying to `changed` domains would
always be marked as pending upon substitution, but that is not true
because we use functional representations where such updates are
delayed, and hence the `changed` flag needs to be propagated after
substitution (if appropriate).
@Halbaroth
Copy link
Collaborator Author

I think we can remove the milestone on this issue because we do not plan extra works on it before the next release.

@bclement-ocp
Copy link
Collaborator

Yes, we won't have constraint simplification for 2.6. Let's keep it to track bv2nat(bvadd) support.

@bclement-ocp
Copy link
Collaborator

I wanted to implement support for bv2nat applied to bvadd etc. operators but did not find the time — or rather, I have several tentative implementations that need to be rebased and compared to figure out which one to use, which I won't have time to do for this release.

We already have many bv improvements, and these changes only add a small additional improvement for the bv2nat problems from our partners (~ 0.2% more problems solved) so it will have to wait for the next release. I'll try to cut a point release once it is integrated.

@bclement-ocp
Copy link
Collaborator

I said this but then realised we are not even able to prove that (int2bv (+ (bv2nat x) (bv2nat y)) and (bvadd x y) are equal currently, so that's annoying. I will make a small patch for that.

@bclement-ocp
Copy link
Collaborator

Turns out this is somewhat rendered useless by #1228 which at least partially explain why I was seeing so little impact here.

@bclement-ocp
Copy link
Collaborator

Postponing the remaining tasks here to 2.7

@bclement-ocp bclement-ocp modified the milestones: 2.6.0, 2.7.0 Aug 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
reasoning This issue is about improving reasoning capabilities. umbrella
Projects
None yet
Development

No branches or pull requests

2 participants