1 Introduction
Separation Logic [9, 14] is a logical framework used in program verification to describe properties of the dynamically allocated memory, such as topologies of data structures (lists, trees), (un)reachability between pointers, etc. The quest for automated pushbutton program verification methods motivates the need for understanding the decidability, complexity and expressive power of various dialects thereof, that are used as assertion languages in Hoarestyle proofs [9], or logicbased abstract domains in static analysis [4].
In a nutshell, given an integer , the logic is obtained from the firstorder theory of a finite functional relation of arity , called a heap^{1}^{1}1Intuitively, is the number of record fields in each memory cell., by adding two nonclassical connectives: (i) the separating conjunction , that asserts a split of the heap into disjoint heaps satisfying and respectively, and (ii) the separating implication or magic wand , stating that each extension of the heap by a heap satisfying must satisfy . The separating connectives and allow concise definitions of program semantics, via weakest precondition calculi [9] and easytowrite specifications of recursive linked data structures (e.g. singly and doublylinked lists, trees with linked leaves and parent pointers, etc.), when higherorder inductive definitions are added [14].
A typical problem in verification, occurring as a subgoal in a Hoarestyle proof of a program or in an inductive proof of inclusion between least fixed point models (sets of heaps) of higherorder predicates, is deciding the validity of entailments between existentially quantified formulae in the base assertion language. This problem is reduced to the (un)satisfiability of an formula with quantifier prefix in the language . In analogy with firstorder logic with equality and uninterpreted predicates [11], we call this fragment BernaysSchönfinkelRamsey Separation Logic [].
Unlike the BernaysSchönfinkelRamsey fragment of firstorder logic, is difficult to reason about, due to the unrestricted use of separating connectives. A way to circumvent this problem is to define a small set of patterns, called test formulae in the literature [10, 3, 7, 8], that are parametric in their arguments and some integer constants, and prove that every formula in the fragment is equivalent to a classical combination of instances of those patterns, bound only with firstorder connectives.
These expressive completeness results are, in some sense, similar to the elimination of existential quantifiers in some interpreted theories of firstorder logic, such as Presburger arithmetic. In fact, the existential quantifiers are not completely eliminated, but rather confined to a small set of modulo constraints, in which they occur in a controlled fashion. Similarly, in , it is possible to confine the separating conjunction and implication to a small set of test formulae and convert each formula from a certain fragment into an equivalent boolean combination of test formulae. As with Presburger arithmetic, this is an argument for showing decidability of the logical fragment under consideration.
Our contributions
The main contributions of this paper are:

We show that the finite and infinite satisfiability problems are undecidable for the logic , interpreted over heaps with record fields. The main reason for undecidability lies in the presence of universally quantified variables within the scope of a separating implication, that occurs, moreover, under an even number of negations.

