Abstract

In this paper we discuss the semantics of a simple block-structured programming language which allows sharing or aliasing. Sharing, which arises naturally in procedural languages which permit certain forms of parameter passing, has typically been regarded as problematical for the semantic treatment of a language. Difficulties have been encountered in both denotational and axiomatic treatments of sharing in the literature. Nevertheless, we find that it is possible to define a clean and elegant formal semantics for sharing. The key to our success is the choice of semantic model; we show that conventional approaches based on locations are less than satisfactory for the purposes of reasoning about partial correctness, and that in a well defined sense locations are unnecessary.We begin by defining a denotational semantics for our programming language. The semantic model is not based on locations, but instead uses an abstract sharing relation on identifiers to represent the notion of aliasing, and uses an abstract state with a stack-like structure to capture the semantics of blocks and accurately model the scope rules. The semantics is shown to be fully abstract with respect to partial correctness properties, in contrast to conventional location-based models. This means that the semantics identifies terms if and only if they induce identical partial correctness behaviour in all program contexts. This property usually fails for location-based semantics because in such models it is possible to distinguish between terms on the basis of their effect on individual locations, which has no bearing on partial correctness.We believe that axiomatic reasoning about program behaviour should be based directly on a semantic model specifically tailored for that purpose; full abstraction with respect to an appropriate behavioural notion is a formal criterion against which to judge the suitability of a semantics. The structure of a semantic model should be used directly to suggest the structure of an assertion language for expressing program properties. With this in mind, we build a Hoare-style (syntax-directed) proof system for partial correctness properties of our programming language, and we prove soundness and relative completeness of this system. The proof system is built up in a hierarchical manner which reflects the syntactic and semantic structure of the programming language. We first design a proof system for declarations, and then use it in building proof rules for commands. We claim that our proof rules are conceptually simpler to understand than other rules proposed in the literature for aliasing, without losing any expressive power. We show, for example, that it is possible to define a “generic” inference rule for blocks which is uniformly applicable to3 blocks headed by different forms of declaration. The important point here is that, unlike most of the proof systems for these constructs in the literature, we do not have to design a separate rule for blocks for each possible form of declaration. This results in greater flexibility and adaptability in our proof system. We demonstrate that some well known rules from the literature for blocks can be derived in our system.

Full Text
Published version (Free)

Talk to us

Join us for a 30 min session where you can share your feedback and ask us any queries you have

Schedule a call