RESULTADOS Y DISCUSION
TIEMPOS DE AHUMADO
A substitution is made up of an expression
e
and an assignment listal
and replaces ine
the names occurring inal
with their assigned value. This is equivalent to evaluatinge
in a state updated with the assignments ofal
. 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 expressione
and assignment listal
, 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 expressione
, the substitution ofal
ine
is a value expression in E writtene / al
and defined:/
:(E Alist)!Ee / al
def3.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 ands
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 andal
the assignment list (x
1;e
1 ) (x
2;e
2 ) wherex
1 6sx
2. Assumex
2 Names,e
2 E,l
2 Labels and label functionf
2 Fl. Assume that
x
sx
2. The substitution ofal
in the expressions is:(
x / al
)se
2(
l / al
)sl
(f
(e
)/ al
)sf
(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 expressionx
is writtenx / al
./
:(EnAlist)!Enx / al
def =x
ifx
2Namesf
(e
1/ al;::: ;e
m/ al
) ifx
=f
(e
1;::: ;e
m ) wheref
2Fn,m
=arity(f
)ande
1
;::: ;e
m2E. 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 withal
.3.1 Expressions ofL 56
Lemma 3.2 For name expression
x
2En, assignment listsal;bl
2 Alist and states
, 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 andal
an assignment list. Letx
be a name in Names,e
an expression andf
a name function. The substitution ofal
in the namex
and name expressionf
(e
)(interpreted as names) isx / al
(In;s)x f
(e
)/ al
(In;s)f
(e / al
) 2Substitution 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 listal
is writtenal / bl
and defined:/
:(AlistAlist)!Alistnil
/ 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 listbl
in assignment listal
and then evaluating an ex- pressione
ofal
in states
is equivalent to evaluatinge
in the states
updated withbl
. 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 states
,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 states
and has the assignments in listal
, it will end in state update(al;s
). If a second commandc
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 states
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 commandsc
1 andc
2. The commandc
with assignment list(
al
(bl / al
))beginning in states
will produce the same state as the execution ofc
1 followed byc
2. Commandc
is therefore the abstraction ofc
1followed byc
2and can be constructed from the text ofc
1 andc
2. For example, if expressione
is interpreted in the state produced after by the execution of bothc
1andc
2then its value (relative to states
) isIe(e
)(update(bl;
update(al;s
)). This can be described syntactically as the expressione /
(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 forx
. Ifx
is a member of the list then its asso- ciated value is the result, otherwise the result isx
. 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 namex
and the assignment list is searched for a value assigned tox
.Example 3.14 Let
s
be a state andal
the assignment list(x
1;v
1 )(x
2;v
2 ). Assume thatx
1 is a basic name,x
12 Names and is distinct from
x
2 Names,x
1 6=x
. Since bothx
1 andx
are constant, In(x
1 )(s
) =x
1 andIn(
x
)(s
) =x
. The substitutionx / al
is therefore equivalent tox /
(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
) ifv
2 Vars. Also assume thatx
is constructed from a register,r
2 Regs andx
= name(r
). For anyv
2 Values, If(a
)(v
)6=x
and, for all expressionse
2E,a
(e
)6sx
. Ifx
1
=
a
(e
)thenx / al
x /
(x
2;v
2). However, if
x
is the name expressiona
(v
)andev
thenx / alv
1. 23.1 Expressions ofL 58
e /
nile
(sr1)v / al
v
(sr2)x
st
x /
((t;r
)al
)sr
(sr3)x
6st
x /
((t;r
)al
)sx / al
(sr4)f
62Fnf
(a
1;::: ;a
n )/ al
f
(a
1/ al;::: ;a
n/ al
) (sr5)f
2Fnf
(a
1/
((t;r
)al
);::: ;a
n/
((t;r
)al
))st
f
(a
1;::: ;a
n )/
((t;r
)al
)sr
(sr6)f
2Fn^v
1 sa
1/
((t;r
)al
)^:::
^v
n sa
n/
((t;r
)al
) ^f
(a
1/
((t;r
)al;::: ;a
n/
((t;r
)al
)6st
f
(a
1;::: ;a
n )/
((t;r
)al
)sf
(v
1;::: ;v
n )/ al
(sr7)x
st
x /
(bl
((t;r
)al
)sr
(sr8)x
6st
x /
(bl
((t;r
)al
)sx /
(blal
) (sr9)f
2Fnf
(a
1/
(bl
(t;r
)al
);::: ;a
n/
(bl
(t;r
)al
))st
f
(a
1;::: ;a
n )/
(bl
(t;r
)al
)sr
(sr10)f
2Fn^v
1 sa
1/
(bl
(t;r
)al
)^:::
^v
n sa
n/
(bl
(t;r
)al
) ^f
(a
1/
(bl
(t;r
)al;::: ;a
n/
(bl
(t;r
)al
)6st
f
(a
1;::: ;a
n )/
(bl
(t;r
)al
)sf
(v
1;::: ;v
n )/
(blal
) (sr11) wherev;v
1;::: ;v
n 2Values;x
2Names;f
2F;
t
2En;r
2E;e
2E;a
1;::: ;a
n2E