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

[bitv] Expand the pattern after B-variable splitting #686

Merged
merged 2 commits into from
Jun 23, 2023

Conversation

bclement-ocp
Copy link
Collaborator

This patch rewrites the slice_composition function to take care of two edge cases:

  • First, it may happen that spliting a B variable causes another instance of the same B variable to become smaller than its expected size in the pattern. When that happens, we record the information, recompute the pattern, then re-slice the whole system.

  • Second, it may happen that we split the second (or third or...) occurence of a B variable. In this case, slice_composition is currently only substituting on the remainder of the composition, and so the first occurence is not substituted. To fix that case, we keep the substitution of B variables around, and apply it to the whole equation once it has been sliced. This can again change the pattern and cause re-slicing.

Note that this keeps the "one-var-to-two-vars" implementation of substitutions. As discussed in #680, we should switch to a non-recursive version, but this is unrelated to the issues fixed by this patch.

Fixes #645

@bclement-ocp bclement-ocp mentioned this pull request Jun 23, 2023
@bclement-ocp bclement-ocp force-pushed the bclement/bsubs branch 2 times, most recently from 678d5a0 to a2a2dac Compare June 23, 2023 08:53
@bclement-ocp
Copy link
Collaborator Author

I messed up the rebase and forgot the tests, should be good now @hra687261

@bclement-ocp
Copy link
Collaborator Author

The build failure is due to Gbury/dolmen#162 being merged. I wlil make a PR shortly to remove B.In_interval in the short-term; the long-term fix is #652

@bclement-ocp
Copy link
Collaborator Author

the long-term fix is #652

I meant #681

This patch rewrites the `slice_composition` function to take care of two
edge cases:

 - First, it may happen that spliting a B variable causes another
   instance of the same B variable to become smaller than its expected
   size in the pattern. When that happens, we record the information,
   recompute the pattern, then re-slice the whole system.

 - Second, it may happen that we split the *second* (or third or...)
   occurence of a B variable. In this case, `slice_composition` is
   currently only substituting on the remainder of the composition, and
   so the first occurence is not substituted. To fix that case, we
   keep the substitution of B variables around, and apply it to the
   whole equation once it has been sliced. This can again change the
   pattern and cause re-slicing.

Note that this keeps the "one-var-to-two-vars" implementation of
substitutions. As discussed in OCamlPro#680, we should switch to a non-recursive
version, but this is unrelated to the issues fixed by this patch.

Fixes OCamlPro#645
Copy link
Contributor

@hra687261 hra687261 left a comment

Choose a reason for hiding this comment

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

LGTM

Splits involving A variables are not recorded, because A variables are
guaranteed to have unique occurences.

Splits involving B and C variables are accumulated in [subs].
Copy link
Contributor

Choose a reason for hiding this comment

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

Hm, difference will probably be insignificant, but would there be a point in splitting subs into b_subs and c_subs? Since B variables can appear multiple times but only in a single composition, while C variables can appear multiple time but not in the same composition, I don't think that it is needed to have both substitutions in the same place.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Unless I am mistaken/misremembering, subs should be a pair (b_subs, c_subs) for this exact reason. I could clarify the comment.

Copy link
Contributor

Choose a reason for hiding this comment

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

Right, line 788

@bclement-ocp bclement-ocp enabled auto-merge (squash) June 23, 2023 10:13
@bclement-ocp bclement-ocp merged commit acbc648 into OCamlPro:next Jun 23, 2023
@bclement-ocp bclement-ocp deleted the bclement/bsubs branch January 3, 2024 14:50
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.

Assertion failure in "src/lib/reasoners/bitv.ml", line 538
2 participants