As we have seen in the preceding examples, the QCP assertion language supports the logical connectives && and *. The former denotes the usual logical "and", while the latter is the separating conjunction. Specifically, "P * Q" states that the current memory can be divided into two disjoint parts, one satisfying P and the other satisfying Q. We can use these connectives to combine multiple clauses and thereby express more complex concepts.
Suppose p is a logical variable whose value is a memory address. Then
exists v, v >= 0 && store_int(p, v)
states that a non-negative number is stored at address p.
Suppose p and q are both logical variables whose values are memory addresses. Then
exists v, store_int(p, v) * store_int(q, v)
states that p and q are different addresses, but the same value is stored at both addresses.
Of course, we can also write more complex assertions:
exists v, store_int(p, v) * store_int(q, v)
This states that p and q are different addresses, but the same non-negative number is stored at both addresses.
As introduced earlier, the separating conjunction ("*") is commutative and associative. That is:
P * Q <----> Q * P
P * (Q * R) <----> (P * Q) * R
It also has the following two important properties:
-
Associativity between
&&and*: IfPis a proposition that does not involve memory (such as a comparisonv >= 0), then(P && Q) * R <----> P && (Q ** R). The left-hand side of this equivalence says that memory can be divided into two parts, one satisfyingP && Qand the other satisfyingR. SincePis a memory-independent proposition, this is equivalent to saying thatPholds and that memory can be divided into two parts satisfyingQandRrespectively -- which is exactly the property described by the right-hand side. Because of this property, when thePconnected by&&is a memory-independent expression, a formula likeP && Q * Rcan be written without parentheses to indicate the binding order between&&and*. -
Associativity between
existsand*:(exists x, P(x)) * Q <----> exists x, (P(x) * Q). Because of this property, we can always hoistexistsfrom within a separating conjunction clause to the outermost level.