z3py: simplify nested Stores with concrete values
<p>I'm using the python API of Z3 [version 4.4.2 - 64 bit] and I'm trying to understand why z3 simplifies the expression in this case:</p>

<pre><code>&gt;&gt;&gt; a = Array('a', IntSort(), IntSort())
&gt;&gt;&gt; a = Store(a, 0, 1)
&gt;&gt;&gt; a = Store(a, 0, 3)
&gt;&gt;&gt; simplify(a)
Store(a, 0, 3)
</code></pre>

<p>but it doesn't in this case:</p>

<pre><code>&gt;&gt;&gt; a = Array('a', IntSort(), IntSort())
&gt;&gt;&gt; a = Store(a, 0, 1)
&gt;&gt;&gt; a = Store(a, 1, 2)
&gt;&gt;&gt; a = Store(a, 0, 3)
&gt;&gt;&gt; simplify(a) 
Store(Store(Store(a, 0, 1), 1, 2), 0, 3)
</code></pre>

<p>The simplifier only applies the cheapest rewrites on arrays. 
So if it finds two adjacent stores for the same key, it knows to squash the inner most key.
There is generally a high cost of finding overlapping keys, and furthermore keys could be variables where it is not possible to determine whether they are overlapping.</p>

python z3 z3py