In this paper, we enrich McCarthy’s theory of extensional arrays with a length and a maxdiff operation. As is well-known, some diff operation (i.e., some kind of difference function showing where two unequal array differ) is needed to keep interpolants quantifier-free in array theories; our maxdiff operation returns the max index where two arrays differ and so it has a univocally determined semantics. The length function is a natural complement of such a maxdiff operation and is needed to handle real arrays. Obtaining interpolation results for such a rich theory is a surprisingly hard task. We get such results via a thorough semantic analysis of the models of the theory and of their amalgamation and strong amalgamation properties. The results are modular with respect to the index theory and we show how to convert them into concrete interpolation algorithms via a hierarchical approach realizing a polynomial reduction to interpolation in linear arithmetics endowed with free function symbols. In this paper, we enrich McCarthy’s theory of extensional arrays with a length and a maxdiff operation. It is known from the literature that a diff operation is required in order for the theory of arrays to enjoy the Craig interpolation property at the quantifier-free level. However, the diff operation introduced in the literature is merely instrumental to this purpose and has only a purely formal meaning (it is obtained from the Skolemization of the extensionality axiom): instead, our maxdiff operation returns the max index where two arrays differ and so it is univocally determined at the semantic level. The length function is a natural complement of such a maxdiff operation and is needed to handle real arrays (which are defined in their specified allocation memory). Obtaining interpolation results for such a rich theory is a surprisingly hard task. We get such results via a thorough semantic analysis of the models of the theory and of their amalgamation and strong amalgamation properties. The results are modular with respect to the index theory and we show how to convert them into concrete interpolation algorithms via a hierarchical approach realizing a polynomial reduction to interpolation in linear arithmetics endowed with free function symbols. The array theory in the paper has been modified so as to model real arrays used in common programming languages (we now require them to be ‘contiguous’, i.e., not undefined in any of their allocation entries); moreover strong amalgamation and interpolation with free function symbols are proved. The interpolation algorithm avoids full instantiation routines and unbounded loops, thus achieving the above mentioned polynomial reduction complexity. The present paper is a substantially revised version of a previous conference paper presented at FoSSaCS 2021.
Read full abstract