By disallowing universally quantified variables in the scope of positive occurrences of separating implications, and even stronger, disallowing positive occurrences thereof, we define two nontrivial fragments and of , for which the infinite and finite satisfiability problems are PSPACEcomplete, respectively. These results establish neat decidability frontiers within .
In contrast with the majority of the literature on Separation Logic, here the universe of available memory locations (besides the ones occurring in the heap, which is finite) is not automatically assumed to be infinite. In fact, we consider both cases in which the universe is countably infinite and finite. In particular, the finite universe hypothesis is useful when dealing with bounded memory issues, for instance checking that the execution of the program satisfies its postcondition, provided that there are enough many available memory cells.
Having different interpretations of the universe is also motivated by a recent integration of within a DPLL()based SMT solver [13, 12], in which the theory is parameterized by the theory of locations, just like the theories of arrays and sets are parameterized by theories of values.
Surprisingly, when considering a finite universe, the separating connectives allow to define bounds also on the cardinality of the universe and on the number of free locations (not in the heap), besides specifying the shape and cardinality of the heap. As a result, the conditions needed for decidability within turn out to be stronger for finite universes than for infinite ones. The argument for decidability relies on (i) the definition of a restricted set of test formulae capturing all properties of heaps, that can be expressed in quantifierfree , together with (ii) an equivalencepreserving syntactic translation of a prenex form formula into a boolean combination of test formulae, with the same quantifier prefix. The latter formula is translated into firstorder logic and decidability is established by tracking those formulae of that translate into the classical BernaysSchönfinkelRamsey fragment of firstorder logic [11].
Related Work.
Expressive completeness results exist for quantifierfree [10, 3] and for with one and two quantified variables [8, 7]. There, the existence of equivalent boolean combinations of test formulae is showed implicitly, using a finite enumeration of equivalence classes of models, instead of an effective transformation. Instead, here we present an explicit equivalencepreserving transformation of quantifierfree formulae over heaps with record fields into boolean combinations of test formulae, and translate the latter into firstorder logic.
Another translation of quantifierfree into firstorder logic with equality has been described in [5]. There, the small model property of quantifierfree [6] is used to bound the number of firstorder variables to be considered and the separating connectives are interpreted as firstorder quantifiers. The result is an equisatisfiable firstorder formula whose satisfiability can be checked in PSPACE. This translation scheme cannot be, however, directly applied to , which does not have a small model property, and is, moreover, undecidable.
Existing decidability and complexity results for various fragments [6, 3, 8, 7] always assume the universe of heap locations to be countably infinite. In this paper we consider, in addition, the case where the universe is finite. Theoryparameterized versions of have been shown to be undecidable, e.g. when integer linear arithmetic is used to reason about locations, and wrongly claimed to be PSPACEcomplete for countably infinite and finite unbounded location sorts, with no relation other than equality [12]. Here we correct the wrong claim of [12] and draw a precise chart of decidability for both infinite and finite satisfiability of .
2 Preliminaries
We denote by the set of integers and by the set of positive integers including zero. We define and , where for each we have and . For a countable set we denote by the cardinality of . A decision problem is in
if it can be decided by a (nondeterministic) Turing machine in space
and in PSPACE if it is in for some integer , independent of the input.Let be a countable set of variables, denoted as and be a sort. A function symbol has arguments of sort and a sort , which is either the boolean sort or . If , we call a constant. We use and for the boolean constants false and true, respectively. Firstorder () terms and formulae are defined by the following grammar:
where , and are function symbols, and . We write for , for , for and for .
The size of a formula , denoted as , is the number of symbols needed to write it down. Let be the set of variables that occur free in , i.e. not in the scope of a quantifier. A sentence is a formula where . Given formulae , and , we write when is a subformula of and denote by the formula obtained by substituting for in .
Firstorder formulae are interpreted over structures (called structures, when no confusion arises) , where is a countable set, called the universe, the elements of which are called locations, is a mapping of variables to locations, called a store and interprets each function symbol by a function , if and if . A structure is finite when and infinite otherwise.
We write iff is true when interpreted in . This relation is defined recursively on the structure of , as usual. When , we say that is a model of . A formula is satisfiable when it has a model. We write when every model of is also a model of and by we mean and . The (in)finite satisfiability problem asks, given a formula , whether a (in)finite model exists for this formula.
The BernaysSchönfinkelRamsey fragment of , denoted by , is the set of sentences , where is a quantifierfree formula in which all function symbols of arity have sort . It is known that any satisfiable sentence has a finite model with at most locations, where is the length of the existential quantifier prefix^{2}^{2}2See, e.g., [2, Proposition 6.2.17]..
2.1 Separation Logic
Let be a strictly positive integer. The logic is the set of formulae generated by the grammar below:
where . The connectives and are respectively called the separating conjunction and separating implication (magic wand). We write for (also called septraction) and denote by , the tuples , respectively. The size of an formula , denoted , is the number of symbols needed to write it down.
Given an formula and a subformula of , we say that occurs at polarity iff one of the following holds: (i) and , (ii) and occurs at polarity in , (iii) or , and occurs at polarity in , for some , or (iv) and either is a subformula of and , or occurs at polarity in . A polarity of or is also referred to as positive, neutral or negative, respectively.
formulae are interpreted over structures (called structures when no confusion arises) , where and are as before and is a finite partial mapping of locations to tuples of locations, called a heap. As before, a structure is finite when and infinite otherwise. We denote by the domain of the heap and by the cardinality of . Two heaps and are disjoint iff , in which case denotes their union ( is undefined for nondisjoint heaps). A heap is an extension of iff , for some heap . The relation is defined inductively, as follows:
The semantics of equality, boolean and firstorder connectives is the usual one. Satisfiability, entailment and equivalence are defined for as for formulae. The (in)finite satisfiability problem for asks whether a (in)finite model exists for a given formula. We write [] whenever holds for every finite [infinite] structure .
The BernaysSchönfinkelRamsey fragment of , denoted by , is the set of sentences , where is a quantifierfree formula. Since there are no function symbols of arity greater than zero in , there are no restrictions, other than the form of the quantifier prefix, defining .
3 Test Formulae for
We define a small set of patterns of formulae, possibly parameterized by a positive integer, called test formulae. These patterns capture properties related to allocation, pointsto relations in the heap and cardinality constraints.
Definition 1
The following patterns are called test formulae:
and , where , and is a positive integer or . A literal is either a test formula or its negation.
The intuitive semantics of test formulae is formally stated below:
Proposition 1
Given an structure , we have:
for all variables and integers .
Proof: Let and, given a set of locations and a finite set , we will denote by the heap with domain , such that for all , . It is clear that .
Assume that . Then by definition, there exist disjoint heaps , such that , and . Thus and . Conversely, assume . Then is of the form , where is the restriction of to and is the restriction of to . It is straightforward to verify that and .
Assume that . Then there cannot be any heap disjoint from , such that . But for , we have , thus is not disjoint from and necessarily, . Conversely, assume , and let be a heap such that . Then cannot be disjoint from , which proves that .
Assume that . Then since has a finite domain, it is clear that if and that no such structure exists if . When , we prove the result by induction on . The case where is straightforward to prove. Otherwise, there exist disjoint heaps such that , and . By the induction hypothesis and by definition, , so that . Conversely, assume that . This always holds if and never holds if . Otherwise, we prove the result by induction on . Assume , so that . Consider and let and respectively denote the restrictions of to and to , so that . Since , by the induction hypothesis , and since , we have the result.
Assume that . Then there exists a heap disjoint from such that . This entails that and since , necessarily, . Conversely, if , then there exists a set such that and . Then , which proves that .
Assume that . Then there is no heap disjoint from with a domain of cardinality at least . In particular, if , then necessarily, . Since , we deduce that . Conversely, if then there is no heap disjoint from with a domain of cardinality at least , so that . ∎
Not all atoms of are test formulae, for instance and are not test formulae. However, by Proposition 1, we have the equivalences and . Moreover, for any , the test formulae and become trivially true and false, respectively, if we consider the universe to be infinite.
The integer parameter occurring in , and is assumed to be written in unary notation. We write for and for , where . For technical convenience, we also define the following linear combinations.
Definition 2
Given integers , where , let
Proposition 2
Given an structure , we have iff , for all , .
Proof: We distinguish the four cases below:

