• No se han encontrado resultados

RESULTADOS Y DISCUSION

TIEMPOS DE AHUMADO

A substitution is made up of an expression

e

and an assignment list

al

and replaces in

e

the names occurring in

al

with their assigned value. This is equivalent to evaluating

e

in a state updated with the assignments of

al

. The substitution operator of Lconstructs a substitution expression using the construct subst (see Definition 3.5). This requires a function of type State ! Values, which will define the semantics of substitution. For expression

e

and assignment list

al

, this can be formed, using the function update, as

(

s

:State):Ie(

e

)(update(

al;s

)).

Definition 3.13 Substitution

For assignment list

al

and expression

e

, the substitution of

al

in

e

is a value expression in E written

e / al

and defined:

/

:(E Alist)!E

e / al

def

3.1 Expressions ofL 55

The interpretation of a substitution expression is that of the constructor subst of the setE(see Definition 3.5 and Definition 3.6). For

e

2E,

al

2Alist and

s

2State, the result ofIe(

e / al

)(

s

) isIe(

e

)(update(

al;s

)). Note that although substitution is a value expression (inE), if it is applied to a label expression (

e

2 El) then the result will also be a label expression. The setEl contains only basic labels or expressions constructed from label functions. Any name which occurs in a label expression can do so only as an argument to a label function.

Example 3.12 Let

s

be a state and

al

the assignment list (

x

1

;e

1 ) (

x

2

;e

2 ) where

x

1 6s

x

2. Assume

x

2 Names,

e

2 E,

l

2 Labels and label function

f

2 F

l. Assume that

x

s

x

2. The substitution of

al

in the expressions is:

(

x / al

)s

e

2

(

l / al

)s

l

(

f

(

e

)

/ al

)s

f

(

e / al

)

2

Substitution in Name Expressions

Substitution must be applied to name expressions as well as to value expressions: the interpre- tation of a name expression also depends on the state in which it is evaluated. It is possible to extend the name expressions with a substitution expression which is interpreted as a name. This would restrict the substitution operator to assignment lists which replace name expres- sions with name expressions. The interpretation, as a name, of the resulting operator would beIn(subst(

e;al

))(

s

)=In(

e

)(update(

al;s

)). However, this approach separates the assignment command from the substitution operator since an assignment is a replacement of name expres- sions with value expressions.

The approach used here is to define substitution as a function on the syntax of name ex- pressions. This applies substitution to the value expressions which occur as arguments to name functions. It is not equivalent to substitution as a name expression, where names are replaced with names, but retains the association with the assignment command.

Definition 3.14 Substitution in name expressions

The substitution of assignment list

al

in the value expressions occurring in name expression

x

is written

x / al

.

/

:(EnAlist)!En

x / al

def =

x

if

x

2Names

f

(

e

1

/ al;::: ;e

m

/ al

) if

x

=

f

(

e

1

;::: ;e

m ) where

f

2Fn,

m

=arity(

f

)and

e

1

;::: ;e

m

2E. 2

The effect of performing the substitutions in assignment list

al

on a name expression is equiv- alent (using the interpretationIn) to updating a state with

al

.

3.1 Expressions ofL 56

Lemma 3.2 For name expression

x

2En, assignment lists

al;bl

2 Alist and state

s

, In(

x / al

)(

s

)=In(

x

)(update(

al;s

))

The interpretation of substitution in a name expression is consistent with its interpretation as a value. If substitution is applied to a constant name then the name is unchanged. If substitution is applied to a function application then the arguments to the function are evaluated in the updated state.

Example 3.13 Let

s

be a state and

al

an assignment list. Let

x

be a name in Names,

e

an expression and

f

a name function. The substitution of

al

in the name

x

and name expression

f

(

e

)(interpreted as names) is

x / al

(In;s)

x f

(

e

)

/ al

(In;s)

f

(

e / al

) 2

Substitution in Assignment Lists

The assignment lists in Alist are used both for the substitution expression and to describe the lists of assignments made by a command. The abstraction of assignment commands requires the ability to apply substitution to the assignment lists of the commands (to model the changes made to a machine state). A particular application of substitution in assignment lists is to describe syntactically the changes made by executing two assignment commands in succession. The correctness of this application justifies the method of abstracting from assignment commands and is established from the semantic interpretation of substitutions.

Substitution is applied to the expressions in an assignment list by applying the substitution for name expressions and the substitution for value expressions to each name-value pair in the assignment list.

Definition 3.15 Substitution in assignment lists

The substitution of assignment list

bl

in assignment list

al

is written

al / bl

and defined:

/

:(AlistAlist)!Alist

nil

/ bl

def =nil ((

x;e

)

al

)

/ bl

def =(

x / bl;e / bl

))(

al / bl

) (

cldl

)

/ bl

def =(

cl / bl

)(

dl / bl

) 2 The effect of substituting assignment list

bl

in assignment list

al

and then evaluating an ex- pression

e

of

al

in state

s

is equivalent to evaluating

e

in the state

s

updated with

bl

. The substi- tution of assignment lists together with the combination operator allows the effect on a state of two assignment commands executed in sequence to be described as a single assignment list.

3.1 Expressions ofL 57

Theorem 3.1 Basis for abstraction

For assignment lists

al;bl

and state

s

,

