Abstract. Higher-order hereditary Harrop formulas, the underlying logical foundation of AProlog [NM88], are more expressive than first-order Horn clauses, the logical foundation of Prolog. In particular, various forms of scoping and abstraction are supported by the logic of higherorder hereditary Harrop formulas while they are not supported by firstorder Horn clauses. Various papers have argued that the scoping and abstraction available in this richer logic can be used to provide for modular programming [MilS9b], abstract data types [Mi189a], and state encapsulation [HM90]. None of these papers, however, have dealt with the problems of programming-in-the-large, that is, the essentially linguistic problems of putting together various different textual sources of code found, say, in different files on a persistent store into one logic program. In this paper, I propose a module system for AProlog and shall focus mostly on its static semantics.
1Module syntax should be declarative Several modern programming languages are built on declarative, formal languages: for example, ML and Scheme are based on the A-calculus and Prolog is based on Horn clauses. Initial work on developing such languages was first concerned with programming-in-the-small: problems with programming-in-the-large were attacked later. At that point, a second language was often added on top of the initial language. For example, parsing and compiler directives, such as use, import, include, and local, were added. This second language generally had little connection with the original declarative foundation of the initial language: it was born out of the necessity to build large programs and its function was expediency. The meaning of the resulting hybrid language is often complex since it loses some of its declarative purity. Occasionally, programming design is inflicted with what we may call the "recreating the Turing machine" syndrome. Turing machines were important because they were the first formal system that obviously computed and were clearly easy to implement (at least the bounded version of them). They have not been considered seriously as programming languages for several reasons, inchlding the * An earlier version of this paper was first presented at the 1992 Workshop on AProlog.