# Termination

Document Sample

```					Definition size-change graph G for a call from function f to function g
(written G : f → g) is a bipartite annotated digraph (Param(f),Param(g),A),
whose arcs (directed from Param(f) to Param(g)) are labeled with either ↓ or ⇞.
when arc is labeled with ↓it means that this is strict arc (x > y) and when it is labeled with ⇞it means that
(x ≥ y). when there is no arc it all it means that no information of the above could be concluded.

Definition ACG A size-change annotated call graph (ACG) for program p is an
annotated digraph whose node set represents the function names in p, and to every
call c from function f to function g the arc     such that  is safe size changed graph for C.
meaning that this is a CFG where the SCG lies on the arcs.

Definition Multipath. A multipath over an ACG (a -multipath) is a non-empty,
finite or infinite sequence of size-change graphs G1G2… that label a (finite or
infinite) path in the call graph. Often we construct a digraph that is G1 connected to G2 …

Definition Thread. A thread in a multipath        =                 is a (finite or
infinite) directed path in    (viewed as a concatenated digraph). A thread can be
written down in the form                     where                      for some s ≥ 0 (the starting position of
the thread).A thread has infinite descent if =↓ for infinitely many i.
A thread is complete if it starts at the beginning of the multipath, and has the
same length as the multipath.

Definition Composition Consider two size-change graphs                   and       Their composition G1;G2
has source function f0 and target f2 Its arcs are given by           ⇞
Where:

Meaning if one of the arc in the path from x to z is strict the arc will be strict otherwise it will be non strict
arc.

Definition idempotent if G;G = G then we call G idempotent.

Definition Closure For a set      of size-change graphs, the composition closure of , denoted , is the least
set satisfying:

we start from and for each 2 graphs g1,g2 we compute g1;g2 and add it to the set , we stop when there is
no change in the set.

THEOREM ([Lee et al. 2001])       satisfies SCT if and only if for every size-change graph               in   such
that G;G=G (an idempotent size-change graph),            for some x.

In basic words what we need to do to verify that statisfies SCT is to compute and check for each graph
in the closure if G;G = G and if so if it has strict arc . This is exponential algorithm because of the
construction of

Definition Anchor. Let     be a set of size-change graphs. We call G             an SCT anchor for H if every
-multipath whose infinity set contains G has infinite descent.
Meaning that if G has an arc of the form           which is strict and x is a member of a thread preserver than
G is an anchor.

LEMMA         satisfies SCT if and only if every non-trivial strongly connected subgraph         has an anchor.

This is because existence of an anchor in SCC means that this section of the program cannot occur infinite
times, thus if all SCC of the program cannot occur infinite times the program must terminate.

Definitions Let G be a size-change graph.
(1) G is fan-out free if the outdegree of any node in G is at most one.
For example:

(2) G is fan-in free if the indegree of any node in G is at most one.
For example:

(3) G has strict fan-out if for any node x in G with outdegree larger than one, all
Arcs              are strict.
For example:

(4) G has strict fan-in if for any node y in G with indegree larger than one, all arcs
are strict.
For example:

Definition Thread Preserver. Let be a set of size-change graphs. A set                     is called a thread
preserver for if for every       where           , it holds that whenever                                 , there is
for some      .

Meaning the thread preserver is close under , also if there is an infinite multipath there is infinite thread
that stays in the thread preserver this comes out straight from the definition.
We mark in MTP(         the maximal thread preserver for

LEMMA Suppose has strict fan-in, and the outdegree of any source node of its size-change graphs is
exactly 1. Let . If G contains a strict arc,then G is an anchor for .

Proof. Suppose that G contains the strict arc         . Consider any idempotent graph                         , with
each           and G= . Observe that in        the outdegree of each source node is 1 (since this is a property
of composition and the fact that all has out degree of each node to be 1) . Thus there is a unique z such
that              (since there is no disconnection of the flow). Consider the case z=x ; then we have the strict
arc        , as required by Theorem 3.7. Now assume that                , and consider the composition          . By
idempotence, this composition must yield an arc              as well. Since all outdegrees are 1, this arc must
result of the arc        in the first copy of    followed by z           in the second copy. Thus     includes two
arcs entering z. By fan-in strictness, the arc z     is strict, fulfilling once again the condition in Theorem
3.7. Hence G is an anchor.
THEOREM Suppose P is a thread preserver for            such that      has strict fan-in. Let      . If   contains
a strict arc, then G is an anchor for .

Proof Suppose that         contains the strict arc     . Now, as P is a thread preserver, any source node of a
size-change graph of         has an outdegree greater than 0. We will delete certain arcs from the size-change
graphs of        so that every outdegree is reduced to 1. For the source node x in      , delete every arc leaving
this node other than         . For any other source node (across       ), simply pick an arc leaving the node and
delete the rest. It is easy to see that P remains a thread preserver (since the deletion removes nodes may
remove params from P but it is still Thread Preserver) under such deletion, and still has strict fan-in (Since
is strict fan in) . Denote by G’ the reduced copy of       and by ’ the set of reduced graphs. Clearly, if
G’ is an anchor for       then so is G for . But the previous lemma guarantees that G’ is an anchor.

Let P be a thread preserver for such that        has strict fan-in.A size-change graph             is a Type 1
anchor with respect to P if    contains a strict arc.

This means that if we have Thread Preserver just go over each graph and check if it has strict arc than we
found an anchor.

DEFINITION. The size-relation graph due to , denoted                  , is the annotated digraph with node set
Par and arc set formed by the union of all arc sets in . Each arc is labeled, in addition to the size-change
label it already has, by an identification of the graph giving rise to it. Formally, the arc set is

Basically we connect all the graphs in      for example:

We Get the following

DEFINITION Let be a set of size-change graphs. The no-descent graph                , is the subgraph of
, consisting of just the non-strict arcs.The interior of the no-descent graph,        , is the subgraph of
consisting of all the arcs internal to a strongly connected component of        .

THEOREM Let                , and     be G minus any arc belonging to       , Consider
. If    has a non-empty MTP, then G is an anchor for .

Prof: Assume, for a contradiction, that there is an -multipath          = G1G2…without infinite descent,
whose infinity set contains G. Let        be obtained by replacing in     every occurrence of G with
Clearly, every thread of      is also a thread of    Let P= MTP( ). By Lemma 3.10,                 has a complete
thread th among P parameters. By assumption, th does not have infinite descent. Thus th eventually stays
within         (Because th is infinite thread with no descent it will arrive and stay in the strongly connected
graph of no descent (NDG)) , Since          has no arc in         ,and hence no arc in           this implies that
th cannot pass infinitely often through        (which it does, since      is in the infinity set of     ).

This theorem defines the Type 2 Anchor.
DEFINITION SCG Transpose Let G=(Param(f),Param(g),A) be a size-change graph. Its transposition is
= (Param(g),Param(f),    ) with                          For a set    of size-change graphs,
.

MTP(    ) Algorithm

Input:   set of SCGs
Output: MTP for .

   For each source node in SCG of     maintain a counter and initialize its value by the out degree.
   For each source node with counter = 0 mark its associated parameter. Insert it this parameter to
work list
   While work list is not empty do
o X <- head of work list
o For each arc y->x do
 Reduce y’s counter by 1
 If counter of y is 0 mark him and add him to the parameter to the worklist.
   Return the unmarked parameters.

IsType1Anchor

Input: set of SCGs
Output: Anchor of if there is Type 1 anchor for

   P = MTP( )
   If has strict fan-in than return set of all G that has strict arc in
   Return empty set

IsType2Anchor

Input: set of SCGs
Output: Anchor of if there is Type 1 anchor for

   P = MTP( )
   D=
   For each
o Work out   from D and      ,                                     .
o If   has MTP then return G
   Return {}

AnchorFind

Input: set of SCGs
Output: Anchor of if there is Type 1 anchor for

   Try to find Type1 Anchor if found return it
   Try to fund Type1 Anchor on       Anchor if found return it
   Try to find Type2 Anchor if found return it
   Try to fund Type2 Anchor on       Anchor if found r
SCP

Input:   set of SCGs
Output: Indication if   terminates

   Compute        and break it to SCCs.
   Remove any arc that is not internal to component C such that   contains at least one strict arc.
     = AnchorFind on
   Call SCP on each member of SCC(

```
DOCUMENT INFO
Shared By:
Categories:
Tags:
Stats:
 views: 4 posted: 3/5/2012 language: pages: 5