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.
While writing this documentation, I read the paper
Generalized, Efficient Array Decision Procedures
of de Moura and Bjorner.Before writing this documentation, I believed that we only implement the basic
inferences rules, which is exposed in Fig 1 of the paper. These rules are:
a == store(b, i, v) ===> a[i] = v
a == store(b, i, v), w == a'[j], a ~ a' ===> i = j \/ a[j] = b[j]
a == store(b, i, v), w = b'[j], b ~ b' ===> i = j \/ a[j] = b[j]
a, b know ===> a = b \/ a[k] <> b[k] (k fresh name)
(I use the double equality symbol
==
to denote syntactical equality and~
for thecongruence relation.)
In fact, we implement a slightly different version of these rules. The
down
,
up
andext
inference rules are implemented by respectivelyget_of_set
,get_and_set
andextensionality
functions inArrays_rel
module.The
idx
axiom is not implemented by a dedicated function. Instead, differentinstantiations of this axiom are produced by
get_of_set
,get_and_set
andget_from_set
:1a. (idx a)
a[i] known, a ~ store(b, j, v) ==> i <> j \/ a[i] = v
1b. (idx b)
store(b, i, v), store(a, j, w) known, a ~ b ==> store(a, j, w)[j] = w
.Technically, our implementation does not send directly instantiated axioms to the
SAT solver. Consider for instance the axiom
down
and assume that all its hypothesesare satisfied. We produce the deduction
i = j \/ a[j] = b[j]
but we do not send itto the SAT solver. Instead, we add the equality
i = j
in the setenv.split
inorder to split on its negation later. If we split on it or we see
i <> j
inassume
,we send
a[j] = b[j]
to the SAT solver.Our implementation suffers from a number of issues:
For instance, we do not need to propagate
a[i] = v
if we already know thata'[i'] = v'
for witha ~ a'
,i ~ i'
andv ~ v'
. The same goes for other axioms.To be more efficient, our implementation only should follow equivalent classes
of read/write terms and relevant indices. When some of these classes merge, we
may have to instantiate axioms. This new version could be implemented using a union-find
in
Arrays_rel
itself but as I explained during the last dev meeting, this modificationwill conflict with our plan for the union-find in UF (using Basile's store).