If and then , never.

If and then , always.

If and , assume first that . Then thus , by Proposition 1. If then , which contradicts , by Proposition 1. Otherwise, we have , with . In this case , which implies , by Proposition 1. Conversely, assume that . Since necessarily , we obtain , i.e., and thus hence . Moreover, if then follows by Proposition 1.
Definition 3
A variable is allocated in an structure iff . For a set of variables , let and . For a set of literals, we define:
We let be the number of equivalence classes of containing variables allocated in every model of and be the number of equivalence classes of containing variables from that are not allocated in any model of . We also let .
Intuitively, [] is the set of variables that must be [are never] allocated in every [any] model of and is the footprint of relative to the set , i.e. the set of formulae describing allocation and pointsto relations over variables from . For example, if , then , , and .
Proposition 3
Given a set of test formulae and a structure , if , we have for any extension of .
Proof: By a case split on the form of the atom in , namely , with . For the case , since then for some variable such that , thus is unsatisfiable, contradicting the assumption that . ∎
3.1 From Test Formulae to
The introduction of test formulae (Definition 1) is motivated by the reduction of the (in)finite satisfiability problem for quantified boolean combinations thereof to the same problem for . Given a quantified boolean combination of test formulae , the formula is defined by induction on the structure of :
where is a ary function symbol of sort and and are constants of sort , for all . These function symbols are related by the following axioms, where and are constants of sort , for all :
()  
()  
()  
()  
()  
()  
() 
Intuitively, or are true iff there are at least locations in the domain of the heap and in the universe, respectively and . However, if is true, then there are at least locations outside of the domain of the heap (free), but the converse does not hold (remark 2). The following remarks motivate some of the restrictions that define decidable fragments of , by reduction to (§5.2).
Remark 1
The translation of introduces existential quantifiers depending on . For instance, the formula is translated as , which lies outside of the fragment. Because upcoming results (Thm. 5.2) require that be in , we consider quantified boolean combinations of test formulae in which the formulae either occur at a negative polarity, or is not universally quantified. In both such cases, is in (Lemma 2).
Remark 2
The axioms do not state the equivalence of with the existence of at least free locations. Such an equivalence seems to be hard, if not impossible, to express in ^{3}^{3}3The converse of : is not in .. Note that if the domain is infinite then this problem does not arise since the formulae are always false.
Definition 4
Given a quantified boolean combination of test formulae , let be the maximum integer parameter occurring in a test formula from and let be the set of axioms related to .
The relationship between a boolean combination of test formulae and its translation into is stated below.
Lemma 1
Let be a quantified boolean combination of test formulae. The following hold, for any universe and any store :

if , for a heap , then , for an interpretation , and

if each test formula in occurs at negative polarity and , for an interpretation , such that , then , for a heap .
Proof: (1) Let be a model of . Considering an arbitrary interpretation and for the boolean constants true and false, we extend to the ary function symbol , the constants of sort and of sort , for all and all , as follows. For all we set
Comments
There are no comments yet.