• No results found

A Preorder over Shapes

We will now make the observation that some shapes cannot be used in the construction of other shapes. Consider the shapesS1 andSJ from figure 5.3. Letσ“qÑw q1 be a path through the SST with shapeS1. As a sample of the main result of this section, we will now

argue that no sub-path ofσcan have shapeSJ. Assume otherwise, so thatσ “q Ñw1 q

1 Ñw2 q2 Ñw3 q1 where the sub-path σ1 “ q1 Ñw2 q

2 has shapeSJ. Then, the values of all three registers atq1flow intoq2 at the end

ofσ1, and therefore, along the prefix pathqÑw1 q

1Ñw2 q2, the initial value ofyflows into

x. We also know that the registers are only upward flowing, and therefore, onceyhas been

“promoted” tox, it is impossible for the suffixq2 Ñw3 q1 to restore this value to registery.

But the shape of the entire pathS1 states that the initial value ofyflows into the final value ofy, leading to a contradiction.

In this section, we will define a pre-order Ďover the space of upward-flowing shapes which captures the notion of “can appear as a sub-path”.

Definition 5.14. The support of a shapeSis defined as:

SupppSq “ tvPV |voccurs inSpvqu. (5.7.1)

IfS and S1 are two shapes, then we say that S Ă S1

iff SupppSq Ľ SupppS1q

. We call the shapes support-equal, and writeS „S1

if SupppSq “ SupppS1q. Finally,S ĎS1

iff either

SĂS1

orS„S1 .

For example, the shape SK from figure 5.3 is the bottom element of Ďand SK Ă SJ.

S1 „S2, and both shapes are strictly sandwiched betweenSKandSJ. The relationĎis easily verified to be a preorder: (a) every shape is support-equal with itself, and Ďis therefore reflexive, and (b) ifSĎS1

ĎS2

, then SupppSq ĚSupppS1

q ĚSupppS2

q, so thatSĎS2 : it is therefore also transitive. The following two claims, 5.15 and 5.16, formalize the intuition thatĎand„describe the possible shapes of sub-paths.

Proposition 5.15. Letσ“qÑwq1be a path through the SSTMwith shapeS, andσ1 be a subpath ofσwith shapeS1. ThenS1 ĎS.

Proof. Assume otherwise, soS1 ­ĎS

. Then, SupppS1q Ğ

SupppSq, so there is some registerv such thatvPSupppSqandvRSupppS1q. The effect of the entire pathσis to make the initial value ofvflow into itself, but on the sub-pathσ1, the value ofvis either lost or promoted to some upper registerv1. The first case (the initial value ofvis lost duringσ1) immediately leads to a contradiction, while the second case (the initial value ofvis promoted to some upper registerv1) leads to a contradiction together with the assumption that all paths through

Mare upward-flowing.

Proposition 5.16. Let there bekregisters in the SSTM. Pickk`1strings,w1,w2, . . . ,wk,w1

PΣ˚, and a pathσ q0

Ñw1 q1 Ñw2 q2 Ñw3 ¨ ¨ ¨ Ñwk qk Ñw1 q1 through the SST such

that for eachiP t1, 2, . . . ,ku, the shapeSiof the subpathqi´1Ñwi qiis support-equal to the

shapeSof the entire pathσ. Then the prefix sub-pathq0 Ñw1w2¨¨¨wk qkalso has shapeS.

Proof. Assume otherwise. Letw “ w1w2¨ ¨ ¨wk, so thatσ1 “q0 Ñw qk has some shape S1

‰S. The concatenation of paths with support-equal shapes also produces a path with the

same support: we conclude thatS1 „S. There are now three cases:

1. For some registeruRSupppSq,uflows intovinS, but does not flow into any register inS1. This indicates that the initial value ofuis lost while processing the prefixw, but somehow regained while processing the suffixw1 so that it can eventually flow intov. This is a contradiction.

2. For some registeruRSupppSq, there exist distinct registersv‰v1

, such thatuÑvin SanduÑv1

Starting withu, consider the sequence of registersuÑS1 u

1 ÑS2 u2 ÑS3 ¨ ¨ ¨ ÑSk uk

through which the initial value ofuflows. Notice that uk “ v1. All the shapes are

upward-flowing, so according to the total order over the registers,

uľu1ľu2 ľ¨ ¨ ¨ľuk “v1.

If any of the above inequalities is non-strict, i.e. ul “ ul`1, then ul P SupppSl`1q,

and the chain collapses by the assumption of support equality:ul“ul`1 “ul`2 “

¨ ¨ ¨uk “ v1, and therefore also v “ v1

, contradicting the assumption that v ‰ v1 . Therefore, all inequalities have to be strict. Now notice that the register-promotion chainuŋu1 ŋu2 ŋ¨ ¨ ¨ŋukisk`1elements long, but there are only but there are onlykregisters in the SST. This again leads to a contradiction.

3. For some registerv P SupppSq, the order of registers inSpvq andS1pvq are different. For some registersu,w, the registeruoccurs beforewinSpvq, butuoccurs afterwin

S1

pvq. However, once the values ofuandwhave been appended tovin the orderwu, the suffixqk Ñw1 q1

cannot separate them to be recast in the orderuw. It is thus a contradiction thatuoccurs beforewinSpvq.

The previous proposition also highlights the importance of stable shapes: an upward- flowing shapeSis stable if for all registersu,v, ifuÑvinS, thenvÑv. By an argument

similar to that used in case 2 above, it can be proved that:

Proposition 5.17. Let there bekregisters in the SSTM. Letσ “q0 Ñw1 q1 Ñw2 q2 Ñw3 ¨ ¨ ¨ Ñwk qkbe a path through the SST such that for each jP t1, 2, . . . ,ku, the shapeS

jof the

subpathwj is support-equal to the shapeSof the entire pathσ. Then the shapeSis stable.

Informally, non-stable shapes cannot be generated by “very long” loops, and therefore, the most important case in the construction ofBSis that of stable shapes.