Add LetBinder to bv_values
#129
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Opening this because the change was in a branch that was rotting; adds
LetBindertobv_values/encoder.ml, which handles creating let-binds for values before encoding them to the solver.The algorithm, given a value
v,min_occurrencesandmin_bindsvalue -> countmapcount >= min_occurrences< min_binds, returnvv(ie. externally defined ones)(string, sexp) list list; each inner list is a group, and all groups should be defined in orderv, return itThen one can encode
v, and wrap it in the let-binds, usingLetBinder.apply_bindingsI would like to make this a functor or part of the behaviour of solvers, so that it can be shared, but it would require exposing quite a few functions that seem too specific to be worth requiring:
Value.map_if : f:(t -> t option) -> t -> t, which recursively tries replacing values iff visSomeValue.hash : t -> int(tbh this is chill)Value.is_atom : t -> boolor something likeValue.can_bind : t -> bool; basically a function to ensure atoms aren't let-bound since that's pointlessIf you think this is worth pursuing I'm happy to add it; we can keep this as draft otherwise.
Example of output encoding (notice the
|208|,|252|,|282|,|342|and|297|)