update(

al;

update(

bl;s

))=update(

bl

(

al / bl

)

;s

)

Theorem (3.1) is the semantic basis for the abstraction of commands by manipulating the text of the commands. If a command

c

1 begins in a state

s

and has the assignments in list

al

, it will end in state update(

al;s

). If a second command

c

2 begins in this state and has assignment list

bl

, it will end in state update(

bl;

update(

al;s

)). From Theorem (3.1), the effect of the two commands on the state

s

is described by the assignment list(

al

(

bl / al

)). This assignment list can be constructed from the syntax of the commands and used to construct an abstraction of commands

c

1 and

c

2. The command

c

with assignment list

(

al

(

bl / al

))beginning in state

s

will produce the same state as the execution of

c

1 followed by

c

2. Command

c

is therefore the abstraction of

c

1followed by

c

2and can be constructed from the text of

c

1 and

c

2. For example, if expression

e

is interpreted in the state produced after by the execution of both

c

1and

c

2then its value (relative to state

s

) isIe(

e

)(update(

bl;

update(

al;s

)). This can be described syntactically as the expression

e /

(

al

(

bl / al

)).

Rules for Substitution

Rules for simplifying the expressions formed by the substitution operator are given in Fig- ure (3.3), their proof is given in Section C.2.2 of the appendix. In Figure (3.3), every substitution expression is the substitution of value expressions (Definition 3.13). Rules (sr1) to (sr5) are the standard rules for substitution. Rules (sr6) and (sr7) describe substitution when the expression is a name function: the substitution is applied to the arguments; the function is evaluated to obtain a name

x

and the assignment list is searched for

x

. If

x

is a member of the list then its asso- ciated value is the result, otherwise the result is

x

. Rules (sr8) to (sr11) describe substitution and the combination of assignment lists: the substitution is carried out on the arguments to any functions; the name expressions are reduced to a name

x

and the assignment list is searched for a value assigned to

x

.

Example 3.14 Let

s

be a state and

al

the assignment list(

x

1

;v

1 )(

x

2

;v

2 ). Assume that

x

1 is a basic name,

x

1

2 Names and is distinct from

x

2 Names,

x

1 6=

x

. Since both

x

1 and

x

are constant, In(

x

1 )(

s

) =

x

1 and

In(

x

)(

s

) =

x

. The substitution

x / al

is therefore equivalent to

x /

(

x

2

;v

2 ).

Assume the registers and memory variables are distinct, Regs\Vars = fg, and that

a

2 Fn constructs a name from the memory variables only, If(

a

)(

v

) = name(

v

) if

v

2 Vars. Also assume that

x

is constructed from a register,

r

2 Regs and

x

= name(

r

). For any

v

2 Values, If(

a

)(

v

)6=

x

and, for all expressions

e

2E,

a

(

e

)6s

x

. If

x

1

=

a

(

e

)then

x / al

x /

(

x

2

;v

2

). However, if

x

is the name expression

a

(

v

)and

ev

then

x / alv

1. 2

3.1 Expressions ofL 58

e /

nil

e

(sr1)

v / al

v

(sr2)

x

s

t

x /

((

t;r

)

al

)s

r

(sr3)

x

6s

t

x /

((

t;r

)

al

)s

x / al

(sr4)

f

62Fn

f

(

a

1

;::: ;a

n )

/ al

f

(

a

1

/ al;::: ;a

n

/ al

) (sr5)

f

2Fn

f

(

a

1

/

((

t;r

)

al

)

;::: ;a

n

/

((

t;r

)

al

))s

t

f

(

a

1

;::: ;a

n )

/

((

t;r

)

al

)s

r

(sr6)

f

2Fn^

v

1 s

a

1

/

((

t;r

)

al

)^

:::

^

v

n s

a

n

/

((

t;r

)

al

) ^

f

(

a

1

/

((

t;r

)

al;::: ;a

n

/

((

t;r

)

al

)6s

t

f

(

a

1

;::: ;a

n )

/

((

t;r

)

al

)s

f

(

v

1

;::: ;v

n )

/ al

(sr7)

x

s

t

x /

(

bl

((

t;r

)

al

)s

r

(sr8)

x

6s

t

x /

(

bl

((

t;r

)

al

)s

x /

(

blal

) (sr9)

f

2Fn

f

(

a

1

/

(

bl

(

t;r

)

al

)

;::: ;a

n

/

(

bl

(

t;r

)

al

))s

t

f

(

a

1

;::: ;a

n )

/

(

bl

(

t;r

)

al

)s

r

(sr10)

f

2Fn^

v

1 s

a

1

/

(

bl

(

t;r

)

al

)^

:::

^

v

n s

a

n

/

(

bl

(

t;r

)

al

) ^

f

(

a

1

/

(

bl

(

t;r

)

al;::: ;a

n

/

(

bl

(

t;r

)

al

)6s

t

f

(

a

1

;::: ;a

n )

/

(

bl

(

t;r

)

al

)s

f

(

v

1

;::: ;v

n )

/

(

blal

) (sr11) where

v;v

1

;::: ;v

n 2Values

;x

2Names

;f

2F

;

t

2En

;r

2E

;e

2E

;a

1

;::: ;a

n

2E

;s

2State

;al;bl

2Alist

;

Figure 3.3: Rules for the Substitution Operator

Documento similar