Published online by Cambridge University Press: 29 May 2025
This chapter illustrates some uses of the kind of semantic definition given in Chapter 19 via a series of examples. We continue to use the notations in Notation 19.2.1.
20.1 Some properties of declarations and commands
Example 20.1.1 (Eliminating an unused variable) Consider the skeleton class declaration in Table 20.1. If none of Ci,…, C*, contains either the expression X or a command of the form X := E, then deleting the declaration of X should not change the behaviour of objects of the class, and hence should not affect the behaviour of any program in which the class appears. To prove this, we use the straightforward equivalence
provided. (For notational convenience, in what follows we assume that T is Int.)
Now suppose that X is the jth variable of A, and write Vj for V〈gj, pj, 0〉 and abbreviate gj to g and pj to p. Then there are processes G and P such that
Let A’ be the class obtained from A by deleting the declaration of X. Then, since none of the method bodies contains the expression X or an assignment to X,
Hence
using (20.2), the equivalence in (20.1), and the observation in (20.3). This completes Example 20.1.1.
Example 20.1.2 (Replacing a variable by a constant) Consider again the skeleton class declaration in Table 20.1. If none of C1,… ,Ck contains a command of the form X : = E, then replacing each occurrence of the expression X in C1,…, Ck by 0 (the initial value of X) and deleting the declaration of X should not change the behaviour of objects of the class, and hence should not affect the behaviour of any program in which the class appears.
Let us reuse the notations Vj, MA, etc. from Example 20.1.1, and write A” for the class obtained from A by applying the transformation.
To save this book to your Kindle, first ensure no-reply@cambridge.org is added to your Approved Personal Document E-mail List under your Personal Document Settings on the Manage Your Content and Devices page of your Amazon account. Then enter the ‘name’ part of your Kindle email address below. Find out more about saving to your Kindle.
Note you can select to save to either the @free.kindle.com or @kindle.com variations. ‘@free.kindle.com’ emails are free but can only be saved to your device when it is connected to wi-fi. ‘@kindle.com’ emails can be delivered even when you are not connected to wi-fi, but note that service fees apply.
Find out more about the Kindle Personal Document Service.
To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Dropbox.
To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Google Drive.