Formally Deriving an STG Machine Starting from P. Sestoft semantics for lazy evaluation , we define a new semantics in which normal forms consist of variables pointing to lambdas or constructions . This is in accordance with the more recent changes in the Spineless Tagless G-machine -LRB- STG -RRB- machine , where constructions only appear in closures -LRB- lambdas only appeared in closures already in previous versions -RRB- . We prove the equivalence between the new semantics and Sestoft 's . Then , a sequence of STG machines are derived , formally proving the correctness of each derivation . The last machine consists of a few imperative instructions and its distance to a conventional language is minimal . The paper also discusses the differences between the final machine and the actual STG machine implemented in the Glasgow Haskell Compiler . D. 3.1 -LSB- Programming Languages -RSB- : Formal Definitions and Theory -- semantics , syntax ; D. 3.2 -LSB- Programming Languages -RSB- : Language Classifications -- applicative -LRB- functional -RRB- languages ; D. 3.4 -LSB- Programming Languages -RSB- : Processors-code generation , compilers ; F. 3.2 -LSB- Logics and meanings of programs -RSB- : Semantics of Programming Languages -- operational semantics Theory , Languages , Verification Work partially supported by the Spanish project TIC 2000-0738 . Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page . To copy otherwise , to republish , to post on servers or to redistribute to lists , requires prior specific permission and/or a fee . PPDP ' 03 , August 27 29 , 2003 , Uppsala , Sweden . Copyright 2003 ACM 1-58113-705-2 / 03/0008 ... $ 5.00 . The Spineless Tagless G-machine -LRB- STG -RRB- -LSB- 6 -RSB- is at the heart of the Glasgow Haskell Compiler -LRB- GHC -RRB- -LSB- 7 -RSB- which is perhaps the Haskell compiler generating the most efficient code . For a description of Haskell language see -LSB- 8 -RSB- . Part of the secret for that is the set of analysis and transformations carried out at the intermediate representation level . Another part of the explanation is the efficient design and implementation of the STG machine . A high level description of the STG can be found in -LSB- 6 -RSB- . If the reader is interested in a more detailed view , then the only available information is the Haskell code of GHC -LRB- about 80.000 lines , 12.000 of which are devoted to the implementation of the STG machine -RRB- and the C code of its different runtime systems -LRB- more than 40.000 lines -RRB- -LSB- 1 -RSB- . In this paper we provide a step-by-step derivation of the STG machine , starting from a description higher-level than that of -LSB- 6 -RSB- and arriving at a description lower-level than that . Our starting point is a commonly accepted operational semantics for lazy evaluation provided by Peter Sestoft in -LSB- 10 -RSB- as an improvement of John Launchbury 's well-known definition in -LSB- 4 -RSB- . Then , we present the following refinements : 1 . A new operational semantics , which we call semantics S3 -- acknowledging that semantics 1 and 2 were defined by Mountjoy in a previous attempt -LSB- 5 -RSB- -- , where normal forms may appear only in bindings . 2 . A first machine , called STG-1 , derived from S3 in which explicit replacement of pointers for variables is done in expressions . 3 . A second machine STG-2 introducing environments in closures , case alternatives , and in the control expression . 4 . A third machine , called ISTG -LRB- I stands for imperative -RRB- with a very small set of elementary instructions , each one very easy to be implemented in a conventional language such as C. 5 . A translation from the language of STG-2 to the language of ISTG in which the data structures of STG-2 are represented -LRB- or implemented -RRB- by the ISTG data structures . 102 e x -- variable | x.e -- lambda abstraction | e x -- application | letrec x i = e i in e -- recursive let | C x i -- constructor application | case e of C i x ij e i -- case expression Figure 1 : Launchbury 's normalized - calculus At each refinement , a formal proof of the soundness and completeness of the lower level with respect to the upper one is carried out 1 . In the end , the final implementation is shown correct with respect to Sestoft 's operational semantics . The main contribution of the work is showing that an efficient machine such as STG can be presented , understood , and formally reasoned about at different levels of abstraction . Also , there are some differences between the machine we arrive at and the actual STG machine implemented in the Glasgow Haskell Compiler . We argue that some design decisions in the actual STG machine are not properly justified . The plan of the paper is as follows : after this introduction , in Section 2 , a new language called FUN is introduced and the semantics S3 for this language is defined . Two theorems relating Launchbury 's original language and semantics to the new ones are presented . Section 3 defines the two machines STG-1 and STG-2 . Some propositions show the consistency between both machines and the correctness and completeness of STG-1 with respect to S3 , eventhough the latter creates more closures in the heap and produces different -LRB- but equivalent -RRB- normal forms . Section 4 defines machine ISTG and Section 5 defines the translation from STG-2 expressions to ISTG instructions . Two invariants are proved which show the correctness of the translation . Section 6 discusses the differences between our translation and the actual implementation done by GHC . Finally , Section 7 concludes . We begin by reviewing the language and semantics given by Sestoft as an improvement to Launchbury 's semantics . Both share the language given in Figure 1 where A i denotes a vector A 1 , ... , A n of subscripted entities . It is a normalized - calculus , extended with recursive let , constructor applications and case expressions . Sestoft 's normalization process forces constructor applications to be saturated and all applications to only have variables as arguments . Weak head normal forms are either lambda abstractions or constructions . Throughout this section , w will denote -LRB- weak head -RRB- normal forms . Sestoft 's semantic rules are given in Figure 2 . There , a judgement : e A : w denotes that expression e , with its free variables bound in heap , reduces to normal form w and produces the final heap . When fresh pointers are created , freshness is understood w.r.t. -LRB- dom -RRB- A , where A contains the addresses of the closures under evaluation 1 The details of the proofs can be found in a technical report at one of the author 's page http://dalila.sip.ucm.es/~albertoe . : x.e A : x.e Lam : C p i A : C p i Cons : e A : x.e : e -LSB- p/x -RSB- A : w : e p A : w App : e A -LCB- p -RCB- : w -LSB- p e -RSB- : p A -LSB- p w -RSB- : w Var -LSB- p i ^ e i -RSB- : ^ e A : w : letrec x i = e i in e A : w where p i fresh Letrec : e A : C k p j : e k -LSB- p j / x kj -RSB- A : w : case e of C i x ij e i A : w Case Figure 2 : Sestoft 's natural semantics -LRB- see rule Var -RRB- . The notation ^ e in rule Letrec means the replacement of the variables x i by the fresh pointers p i . This is the only rule where new closures are created and added to the heap . We use the term pointers to refer to dynam-ically created free variables , bounded to expressions in the heap , and the term variables to refer to -LRB- lambda-bound , let-bound or case-bound -RRB- program variables . We consistently use p , p i , ... to denote free variables and x , y , ... to denote program variables . J. Mountjoy 's -LSB- 5 -RSB- had the idea of changing Launchbury-Sestoft 's language and semantics in order to get closer to the STG language , and then to derive the STG machine from the new semantics . He developed two different semantics : In the first one , which we call semantics S1 , the main change was that normal forms were either constructions -LRB- as they were in Sestoft 's semantics -RRB- or variables pointing to closures containing - abstractions , instead of just - abstractions . The reason for this was to forbid a - abstraction in the control expression as it happens in the STG machine . Another change was to force applications to have the form x x 1 , i.e. consisting of a variable in the functional part . This is also what the STG language requires . These changes forced Mountjoy to modify the source language and to define a normalization from Launchbury 's language to the new one . Mountjoy proved that the normalization did not change the normal forms arrived at by both semantics . The second semantics , which we call semantics S2 , forced applications to be done at once to n arguments instead of doing it one by one . Correspondingly , - abstractions were allowed to have several arguments . This is exactly what the STG machine requires . Semantics S2 was informally derived and contained some mistakes . In particular , -LRB- cf. -LSB- 5 , pag . 171 -RSB- -RRB- rule App M makes a - abstraction to appear in the control expression , in contradiction with the desire of having - abstractions only in the heap . Completing and correcting Mountjoy 's work we have defined a new semantics S3 in which the main changes in the source language w.r.t. Mountjoy 's are the following : 1 . We force constructor applications to appear only in bindings , i.e. in heap closures . Correspondingly , normal forms are variables pointing to either - abstractions or constructions . We will use the term lambda forms to refer to - abstractions or constructions alike . The motivation for this decision is to generate more efficient code as it will be seen in Section 5.1 . 103 e e x in -- n > 0 , application | x -- variable | letrec x i = lf i in e -- recursive let | case e of alt i -- case expression alt C x j e -- case alternative lf x in . e -- n > 0 , lambda abstraction | C x in -- constructor application | e -- expression Figure 3 : Language FUN 2 . We relax applications to have the form e x in , where e is an arbitrary expression -LRB- excluding , of course , lambda forms -RRB- . The initial motivation for this was not to introduce unjustified restrictions . In the conclusions we discuss that the generated code is also more efficient than the one produced by restricting applications to be of the form x x in . Additionally , our starting point is Sestoft 's semantics instead of Launchbury 's . The main difference is that Sestoft substitutes fresh pointers for program variables in rule Letrec while Launchbury substitutes fresh variables for all bound variables in rule Var instead . The syntax of the language , called FUN , is shown in Figure 3 . Notice that applications are done to n arguments at once , being e x in an abbreviation of -LRB- ... -LRB- e x 1 -RRB- ... -RRB- x n , and that consequently - abstractions may have several arguments . Its operational semantics , called S3 is given in Figure 4 . For simplicity , we have eliminated the set A of pending updates appearing in Sestoft 's semantics . This set is not strictly needed provided that the fresh name generator for pointers does not repeat previously generated names and provided that pointer 's names are always distinguish-able from program variables . In rule Case S3 , expression e k is the righthand side expression of the alternative alt k . The notation -LSB- p e -RSB- highlights the fact that -LRB- p e -RRB- , and -LSB- p e -RSB- means the disjoint union of and -LRB- p e -RRB- . Please notice that this notation may not coincide with other notations in which and -LSB- p e -RSB- denote different heaps . Finally notice that , besides rule Letrec S3 , also rule App S3 creates closures in the heap . Language FUN is at least as expressive as Launchbury 's - calculus . The following normalization function transforms any Launchbury 's expression into a semantically equivalent FUN expression . Definition 1 . We define the normalization function N : Launch FUN : N x def = x N -LRB- e x -RRB- def = -LRB- N e -RRB- x N -LRB- x.e -RRB- def = letrec y = N -LRB- x.e -RRB- in y , y fresh N -LRB- C x i -RRB- def = letrec y = C x i in y , y fresh N -LRB- letrec x i = e in in e -RRB- def = letrec x i = N e i n in N e N -LRB- case e of C i y ij e i -RRB- def = case N e of C i y ij N e i N , N : Launch FUN : N -LRB- C x in -RRB- def = C x in N e def = N e , e = C x in N -LRB- x.e -RRB- def = x.N e N e def = N e , e = x.e The following proposition prove that the normalization functions are well defined . Proposition 1 . 1 . Let e Launch then N e FUN 2 . Let e lf then N e lf 3 . Let e = x.e and e = C x i then , N e = N e 4 . -LRB- N e -RRB- -LSB- p i / x i -RSB- = N -LRB- e -LSB- p i / x i -RSB- -RRB- 5 . -LRB- N e -RRB- -LSB- p i / x i -RSB- = N -LRB- e -LSB- p i / x i -RSB- -RRB- Proof . 1 . By structural induction on e. 2 . Trivial . 3 . Trivial . 4 . By definition of N and of substitutions . 5 . By definition of N and of substitutions . To see that both semantics reduce an expression to equivalent normal forms , first we prove that the normalization does not change the meaning of an expression within Sestoft 's semantics . Then , we prove that both semantics reduce any FUN expression to equivalent normal forms , provided that such normal forms exist . 2.1 Soundness and completeness The following two propositions prove that the normalization does not change the meaning of an expression . We use the following notation : denotes a one-to-one renaming of pointers , and means that . This is needed to express the equivalence between the heaps of both semantics up to some renaming . As S3 generates more closures than Sestoft 's , it is not possible to guarantee that the fresh pointers are exactly the same in the two heaps . Proposition 2 . -LRB- Sestoft Sestoft -RRB- For all e Launch we have : -LCB- -RCB- : e : w -LCB- -RCB- : N e : w . w = N -LRB- w -RRB- N Proof . By induction on the number of reductions of Launchbury expressions . Proposition 3 . -LRB- Sestoft Sestoft -RRB- For all e FUN we have : -LCB- -RCB- : e : w e Launch . N e = e -LCB- -RCB- : e : w . N -LRB- w -RRB- = w N 104 -LSB- p x in . e -RSB- : p : p Lam S3 -LSB- p C p i -RSB- : p : p Cons S3 : e -LSB- p x in . y im . e -RSB- : p : e p in -LSB- q y im . e -LSB- p i / x i n -RSB- -RSB- : q m , n > 0 , q fresh App S3 : e -LSB- p x im . e -RSB- : p : e -LSB- p i / x i m -RSB- p m +1 ... p n -LSB- q w -RSB- : q : e p in : q n m App S3 : e -LSB- q w -RSB- : q -LSB- p e -RSB- : p -LSB- p w -RSB- : q Var S3 -LSB- p i ^ lf i -RSB- : ^ e -LSB- p w -RSB- : p : letrec x i = lf i in e : p p i fresh Letrec S3 : e -LSB- p C k p j -RSB- : p : e k -LSB- p j / y kj -RSB- -LSB- q w -RSB- : q : case e of C i y ij e i : q Case S3 Figure 4 : Semantics S3 Proof . By induction on the number of reductions of Launchbury expressions . Now we prove the equivalence between the two semantics . We consider only FUN expressions because it has been proved that the normalization does not change the meaning of an expression . Proposition 4 . -LRB- Sestoft S3 , completeness of S3 -RRB- For all e FUN we have : -LCB- -RCB- : e : w -LCB- -RCB- : e -LSB- p w -RSB- : p . w = w Proof . By induction on the number of reductions of FUN expressions . Proposition 5 . -LRB- S3 Sestoft , soundness of S3 -RRB- For all e FUN we have : -LCB- -RCB- : e -LSB- p w -RSB- : p -LCB- -RCB- : e : w . w = w Proof . By induction on the number of reductions of FUN expressions . Once adapted the source language to the STG language , we are ready to derive an STG-like machine from semantics S3 . Following a similar approach to Sestoft MARK-1 machine -LSB- 10 -RSB- , we first introduce a very simple STG machine , which we will call STG-1 , in which explicit variable substitutions are done . A configuration in this machine is a triple -LRB- , e , S -RRB- where represents the heap , e is the control expression and S is the stack . The heap binds pointers to lambda forms which , in turn , may reference other pointers . The stack stores three kinds of objects : arguments p i of pending applications , case alternatives alts of pending pattern matchings , and marks # p of pending updates . In Figure 5 , the transitions of the machine are shown . They look very close to the lazy semantics S3 presented in Section 2 . For instance , the single rule for letrec in Figure 5 is a literal transcription of the Letrec S3 rule of Figure 4 . The semantic rules for case and applications are split each one into two rules in the machine . The semantic rule for variable is also split into two in order to take care of updating the closure . So , in principle , an execution of the STG-1 machine could be regarded as the linearization of the semantic derivation tree by introducing an auxiliary stack . But sometimes appearances are misleading . The theorem below shows that in fact STG-1 builds less closures in the heap than the semantics and it may arrive to different -LRB- but semantically equivalent -RRB- normal forms . In order to prove the soundness and completeness of STG-1 , we first enrich the semantics with a stack parameter S in the rules . The new rules for S -LRB- only those which modify S -RRB- are shown in Figure 6 . It is trivial to show that the rules are equivalent to the ones in Figure 4 as the stack is just an observation of the derivations . It may not influence them . The following theorem establishes the correspondence between the -LRB- enriched -RRB- semantics and the machine . Proposition 6 . Given , e and S , then : e S -LSB- p w -RSB- : p iff -LRB- , e , S -RRB- -LRB- , p , S -RRB- , where 1 . 2 . if -LSB- p C p in -RSB- then S = S , p = p and -LSB- p C p in -RSB- 3 . if -LSB- p x in . e -RSB- then there exists m 0 s.t. -LSB- p y im . x in . e -RSB- and S = q im : S and e = e -LSB- q i / y i m -RSB- 105 Heap Control Stack rule letrec -LCB- x i = lf i -RCB- in e S letrec -LRB- 1 -RRB- = -LSB- p i lf i -LSB- p j / x j -RSB- -RSB- e -LSB- p i / x i -RSB- S case e of alts S case1 = e alts : S -LSB- p C k p i -RSB- p C j y ji e j : S case2 = e k -LSB- p i / y ki -RSB- S e p in S app1 = e p in : S -LSB- p x in . e -RSB- p p in : S app2 = e -LSB- p i / x i n -RSB- S -LSB- p e -RSB- p S var1 = e # p : S -LSB- p x ik . y im . e -RSB- p p ik : # q : S var2 = -LSB- q p p ik -RSB- p p ik : S -LSB- p C k p i -RSB- p # q : S var3 = -LSB- q C k p i -RSB- p S -LRB- 1 -RRB- p i are distinct and fresh w.r.t. , letrec -LCB- x i = lf i -RCB- in e , and S Figure 5 : The STG-1 Machine Proof . By induction on the number of reductions of FUN expressions . The proposition shows that the semantic rule App S3 of Figure 4 is not literally transcribed in the machine . The machine does not create intermediate lambdas in the heap unless an update is needed . Rule app2 in Figure 5 applies a lambda always to all its arguments provided that they are in the stack . For this reason , a lambda with more parameters than that of the semantics may be arrived at as normal form of a functional expression . Also for this reason , an update mark may be interspersed with arguments in the stack when a lambda is reached -LRB- see rule var2 in Figure 5 -RRB- . A final implication is that the machine may stop with m pending arguments in the stack and a variable in the control expression pointing to a lambda with n > m parameters . The semantics always ends a derivation with a variable as normal form and an empty stack . Again , following Sestoft and his MARK-2 machine , once we have proved the soundness and completeness of STG-1 , we introduce STG-2 having environments instead of explicit variable substitutions . Also , we add trimmers to this machine so that environments kept in closures and in case alternatives only reference the free variables of the expression instead of all variables in scope . A configuration of STG-2 is a quadruple -LRB- , e , E , S -RRB- where E is the environment of e , the alternatives are pairs -LRB- alts , E -RRB- , and a closure is a pair -LRB- lf , E -RRB- . Now expressions and lambda forms keep their original variables and the associated environment maps them to pointers in the heap . The notation E | t means the trimming of environment E to the trimmer t . A trimmer is just a collection of variable names . The resulting machine is shown in Figure 7 . Proposition 7 . Given a closed expression e 0 . -LRB- -LCB- -RCB- , e 0 , -LSB- -RSB- -RRB- STG-1 - -LRB- , q , p in -RRB- where either : -LSB- q C q im -RSB- n = 0 or -LSB- q x im . e -RSB- m > n 0 if and only if -LRB- -LCB- -RCB- , e 0 , -LCB- -RCB- , -LSB- -RSB- -RRB- STG-2 - -LRB- , x , E -LSB- x q -RSB- , p in -RRB- -RRB- and either : -LSB- q -LRB- C x im , -LCB- x i q im -RCB- -RRB- -RSB- n = 0 or -LSB- q -LRB- x im . e , E -RRB- -RSB- m > n 0 e = E e . Proof . By induction on the number of reductions . In this Section we ` invent ' an imperative STG machine , called ISTG , by defining a set of machine instructions and an operational semantics for them in terms of the state transition that each instruction produces . In fact , this machine tries to provide an intermediate level of reasoning between the STG-2 machine and the final C implementation . In the actual GHC implementation , ` below ' the operational description of -LSB- 6 -RSB- we find only a translation to C. By looking at the compiler and at the runtime system listings , one can grasp some details , but many others are lost . We think that the gap to be bridged is too high . Moreover , it is not possible to reason about the correctness of the implementation when so many details are introduced at once . The ISTG architecture has been inspired by the actual implementation of the STG machine done by GHC , and the ISTG instructions have been derived from the STG-2 machine by analyzing the elementary steps involved in every machine transition . An ISTG machine configuration consists of a 5-tuple -LRB- is , S , node , , cs -RRB- , where is is a machine instruction sequence ended with the instruction ENTER or RETURNCON , S is the stack , node is a heap pointer pointing to the closure under execution -LRB- the one to which is belongs to -RRB- , is the heap and cs is a code store where the instruction sequences resulting from compiling the program expressions are kept . We will use the following notation : a for pointers to closures in , as and ws for lists of such pointers , and p for 106 : e p in : S -LSB- p x in . y im . e -RSB- : p : e p in S -LSB- q y im . e -LSB- p i / x i n -RSB- -RSB- : q m , n > 0 , q fresh App S3 : e p in : S -LSB- p x im . e -RSB- : p : e -LSB- p i / x i m -RSB- p m +1 ... p n S -LSB- q w -RSB- : q : e p in S : q n m App S3 : e # p : S -LSB- q w -RSB- : q -LSB- p e -RSB- : p S -LSB- p w -RSB- : q Var S3 : e alts : S -LSB- p C k p j -RSB- : p : e k -LSB- p j / y kj -RSB- S -LSB- q w -RSB- : q : case e of alts S : q Case S3 Figure 6 : The enriched semantics pointers to code fragments in cs . By cs -LSB- p is -RSB- we denote that the code store cs maps pointer p to the instruction sequence is and , by cs -LSB- p is i n -RSB- , that cs maps p to a vectored set of instruction sequences is 1 , ... , is n , each one corresponding to an alternative of a case expression with n constructors C 1 , ... , C n . Also , S ! i will denote the i-th element of the stack S counting from the top and starting at 0 . Likewise , node ! i will denote the i-th free variable of the closure pointed to by node in , this time starting at 1 . Stack S may store pointers a to closures in , pointers p to code sequences and code alternatives in cs , and update marks # a indicating that closure pointed to by a must be updated . A closure is a pair -LRB- p , ws -RRB- where p is a pointer to an instruction sequence is in cs , and ws is the closure environment , having a heap pointer for every free variable in the expression whose translation is is . These representation decisions are very near to the GHC implementation . In its runtime system all these elements -LRB- stack , heap , node register and code -RRB- are present -LSB- 9 -RSB- . Our closures are also a small simplification of theirs . In Figure 8 , the ISTG machine instructions and its operational semantics are shown . The machine instructions BUILDENV , PUSHALTS and UPDTMARK roughly correspond to the three possible pushing actions of machine STG-2 . The SLIDE instruction has no clear correspondence in the STG-2 . As we will see in Section 5 , it will be used to change the current environment when a new closure is entered . Instructions ALLOC and BUILDCLS will implement heap closure creation in the letrec rule of STG-2 . Both BUILDENV and BUILDCLS make use of a list of pairs , each pair indicating whether the source variable is located in the stack or in the current closure . Of course , it is not intended this test to be done at runtime . An efficient translation of these ` machine ' instructions to an imperative language will generate the appropriate copy statement for each pair . Instructions ENTER and RETURNCON are typical of the actual STG machine as described in -LSB- 6 -RSB- . It is interesting to note that it has been possible to describe our previous STG machines without any reference to them . In our view , they belong to ISTG , i.e. to a lower level of abstraction . Finally , instruction ARGCHECK , which implements updates with lambda normal forms , is here at the same level of abstraction as RETURNCON , which implements updates with constructions normal forms . Predefined code is stored in cs for updating with a partial application and for blackholing a closure under evaluation . The corresponding code pointers are respectively called p n +1 pap and p bh in Figure 8 . The associated code is the following : p bh = -LSB- -RSB- p n +1 pap = -LSB- BUILDENV -LSB- -LRB- NODE , 1 -RRB- , ... , -LRB- NODE , n + 1 -RRB- -RSB- , ENTER -RSB- The code of a blackhole just blocks the machine as there is no instruction to execute . There is predefined code for partial applications with different values for n . The code just copies the closure into the stack and jumps to the first pointer that is assumed to be pointing to a - abstraction closure . The translation to C of the 9 instructions of the ISTG should appear straightforward for the reader . For instance , BUILDCLS and BUILDENV can be implemented by a sequence of assignments , copying values to/from the stack an the heap ; PUSHALTS , UPDTMARK and ENTER do straightforward stack manipulation ; SLIDE is more involved but can be easily translated to a sequence of loops moving information within the stack to collapse a number of stack fragments . The more complex ones are RETURNCON and ARGCHECK . Both contains a loop which updates the heap with normal forms -LRB- respectively , constructions and partial applications -RRB- as long as they encounter update marks in the stack . Finally , the installation of a new instruction sequence in the control made by ENTER and RETURNCON are implemented by a simple jump . In this Section , we provide first the translation schemes for the FUN expressions and lambda forms and then prove that this translation correctly implements the STG-2 machine on top of the ISTG machine . Before embarking into the details , we give some hints to intuitively understand the translation : The ISTG stack will represent not only the STG-2 stack , but also -LRB- part of -RRB- the current environment E and all the environments associated to pending case alternatives . So , care must be taken to distinguish between environments and other objects in the stack . The rest of the current environment E is kept in the current closure . The translation knows where each free 107 Heap Control Environment Stack rule letrec -LCB- x i = lf i | t i -RCB- in e E S letrec -LRB- 1 -RRB- -LSB- p i -LRB- lf i , E | t i -RRB- -RSB- e E S case e of alts | t E S case1 e E -LRB- alts , E | t -RRB- : S -LSB- p -LRB- C k x i , -LCB- x i p i -RCB- -RRB- -RSB- x E -LCB- x p -RCB- -LRB- alts , E -RRB- : S case2 -LRB- 2 -RRB- e k E -LCB- y ki p i -RCB- S e x in E -LCB- x i p in -RCB- S app1 e E p in : S -LSB- p -LRB- x in . e , E -RRB- -RSB- x E -LCB- x p -RCB- p in : S app2 e E -LCB- x i p in -RCB- S -LSB- p -LRB- e , E -RRB- -RSB- x E -LCB- x p -RCB- S var1 e E # p : S -LSB- p -LRB- x ik . y in . e , E -RRB- -RSB- x E -LCB- x p -RCB- p ik : # q : S var2 -LRB- 3 -RRB- -LSB- q -LRB- x x ik , E -RSB- -RRB- x E p ik : S -LSB- p -LRB- C k x i , E -RRB- -RSB- x E -LCB- x p -RCB- # q : S var3 -LSB- q -LRB- C k x i , E -RRB- -RSB- x E S -LRB- 1 -RRB- p i are distinct and fresh w.r.t. , letrec -LCB- x i = lf i -RCB- in e , and S. E = E -LCB- x i p i -RCB- -LRB- 2 -RRB- Expression e k corresponds to alternative C k y ki e k in alts -LRB- 3 -RRB- E = -LCB- x p , x i p ik -RCB- Figure 7 : The STG-2 machine variable is located by maintaining two compile-time environments and . The first one corresponds to the environment kept in the stack , while the second one corresponds to the free variables accessed through the node pointer . The stack can be considered as divided into big blocks separated by code pointers p pointing to case alternatives . Each big block topped with such a pointer corresponds to the environment of the associated alternatives . In turn , each big block can be considered as divided into small blocks , each one topped with a set of arguments of pending applications . The compile-time environment is likewise divided into big and small blocks , so reflecting the stack structure . When a variable is reached in the current instruction sequence , an ENTER instruction is executed . This will finish the current sequence and start a new one . The upper big block of the stack must be deleted -LRB- corresponding to changing the current environment -RRB- but arguments of pending applications must be kept . This stack restructuring is accomplished by a SLIDE operation with an appropriate argument . Definition 2 . A stack environment is a list -LSB- -LRB- k , m k , n k -RRB- , ... , -LRB- 1 , m 1 , n 1 -RRB- -RSB- of blocks . It describes the variables in the stack starting from the top . In a block -LRB- , m , n -RRB- , is an environment mapping exactly m - | n | program variables to disjoint numbers in the range 1 . . m - | n | . The empty environment , denoted is the list -LSB- -LRB- -LCB- -RCB- , 0 , 0 -RRB- -RSB- . A block -LRB- , m , n -RRB- corresponds to a small block in the above explanation . Blocks with n = -1 , are topped with a code pointer pointing to alternatives . So , they provide a separation between big blocks . The upper big block consists of all the small blocks up to -LRB- and excluding -RRB- the first small block with n = -1 . Blocks with n > 0 have m - n free variables and are topped with n arguments of pending applications . The upper block is the only one with n = 0 meaning that it is not still closed and that it can be extended . Definition 3 . A closure environment with n variables is a mapping from these variables to disjoint numbers in the range 1 . . n. Definition 4 . The offset of a variable x in from the top of the stack , denoted x , is given by x def = -LRB- k i = l m i -RRB- l x , being x dom l If the initial closed expression to be translated has different names for bound variables , then the compile time environments and will never have duplicate names . It will be proved below that every free variable of an expression being compiled will necessarily be either in or in , and never in both . This allows us to introduce the notation -LRB- , -RRB- x to mean -LRB- , -RRB- x def = -LRB- STACK , x -RRB- if x dom -LRB- NODE , x -RRB- if x dom The stack environment may suffer a number of operations : closing the current small block with a set of arguments , enlarging the current small block with new bindings , and closing the current big block with a pointer to case alternatives . These are formally defined as follows . Definition 5 . The following operations with stack environments are defined : 1 . -LRB- -LRB- , m , 0 -RRB- : -RRB- + n def = -LRB- -LCB- -RCB- , 0 , 0 -RRB- : -LRB- , m + n , n -RRB- : 108 Instructions Stack Node Heap Code control -LSB- ENTER -RSB- a : S node -LSB- a -LRB- p , ws -RRB- -RSB- cs -LSB- p is -RSB- = is S a cs -LSB- RETURNCON C m k -RSB- p : S node cs -LSB- p is i n -RSB- = is k S node cs -LSB- RETURNCON C m k -RSB- # a : S node -LSB- a -LRB- p bh , as -RRB- , node -LRB- p , ws -RRB- -RSB- cs = -LSB- RETURNCON C m k -RSB- S node -LSB- a -LRB- p , ws -RRB- -RSB- cs ARGCHECK m : is a im : S node cs = is a im : S node cs ARGCHECK m : is a in : # a : S node -LSB- a -LRB- p bh , ws -RRB- -RSB- cs n < m = ARGCHECK m : is a in : S node -LSB- a -LRB- p n +1 pap , node : a in -RRB- -RSB- cs heap ALLOC m : is S node cs -LRB- 1 -RRB- = is a m : S node cs BUILDCLS i p z in : is S node cs -LRB- 2 -RRB- = is S node -LSB- S!i -LRB- p , a in -RRB- -RSB- cs stack BUILDENV z in : is S node cs -LRB- 2 -RRB- = is a in : S node cs PUSHALTS p : is S node cs = is p : S node cs UPDTMARK : is S node -LSB- node -LRB- p , ws -RRB- -RSB- cs = is #node : S node -LSB- node -LRB- p bh , ws -RRB- -RSB- cs SLIDE -LRB- n k , m k -RRB- l : is a kj n k : b kj m k l : S node cs = is a kj n k l : S node cs -LRB- 1 -RRB- a m is a pointer to a new closure with space for m free variables , and is the resulting heap after the allocation -LRB- 2 -RRB- a i = S!i if z i = -LRB- STACK , i -RRB- node ! i if z i = -LRB- NODE , i -RRB- Figure 8 : The ISTG machine 2 . -LRB- -LRB- , m , 0 -RRB- : -RRB- + -LRB- -LCB- x i j i n -RCB- , n -RRB- def = -LRB- -LCB- x i m + j i n -RCB- , m + n , 0 -RRB- : 3 . -LRB- -LRB- , m , 0 -RRB- : -RRB- + + def = -LRB- -LCB- -RCB- , 0 , 0 -RRB- : -LRB- , m + 1 , -1 -RRB- : 5.1 Translation schemes Functions trE and trA respectively translate a FUN expression and a case alternative to a sequence of ISTG machine instructions ; function trAs translates a set of alternatives to a pointer to a vectored set of machine instruction sequences in the code store ; and function trB translates a lambda form to a pointer to a machine instruction sequence in the code store . The translation schemes are shown in Figure 9 . The notation ... & cs -LSB- p ... -RSB- means that the corresponding translation scheme has a side effect which consists of creating a code sequence in the code store cs and pointing it by the code pointer p. Proposition 8 . -LRB- static invariant -RRB- Given a closed expression e 0 with different bound variables and an initial call trE e 0 -LCB- -RCB- , in all internal calls of the form trE e : 1 . The stack environment has the form = -LRB- , m , 0 -RRB- : . Moreover , there is no other block -LRB- , m , n -RRB- in with n = 0 . Consequently , all environment operations in the above translation are well defined . 2 . All free variables of e are defined either in or in . Moreover , dom dom = . 3 . The last instruction generated for e is ENTER . Consequently , the main instruction sequence and all sequences corresponding to case alternatives and to non-constructor closures , end in an ENTER . Proof . -LRB- 1 -RRB- and -LRB- 2 -RRB- are proved by induction on the tree structure of calls to trE ; -LRB- 3 -RRB- is proved by structural induction on FUN expressions . In order to prove the correctness of the translation , we only need to consider ISTG machine configurations of the form -LRB- is , S I , node , I , cs -RRB- in which is is generated by a call to trE for some expression e and environments , . We call these stable configurations . We enrich then these configurations with three additional components : the environments 109 trE -LRB- e x in -RRB- = -LSB- BUILDENV -LRB- , -RRB- x i n -RSB- + + trE e -LRB- + n -RRB- trE -LRB- case e of alts | x in -RRB- = -LSB- BUILDENV zs , PUSHALTS p -RSB- + + trE e + + -LRB- - xs -RRB- where p = trAs alts = + -LRB- -LCB- xs j m - j + 1 m -RCB- , m -RRB- xs = -LSB- x | x x in x dom -RSB- zs = -LSB- -LRB- node , x -RRB- | x xs -RSB- m = | xs | trE -LRB- letrec x i = lf i | y ij mi n in e -RRB- = -LSB- ALLOC m n , ... , ALLOC m 1 -RSB- + + -LSB- BUILDCLS -LRB- i - 1 -RRB- p i zs i n -RSB- + + trE e where = + -LRB- -LCB- x i n - i + 1 n -RCB- , n -RRB- p i = trB -LRB- lf i | y ij mi -RRB- , i -LCB- 1 . . n -RCB- zs i = -LRB- , -RRB- y ij m i , i -LCB- 1 . . n -RCB- trE x = -LSB- BUILDENV -LSB- -LRB- , -RRB- x -RSB- , SLIDE -LRB- -LRB- 1 , 0 -RRB- : ms -RRB- , ENTER -RSB- where ms = map -LRB- \ -LRB- , m , n -RRB- -LRB- n , m - n -RRB- -RRB- -LRB- takeWhile nn -RRB- nn -LRB- , m , -1 -RRB- = False nn = True trAs -LRB- alt i n -RRB- = p & cs -LSB- p trA alt i n -RSB- trA -LRB- C x in e -RRB- = trE e -LCB- x i i n -RCB- trB -LRB- C n k x in | x in -RRB- = p & cs -LSB- p -LSB- RETURNCON C n k -RSB- -RSB- trB -LRB- x il . e | y j n -RRB- = p & cs -LSB- p -LSB- ARGCHECK l -RSB- + + trE e -RSB- where = -LSB- -LRB- -LCB- x i l - i + 1 l -RCB- , l , 0 -RRB- -RSB- = -LCB- y j j n -RCB- trB -LRB- e | y j n -RRB- = p & cs -LSB- p -LSB- UPDTMARK -RSB- + + trE e -RSB- where = -LCB- y j j n -RCB- Figure 9 : Translation schemes from STG-2 to ISTG and used to generate is , and an environment stack S env containing a sequence of stack environments . The environments in S env are in one to one correspondence with case pointers stored in S I . Initially S env is empty . Each time an instruction PUSHALTS is executed -LRB- see trE definition for case -RRB- , the environment the corresponding alternatives are compiled with , is pushed onto stack S env . Each time a RETURNCON pops a case pointer , stack S env is also pop-ed . So , enriched ISTG configurations have the form -LRB- is , , , S I , S env , node , I , cs -RRB- . Definition 6 . A STG-2 environment E is equivalent to an ISTG environment defined by , , S I , I and node , denoted E -LRB- , S I , , I , node -RRB- if dom E dom dom and x dom E E x = S I ! -LRB- x -RRB- if x dom E x = node I ! -LRB- x -RRB- if x dom Definition 7 . A STG-2 stack S is equivalent to a triple -LRB- , S I , S env -RRB- of an ISTG enriched configuration , denoted S -LRB- , S I , S env -RRB- , if 1 . Whenever = -LRB- , m , 0 -RRB- : , then S I = a im : S I and S -LRB- , S I , S env -RRB- 2 . Whenever = -LRB- , m , n -RRB- : , n > 0 , then S = a in : S , S I = a in : b j m-n : S I and S -LRB- , S I , S env -RRB- 3 . Whenever = -LRB- , m , -1 -RRB- : , then S = -LRB- alts , E -RRB- : S , S I = p alts : S I , S env = alts : S env , p alts = trAs alts alts , E -LRB- alts , S I , , , -RRB- and S -LRB- alts , S I , S env -RRB- 4 . Whenever S = # a : S and S I = # a : S I , then S -LRB- , S I , S env -RRB- 5 . Additionally , -LSB- -RSB- -LRB- -LCB- -RCB- , -LSB- -RSB- , -LSB- -RSB- -RRB- 110 Definition 8 . A STG-2 heap is equivalent to an ISTG pair -LRB- I , cs -RRB- , denoted -LRB- I , cs -RRB- , if for all p we have -LSB- p -LRB- lf | x in , E -RRB- -RSB- if and only if I -LSB- p -LRB- q , ws -RRB- -RSB- , cs -LSB- q is -RSB- , is = trB -LRB- lf | x in -RRB- and ws = E x i n . Definition 9 . A STG-2 configuration is equivalent to an ISTG enriched stable configuration , denoted -LRB- , e , E , S -RRB- -LRB- is , , , S I , S env , node , I , cs -RRB- if 1 . -LRB- I , cs -RRB- 2 . is = trE e 3 . E -LRB- , S I , , I , node -RRB- 4 . S -LRB- , S I , S env -RRB- Proposition 9 . -LRB- dynamic invariant -RRB- Given a closed expression e 0 with different bound variables and initial STG-2 and ISTG configurations , respectively -LRB- -LCB- -RCB- , e 0 , -LCB- -RCB- , -LSB- -RSB- -RRB- and -LRB- trE e 0 -LCB- -RCB- , , -LCB- -RCB- , -LSB- -RSB- , -LSB- -RSB- , , -LCB- -RCB- , cs -RRB- , where cs is the code store generated by the whole translation of e 0 , then both machines evolve through equivalent configurations . Proof . By induction on the number of transitions of both machines . Only transitions between ISTG stable configurations are considered . Corollary 10 . The translation given in Section 5.1 is correct . There are some differences between the machine translation presented in Section 5 and the actual code generated by GHC . Some are just omissions , other are non-substantial differences and some other are deeper ones . In the first group it is the treatment of basic values , very elaborated in GHC -LRB- see for example -LSB- 3 -RSB- -RRB- and completely ig-nored here . We have preferred to concentrate our study in the functional kernel of the machine but , of course , a formal reasoning about this aspect is a clear continuation of our work . In the second group it is the optimization of update implementation . In GHC , updates can be done either by indirection or by closure creation , depending on whether there is enough space or not in the old closure to do update in place . This implies to keep closure size information somewhere . GHC keeps it in the so called info table , a static part shared by all closures created from the same bind . This table forces an additional indirection to access the closure code . Our model has simplified these aspects . We understand also that stack restructuring , as the one performed by our SLIDE instruction , is not implemented in this way by GHC . Apparently , stubbing of non used stack positions is done instead . An efficiency study could show which implementation is better . The cost of our SLIDE instruction is in O -LRB- n -RRB- , being n the number of arguments to be preserved in the stack when the current environment is discarded . Perhaps the deeper difference between our derived machine and the actual STG is our insistence in that FUN applications should have the form e x in instead of x x in as it is the case in the STG language . This decision is not justified in the GHC papers and perhaps could have a noticeable negative impact in performance . In a lazy language , the functional part of an application should be eagerly evaluated , but GHC does it lazily . This implies constructing a number of closures that will be immediately entered -LRB- and perhaps updated afterwards -RRB- , with a corresponding additional cost both in space and time . Our translation avoids creating and entering these closures . If the counter-argument were having the possibility of sharing functional expressions , this is always available in FUN since a variable is a particular case of an expression . What we claim is that the normalization process in the Core-to-STG translation should not introduce unneeded sharing . We have presented a stepwise derivation of a -LRB- well known -RRB- abstract machine starting from Sestoft 's operational semantics , going through several intermediate machines and arriving at an imperative machine very close to a conventional imperative language . This strategy of adding a small amount of detail in each step has allowed us both to provide insight on fundamental decisions underlying the STG design and , perhaps more importantly , to be able to show the correctness of each refinement with respect to the previous one and , consequently , the correctness of the whole derivation . To our knowledge , this is the first time that formal translation schemes and a formal proof of correctness of the STG to C translation has been done . Our previous work -LSB- 2 -RSB- followed a different path : it showed the soundness and completeness of a STG-like machine called STG-1S -LRB- laying somewhere between machines STG-2 and ISTG of this paper -RRB- with respect to Sestoft 's semantics . The technique used was also different : a bisimulation between the STG-1S machine and Sestoft 's MARK-2 machine was proved . We got the inspiration for the strategy followed here from Mountjoy -LSB- 5 -RSB- and in Section 2 we have explained the differences between his and our work . The previous machines of all these works , including STG-1 and STG-2 of this paper , are very abstract in the sense that they deal directly with functional expressions . The new machine ISTG introduced here is a really low level machine dealing with raw imperative instructions and pointers . Two contributions of this paper have been to bridge this big gap by means of the translations schemes and the proof of correctness of this translation . Our experience is that formal reasoning about even well known products always reveals new details , give new insight , makes good decisions more solid and provides trust in the behavior of our programs . -LSB- 1 -RSB- A. at URL : http://www.haskell.org/ghc/ . -LSB- 2 -RSB- A. Encina and R. Pe ~ na . Proving the Correctness of the STG Machine . In Implementation of Functional Languages , IFL ' 01 . Selected Papers . LNCS 2312 , pages 88 104 . Springer-Verlag , 2002 . -LSB- 3 -RSB- S. P. Jones and J. Launchbury . Unboxed values as first class citizens in a non-strict functional language . Conference on Functional Programming Languages and Computer Architecture FPCA ' 91 , LNCS 523 , September 1991 . -LSB- 4 -RSB- J. Launchbury . A Natural Semantics for Lazy Evaluation . In Proc . Conference on Principles of Programming Languages , POPL ' 93 . ACM , 1993 . -LSB- 5 -RSB- J. Mountjoy . The Spineless Tagless G-machine , Naturally . In Third International Conference on Functional Programming , ICFP ' 98 , Baltimore . ACM Press , 1998 . 111 -LSB- 6 -RSB- S. L. Peyton Jones . Implementing Lazy Functional Languages on Stock Hardware : the Spineless Tagless G-machine , Version 2.5 . Journal of Functional Programming , 2 -LRB- 2 -RRB- : 127 202 , April 1992 . -LSB- 7 -RSB- S. L. Peyton Jones , C. V. Hall , K. Hammond , W. D. Partain , and P. L. Wadler . The Glasgow Haskell Compiler : A Technical Overview . In Joint Framework for Inf . Technology , Keele , pages 249 257 , 1993 . -LSB- 8 -RSB- S. L. Peyton Jones and J. Hughes , editors . Report on the Programming Language Haskell 98 . URL http://www.haskell.org , February 1999 . -LSB- 9 -RSB- S. L. Peyton Jones , S. Marlow , and A. Reid . The STG Runtime System -LRB- revised -RRB- . http://www.haskell.org/ghc/docs , 1999 . -LSB- 10 -RSB- P. Sestoft . Deriving a Lazy Abstract Machine . Journal of Functional Programming , 7 -LRB- 3 -RRB- : 231 264 , May 1997 . 112

