• No results found

Assignment Lists

In document Object code verification (Page 69-72)

2.6 Conclusion

3.1.6 Assignment Lists

The assignments made by a command are a list of name expressions and value expressions, where each name expression is paired with the value expression it is assigned. An assignment list can be empty, the result of adding a name-value expression pair to an assignment list or the combination of two assignment lists.

Definition 3.9 Assignment lists

There is a set Alist and constructor functions nil, cons and combine satisfying:

nil2Alist

x

2En

e

2E

al

2Alist

cons((

x;e

)

;al

)2Alist

al

2Alist

bl

2Alist

3.1 Expressions ofL 52

(

x;e

)

al

will be written for cons((

x;e

)

;al

)and(

x;e

)nil will be abbreviated(

x;e

).

albl

will be written for combine(

al;bl

).

Function combine? is a recogniser for assignment lists constructed by combination.

combine?:Alist!boolean

combine?(

al

) def

= 9(

bl;cl

:Alist):

al

=

blcl

2 The combination of assignments lists is by the use of the syntactic construct combine. This allows the order of assignments to be preserved. When a sequence of assignment lists is combined, the order in which assignments to a name are made can be determined from the syntax of the assignment lists.

The structure of an assignment list, in the set Alist, is strictly a tree. The assignment lists occurring in processor commands would not be formed using the combine constructor and can be described by the subset of the assignment lists which excludes this constructor. This subset contains the simple assignment lists, corresponding to the usual list structures. The prefix of an assignment list, up to the first combination of lists, is a simple list and an assignment list is made up of the combination of a finite set of simple lists.

Definition 3.10 Simple lists

An assignment list

al

is simple, simple?(

al

), if no sub-list of

al

is constructed by combine.

simple?:Alist!boolean

simple?(

al

) def

=8(

bl

:Alist):

blal

):combine?(

bl

)

Slist is the set of all simple lists, Slistdef

= f

al

:Alistjsimple?(

al

)g.

Function initial constructs a simple list from the prefix of an assignment list.

initial:Alist!Slist

initial(nil) def = nil initial((

v;x

)

al

) def = (

v;x

)initial(

al

) initial(

albl

) def = nil 2 Function initial allows an arbitrary assignment list to be considered as a set of simple lists. This allows the assignments made by an individual list to be examined separately from the remainder of an assignment list.

Example 3.10 With assignment lists

al;bl

2 Alist and name-value pairs,

a;b

2 (En E), the set of assignment lists, Alist, includes

a

(

al

bl

)and

ab

((

b

al

)

bl

). Neither of these would occur in an command nor would they be formed to describe a sequence of instructions. The result of applying the function initial to the first list is the simple list

a

nil and to the second

3.1 Expressions ofL 53

Finding Assignments in Lists

An assignment list associates name expressions with the value expressions which they are as- signed. Name expression

x

is associated in state

s

with a value

v

by an assignment list

al

if there is a pair(

x

0

;e

0 )2(EnE)in

al

such that

x

s

x

0 and

v

s

e

0

. The value associated with a name

x

in a state

s

by

al

is found by traversing the assignment list. If the assignment list is constructed from the addition of a pair(

x

1

;e

1

)to an assignment list

bl

then

x

1is compared (in state

s

with

x

) before searching

bl

. If the assignment list is constructed from the combination of two assignment lists(

blcl

)then the list

cl

is searched before the list

bl

(the choice is arbitrary).

Definition 3.11 Membership and find

For an assignment list

al

and state

s

, the name

x

2s En is a member in

s

of

al

iff there is a name expression in

al

which is equivalent in

s

to

x

.

2 :(EnStateAlist)!boolean

x

2s nil def =false

x

2s(

x

1

;e

1 )

al

def =(

x

s

x

1 )_(

x

2s

al

)

x

2s(

albl

) def =

x

2s

al

_

x

2s

bl

Function find searches an assignment list for the value expression assigned to a name expression.

find:(EnAlist)!State!E

find(

x;

nil)(

s

) def =

x

find(

x;

(

x

1

;e

1 )

al

)(

s

) def =

e

1 if

x

s

x

1

find(

x;al

) otherwise

find(

x;

(

albl

))(

s

) def

=

find(

x;bl

)(

s

) if

x

2s

bl

find(

x;al

)(

s

) otherwise

2 Given a name expression

x

, assignment list

al

and state

s

, the result of find(

x;al

)(

s

)is the value expression associated with name

x

in

al

, if

x

is a member in

s

of

al

. If

x

is not a member in

x

of

al

, the result is the name expression

x

.

Example 3.11 Let

x

1

;x

2

;x

3 be name expressions,

e

1

;e

2

;e

3

;e

4 be expressions,

s

a state,

al

the assignment list(

x

1

;e

2 )(

x

2

;e

2

)and

bl

the assignment list(

x

2

;e

3

)(

x

3

;e

4

). Assume that

x

1

;x

2 and

x

3 are distinct in

s

:

x

1

6s

x

2,

x

2

6s

x

3 and

x

1

6s

x

3. The expressions associated with

x

1

;x

2and

x

3in

al

are

find(

x

1

;al

)(

s

)=

e

1

;

find (

x

2

;al

)(

s

)=

e

2

;

find (

x

3

;al

)(

s

)=

x

3 The values associated with

x

1

;x

2and

x

3in

al

bl

are find(

x

1

;al

bl

)(

s

)=

e

1

;

find (

x

2

;al

bl

)(

s

)=

e

3

;

find (

x

3

;al

bl

)(

s

)=

e

4

3.1 Expressions ofL 54

In document Object code verification (Page 69-72)