O O O B I O O O O O O B I O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B I O O O O B I O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B I O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B I O O O O O O O O O O B I O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B I O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B I O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B I O O O O O O O O O O O O O O O O O O O O O O O O O O O O B I O B I O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B I O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B I O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B I O O O O B I O O O O O O O O O O B I O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B I O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B I O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B I O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B I O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B I O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B I O O O O O O O O O O O O O B I O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B I O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O B I O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B I O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B I O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B I O O O O O O B I O O O O B I O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B I O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B I O O O O O O O O O O O O O O O O O O O O O O O O B I O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B I O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B I O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B I O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B I O O O B I O O O O O O O O O O O O O

functional programming
translation scheme
haskell compiler
stepwise derivation
abstract machine
closures
operational semantics
lazy evaluation
stg machine


Handoff Trigger Table for Integrated 3G/WLAN Networks Vertical handoff is a switching process between heterogeneous wireless networks in a hybrid 3G/WLAN network . Vertical handoffs fromWLAN to 3G network often fail due to the abrupt degrade of the WLAN signal strength in the transition areas . In this paper , a Handoff Trigger Table is introduced to improve the performance of vertical handoff . Based on this table , a proactive handoff scheme is proposed . Simulation results show that with the proposed scheme , the vertical handoff decisions will be more efficient so that dropping probability can be decreased dramatically . C. 4 -LSB- Performance of Systems -RSB- : Design Studies ; C. 2.1 -LSB- Network Architecture and Design -RSB- : Wireless Communications -- Integrated 3G/WLAN Networks Performance With the emergence of different wireless technologies , which are developed for different purposes , the integration of these wireless networks has attracted much attention from both academia and industry . Among them , the integration of 3G cellular networks and wireless local access networks -LRB- WLAN -RRB- has become a very active area in the development toward the Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page . To copy otherwise , to republish , to post on servers or to redistribute to lists , requires prior specific permission and/or a fee . IWCMC ' 06 , July 3 6 , 2006 , Vancouver , British Columbia , Canada . Copyright 2006 ACM 1-59593-306-9 / 06/0007 ... $ 5.00 . next generation wireless networks . WLAN access technology can offer high-speed data connections in a small coverage with relatively low cost . On the other hand , cellular networks can offer connectivity over several square kilometers but with relatively low data rate . Taking advantages of both networks will bring great benefits to both service providers and users . One of the desired features of such a heterogeneous wireless network is to support seamless global roaming or vertical handoff . Traditionally , handoff is performed within the same wireless system , which is called horizontal handoff . In contrast , a vertical handoff takes place between different wireless networks -LSB- 2 -RSB- . In an integrated 3G/WLAN network , there are two directions in vertical handoff , one is from WLANs to 3G networks and the other is from3G Networks to WLANs . In the first direction , the objective for handoff is to maintain the connectivity , i.e. , switching to the cellular network before the WLAN link breaks while trying to stay in the WLAN as long as possible because of its relatively high bandwidth and low cost . Since a WLAN has smaller coverage and is usually covered by a 3G network , when the mobile terminal -LRB- MT -RRB- steps out of the WLAN area , the decay of the signal fromthe WLAN should be accurately detected . A timely decision of handoff should be made properly , and the MT should switch the connection to the appropriate 3G network successfully . In the second direction , the objective of handoff is usually to improve QoS and acquire higher bandwidth with lower cost . In this paper , we will focus on the first direction , which is the handoff fromthe WLAN to the 3G network . For a WLAN , signal power is limited , which causes the signal strength to be quite easily influenced by physical obstruction and blocks . For example , if the MT passes some blocks or moves into the elevator , there will be an abrupt drop in its received WLAN signal strength . In this case , the MT may not have enough time to finish the WLAN-to -3 G-Network vertical handoff procedure before the link to WLAN breaks . Therefore , how to effectively detect the signal decay to trigger the handoff becomes a very important issue . In this paper , we propose to maintain a Handoff Trigger Table -LRB- HTT -RRB- at the Access Point -LRB- AP -RRB- to record some location information on transition areas in which vertical 575 handoffs occur . With the information of the HTT , a proactive handoff scheme is proposed to enable the MTs to start the vertical handoff procedure early enough to finish the vertical handoff procedure , thus the handoff call dropping probability can be decreased dramatically . The rest of this paper is organized as follows . In Section 2 , some related work is discussed . In Section 3 , we propose a Handoff Trigger Table to assist making handoff decisions . The handoff schem e based on this table is also presented . Section 4 gives simulation results to demonstrate the better performance of the proposed scheme in comparison with the traditional one . Section 5 concludes the paper . In traditional handoff schemes , the received signal strength -LRB- RSS -RRB- has been used as an indicator for making handoff decisions . Some of the traditional approaches are as follows : -LSB- 5 -RSB- RSS : handoff takes place if the RSS of a candidate point of attachment is larger than the RSS of the current point of attachm ent -LRB- RSS new > RSS current -RRB- ; RSS plus threshold : handoff is made if the RSS of a candidate point of attachment is larger than that of the current point of attachment and the latter is less than a certain pre-defined threshold T -LRB- RSS new > RSS current and RSS current < T -RRB- ; RSS plus hysteresis : a handoff takes place if the RSS of the candidate point of attachment is larger than the RSS of the current one with a pre-defined hysteresis margin H -LRB- RSS new > RSS current + H -RRB- ; Algorithm plus dwell timer : sometimes a dwell timer can be added to the above algorithms . This timer is started when one of the above conditions happens , and the handoff takes place if the condition is met for the entire dwell timer interval . For the vertical handoff process , it may not be very reliable to make handoff decisions based only on the RSS of the point of attachment -LRB- e.g. , AP of the WLAN -RRB- and the candidate point of attachment -LRB- e.g. , base station of the 3G network -RRB- because of the asymmetric nature of the handoff problem -LSB- 6 -RSB- . As mentioned before , the handoff from WLAN to 3G network is expected to be efficient and effective . Some methods have been proposed to achieve this goal . One of them is the Fast Fourier Transform -LRB- FFT -RRB- - based decay detection -LSB- 1 -RSB- . This approach tries to estimate the signal decay , and will trigger the handoff after the signal is confirmed to be decreased to a certain threshold . However , this approach has high calculation complexity with the need of frequent sampling , and suffers from estimation errors . In -LSB- 2 -RSB- , handoff triggering nodes are used to notify the mobile terminal to start the handoff . These special nodes are data stations installed in WLAN/cellular transition regions where vertical handoffs occur . When an MT moves close to it , the handoff triggering node will send a handoff trigger command to trigger the link layer handoff . Using handoff trigger node can be good at triggering the handoffs , but if they are needed in many places within a WLAN , it will be costly to set up many trigger nodes . In addition , if there are new blocks appearing in the WLAN , it is hard to determine where the additional trigger nodes should be installed . Therefore , this approach is not very flexible . The Fuzzy logic based handoff algorithm -LSB- 3 -RSB- -LSB- 4 -RSB- is proposed to assist making handoff decisions . This algorithmdecreases handoff delay and the number of unnecessary handoffs by changing the RSS average window according to the MT speed . It is worth mentioning that some fuzzy logic based algorithms are complex and may not be easy to be implemented in practical systems . Recently , WLAN has been expected to provide user location information -LSB- 6 -RSB- - -LSB- 10 -RSB- , which is helpful for making vertical handoffs . We propose to use a Handoff Trigger Table -LRB- HTT -RRB- to store such location information at the AP and utilize it to trigger the WLAN-to-3G vertical handoff explicitly . Based on this table , a proactive handoff scheme is proposed to assist MTs to handoff in the right places at the right time . With this scheme , handoff decisions can be more efficient and handoffs are more likely to succeed compared with the traditional schemes which trigger the handoff mainly based on the received signal strength at the MTs . 3.1 Handoff Trigger Table A typical integrated 3G/WLAN network is shown in Fig. 1 . The HTT is normally implemented at the APs of WLAN and used to record the user location information which will be helpful to make handoff decisions as explained later . An example of the HTT is given in Table 1 . Table 1 : An example of HandoffTrigger Table X 1 + D > x > X 1 - D Y 1 + D > y > Y 1 - D X 2 + D > x > X 2 - D Y 2 + D > y > Y 2 - D X n + D > x > X n - D Y n + D > y > Y n - D In the HTT , the information of the locations where an MT needs to handoff is given . We defined Black Holes -LRB- BH -RRB- the small areas in which the received signal strength at an MT decreases abruptly and the link to the AP breaks in a very short time . In such BHs , if the MT does not switch the connection to the 3G network , it will not be able to keep the connectivity to its correspondence node . Each BH is proposed to be covered by a slightly larger area , namely , proactive area . When MTs move into a proactive area , the AP will send a message to notify the MT to start proactive handoff -LRB- detailed in Section 3.2 -RRB- , regardless of the current received signal strength at the MT. In Table 1 , -LRB- X i , Y i , i = 1 , 2 , , n -RRB- are the location coordinates of the center of the BHs , and D is the distance between the center of the black hole and proactive area edges . -LRB- X n + D > x > X n - D , Y n + D > y > Y n - D -RRB- is an example of possible ways to describe the proactive area . Note that other types of proactive areas such as circles can also be adopted . Fig. 1 illustrates the above two concepts , wherein A , B and C are three BHs within the WLAN , and A ' , B ' , C ' are the corresponding proactive areas . The HTT will be initialized when the AP is installed in the WLAN , then it will be dynamically updated . In the initial stage , MTs will handoff in a traditional way , i.e. , handoff 576 Figure 1 : An example of WLAN with Black Holes when the received signal strength decreases to a threshold . In addition , the MT sends out a handoff notification to the AP , and the AP will record the coordinates of this handoff location into the HTT . Usually BH is not a dot , but a small area . Therefore , for each BH , the HTT will store many coordinates of points where vertical handoffs occur , then the AP will try to merge these coordinates to form a corresponding proactive area and put it into the HTT . After the initialization stage , the HTT will only contain the description of proactive areas instead of individual coordinates of BHs . Meanwhile , the AP will often check the HTT to decide whether any MT enters the proactive areas . When a new BH appears , the AP will be able to record its proactive area into the HTT after some vertical handoffs take place near this BH , similar to the initial stage . When a BH disappears due to some reasons -LRB- e.g. , restructure in the WLAN -RRB- , there will be no vertical handoffs occur in the corresponding proactive area . As a result , the AP will remove the entry of this proactive area fromthe HTT after some predefined time , which can be decided by the system administrator . With the above methods , the HTT is maintained dynamically and can adaptive to the change of the environment . 3.2 Proactive Handoff Scheme Based on the Handoff Trigger Table , we propose a proactive handoff scheme to achieve better handoff performance . In the traditional scheme , the handoff decision mechanism is that a handoff will be triggered when the current RSS is lower than a threshold -LRB- THm -RRB- or RSS from the candidate network is higher than a threshold -LRB- THw -RRB- . The procedure is illustrated in Fig. 2 . In the proposed scheme , we divide the handoff into two stages , a proactive handoff stage and a handoff stage . In the proactive handoff stage , when an MT moves into a proactive area , the AP will send it a proactive handoff message . Following that the MT will send out a binding update message to the AP and start this network layer handoff . The procedure is given in Fig. 3 . When an MT enters the WLAN , the RSSs in sampling intervals will be measured and their averages are computed . At the same time , the AP will check if the MT is in any proactive area . If yes , it will send a control message Pre-Handoff - CMD to the MT. After receiving this message , the MT will start to send the cellular network a message to request a connection . When the signal decreases to a certain threshold R t , the link-layer handoff starts , and the MT will Handoff execution RSS < Rt No Yes Start handoff Averaging Measurements Figure 2 : Traditional handoffscheme for Hybrid Networks Measurements Averaging Handoff Trigger Table Handoff execution RSS < Rt Pre-handoff Yes No Figure 3 : Proactive handoffscheme for Hybrid Networks switch the connection to the cellular network . When the received signal strength decreases to R t , but the MT still does not receive the Pre-Handoff-CMD , it will send a message to informthe AP to add this location coordinate into the HTT . The threshold R t is a design parameter that can be set by the administrator to best enable vertical handoff procedure under the WLAN-specific physical situation . In this section , we compare the performance of the proposed vertical handoff scheme with HTT and the traditional handoff scheme by simulation . Consider the simplified network model for 3G/WLAN networks shown in Fig. 1 . We assume that the 3G network covers the WLAN area . The RSS of the WLAN signal at an MH is assumed as a function of the distance d between the MH and the AP -LSB- 11 -RSB- : RSS -LRB- d -RRB- = P T L 10n log -LRB- d -RRB- + f -LRB- , -RRB- dBm , where P T is the transmitted power , L is a constant signal power loss , n is the path loss exponent , and f -LRB- , -RRB- represents shadow fading modeled as zero mean Gaussian random variable with mean and standard deviation . In the WLAN , there are a number of BHs , in which the RSS will decrease to almost zero immediately and the MT will have to handoff to the 3G networks . 577 The popular Random Waypoint mobility model -LSB- 12 -RSB- is used to simulate the mobility of the MTs in the WLAN . At the beginning , the MTs ' positions in the WLAN are uniformly distributed . Each MT will move at a random speed V , which is uniformly distributed in -LSB- V min , V max -RSB- , and in a randomdirection . After randomtime T m , the MT will stop and stay for randomtime T s , with both T m and T s uniformly distributed in -LSB- 0 , 2s -RSB- . The MT will continue the movement as described above . Any MT that moves out of the WLAN will be eliminated , and a new MT will be gener-ated in the WLAN with a randomly chosen location . Some other parameters used in the simulations are given in Table 2 . Table 2 : Parameters for the numerical examples Parameter Value PT 100mW R t -85 dbm n 3.3 7dB Handoff time 2s Velocity range 0 2 m / sec Number of BHs 3 WLAN area 100m 100m We define the transition time as the time from when an MT starts handoff to the moment it moves into a BH , and handoff time as the time from when an MT sends out the binding update message to the moment it receives the first package fromthe Base Station . The drop of a call only happens when the transition time is less than the handoff time . In Figs. 4 , 5 and 6 , we present the dropping probability of the proposed scheme and the traditional handoff scheme based on different proactive distance , D , and two values of user mobility rate , V , respectively . Fig. 4 illustrates the 0 0.5 1 1.5 2 0 0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4 0.45 User Mobility rate Drop Probablity Traditional Method D = 0.4 HTT Method D = 0.5 HTT Method Figure 4 : Effect of user mobility effect of user mobility on the connection dropping probability . In this figure , the dropping probabilities for proactive distance D = 0.4 and D = 0.5 , are given . In these results , handoff time is 2s . From the figure , we can see that the handoff probability has been reduced with the explicit handoff trigger in the proposed scheme , because mobile terminals can have more time to execute the handoff . When the proactive distance increases , the dropping probability decreases . This is due to the fact that when the proactive distance is larger , the time for the MT to execute the handoff will be longer . We can also see that when the MTs move faster , dropping probability will increase as well , because shorter time is made available for the MT to execute the vertical handoff given the same D. Compared with the HTT scheme , the traditional scheme is more sensitive to the user mobility rate , and the dropping probability increases rapidly as the mobility increases . 0.1 0.15 0.2 0.25 0.3 0.35 0.4 0.45 0.5 0 0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4 0.45 Distance of prehandoff D r oppi ng P r obabl i t y V = 0.5 Traditional Method V = 0.5 HTT Method V = 1 Traditional Method V = 1 HTT Method Figure 5 : Effect of proactive distance Fig. 5 shows that as the proactive distance increases , the dropping probability of HTT scheme decreases very fast and it is quite sensitive to the distance increasing . When the user mobility rate increases , the dropping probability will also increase , which conforms with the results in Fig. 4 . Fig. 6 shows the impact of the handoff time -LRB- in practical value range -RRB- on the dropping probability . With a given transition time , if the handoff time increases , the dropping probability will be higher , as expected . Fig. 7 shows that the impact of the distance between AP and BH on the dropping probability . The signal strength decays with the distance to the AP in WLANs . In the proposed scheme , MTs start network layer handoff in advance according to the parameter D and regardless of the RSS , so the performance of the proposed scheme is independent from the distance d between the BH and the AP . However , for a given RSS threshold , the performance of traditional handoff scheme relies heavily on d , and it has better performance for the BHs which are far fromthe AP . This is because the signal strength is relatively high near the AP , and MT will normally find that its RSS is above the threshold . As the MT enters the BH , the signal strength degrades so abruptly that the MT does not have enough time to do handoff , which leads to high dropping probability . In contrast , the RSS of an MT moving around a BH that is far from the AP will be relatively low and may be close to the threshold , hence a handoff decision may be easily triggered before the MT enters the BH . In this case , the MT gets longer time to conduct the handoff procedure so a relatively lower dropping probability can be achieved . 578 1.8 2 2.2 2.4 2.6 2.8 3 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 Handoff time -LRB- s -RRB- D r oppi ng P r o bab l i t y Traditional Method HTT Method Figure 6 : Effect of Vertical handoff time 2 3 4 5 6 7 8 9 10 11 12 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 Distance between AP and BH Dr oppi ng P r obabl i t y Traditional Method D = 0.4 HTT Method D = 0.5 HTT Method Figure 7 : Effect of distance between AP and BH FromFig . 7 , we can also see that for the proposed scheme , the proactive distance D should be set properly . Similar requirement applies to the setting of the threshold in the traditional scheme . If D or the threshold is set to be high , there will be many unnecessary handoffs although the dropping probability will decrease . On the other hand , if D or the threshold is too low , the dropping probability will increase . However , the dependence on d of the traditional handoff scheme can not be eliminated by simply adjusting the threshold , which makes the selection of a proper threshold in the traditional scheme even more difficult . We further study the performance of the two schemes in the WLAN with different number of BHs . The locations of the BHs are set to be uniformly distributed within the WLAN . FromFig . 8 , it can be seen that for both schemes the dropping probability is not sensitive to the number of BHs when their locations are uniformly distributed . The case for BHs with non-uniformdistribution is left as future work . 2 4 6 8 10 12 14 16 18 0.01 0.015 0.02 0.025 0.03 0.035 0.04 0.045 Number of BHs Dropping Probablity Traditional Method D = 0.4 HTT Method Figure 8 : Effect of number of BHs In this paper , vertical handoffs fromWLAN to 3G cellular network has been investigated . To support making proper handoff decisions , a Handoff Trigger Table -LRB- HTT -RRB- has been proposed to be implemented at the AP of WLAN to record the location information of BHs . Based on this table , a proactive handoff scheme has been proposed . Simulation results have been given to show that with the information in the HTT , the vertical handoff decisions can be made more efficiently and dropping probability can be decreased signif-icantly . Possible future work include making the proactive distance D a variable for different environments and further investigating the unnecessary handoff events in different prehandoff schemes . The HTT scheme can also be used in sys-temdiscovery to assist reducing MH power consumption . This work has been supported jointly by the Natural Sciences and Engineering Research Council -LRB- NSERC -RRB- of Canada under Strategic Grant No. 257682 and Research in Motion -LRB- RIM -RRB- . -LSB- 1 -RSB- Q. Zhang , C. Guo , Z. Guo and W. Zhu , `` Efficient mobility management for vertical handoff between WWAN and WLAN '' , IEEE Communications Magazine Vol . 41 , Issue 11 , Nov. 2003 , pp. 102 108 . -LSB- 2 -RSB- W.-T . Chen ; J.-C . Liu ; H.-K . Huang , `` An adaptive scheme for vertical handoff in wireless overlay networks '' , Proceedings of International Conference on Parallel and Distributed Systems 2004 , 7-9 July 2004 , pp. 541 548 . -LSB- 3 -RSB- P. Khadivi , T.D. Todd and D. Zhao , `` Handoff trigger nodes for hybrid IEEE 802.11 WLAN/cellular networks '' , Proc . QSHINE 2004 , pp. 164 170 . -LSB- 4 -RSB- A. Majlesi and B.H. Khalaj , `` An adaptive fuzzy logic based handoff algorithmfor interworking between WLANs and mobile networks '' , Proc . PIMRC ' 02 , Sept. 2002 , pp. 2446 2451 . -LSB- 5 -RSB- K. Pahlavan , et al. , `` Handoff in hybrid mobile data 579 networks '' , IEEE Personal Communications , Vol .7 , No. 2 , April 2000 , pp. 34 47 . -LSB- 6 -RSB- J.-Z . Sun , J. Sauvola and D. Howie , `` Features in future : 4G visions froma technical perspective '' , Proc . GLOBECOM ' 01 , Nov. 2001 , pp. 3533 3537 . -LSB- 7 -RSB- P. Bahl and V. Padmanabhan , `` RADAR : An in-building RF-based user location and tracking system '' , Proc . IEEE INFOCOM ' 00 , Tel-Aviv , Israel , 2000 , pp. 775 784 . -LSB- 8 -RSB- P.Krishnan , A.S. Krishnakumar , W.-H . Ju , C. Mallows , and S. Ganu , `` A systemfor LEASE : location estimationassisted by stationary emitters for indoor RF wireless networks '' , Proc . IEEE INFOCOM ' 04 , Hongkong , 2004 , pp. 1001 1011 . -LSB- 9 -RSB- K.-I . Itoh , S. Watanabe , J.-S . Shih , and T. Sato , `` Performance of handoff algorithm based on distance and RSSI measurements '' , IEEE Trans . Vehic . Technol. , Vol . 51 , No. 6 , Nov. 2002 , pp. 1460 - 1468 . -LSB- 10 -RSB- J. Makela , M. Ylianttila and K. Pahlavan , `` Handoff decision in multi-service networks '' , Proc . PIMRC ' 00 , Sept. 2000 , pp. 655 659 . -LSB- 11 -RSB- A.H. Zahran and B. Liang , `` Performance evaluation framework for vertical handoff algorithms in heterogeneous networks '' , Proc ICC 2005 , May 2005 , pp. 173 178 -LSB- 12 -RSB- C Bettstetter , H Hartenstein and X Perez-Costa , `` Stochastic properties of the randomwaypoint mobility model '' , Wireless Networks , Vol . 10 , No. 5 , Sept. 2004 , pp. 555 567 . 580

B I I O O O O B I O O O O O O O O O O O O O O O O O O B O O O O O O O O O O B O O O O O O O O O O O O B I I O O O O O O O B I O O O O O O O O O O O O O O O O O O O O O O O B I O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B I O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B I O O O O O O O O O O O O O O O O O O O O O O B I O O O O O O O O O O O O O O O O O O O O O B I O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B I O O B O O O O O O O O B O O O O O O O O O O O O O O O O B O O O O O O O O O B O O O O O O O O O O O O O B O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O B O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O B I O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B I I O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B I O O O O O O B I O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B I I O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B I O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O B O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B I I O O O O O O O O O O O O O O O O O O B I O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B I I O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B I I O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B I O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B I I O O O O O O O O O O O O O O O O O O O O O B I O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B I O O O O O O O O O O O O O O O O O O B I O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O B O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B I O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B I O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B B I O O O O O O O O O O O O B I I O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B I O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B I O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B I O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B I O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O

wlan
3g
cellular network
handoff trigger table
vertical handoff
wireless communications