TVLA: A Framework for Kleene Logic Based Static Analyses

Size: px
Start display at page:

Download "TVLA: A Framework for Kleene Logic Based Static Analyses"

Transcription

1 TVLA: A Framework for Kleee Logic Based Static Aalyses Tal Lev-Ami Departmet of Computer Sciece, Tel-Aviv Uiversity, Israel May 28, 2000 Ackowledgmets First ad foremost I would like to thak Dr. Mooly Sagiv for his guidace, support ad drive. Without it, this thesis would ever have bee writte. I would like to thak Nurit Dor, Mauel Fahdrich, Noam Rietskey, Tom Reps, ad Reihard Wilhelm for readig the drafts ad for their helpful commets. I ejoyed havig valuable discussios with Hae Riis ad Flemmig Nielso. Thaks also to Guy Lade, Ra Shaham ad Oded Shmueli. I would like to thak my parets Liora ad Uzi for listeig ad givig a kid word where is was eeded. May thaks to the Acadamy of Sciece for their Fiacial support. Abstract We preset TVLA (Three-Valued-Logic Aalyzer). TVLA is a YACC -like framework for automatically costructig static-aalysis algorithms from a operatioal sematics, where the operatioal sematics is specified usig logical formulae. TVLA has bee implemeted i Java ad was successfully used to perform shape aalysis o programs maipulatig liked data structures (sigly ad doubly liked lists), to prove safety properties of Mobile Ambiets, ad to verify the partial correctess of several sortig programs. tla@math.tau.ac.il 1

2 Cotets 1 Itroductio Mai Results Applicatios Techical Cotributios Outlie of the Thesis A Primer o 3-Valued-Logic-Based Aalysis Represetig Memory States via Logical Structures Coservative Represetatio of Sets of Memory States via 3-valued Structures Embeddig Summary odes Formulae Subclasses of formulae Sematics System Descriptio TVP Declaratios Actios CFG Process Focus Precoditios Update Formulae Coerce Blur Output Additioal Features Applicatios Sigly Liked Lists Doubly Liked Lists Sortig Algorithms Specifyig a Aalysis for Observig ADT Properties Specifyig ad Checkig Partial Correctess of ADT Operatios Mobile Ambiets

3 5 The Coerce Algorithm Costraits Automatic Geeratio of Costraits Order of Costraits Memoizig Trasitive Closures Icremetal Evaluatio Icremetal Formula Evaluatio The Focus Algorithm Normalizig Focus Formulae Focusig o Cojuctios of Literals Focusig o Literals Usig Fuctioal Properties i Focus The Actual Implemetatio Active Nodes Geeralized Embeddig Formula Evaluatio Coerce Focus Actios New Retai Sigle Structure Usig Nullary Predicates to Improve Precisio Coclusio The Essece of Istrumetatio Compariso to Related Work Further Work A Empirical 80 B Proof of the Geeralized Embeddig Theorem 80 C User s Maual 85 C.1 Graphical Represetatio C.2 TVP C.2.1 Predicates C.3 Formulae C.3.1 Cosistecy Rules

4 C.3.2 Actios C.4 Cotrol Flow Graph C.5 Usability C.5.1 Commets C.5.2 Preprocessig C.5.3 Sets C.5.4 Foreach C.5.5 Composite Operatios C.6 TVS C.7 Commad Lie Optios Itroductio The abstract-iterpretatio techique [CC79] for static aalysis allows oe to summarize the behavior of a statemet o a ifiite set of possible memory states. This is sometimes called a abstract sematics for the statemet. With this methodology it is ecessary to show that the abstract sematics is coservative, i.e., it summarizes the (cocrete) operatioal sematics of the statemet for every possible memory state. Ituitively speakig, the operatioal sematics of a statemet is a formal defiitio of a iterpreter for this statemet. This operatioal sematics is usually quite atural. However, desigig ad implemetig soud ad reasoably precise abstract sematics is quite cumbersome (the best iduced abstract sematics defied i [CC79] is usually ot computable). This is particularly true i problems like shape aalysis ad poiter aalysis (e.g., see [Deu94, SRW00, SRW98]), where the operatioal sematics ivolves destructive memory updates. I this paper, we preset TVLA (Three-Valued-Logic Aalyzer), a system for automatically geeratig a static-aalysis algorithm from the operatioal sematics of a give program. The operatioal sematics is writte i a special form, based o first-order predicate logic with trasitive closure. A additioal iput to TVLA is a abstract represetatio of all the possible memory states at the begiig of the aalyzed program. TVLA automatically geerates the abstract sematics, ad, for each program poit, produces a coservative abstract represetatio of the memory states at that poit. 1.1 Mai Results TVLA is iteded as a proof of cocept for itra-procedural shape aalysis, ad other static-aalysis algorithms. It is a test-bed i which it is 4

5 quite easy to try out ew ideas. The theory behid TVLA is based o [SRW99, SRW00] (see Sectio 8.2). The system is publicly available from tla. TVLA was implemeted i Java ad has bee successfully used to perform shape aalysis o programs maipulatig liked data structures (sigly ad doubly liked lists), to prove safety properties of Mobile Ambiets, ad to verify partial correctess of several programs. We also report o some programs that are too complex for the curret system. The system was tested o a Petium II 400 MHz ruig Liux with JDK 1.2. All the timig iformatio about the system refers to this computer Applicatios TVLA has bee utilized to aalyze a variety of small but itricate programs from the groups described below. Sigly Liked Lists: We performed shape aalysis o the set of programs maipulatig sigly liked lists used i [DRS00], icludig oes for searchig, elemet isertio, ad elemet deletio. These programs perform destructive updatig. Some of these programs are (deliberately) sematically icorrect, ad we are able to locate the bugs i them. The aalysis times are reported i AppedixA. Doubly Liked Lists: Doubly liked lists are more challegig tha sigly liked lists because they create shared memory cells ad cycles. We have aalyzed a program that iserts a ew elemet ito a arbitrary place i a doubly liked list, ad the aalysis was able to coclude that the isertio results i a doubly liked list. Sortig Programs: A differet kid of applicatio of TVLA is for program verificatio. We applied TVLA to several implemetatios of sortig algorithms, ad proved that, give a possibly usorted liked list as iput, we always ed up with a sorted list. This is prove without the eed for programmer-specified loop ivariats. Istead, the operatioal sematics also keeps track of iequalities betwee the list elemets. We are ecouraged by the fact that we have successfully verified both isert sort ad bubble sort o sigly liked lists. Mobile Ambiets: We implemeted the aalysis of [NNS00] ad foud out that it is imprecise ad quite slow. This motivated us to geeralize the techiques preseted i [SRW99, SRW00] i order to guaratee that oly a costat umber of structures arise at each program poit (see Sectio 3.4). 1 Our experiece idicates that usig JVM o Widows, the system rus about 20% faster. 5

6 With this extesio, TVLA was able to successfully aalyze a slight variat of the origial specificatio used i [NNS00]. This took 336 CPU secods ad the aalysis proved the ecessary properties (uiqueess of ambiet istace ad mutual exclusio) precisely. 1.2 Techical Cotributios The TVLA system itroduces several ew cotributios, which are described i this thesis. Focus: We preset a otrivial algorithm for focusig o a geeral formula. Thus, ulike [SRW00], our Focus is ot limited to the formulae specific to shape aalysis. This geeralizatio is crucial i order to go beyod shape aalysis. For example, to verify sortig programs we use more complex formulae tha the oes eeded i shape aalysis. The Focus algorithm preseted i this thesis is also more efficiet tha the algorithm from [SRW99] for the formulae that they both hadle. Coerce: The Coerce operatio is very time cosumig. TVLA itroduces a ew algorithm for Coerce (see Sectio 5) which is more efficiet tha the o give i [SRW00, SRW99], for empirical results, see Appedix A. Automatic geeratio of cosistecy rules: Oe of the complicated aspects of usig the three-valued logic approach is the desig of cosistecy rules. This is particularly complicated because two logically equivalet sets of cosistecy rules may result i icomparable aalyses (both of which are coservative). Furthermore, usig cosistecy rules that are ot global ivariats may lead to a icorrect aalysis. TVLA icorporates a algorithm that automatically geerates cosistecy rules from the specificatio, ad thus the user of the system does ot usually eed to add explicit cosistecy rules (see Sectio 5). Costat umber of structures: TVLA allows the use of a eve more compact abstract represetatio i which oly a costat umber of abstract structures arise at each program poit. I some cases (such as the aalysis preformed o Mobile Ambiets), this makes a otherwise ifeasible aalysis possible. 1.3 Outlie of the Thesis The rest of the thesis is orgaized as follows. I Sectio 2, we give a primer of the use of 3-valued logic i static aalysis. Sectio 3 cotais a overview of the TVLA system ad its capabilities. Sectio 4 gives a descriptio of the aalyses doe with the system. We the give a descriptio of the 6

7 /* list.h */ typedef struct ode { struct ode *; it data; *L; (a) /* reverse.c */ #iclude list.h L reverse(l x) { L y, t; y = NULL; while (x!= NULL) { t = y; y = x; x = x->; y-> = t; t = NULL; retur y; (b) Figure 1: (a) Declaratio of a liked-list data type i C. (b) A C fuctio that uses destructive updatig to reverse the list poited to by parameter x. mai algorithms developed for the system: a efficiet Coerce algorithm (Sectio 5) ad a geeral Focus algorithm (Sectio 6). Sectio 7 explais the more advaced topic of active odes. We coclude by summarizig related work ad further research directios (Sectio 8). Appedix A presets the empirical results for test rus of the system. Appedix C is a user s maual for the TVLA system. A program that destructively reverses a sigly liked list is show i Figure 1. The shape aalysis of this program serves as a ruig example i this thesis. 2 A Primer o 3-Valued-Logic-Based Aalysis Kleee s 3-valued logic is a extesio of ordiary 2-valued logic with the special value of 1/2 (ukow) for cases that ca be either 1 or 0. Kleee s iterpretatio of the propositioal operators is give i Table 1. We say that the values 0 ad 1 are defiite values ad that 1/2 is a idefiite value. We say that the values 0 ad 1 are defiite values ad that 1/2 is a idefiite value, ad defie a partial order o truth values to reflect iformatio 7

8 0 1 1/ /2 1/2 0 1/2 1/ / / /2 1/2 1 1/ /2 1/2 Table 1: Kleee s 3-valued iterpretatio of the propositioal operators. cotet: l 1 l 2 deotes that l 1 has more defiite iformatio tha l 2 : Defiitio 2.1 [Iformatio Order]. For l 1,l 2 {0, 1/2, 1, we defie the iformatio order o truth values as follows: l 1 l 2 if l 1 = l 2 or l 2 =1/2. The symbol (joi) deotes the least-upper-boud operatio with respect to, i.e., l 1 l 2 = l 1, if l 1 = l 2 ad 1/2 otherwise. Kleee s sematics of 3-valued logic is mootoic i the iformatio order. 2.1 Represetig Memory States via Logical Structures Our vocabulary icludes a set of predicate symbols partitioed ito two disjoit sets: core ad istrumetatio predicates. Istrumetatio predicates are used to observe derived properties based o core predicates. A 2-valued logical structure S is comprised of a set of idividuals (odes) called a uiverse, deoted by U S, ad a iterpretatio over that uiverse for a set of predicate symbols. The iterpretatio of a predicate symbol p i S is deoted by p S. For every (core ad istrumetatio) predicate p of arity k, p S is a fuctio p S :(U S ) k {0, 1. 2-valued structures are used to represet memory states used i the operatioal sematics of the program. TVLA makes a explicit assumptio that the set of predicate symbols used throughout the aalysis is fixed. (The umber of idividuals i structures ca vary throughout the aalysis.) TVLA oly supports predicates of arity 2; such logical structures ca be thought of as directed graphs. A directed edge labeled by p from u 1 to u 2 deotes that p S (u 1,u 2 ) = 1. Also, we draw p iside a ode u whe p S (u) = 1. Example 2.2 I the ruig example, a 2-valued structure represets a memory state (also called a store); a idividual correspods to a list elemet. The iteded meaig of the core predicates is give i Table 2, ad the iteded meaig of the istrumetatio predicates is give i Table 3 8

9 Predicate Iteded Meaig x(v) Is v poited to by variable x? y(v) Is v poited to by variable y? t(v) Is v poited to by variable t? (v 1,v 2 ) Does the -field of v 1 poit to v 2? Table 2: The core predicates used i the aalysis of the ruig example. Predicate Iteded Meaig Defiig Formula r[, x](v) Is v reachable from program v 1 :(x(v 1 ) (v 1,v)) variable x usig field? r[, y](v) Is v reachable from program v 1 :(y(v 1 ) (v 1,v)) variable y usig field? r[, t](v) Is v reachable from program v 1 :(t(v 1 ) (v 1,v)) variable t usig field? c[](v) Does v reside o a directed + (v, v) cycle via derefereces alog -fields? is[](v) Is v poited to by more v 1,v 2 : (v 1,v) (v 2,v) v 1 v 2 tha oe -field Table 3: The istrumetatio predicates used i the aalysis of the ruig example ad their meaig. Similar istrumetatio predicates are used i all of our shape aalyses for sigly liked lists. The defiig formulae are explaied i Sectio 2.3. (for the momet igore the third colum). The store i Figure 2 is represeted by the 2-valued structure S 3 show i Figure 3. The structure S 3 has four odes, u 0, u 1, u 2, ad u 3 represetig the four list elemets. This represetatio itetioally igores the values of the data field, which are usually immaterial for the aalysis. Poiter variables are represeted by uary predicates (i.e., x S (u) =1 if the variable x poits to the list elemet represeted by u). I Figure 3, the variable x is represeted by the uary predicate x, which is 1 oly for u 0. Notice that TVLA allows the user to specify that a uary predicate is draw as a box with a arrow ito each ode for which it holds. I Figure 3, x is draw as a box ad has a arrow to u 0. Poiter fields withi the list elemets are represeted as biary predicates (i.e., S (u 1, u 2 ) = 1 if the 9

10 x NULL Figure 2: A possible store for the ruig example. x u0 r[,x] u1 r[,x] u2 r[,x] u3 r[,x] x y t r[, x] r[, y] r[, t] is[] c[] u u u u u0 u1 u2 u3 u u u u Figure 3: A logical structure S 3 represetig the store show i Figure 2 i a graphical ad tabular represetatio. -field of u 1 poits to u 2 ). The istrumetatio predicate r[, x] holds for list elemets that are reachable from program variable x, possibly usig a sequece of accesses through the -field. The structure S 3 i Figure 3 has r[, x] S 3 set to 1 for all the odes because they are all reachable from x. A importat aspect of explicitly storig r[, x] is that we ca icremetally compute the appropriate values for the predicates after executio of the program statemet (see [SRW00, Sectio 6.1]). For example, for the statemet y=x, the odes reachable from y after the statemet executes are the same as the odes reachable from x. The istrumetatio predicate is[] holds for odes shared by -fields (a ode is shared by -fields, if it is poited to by more tha oe list elemet usig the field ). I Figure 3, all the elemets of the list are ushared, ad thus is[] S 3 is 0 for all of them. The istrumetatio predicate c[] holds for odes o a cycle of accesses alog -fields. We use the cyclicity istrumetatio to avoid performig a trasitive-closure operatio whe updatig the reachability iformatio. I Figure 3, the list is acyclic, ad thus c[] S 3 is 0 for all of the odes. I fact, throughout the aalysis of the ruig example, is[] S ad c[] S are 0 for all of the odes. 10

11 2.2 Coservative Represetatio of Sets of Memory States via 3-valued Structures Like 2-valued structures, a 3-valued logical structure S is also comprised of a uiverse U S, ad a iterpretatio p S for every predicate symbol p. But, for every predicate p of arity k, p S is a fuctio p S :(U S ) k {0, 1, 1/2, where 1/2 explicitly captures ukow predicate values. 3-valued logical structures are also draw as directed graphs. Defiite values are draw as i the 2-valued structures. Biary idefiite (1/2) predicate values are draw as dotted directed edges. Uary idefiite predicate values are draw iside the odes ad marked as idefiite (this does ot occur i the ruig example) Embeddig Although structures may have differet idividuals, we ca defie a order o structures, deoted by based o the cocept of embeddig. The goal is to guaratee that if S S the the value of every formula i S is less or equal to its value i S. I particular, wheever the formula evaluates to a defiite value i S the the formula has the same value i S. Formally, Defiitio 2.3 Let S ad S be two structures. Let f : U S U S be surjective. We say that f embeds S i S (deoted by S f S ) if (i) for every predicate p (icludig sm) of arity k ad all u 1,..., u k U S, ad (ii) for all u U S p S (u 1,..., u k ) p S (f(u 1 ),..., f(u k )) (1) ( {u f(u) =u > 1) sm S (u ) (2) We say that S ca be embedded i S (deoted by S S ) if there exists a fuctio f such that S f S. A special kid of embeddig is a tight embeddig, i which iformatio loss is miimized whe multiple idividuals of S are mapped to the same idividual i S : Defiitio 2.4 A structure S is a tight embeddig of S if there exists a surjective fuctio blur : U S U S such that, for every p sm of arity k, p S (u 1,..., u k )= p S (u 1,..., u k ) (3) blur(u i )=u i,1 i k 11

12 x u0 r[,x] u r[,x] x y t r[, x] r[, y] r[, t] is[] c[] u u u0 u u0 0 1/2 u 0 1/2 Figure 4: A 3-valued structure S 4 represetig lists of legth 2 or more that are poited to by program variable x (e.g., S 3 ). ad for every u U S, sm S (u ) = ( {u blur(u) =u > 1) blur(u)=u sm S (u) (4) Because blur is surjective, equatios (3) ad (4) uiquely determie S (up to isomorphism); therefore, we say that S = blur(s). Example 2.5 I the ruig example, the 3-valued structure S 4 show i Figure 4 represets the 2-valued structure S 3 for f(u 0 )=u 0 ad f(u 1 )= f(u 2 )=f(u 3 )=u. I fact, the structure show i Figure 4 represets all the lists with two or more elemets. The uary predicate symbol x has x S 4 (u 0 ) = 1, idicatig that the program variable x is kow to poit to the list elemet represeted by u 0, ad x S 4 (u) = 0, idicatig that x is kow ot to poit to ay of the list elemets represeted by u. The biary predicate symbol has S 4 (u 0,u)=1/2, idicatig that the -field of the list elemet represeted by u 0 may poit to a list elemet represeted by u amely the secod list elemet (u 1 i Figure 3) but does ot poit to all the list elemets represeted by u (e.g. u 2 i Figure 3). Also, S 4 (u, u) = 1/2, idicatig that the -field of a list elemet represeted by u may poit to aother list elemet represeted by u or eve to itself but does ot poit to all the list elemets represeted by u (e.g., i Figure 3 the -field of u 2 poits to u 3, but ot to u 1 ). 12

13 2.2.2 Summary odes Nodes i a 3-valued structure that may represet more tha oe idividual from a give 2-valued structure are called summary odes. For example, i the structure show i Figure 3, the odes u 1, u 2, ad u 3 are represeted by the sigle ode u i Figure 4. TVLA uses a special desigated uary predicate sm to maitai summaryode iformatio. Such a summary ode w has sm S (w) = 1/2, idicatig that it may represet more tha oe ode i the embedded 2-valued structures. These odes are graphically draw as dotted ellipsis. I cotrast, if sm S (w) = 0 the w is kow to represet a uique ode. Oly odes with sm S (w) = 1/2 ca have more tha oe ode mapped to them by the embeddig fuctio. The exact choice of which odes should be summarized is crucial for the precisio of the aalysis ad is discussed i Sectio Formulae Properties of structures ca be extracted by evaluatig formulae. We use first-order logic with trasitive closure ad equality, but without fuctio symbols ad costat symbols. For example, the formula v 1 :(x(v 1 ) (v 1,v)) (5) extracts reachability iformatio. Here, deotes the reflexive trasitive closure of the predicate. Therefore, i every structure S, x(v 1 ) evaluates to 1 if v 1 is the ode poited to by x ad (v 1, v) evaluates to 1 i S if there exists a path of zero or more -edges from v 1 to v. The third colum of Table 3 displays the defiig formula of all the istrumetatio predicates used i the ruig example Subclasses of formulae Atomic formulae are oe of the followig (i) p(v 1,..., v k ), (ii) v 1 = v 2, ad (iii) 0 or 1. Without loss of geerality oly ullary, uary, ad biary predicates are supported. A literal is a atomic formula or a egatio of a atomic formula. Defiitio 2.6 A Hor clause is a formula of the form m 1 ( i=1 ϕ i ) ϕ m, 13

14 where m>1, ad ϕ i is a atomic formula, We ow geeralize the defiitio. Toward this ed, for a formula ϕ, we defie ϕ 1 ϕ ad ϕ 0 ϕ. A exteded Hor clause is a formula ϕ of the form (ϕ i ) B i ) (ϕ m ) Bm, m 1 ( i=1 where m>1, ϕ i is a atomic formula, B i {0, Sematics Defiitio 2.7 A assigmet Z is a fuctio that maps free variables to idividuals (i.e., a assigmet has the fuctioality Z : {v 1,v 2,... U S ). A assigmet that is defied o all free variables of a formula ϕ is called complete for ϕ. I the sequel, we assume that every assigmet Z that arises i coectio with the discussio of some formula ϕ is complete for ϕ. The meaig of a formula ϕ, deoted by [[ϕ]] S (Z), yields a truth value i {0, 1, 1/2. The meaig of ϕ is defied iductively as follows: Atomic For a logical literal l {0, 1, 1/2, [[l]] S (Z) =l (where l {0, 1, 1/2). For a atomic formula p(v 1,..., v k ), [[p(v 1,..., v k )]] S (Z) =p S (Z(v 1 ),..., Z(v k )) For a atomic formula (v 1 = v 2 ), 0 Z(v 1 ) Z(v 2 ) [[v 1 = v 2 ]] S (Z) = 1 Z(v 1 )=Z(v 2 ) ad sm S (Z(v 1 )) = 0 1/2 otherwise Logical Coectives For logical formulae ϕ 1 ad ϕ 2 [[ϕ 1 ϕ 2 ]] S (Z) = mi([[ϕ 1 ]] S (Z), [[ϕ 2 ]] S (Z)) [[ϕ 1 ϕ 2 ]] S (Z) = max([[ϕ 1 ]] S (Z), [[ϕ 2 ]] S (Z)) [[ ϕ 1 ]] S (Z) = 1 [[ϕ 1 ]] S (Z) Quatifiers If ϕ is a logical formula, [[ v 1 : ϕ]] S (Z) = mi u U S [[ϕ 1]] S (Z[v 1 u]) [[ v 1 : ϕ]] S (Z) = max u U S [[ϕ 1]] S (Z[v 1 u]) 14

15 Trasitive Closure For (TC v 1,v 2 : ϕ)(v 3,v 4 ), [[(TC v 1,v 2 : ϕ)(v 3,v 4 )]] S (Z) = max 1,u 1,..., u +1 U, Z(v 3 )=u 1,Z(v 4 )=u +1 mi i=1 [[ϕ]]s (Z[v 1 u i,v 2 u i+1 ]) We say that S ad Z potetially satisfy ϕ (deoted by S, Z = ϕ) if [[ϕ]] S (Z) = 1/2 or [[ϕ]] S (Z) = 1. Fially, we write S = ϕ if for every Z: S, Z = ϕ. The Embeddig Theorem: The Embeddig Theorem (see [SRW99, Theorem 3.7]) states that ay formula that evaluates to a defiite value i a 3-valued structure evaluates to the same value i all the 2-valued structures embedded ito that structure. The Embeddig Theorem is the foudatio for the use of 3-valued logic i static-aalysis: it esures that it is sesible to reiterpret o the 3-valued structures the formulae, that whe iterpreted i 2-valued logic, defie the operatioal sematics. TVLA requires each istrumetatio predicate to be associated with a formula over the core predicates defiig its meaig. For example, evaluatig formula (5) o the 3-valued structure show i Figure 4, yields 1 for v u 0, which idicates that the list elemet represeted by u 0 is reachable from variable x, ad 1/2 for v u, which idicates that the list elemets represeted by u may or may ot be reachable from program variable x. Notice that r[, x] S 4 (u) = 1, which is more precise. This is a geeral priciple with istrumetatio predicates (referred to as the istrumetatio priciple i [SRW99]). The stored iformatio ca be more precise tha the result of evaluatig the correspodig formula. 3 System Descriptio The iput to TVLA cosists of two files: (i) a TVS (Three Valued logical Structure) file cotaiig a textual represetatio of the iput structures (see Figure 5), ad (ii) a TVP (Three Valued Program) file, which icludes the operatioal sematics ad the associatio of the operatioal sematics with the edges of the cotrol flow graph (CFG) of the aalyzed program (see Figs. 6 ad 7). To simplify the specificatio, we allow the operatioal sematics to be specific to the aalyzed data type (e.g., sigly liked lists i the ruig example). I the coversio of a C program ito a TVP file, some 15

16 % = {u, u0 %p = sm = {u :1/2 = {u u :1/2,u0 u :1/2 x = {u0 : 1 r[, x] = {u :1,u0 : 1 Figure 5: A TVS structure describig a sigly liked list poited to by x. ormalizig trasformatios are applied (see [CWZ90, SRW98]). For example, the assigmet y->=t is broke ito two statemets: (i) y->=null, followed by (ii) y->=t assumig that y->==null. The full operatioal sematics for programs maipulatig sigly-liked-lists of type L is give i Sectio TVP There are two challegig aspects to writig a good TVP specificatio: oe is the desig of the istrumetatio predicates, which is importat for the precisio of the aalysis; the other is writig the operatioal sematics maipulatig these predicates. A importat observatio is that the TVP specificatio should always be thought of i the terms of the cocrete 2-valued world rather tha the abstract 3-valued world: the Embeddig Theorem guaratees the soudess of the reiterpretatio of the formulae i the abstract world. This is a applicatio of the well-kow credo of Patrick ad Radhia Cousot that the desig of a static aalysis always starts with a cocrete operatioal sematics. The TVP file is divided ito sectios separated by %%, give i the order described below Declaratios The first sectio of the TVP file cotais all the declaratios eeded for the aalysis. Sets: The first declaratio i the TVP file is the set PVar, which specifies the variables used i the program (here x, y, ad t). I the remaider of the specificatio, set otatio allows the user to defie the operatioal sematics for all programs maipulatig a certai data type, i.e., it is parametric i PVar. 16

17 /* Declaratios */ %s PVar {x, y, t // The set of program variables #iclude sll pred.tvp // Core ad Istrumetatio Predicates %% /* A Operatioal Sematics */ #iclude ptr cod.tvp // Operatioal Sematics of Coditios #iclude sll stat.tvp // Operatioal Sematics of Statemets %% /* The program s CFG ad the effect of its edges */ 1 Set Null L(y) 2 // y = NULL; 2 Is Null Var(x) exit // x == NULL 2 Is Not Null Var(x) 3 // x!= NULL 3 Copy Var L(t, y) 4 // t = y; 4 Copy Var L(y, x) 5 // y = x; 5 Get Next L(x, x) 6 // x = x->; 6 Set Next Null L(y) 7 // y-> = NULL; 7 Set Next L(y, t) 8 // y-> = t; 8 Set Null L(t) 2 // t = NULL; Figure 6: The TVP file for the ruig example show i Figure 1. Files sll pred.tvp, sll cod.tvp, ad sll stat.tvp are give i Figures 7, 10, ad 11 respectively. 17

18 /* sll pred.tvp */ foreach (z i PVar) { %p z(v 1 ) uique box // Core predicates correspodig to program variables %p (v 1,v 2 ) fuctio // -field core predicate %i is[](v) = v 1,v 2 :((v 1,v) (v 2,v) v 1 v 2 ) // Is shared istrumetatio foreach (z i PVar) { %i r[, z](v) = v 1 :(z(v 1 ) (v 1,v)) // Reachability istrumetatio %i c[](v) = v! : (v, v 1 ) (v 1,v) // Cyclicity istrumetatio Figure 7: The TVP predicate declaratios for maipulatig liked lists as declared i Figure 1 (a). The core predicates are take from Table 2. Istrumetatio predicates are take from Table 3. Predicates: The predicates for maipulatig sigly liked lists as declared i Figure 1(a) are give i Figure 7. The foreach clause iterates over all the program variables i the set PVar ad for each of them defies the appropriate core predicate the uary predicates x, y, ad t (box tells TVLA to display the predicate as a box). The biary predicate represets the poiter field. For readability, we use some mathematical symbols here that are writte i C-like sytax i the actual TVP file (see [LA00, Appedix B]). The secod foreach clause (i Figure 7) uses PVar to defie the reachability istrumetatio predicates for each of the variables of the program (as opposed to Table 3, which is program specific). Thus, to aalyze other programs that maipulate sigly liked lists the oly declaratio that is chaged is that of PVar. The fact that the TVP file is specific for the data type L declared i Figure 1(a) allows us to explicitly refer to. Fuctioal properties: TVLA also supports a cocept of fuctioal properties borrowed from the database commuity. Sice program variables ca poit to at most oe heap cell at a time, they are declared as uique. The biary predicate represets the poiter field ; the -field of each list elemet ca oly poit to at most oe target list elemet, ad thus is declared as a (partial) fuctio. 18

19 3.1.2 Actios I the secod sectio of the TVP file, we defie actios that specify the operatioal sematics of program statemets ad coditios. A actio defies a 2-valued structure trasformer. The actios are associated with CFG edges i the third sectio of the TVP file. A actio specificatio cosists of several parts, each of which is optioal (the meaig of these costructs is explaied i Sectio 3.2). There are three major parts to the actio: (i) Focus formulae (explaied i Sectio 3.2.1), (ii) precoditio formula specifyig whe the actio is evaluated, ad (iii) update formulae specifyig the actual structure trasformer. For example, the actio Is Null Var(x1) (see Figure 10) specifies whe the true brach of the coditio x1 == NULL, is eabled by meas of the formula v : x1(v), which holds if x1 does ot poit to ay list elemet. Sice this coditio has o side effects there are o update formulae associated with this actio ad thus the structure remais uchaged. As aother example, the actio Copy Var L(x1, x2) (see Figure 11) specifies the sematics the statemet x1 = x2. It has o precoditio, ad its side effect is to set the x1 predicate to x2 ad the r[, x1] predicate to r[, x2] CFG The third sectio of the TVP specificatio is the CFG with actios associated with each of its edges. The edges are specified as source actio target. The first CFG ode that appears i the specificatio is the etry ode of the CFG. The CFG specificatio for the ruig example, is give i Figure Process This sectio presets a more detailed explaatio, usig the example show i Figure 8, of how the effect of a actio associated with a CFG edge is computed. To complete the picture, a iterative (fixed-poit) algorithm to compute the result of static-aalysis is preseted i Sectio Focus First, the Focus operatio coverts the iput structure ito a more refied set of structures that represets the same 2-valued structures as the iput structure. Give a formula, Focus guaratees that the formula ever evaluates to 1/2 i the focused structures. Focus (ad Coerce) are sematic 19

20 iput structure x y u0 r[,x] r[,y] u r[,x] r[,y] focus formulae x u0 r[,x] r[,y] y x u0 r[,x] r[,y] S i { v 1 : x(v 1 ) (v 1,v) y x y u0 r[,x] r[,y] u.1 r[,x] r[,y] focused structures update formulae u r[,x] r[,y] y u0 r[,y] u r[,x] r[,y] u.0 r[,x] r[,y] S f0 S f1 S f2 Predicate Update Formula x(v) v 1 : x(v 1 ) (v 1,v) r[, x](v) r[, x](v) (c[](v) x(v)) x y u0 r[,y] y x u0 r[,y] u.1 r[,x] r[,y] output structures u r[,y] u r[,x] r[,y] u.0 r[,x] r[,y] S o0 S o1 S o2 y x x u0 r[,y] y u0 r[,y] u.1 r[,x] r[,y] coerced structures u r[,x] r[,y] 20 S c1 u.0 r[,x] r[,y] S c2 Figure 8: The first applicatio of abstract iterpretatio for the statemet x = x-> i the reverse fuctio show i Figure 1.

21 reductios (see [CC79]), i.e., they trasfer a 3-valued structure ito a set of 3-valued structures represetig the same memory states. A algorithm for Focus of a geeral formula is give i [LA00]. I the ruig example, the most iterestig focus formula is v 1 : x(v 1 ) (v 1,v), which determies the value of the variable x after the Get Next L(x, x) actio (which correspods to the statemet x = x->). Focusig o this formula esures that x S (u) is defiite at every ode u i every structure S after the actio. Figure 8 shows how the structure S i is focused for this actio. Three cases are cosidered i refiig S i : (i) The -field of u 0 does ot poit to ay of the list elemets represeted by u (S f0 ); (ii) The -field of u 0 poits to all of the list elemets represeted by u (S f1 ); ad (iii) The -field of u 0 poits to oly some of the list elemets represeted by u (S f2 ): u is bifurcated ito two odes odes poited to by the -field of u 0 are represeted by u.1, ad odes ot poited to by the -field of u 0 are represeted by u.0. As explaied later, the result ca be improved (e.g., S f0 ca be discarded sice u is ot reachable from x, ad yet r[, x] S f0(u) = 1). This is solved by the Coerce operatio, which is applied after the abstract iterpretatio of the statemet (see Sectio 3.2.4) Precoditios After Focus, precoditios are evaluated. If the precoditio formula is potetially satisfied, the the actio is performed; otherwise, the actio is igored. This mechaism comes i hady for (partially) iterpretig program coditios. I the ruig example, the loop while (x!= NULL) has two outgoig edges i the CFG: oe with the precoditio ( v : x(v)), specifyig that if x is NULL the statemet followig the loop is executed (the exit i our case). The other edge has the precoditio v : x(v), specifyig that if x is ot NULL the loop body is executed Update Formulae The effect of the operatioal sematics of a statemet is described by a set of update formulae defiig the value of each predicate after the statemet s actio. The Embeddig Theorem eables us to reevaluate the formulae o the abstract structures ad kow that the result provides a coservative abstract sematics. If o update formula is specified for a predicate, it is left uchaged by the actio. 21

22 I Figure 8, the effect of the Get Next L actio (x = x->) is computed usig the followig update formulae: (i) x(v) = v 1 : x(v 1 ) (v 1,v), (ii) r[, x](v) = r[, x](v) (c[](v) x(v)). The first formula updates the x variable to be the -successor of the origial x. The secod formula updates the iformatio about which odes are reachable from x after the actio: A ode is reachable from x after the actio if it is reachable from x before the actio, except for the ode directly poited to by x (uless x appears o a -cycle, i which case the ode poited to by x is still reachable eve though we advaced to its -successor). For S f2, the update formula for x evaluates to 1 for v u.1 ad to 0 for all odes other tha u.1. Therefore, after the actio, the resultig structure S o2 has x S o2 (u.1) = 1 but x S o2 (u.0) = 0 ad x S o2 (u 0 ) = Coerce The last stage of the computatio is the Coerce operatio, which uses a set of cosistecy rules (defied i [SRW99, SRW00, LA00]) to make structures more precise by removig uecessary idefiite values ad discardig ifeasible structures. The set of cosistecy rules used is idepedet of the curret actio beig performed. See [LA00] for a detailed descriptio of the Coerce algorithm used i TVLA ad how TVLA automatically geerated cosistecy rules from the istrumetatio predicates ad the fuctioal properties of predicates. For example, Figure 8 shows how the Coerce operatio improves precisio. The structure S o0 is ifeasible because the ode u must be reachable from y (sice r[, y] S o0 (u) = 1) ad this is ot the case i S o0. I the structure S o1, u is o loger a summary ode because x is uique; u s self-loop is removed because u already has a icomig -field ad it does ot represet a shared list elemet (is[] S o1 (u) = 0). For the same reaso, i S o2, u.1 is o loger a summary ode; Also, the list elemet represeted by u.1 already has a icomig -field ad it is ot shared (is[] S o2 (u.1) = 0), ad thus u.1 s self-loop is removed. For a similar reaso, the idefiite -edge from u.0 to u.1 is removed Blur To guaratee that the aalysis termiates o programs cotaiig loops, we require the umber of potetial structures for a give program to be fiite. Toward this ed, we defie the cocept of a bouded structure. For each aalysis, we choose a set of uary predicates called the abstractio 22

23 predicates. 2 I the bouded structure, two odes u 1, u 2 are merged if p S (u 1 )=p S (u 2 ) for each abstractio predicate p. Whe odes are merged, the predicate values for their o-abstractio predicates are joied (i.e., the result is 1/2 if their values are differet). This is a form of wideig (see [CC79]). The operatio of computig this kid of bouded structure is called Blur. The choice of abstractio predicates is very importat for the balace betwee space ad precisio. TVLA allows the user to select the abstractio predicates. By default, all the uary predicates are abstractio predicates, as i the ruig example. Example 3.1 I Figure 4, the odes u 0 ad u are differetiated by the fact that x S 4 (u 0 ) = 1, whereas x S 4 (u) = 0. (All other predicates are 0.) If x was ot a abstractio predicate, the the appropriate bouded structure S 4 would have had a sigle ode, say u, with xs 4 (u) =1/2 ad S 4 (u, u) = 1/2. After the actio is computed ad Coerce applied, the Blur operatio is used to trasform the output structures ito bouded structures, thereby geeratig more compact, but potetially less precise structures. 3.3 Output Now that we have a method for computig the effect of a sigle actio, what remais is to compute the effect of the whole program, i.e., to compute what structures ca arise at each CFG ode if the program was used o the give iput structures. We use a stadard iterative algorithm (e.g., see [Muc99]) with a set of bouded structures as the abstract elemets. A ew structure is added to the set if the set does ot already cotai a member that is isomorphic to the ew structure. I the ruig example, the aalysis termiates whe the structures created i the fourth iteratio are isomorphic to the oes created i the third iteratio (see Figure 9). We ca see that the aalysis precisely captures the behavior of the reverse program. 3.4 Additioal Features The system allows several customizatios o the stadard iterative algorithm for optimizig the aalysis (as commad lie optios). The user ca choose whether the actios are evaluated i depth first search post-order or reverse depth first search post-order. Eve though reverse depth first search 2 I [SRW99, SRW00] the abstractio predicates are all the uary predicates. 23

24 Iter Structures x 0 r[,x] x r[,x] x y r[,x] y r[,x] 1 r[,x] y r[,y] r[,y] x r[,y] r[,y] r[,x] y x y r[,x] 2 r[,y] r[,y] r[,x] y r[,y] x r[,y] r[,y] r[,y] r[,x] r[,x] y x y 3 r[,y] r[,y] r[,x] r[,y] r[,y] Figure 9: The structures arisig i the reverse fuctio show i Figure 1 at CFG ode 2 for the iput structure show i Figure 4. 24

25 post order is usually more efficiet (sice a actio is evaluated oly after its predecessors are evaluated), usig post order causes structures to reach the ed of the program more quickly. This is very useful i case the aalysis is ot feasible ad yet we wat to see a glimpse of what is expected, a example for such a aalysis is the merge fuctio without reachability as defied i Sectio 4.1. Aother form of customizatio is the choice of CFG odes i which the set of structures is saved. At the miimum at least oe such ode should reside o each loop i the CFG. Three forms are available: (i) at every CFG ode, (ii) at every merge poit (i.e., CFG ode with two icomig edges), ad (iii) at every back edge of the depth first search tree. The more CFG odes i which the structures are saved the faster the aalysis is (sice structures eed ot be recreated). However, more space is eeded (by factor of 10 eve for simple programs). Oe of the mai features of TVLA is the support of sigle structure aalysis. Sometimes whe the umber of structures that arise at each program poit is too large, it is better to merge these structures ito a sigle structure that represets at least the same set of 2-valued structures. TVLA ehaces this feature eve more by allowig the user to specify that some chose costat umber of structures will be associated with each program poit. More specifically, ullary predicates (i.e., predicates of 0-arity) are used to discrimiate betwee differet structures. For example, for liked lists we use the predicate [x]() = v : x(v) which discrimiates betwee structures i which x actually poits to a list elemet from structures i which it does ot. For example, cosider a structure S 1 i which both x ad y poit to list elemets, ad aother structure S 2 i which both x ad y are NULL. Mergig S 1 ad S 2 will loose the iformatio that x ad y are simultaeously allocated or ot allocated. Notice that S 1 has [x] =[y] = 1 ad S 2 has [x] =[y] = 0 therefore S 1 ad S 2 will ot be merged together. I some cases (such as safety aalysis of Mobile Ambiets, see [NNS00]) this optio makes a otherwise ifeasible aalysis ru i a reasoable time. However, there are other cases i which the sigle-structure method is less precise or eve more time cosumig tha the usual method, which uses sets of structures. TVLA also supports modelig statemets that hadle dyamically allocated ad freed memory. 25

26 /* ptr cod.tvp */ %actio Is Not Null Var(x1) { %t x1 +!= NULL %f { x1(v) %p v : x1(v) %actio Is Null Var(x1) { %t x1 + == NULL %f { x1(v) %p ( v : x1(v)) %actio Is Eq Var(x1, x2) { %t x1 + == + x2 %f { x1(v), x2(v) %p v : x1(v) x2(v) %actio Is Not Eq Var(x1, x2) { %t x1 +!= + x2 %f { x1(v), x2(v) %p v : x1(v) x2(v) Figure 10: A operatioal sematics i TVP for hadlig poiter coditios. 4 Applicatios 4.1 Sigly Liked Lists We used the fuctios aalyzed i [DRS00] with sharig ad reachability istrumetatios (see Table 4). The specificatio for all the fuctios was writte oce ad used with each of the CFGs. The actios for hadlig program coditios that cosists of poiter equalities ad iequalities are give i Figure 10. The actios for maipulatig the struct ode declaratio from Figure 1(a) are give i Figure 11. The actios Set Next Null L ad Set Next L model destructive updatig (i.e., assigmet to x1->), ad therefore have a otrivial specificatio. We use the otatio ϕ 1?ϕ 2 : ϕ 3 for a if-the-else clause. If ϕ 1 is 1 the the result is ϕ 2, if ϕ 2 is 0 the the result is ϕ 3. If ϕ 1 is 1/2 the the result is ϕ 2 ϕ 3. We use the otatio TC(v 1,v 2 )(v 3,v 4 ) for the trasitive-closure operator. The variables v 3 ad v 4 are the free variables of the sub-formula over which the trasitive closure is performed, ad v 1 ad v 2 are the variables used o the resultig biary relatio. Most of the aalyses were very precise with ruig times of up to 8 secods for the most complex fuctio (merge). 26

27 /* sll stat.tvp */ %actio Set Null L(x1) { %t x1 + = NULL { x1(v) =0 r[, x1](v) = 0 %actio Copy Var L(x1, x2) { %t x1 + = + x2 %f { x2(v) { x1(v) =x2(v) r[, x1](v) =r[, x2](v) %actio Malloc L(x1) { %t x1 + = (L) malloc(sizeof(struct ode))) %ew { x1(v) =isn ew(v) r[, x1](v) =isn ew(v) %actio Free L(x1) { %t free(x1) %f {x1(v) %message v 1,v 2 : x1(v 1 ) (v 1,v 2 ) -> Iteral error! assume that + x1 + -> + + ==NULL %retai x1(v) %actio Get Next L(x1, x2) { %t x1 + = + x2 + -> + %f { v 1 : x2(v 1 ) (v 1,v) { x1(v) = v 1 : x2(v 1 ) (v 1,v) r[, x1](v) =r[, x2](v) (c[](v) x2(v)) %actio Set Next Null L(x1) { %t x1 + -> + + = NULL %f { x1(v) { (v 1,v 2 )=(v 1,v 2 ) x1(v 1 ) is[](v) =is[](v) ( ( v 1 : x1(v 1 ) (v 1,v)) v 1,v 2 :((v 1,v) x1(v 1 )) ((v 2,v) x1(v 2 )) v 1 v 2 ) r[, x1](v) =x1(v) foreach(z i PVar-{x1) { r[, z](v) =(c[](v) r[, x1](v)? z(v) v 1 : z(v 1 ) TC(v 1,v)(v 3,v 4 )((v 3,v 4 ) x1(v 3 )) : r[, z](v) (r[, x1](v) x1(v) v 1 : r[, z](v 1 ) x1(v 1 ))) c[](v) =c[](v) ( v 1 : x1(v 1 ) c[](v 1 ) r[, x1](v)) %actio Set Next L(x1, x2) { %t x1 + -> + + = + x2 %f { x1(v),x2(v) %message v 1,v 2 : x1(v 1 ) (v 1,v 2 ) -> Iteral error! assume that + x1 + -> + + ==NULL { (v 1,v 2 )=(v 1,v 2 ) x1(v 1 ) x2(v 2 ) is[](v) =is[](v) v 1 : x2(v) 27 (v 1,v) foreach(z i PVar) { r[, z](v) =r[, z](v) r[, x2](v) v 1 : r[, z](v 1 ) x1(v 1 ) c[](v) =c[](v) (r[, x2](v) v 1 : x1(v 1 ) r[, x2](v 1 )) Figure 11: A operatioal sematics i TVP for hadlig the poitermaipulatio statemets of liked lists as declared i Figure 1(a).

28 program search ull deref delete del all isert create merge reverse fumble rotate swap getlast descriptio searches for a elemet i a liked list searches a liked list but with a typical error of ot checkig for the ed of the list deletes a give elemet from a liked list deletes a etire liked list iserts a elemet ito a sorted liked list preped a varyig umber of ew elemets to a liked list merges two sorted liked lists ito oe sorted list reverses a liked list via destructive updates a erroeous versio of reverse which loses the list performs a cyclic rotatio whe give poiters to the first ad last elemets swaps the first ad secod elemets of a list, fails whe the list is 1 elemet log returs the last elemet of the list Table 4: Descriptio of the aalyzed sigly liked list programs. These programs are collectios of iterestig programs from LCLit [Eva96], [JJNS97], Thomas Ball ad from first-year studets. They are available at urr. x x u0 r[,x] u r[,x] last u1 r[,last] r[,x] u3 r[,x] u2 r[,x]=1/2 last u4 r[,last] r[,x]=1/2 Figure 12: The structure before ad after the rotate fuctio. 28

29 The rotate fuctio gives a example of a aalysis which is ot as precise as possible (see Figure 12). The idefiite edge [u.1, [u.0, u0].0], u1 is superfluous ad all the list should be kow to be reachable from x. The imprecisio arises because the list becomes cyclic i the process ad the reachability update formula i the actio Set Next Null L show i Figure 11 is ot very precise i case of cyclic lists. The merge fuctio is a good example of how precisio problems i the aalysis ca create too may structures. Aalyzig the merge fuctio without the reachability istrumetatio creates tes of thousads of graphs ad takes too much space for the machie we were usig. Addig the reachability iformatio reduces the umber of graphs to 327 ad the time to about 8 secods. 4.2 Doubly Liked Lists Doubly liked lists are a example of a more complex abstract datatype which ca still be aalyzed accurately i may cases. The aalysis is also a good example for how uaces i the istrumetatio predicates used ca chage the accuracy of the aalysis. We use a stroger istrumetatio predicate tha the oe described i [SRW99], i.e., we keep a stroger program ivariat. We show how usig the ew istrumetatio icreases the accuracy of the aalysis. It is hard to predict how these small differeces are goig to affect the aalysis, this demostrates the importace of the system as a platform for developig ad testig ew aalysis algorithms. The splice fuctio aalyzed ad the appropriate data structure are give i Figure 13. The TVP for splice is specified i figures 14, 16, ad 15. The istrumetatio predicate that eables us to aalyze the DLL programs precisely is the cacel f by b (c[f, b]), a uary predicate statig that v->f->b == v. A similar istrumetatio is maitaied for cacel b by f. The formula used i [SRW99] for the istrumetatio is, c[f, b](v) = v 1,v 2 : f(v, v 1 ) b(v 1,v 2 ) v 1 = v 2 (6) whe tryig to ru the aalysis o the splice fuctio utilizig this defiig formula, we foud out that the aalysis was ot as precise as we wated. We came up with the followig defiitio of the istrumetatio predicate, c[f, b](v) = v 1 : f(v, v 1 ) b(v 1,v) (7) The differece may seem isigificat. However, (7) is stroger tha (6), i.e., a ode that satisfies (7) must satisfy (6) but ot vice versa. The costraits 29

30 /* dlist.h */ typedef struct DNode { struct DNode *f, *b; it data; DNode, *DL; (a) /* splice.c */ #iclude dlist.h void splice(it v, DL p) { DL e, t; e = (DL)malloc(sizeof(DNode)); e->data = v; t = p->f; e->f = t; (b) if (t!= NULL) t->b = e; p->f = e; e->b = p; Figure 13: (a) Declaratio of a doubly liked-list data type i C. (b) A program that splices a elemet with a data value v ito a doubly liked list with a head poited by l, after a elemet poited to by p. geerated by the system from this istrumetatio, ad, c[f, b](v) f(v, v 1 ) b(v 1,v) c[f, b](v) b(v 1,v) f(v, v 1 ) are very importat i keepig the aalysis of the splice program precise. For example, Lets look at the simple t = p->f istructio with both versios of the istrumetatio o the structure i Figure 17. Figure 17 depicts a doubly liked list poited to by p. Figure 18 illustrates a 4.3 Sortig Algorithms I this sectio, we describe how the 3-valued-logic aalysis framework ca be used to prove that a implemetatio of a abstract datatype (ADT) is partially correct. Here we will be cocered with a ADT of sorted liked lists i.e., a subset of the full set of data structures allowed accordig to the C typedef show i Figure 1(a), cosistig of those structures that 30

Putting Static Analysis to Work for Verification: A Case Study

Putting Static Analysis to Work for Verification: A Case Study Puttig Static Aalysis to Work for Verificatio: A Case Study Tal Lev-Ami Thomas Reps Mooly Sagiv, Reihard Wilhelm Abstract We study how program aalysis ca be used to: Automatically prove partial correctess

More information

VERIFICATION AND ABSTRACT INTERPRETATION

VERIFICATION AND ABSTRACT INTERPRETATION Lecture 05 Shape Aalysis (puttig it all together eample I) VERIFICATION AND ABSTRACT INTERPRETATION Ora Grumberg ad EraYahav Slides i this lecture are based o some slides from Tom Reps ad Mooly Sagiv 1

More information

PROGRAM ANALYSIS & SYNTHESIS

PROGRAM ANALYSIS & SYNTHESIS Lecture 07 Shape Aalysis PROGRAM ANALYSIS & SYNTHESIS EraYahav 1 Previously LFP computatio ad joi-over-all-paths Iter-procedural aalysis call-strig approach fuctioal approach 2 Today Shape Aalysis Typestate

More information

Constructing Specialized Shape Analyses for Uniform Change

Constructing Specialized Shape Analyses for Uniform Change Costructig Specialized Shape Aalyses for Uiform Chage Tal Lev-Ami 1, Mooly Sagiv 1, Neil Immerma 2, ad Thomas Reps 3 1 School of Computer Sciece, Tel Aviv Uiversity, {tla,msagiv}@post.tau.ac.il 2 Departmet

More information

6.854J / J Advanced Algorithms Fall 2008

6.854J / J Advanced Algorithms Fall 2008 MIT OpeCourseWare http://ocw.mit.edu 6.854J / 18.415J Advaced Algorithms Fall 2008 For iformatio about citig these materials or our Terms of Use, visit: http://ocw.mit.edu/terms. 18.415/6.854 Advaced Algorithms

More information

Shape Analysis and Applications 1

Shape Analysis and Applications 1 12 Shape Aalysis ad Applicatios 1 Thomas Reps 2 Computer Scieces Departmet, Uiversity of Wiscosi-Madiso, WI reps@cs.wisc.edu Mooly Sagiv Departmet of Computer Sciece, School of Mathematics ad Sciece, Tel

More information

A Relational Approach to Interprocedural Shape Analysis

A Relational Approach to Interprocedural Shape Analysis A Relatioal Approach to Iterprocedural Shape Aalysis BERTRAND JEANNET ad ALEXEY LOGINOV ad THOMAS REPS ad MOOLY SAGIV This paper addresses the verificatio of properties of imperative programs with recursive

More information

Chapter 11. Friends, Overloaded Operators, and Arrays in Classes. Copyright 2014 Pearson Addison-Wesley. All rights reserved.

Chapter 11. Friends, Overloaded Operators, and Arrays in Classes. Copyright 2014 Pearson Addison-Wesley. All rights reserved. Chapter 11 Frieds, Overloaded Operators, ad Arrays i Classes Copyright 2014 Pearso Addiso-Wesley. All rights reserved. Overview 11.1 Fried Fuctios 11.2 Overloadig Operators 11.3 Arrays ad Classes 11.4

More information

Pseudocode ( 1.1) Analysis of Algorithms. Primitive Operations. Pseudocode Details. Running Time ( 1.1) Estimating performance

Pseudocode ( 1.1) Analysis of Algorithms. Primitive Operations. Pseudocode Details. Running Time ( 1.1) Estimating performance Aalysis of Algorithms Iput Algorithm Output A algorithm is a step-by-step procedure for solvig a problem i a fiite amout of time. Pseudocode ( 1.1) High-level descriptio of a algorithm More structured

More information

Chapter 1. Introduction to Computers and C++ Programming. Copyright 2015 Pearson Education, Ltd.. All rights reserved.

Chapter 1. Introduction to Computers and C++ Programming. Copyright 2015 Pearson Education, Ltd.. All rights reserved. Chapter 1 Itroductio to Computers ad C++ Programmig Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Overview 1.1 Computer Systems 1.2 Programmig ad Problem Solvig 1.3 Itroductio to C++ 1.4 Testig

More information

Elementary Educational Computer

Elementary Educational Computer Chapter 5 Elemetary Educatioal Computer. Geeral structure of the Elemetary Educatioal Computer (EEC) The EEC coforms to the 5 uits structure defied by vo Neuma's model (.) All uits are preseted i a simplified

More information

Refinement-Based Verification for Possibly-Cyclic Lists

Refinement-Based Verification for Possibly-Cyclic Lists Refiemet-Based Verificatio for Possibly-Cyclic Lists Alexey Logiov 1, Thomas Reps 2, ad Mooly Sagiv 3 1 IBM T.J. Watso Research Ceter; alexey@us.ibm.com 2 Comp. Sci. Dept., Uiversity of Wiscosi; reps@cs.wisc.edu

More information

Python Programming: An Introduction to Computer Science

Python Programming: An Introduction to Computer Science Pytho Programmig: A Itroductio to Computer Sciece Chapter 1 Computers ad Programs 1 Objectives To uderstad the respective roles of hardware ad software i a computig system. To lear what computer scietists

More information

How do we evaluate algorithms?

How do we evaluate algorithms? F2 Readig referece: chapter 2 + slides Algorithm complexity Big O ad big Ω To calculate ruig time Aalysis of recursive Algorithms Next time: Litterature: slides mostly The first Algorithm desig methods:

More information

the beginning of the program in order for it to work correctly. Similarly, a Confirm

the beginning of the program in order for it to work correctly. Similarly, a Confirm I our sytax, a Assume statemet will be used to record what must be true at the begiig of the program i order for it to work correctly. Similarly, a Cofirm statemet is used to record what should be true

More information

Copyright 2016 Ramez Elmasri and Shamkant B. Navathe

Copyright 2016 Ramez Elmasri and Shamkant B. Navathe Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe CHAPTER 26 Ehaced Data Models: Itroductio to Active, Temporal, Spatial, Multimedia, ad Deductive Databases Copyright 2016 Ramez Elmasri ad Shamkat B.

More information

Analysis Metrics. Intro to Algorithm Analysis. Slides. 12. Alg Analysis. 12. Alg Analysis

Analysis Metrics. Intro to Algorithm Analysis. Slides. 12. Alg Analysis. 12. Alg Analysis Itro to Algorithm Aalysis Aalysis Metrics Slides. Table of Cotets. Aalysis Metrics 3. Exact Aalysis Rules 4. Simple Summatio 5. Summatio Formulas 6. Order of Magitude 7. Big-O otatio 8. Big-O Theorems

More information

A New Morphological 3D Shape Decomposition: Grayscale Interframe Interpolation Method

A New Morphological 3D Shape Decomposition: Grayscale Interframe Interpolation Method A ew Morphological 3D Shape Decompositio: Grayscale Iterframe Iterpolatio Method D.. Vizireau Politehica Uiversity Bucharest, Romaia ae@comm.pub.ro R. M. Udrea Politehica Uiversity Bucharest, Romaia mihea@comm.pub.ro

More information

Running Time. Analysis of Algorithms. Experimental Studies. Limitations of Experiments

Running Time. Analysis of Algorithms. Experimental Studies. Limitations of Experiments Ruig Time Aalysis of Algorithms Iput Algorithm Output A algorithm is a step-by-step procedure for solvig a problem i a fiite amout of time. Most algorithms trasform iput objects ito output objects. The

More information

Shape Analysis via 3-Valued Logic

Shape Analysis via 3-Valued Logic Shape Aalysis via 3-Valued Logic Mooly Sagiv Tel Aviv Uiversity http://www.cs.tau.ac.il/~msagiv/toplas02.pdf www.cs.tau.ac.il/~tvla Pla Questios & Aswers The TVLA system Realistic applicatios Abstract

More information

Running Time ( 3.1) Analysis of Algorithms. Experimental Studies. Limitations of Experiments

Running Time ( 3.1) Analysis of Algorithms. Experimental Studies. Limitations of Experiments Ruig Time ( 3.1) Aalysis of Algorithms Iput Algorithm Output A algorithm is a step- by- step procedure for solvig a problem i a fiite amout of time. Most algorithms trasform iput objects ito output objects.

More information

Analysis of Algorithms

Analysis of Algorithms Aalysis of Algorithms Iput Algorithm Output A algorithm is a step-by-step procedure for solvig a problem i a fiite amout of time. Ruig Time Most algorithms trasform iput objects ito output objects. The

More information

Outline and Reading. Analysis of Algorithms. Running Time. Experimental Studies. Limitations of Experiments. Theoretical Analysis

Outline and Reading. Analysis of Algorithms. Running Time. Experimental Studies. Limitations of Experiments. Theoretical Analysis Outlie ad Readig Aalysis of Algorithms Iput Algorithm Output Ruig time ( 3.) Pseudo-code ( 3.2) Coutig primitive operatios ( 3.3-3.) Asymptotic otatio ( 3.6) Asymptotic aalysis ( 3.7) Case study Aalysis

More information

Chapter 4. Procedural Abstraction and Functions That Return a Value. Copyright 2015 Pearson Education, Ltd.. All rights reserved.

Chapter 4. Procedural Abstraction and Functions That Return a Value. Copyright 2015 Pearson Education, Ltd.. All rights reserved. Chapter 4 Procedural Abstractio ad Fuctios That Retur a Value Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Overview 4.1 Top-Dow Desig 4.2 Predefied Fuctios 4.3 Programmer-Defied Fuctios 4.4

More information

Lecture Notes 6 Introduction to algorithm analysis CSS 501 Data Structures and Object-Oriented Programming

Lecture Notes 6 Introduction to algorithm analysis CSS 501 Data Structures and Object-Oriented Programming Lecture Notes 6 Itroductio to algorithm aalysis CSS 501 Data Structures ad Object-Orieted Programmig Readig for this lecture: Carrao, Chapter 10 To be covered i this lecture: Itroductio to algorithm aalysis

More information

CSC 220: Computer Organization Unit 11 Basic Computer Organization and Design

CSC 220: Computer Organization Unit 11 Basic Computer Organization and Design College of Computer ad Iformatio Scieces Departmet of Computer Sciece CSC 220: Computer Orgaizatio Uit 11 Basic Computer Orgaizatio ad Desig 1 For the rest of the semester, we ll focus o computer architecture:

More information

BOOLEAN MATHEMATICS: GENERAL THEORY

BOOLEAN MATHEMATICS: GENERAL THEORY CHAPTER 3 BOOLEAN MATHEMATICS: GENERAL THEORY 3.1 ISOMORPHIC PROPERTIES The ame Boolea Arithmetic was chose because it was discovered that literal Boolea Algebra could have a isomorphic umerical aspect.

More information

CIS 121 Data Structures and Algorithms with Java Spring Stacks, Queues, and Heaps Monday, February 18 / Tuesday, February 19

CIS 121 Data Structures and Algorithms with Java Spring Stacks, Queues, and Heaps Monday, February 18 / Tuesday, February 19 CIS Data Structures ad Algorithms with Java Sprig 09 Stacks, Queues, ad Heaps Moday, February 8 / Tuesday, February 9 Stacks ad Queues Recall the stack ad queue ADTs (abstract data types from lecture.

More information

. Written in factored form it is easy to see that the roots are 2, 2, i,

. Written in factored form it is easy to see that the roots are 2, 2, i, CMPS A Itroductio to Programmig Programmig Assigmet 4 I this assigmet you will write a java program that determies the real roots of a polyomial that lie withi a specified rage. Recall that the roots (or

More information

Data Structures and Algorithms. Analysis of Algorithms

Data Structures and Algorithms. Analysis of Algorithms Data Structures ad Algorithms Aalysis of Algorithms Outlie Ruig time Pseudo-code Big-oh otatio Big-theta otatio Big-omega otatio Asymptotic algorithm aalysis Aalysis of Algorithms Iput Algorithm Output

More information

Basic allocator mechanisms The course that gives CMU its Zip! Memory Management II: Dynamic Storage Allocation Mar 6, 2000.

Basic allocator mechanisms The course that gives CMU its Zip! Memory Management II: Dynamic Storage Allocation Mar 6, 2000. 5-23 The course that gives CM its Zip Memory Maagemet II: Dyamic Storage Allocatio Mar 6, 2000 Topics Segregated lists Buddy system Garbage collectio Mark ad Sweep Copyig eferece coutig Basic allocator

More information

Copyright 2016 Ramez Elmasri and Shamkant B. Navathe

Copyright 2016 Ramez Elmasri and Shamkant B. Navathe Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe CHAPTER 19 Query Optimizatio Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe Itroductio Query optimizatio Coducted by a query optimizer i a DBMS Goal:

More information

1.2 Binomial Coefficients and Subsets

1.2 Binomial Coefficients and Subsets 1.2. BINOMIAL COEFFICIENTS AND SUBSETS 13 1.2 Biomial Coefficiets ad Subsets 1.2-1 The loop below is part of a program to determie the umber of triagles formed by poits i the plae. for i =1 to for j =

More information

Chapter 9. Pointers and Dynamic Arrays. Copyright 2015 Pearson Education, Ltd.. All rights reserved.

Chapter 9. Pointers and Dynamic Arrays. Copyright 2015 Pearson Education, Ltd.. All rights reserved. Chapter 9 Poiters ad Dyamic Arrays Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Overview 9.1 Poiters 9.2 Dyamic Arrays Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 9-3

More information

Heaps. Presentation for use with the textbook Algorithm Design and Applications, by M. T. Goodrich and R. Tamassia, Wiley, 2015

Heaps. Presentation for use with the textbook Algorithm Design and Applications, by M. T. Goodrich and R. Tamassia, Wiley, 2015 Presetatio for use with the textbook Algorithm Desig ad Applicatios, by M. T. Goodrich ad R. Tamassia, Wiley, 201 Heaps 201 Goodrich ad Tamassia xkcd. http://xkcd.com/83/. Tree. Used with permissio uder

More information

Chapter 10. Defining Classes. Copyright 2015 Pearson Education, Ltd.. All rights reserved.

Chapter 10. Defining Classes. Copyright 2015 Pearson Education, Ltd.. All rights reserved. Chapter 10 Defiig Classes Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Overview 10.1 Structures 10.2 Classes 10.3 Abstract Data Types 10.4 Itroductio to Iheritace Copyright 2015 Pearso Educatio,

More information

Symbolic Execution with Abstraction

Symbolic Execution with Abstraction Software Tools for Techology Trasfer mauscript No. (will be iserted by the editor) Symbolic Executio with Abstractio Saswat Aad 1, Coria S. Păsăreau 2, Willem Visser 3 1 College of Computig, Georgia Istitute

More information

Lecture 5. Counting Sort / Radix Sort

Lecture 5. Counting Sort / Radix Sort Lecture 5. Coutig Sort / Radix Sort T. H. Corme, C. E. Leiserso ad R. L. Rivest Itroductio to Algorithms, 3rd Editio, MIT Press, 2009 Sugkyukwa Uiversity Hyuseug Choo choo@skku.edu Copyright 2000-2018

More information

Big-O Analysis. Asymptotics

Big-O Analysis. Asymptotics Big-O Aalysis 1 Defiitio: Suppose that f() ad g() are oegative fuctios of. The we say that f() is O(g()) provided that there are costats C > 0 ad N > 0 such that for all > N, f() Cg(). Big-O expresses

More information

The Magma Database file formats

The Magma Database file formats The Magma Database file formats Adrew Gaylard, Bret Pikey, ad Mart-Mari Breedt Johaesburg, South Africa 15th May 2006 1 Summary Magma is a ope-source object database created by Chris Muller, of Kasas City,

More information

APPLICATION NOTE PACE1750AE BUILT-IN FUNCTIONS

APPLICATION NOTE PACE1750AE BUILT-IN FUNCTIONS APPLICATION NOTE PACE175AE BUILT-IN UNCTIONS About This Note This applicatio brief is iteded to explai ad demostrate the use of the special fuctios that are built ito the PACE175AE processor. These powerful

More information

Copyright 2016 Ramez Elmasri and Shamkant B. Navathe

Copyright 2016 Ramez Elmasri and Shamkant B. Navathe Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe CHAPTER 18 Strategies for Query Processig Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe Itroductio DBMS techiques to process a query Scaer idetifies

More information

Lecture 1: Introduction and Strassen s Algorithm

Lecture 1: Introduction and Strassen s Algorithm 5-750: Graduate Algorithms Jauary 7, 08 Lecture : Itroductio ad Strasse s Algorithm Lecturer: Gary Miller Scribe: Robert Parker Itroductio Machie models I this class, we will primarily use the Radom Access

More information

Chapter 5. Functions for All Subtasks. Copyright 2015 Pearson Education, Ltd.. All rights reserved.

Chapter 5. Functions for All Subtasks. Copyright 2015 Pearson Education, Ltd.. All rights reserved. Chapter 5 Fuctios for All Subtasks Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Overview 5.1 void Fuctios 5.2 Call-By-Referece Parameters 5.3 Usig Procedural Abstractio 5.4 Testig ad Debuggig

More information

Task scenarios Outline. Scenarios in Knowledge Extraction. Proposed Framework for Scenario to Design Diagram Transformation

Task scenarios Outline. Scenarios in Knowledge Extraction. Proposed Framework for Scenario to Design Diagram Transformation 6-0-0 Kowledge Trasformatio from Task Scearios to View-based Desig Diagrams Nima Dezhkam Kamra Sartipi {dezhka, sartipi}@mcmaster.ca Departmet of Computig ad Software McMaster Uiversity CANADA SEKE 08

More information

Hash Tables. Presentation for use with the textbook Algorithm Design and Applications, by M. T. Goodrich and R. Tamassia, Wiley, 2015.

Hash Tables. Presentation for use with the textbook Algorithm Design and Applications, by M. T. Goodrich and R. Tamassia, Wiley, 2015. Presetatio for use with the textbook Algorithm Desig ad Applicatios, by M. T. Goodrich ad R. Tamassia, Wiley, 2015 Hash Tables xkcd. http://xkcd.com/221/. Radom Number. Used with permissio uder Creative

More information

Computers and Scientific Thinking

Computers and Scientific Thinking Computers ad Scietific Thikig David Reed, Creighto Uiversity Chapter 15 JavaScript Strigs 1 Strigs as Objects so far, your iteractive Web pages have maipulated strigs i simple ways use text box to iput

More information

Chapter 8. Strings and Vectors. Copyright 2014 Pearson Addison-Wesley. All rights reserved.

Chapter 8. Strings and Vectors. Copyright 2014 Pearson Addison-Wesley. All rights reserved. Chapter 8 Strigs ad Vectors Overview 8.1 A Array Type for Strigs 8.2 The Stadard strig Class 8.3 Vectors Slide 8-3 8.1 A Array Type for Strigs A Array Type for Strigs C-strigs ca be used to represet strigs

More information

9.1. Sequences and Series. Sequences. What you should learn. Why you should learn it. Definition of Sequence

9.1. Sequences and Series. Sequences. What you should learn. Why you should learn it. Definition of Sequence _9.qxd // : AM Page Chapter 9 Sequeces, Series, ad Probability 9. Sequeces ad Series What you should lear Use sequece otatio to write the terms of sequeces. Use factorial otatio. Use summatio otatio to

More information

CS 11 C track: lecture 1

CS 11 C track: lecture 1 CS 11 C track: lecture 1 Prelimiaries Need a CMS cluster accout http://acctreq.cms.caltech.edu/cgi-bi/request.cgi Need to kow UNIX IMSS tutorial liked from track home page Track home page: http://courses.cms.caltech.edu/courses/cs11/material

More information

CIS 121 Data Structures and Algorithms with Java Fall Big-Oh Notation Tuesday, September 5 (Make-up Friday, September 8)

CIS 121 Data Structures and Algorithms with Java Fall Big-Oh Notation Tuesday, September 5 (Make-up Friday, September 8) CIS 11 Data Structures ad Algorithms with Java Fall 017 Big-Oh Notatio Tuesday, September 5 (Make-up Friday, September 8) Learig Goals Review Big-Oh ad lear big/small omega/theta otatios Practice solvig

More information

arxiv: v2 [cs.ds] 24 Mar 2018

arxiv: v2 [cs.ds] 24 Mar 2018 Similar Elemets ad Metric Labelig o Complete Graphs arxiv:1803.08037v [cs.ds] 4 Mar 018 Pedro F. Felzeszwalb Brow Uiversity Providece, RI, USA pff@brow.edu March 8, 018 We cosider a problem that ivolves

More information

CS : Programming for Non-Majors, Summer 2007 Programming Project #3: Two Little Calculations Due by 12:00pm (noon) Wednesday June

CS : Programming for Non-Majors, Summer 2007 Programming Project #3: Two Little Calculations Due by 12:00pm (noon) Wednesday June CS 1313 010: Programmig for No-Majors, Summer 2007 Programmig Project #3: Two Little Calculatios Due by 12:00pm (oo) Wedesday Jue 27 2007 This third assigmet will give you experiece writig programs that

More information

GE FUNDAMENTALS OF COMPUTING AND PROGRAMMING UNIT III

GE FUNDAMENTALS OF COMPUTING AND PROGRAMMING UNIT III GE2112 - FUNDAMENTALS OF COMPUTING AND PROGRAMMING UNIT III PROBLEM SOLVING AND OFFICE APPLICATION SOFTWARE Plaig the Computer Program Purpose Algorithm Flow Charts Pseudocode -Applicatio Software Packages-

More information

Homework 1 Solutions MA 522 Fall 2017

Homework 1 Solutions MA 522 Fall 2017 Homework 1 Solutios MA 5 Fall 017 1. Cosider the searchig problem: Iput A sequece of umbers A = [a 1,..., a ] ad a value v. Output A idex i such that v = A[i] or the special value NIL if v does ot appear

More information

Appendix D. Controller Implementation

Appendix D. Controller Implementation COMPUTER ORGANIZATION AND DESIGN The Hardware/Software Iterface 5 th Editio Appedix D Cotroller Implemetatio Cotroller Implemetatios Combiatioal logic (sigle-cycle); Fiite state machie (multi-cycle, pipelied);

More information

Ones Assignment Method for Solving Traveling Salesman Problem

Ones Assignment Method for Solving Traveling Salesman Problem Joural of mathematics ad computer sciece 0 (0), 58-65 Oes Assigmet Method for Solvig Travelig Salesma Problem Hadi Basirzadeh Departmet of Mathematics, Shahid Chamra Uiversity, Ahvaz, Ira Article history:

More information

Solution printed. Do not start the test until instructed to do so! CS 2604 Data Structures Midterm Spring, Instructions:

Solution printed. Do not start the test until instructed to do so! CS 2604 Data Structures Midterm Spring, Instructions: CS 604 Data Structures Midterm Sprig, 00 VIRG INIA POLYTECHNIC INSTITUTE AND STATE U T PROSI M UNI VERSI TY Istructios: Prit your ame i the space provided below. This examiatio is closed book ad closed

More information

The isoperimetric problem on the hypercube

The isoperimetric problem on the hypercube The isoperimetric problem o the hypercube Prepared by: Steve Butler November 2, 2005 1 The isoperimetric problem We will cosider the -dimesioal hypercube Q Recall that the hypercube Q is a graph whose

More information

1 Graph Sparsfication

1 Graph Sparsfication CME 305: Discrete Mathematics ad Algorithms 1 Graph Sparsficatio I this sectio we discuss the approximatio of a graph G(V, E) by a sparse graph H(V, F ) o the same vertex set. I particular, we cosider

More information

Graphs. Minimum Spanning Trees. Slides by Rose Hoberman (CMU)

Graphs. Minimum Spanning Trees. Slides by Rose Hoberman (CMU) Graphs Miimum Spaig Trees Slides by Rose Hoberma (CMU) Problem: Layig Telephoe Wire Cetral office 2 Wirig: Naïve Approach Cetral office Expesive! 3 Wirig: Better Approach Cetral office Miimize the total

More information

Bayesian approach to reliability modelling for a probability of failure on demand parameter

Bayesian approach to reliability modelling for a probability of failure on demand parameter Bayesia approach to reliability modellig for a probability of failure o demad parameter BÖRCSÖK J., SCHAEFER S. Departmet of Computer Architecture ad System Programmig Uiversity Kassel, Wilhelmshöher Allee

More information

CSE 417: Algorithms and Computational Complexity

CSE 417: Algorithms and Computational Complexity Time CSE 47: Algorithms ad Computatioal Readig assigmet Read Chapter of The ALGORITHM Desig Maual Aalysis & Sortig Autum 00 Paul Beame aalysis Problem size Worst-case complexity: max # steps algorithm

More information

Chapter 8. Strings and Vectors. Copyright 2015 Pearson Education, Ltd.. All rights reserved.

Chapter 8. Strings and Vectors. Copyright 2015 Pearson Education, Ltd.. All rights reserved. Chapter 8 Strigs ad Vectors Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Overview 8.1 A Array Type for Strigs 8.2 The Stadard strig Class 8.3 Vectors Copyright 2015 Pearso Educatio, Ltd..

More information

COSC 1P03. Ch 7 Recursion. Introduction to Data Structures 8.1

COSC 1P03. Ch 7 Recursion. Introduction to Data Structures 8.1 COSC 1P03 Ch 7 Recursio Itroductio to Data Structures 8.1 COSC 1P03 Recursio Recursio I Mathematics factorial Fiboacci umbers defie ifiite set with fiite defiitio I Computer Sciece sytax rules fiite defiitio,

More information

On (K t e)-saturated Graphs

On (K t e)-saturated Graphs Noame mauscript No. (will be iserted by the editor O (K t e-saturated Graphs Jessica Fuller Roald J. Gould the date of receipt ad acceptace should be iserted later Abstract Give a graph H, we say a graph

More information

Configurable Software Verification: Concretizing the Convergence of Model Checking and Program Analysis

Configurable Software Verification: Concretizing the Convergence of Model Checking and Program Analysis Cofigurable Software Verificatio: Cocretizig the Covergece of Model Checkig ad Program Aalysis Dirk Beyer 1, Thomas A. Heziger 2, ad Grégory Théoduloz 2 1 Simo Fraser Uiversity, B.C., Caada 2 EPFL, Switzerlad

More information

From last week. Lecture 5. Outline. Principles of programming languages

From last week. Lecture 5. Outline. Principles of programming languages Priciples of programmig laguages From last week Lecture 5 http://few.vu.l/~silvis/ppl/2007 Natalia Silvis-Cividjia e-mail: silvis@few.vu.l ML has o assigmet. Explai how to access a old bidig? Is & for

More information

CHAPTER IV: GRAPH THEORY. Section 1: Introduction to Graphs

CHAPTER IV: GRAPH THEORY. Section 1: Introduction to Graphs CHAPTER IV: GRAPH THEORY Sectio : Itroductio to Graphs Sice this class is called Number-Theoretic ad Discrete Structures, it would be a crime to oly focus o umber theory regardless how woderful those topics

More information

Data Structures and Algorithms Part 1.4

Data Structures and Algorithms Part 1.4 1 Data Structures ad Algorithms Part 1.4 Werer Nutt 2 DSA, Part 1: Itroductio, syllabus, orgaisatio Algorithms Recursio (priciple, trace, factorial, Fiboacci) Sortig (bubble, isertio, selectio) 3 Sortig

More information

What are we going to learn? CSC Data Structures Analysis of Algorithms. Overview. Algorithm, and Inputs

What are we going to learn? CSC Data Structures Analysis of Algorithms. Overview. Algorithm, and Inputs What are we goig to lear? CSC316-003 Data Structures Aalysis of Algorithms Computer Sciece North Carolia State Uiversity Need to say that some algorithms are better tha others Criteria for evaluatio Structure

More information

Big-O Analysis. Asymptotics

Big-O Analysis. Asymptotics Big-O Aalysis 1 Defiitio: Suppose that f() ad g() are oegative fuctios of. The we say that f() is O(g()) provided that there are costats C > 0 ad N > 0 such that for all > N, f() Cg(). Big-O expresses

More information

Computer Science Foundation Exam. August 12, Computer Science. Section 1A. No Calculators! KEY. Solutions and Grading Criteria.

Computer Science Foundation Exam. August 12, Computer Science. Section 1A. No Calculators! KEY. Solutions and Grading Criteria. Computer Sciece Foudatio Exam August, 005 Computer Sciece Sectio A No Calculators! Name: SSN: KEY Solutios ad Gradig Criteria Score: 50 I this sectio of the exam, there are four (4) problems. You must

More information

Exact Minimum Lower Bound Algorithm for Traveling Salesman Problem

Exact Minimum Lower Bound Algorithm for Traveling Salesman Problem Exact Miimum Lower Boud Algorithm for Travelig Salesma Problem Mohamed Eleiche GeoTiba Systems mohamed.eleiche@gmail.com Abstract The miimum-travel-cost algorithm is a dyamic programmig algorithm to compute

More information

Major CSL Write your name and entry no on every sheet of the answer script. Time 2 Hrs Max Marks 70

Major CSL Write your name and entry no on every sheet of the answer script. Time 2 Hrs Max Marks 70 NOTE:. Attempt all seve questios. Major CSL 02 2. Write your ame ad etry o o every sheet of the aswer script. Time 2 Hrs Max Marks 70 Q No Q Q 2 Q 3 Q 4 Q 5 Q 6 Q 7 Total MM 6 2 4 0 8 4 6 70 Q. Write a

More information

CIS 121 Data Structures and Algorithms with Java Spring Stacks and Queues Monday, February 12 / Tuesday, February 13

CIS 121 Data Structures and Algorithms with Java Spring Stacks and Queues Monday, February 12 / Tuesday, February 13 CIS Data Structures ad Algorithms with Java Sprig 08 Stacks ad Queues Moday, February / Tuesday, February Learig Goals Durig this lab, you will: Review stacks ad queues. Lear amortized ruig time aalysis

More information

Data diverse software fault tolerance techniques

Data diverse software fault tolerance techniques Data diverse software fault tolerace techiques Complemets desig diversity by compesatig for desig diversity s s limitatios Ivolves obtaiig a related set of poits i the program data space, executig the

More information

Sorting in Linear Time. Data Structures and Algorithms Andrei Bulatov

Sorting in Linear Time. Data Structures and Algorithms Andrei Bulatov Sortig i Liear Time Data Structures ad Algorithms Adrei Bulatov Algorithms Sortig i Liear Time 7-2 Compariso Sorts The oly test that all the algorithms we have cosidered so far is compariso The oly iformatio

More information

Analysis of Algorithms

Analysis of Algorithms Presetatio for use with the textbook, Algorithm Desig ad Applicatios, by M. T. Goodrich ad R. Tamassia, Wiley, 2015 Aalysis of Algorithms Iput 2015 Goodrich ad Tamassia Algorithm Aalysis of Algorithms

More information

Behavioral Modeling in Verilog

Behavioral Modeling in Verilog Behavioral Modelig i Verilog COE 202 Digital Logic Desig Dr. Muhamed Mudawar Kig Fahd Uiversity of Petroleum ad Mierals Presetatio Outlie Itroductio to Dataflow ad Behavioral Modelig Verilog Operators

More information

Copyright 2016 Ramez Elmasri and Shamkant B. Navathe

Copyright 2016 Ramez Elmasri and Shamkant B. Navathe Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe CHAPTER 22 Database Recovery Techiques Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe Itroductio Recovery algorithms Recovery cocepts Write-ahead

More information

Evaluation scheme for Tracking in AMI

Evaluation scheme for Tracking in AMI A M I C o m m u i c a t i o A U G M E N T E D M U L T I - P A R T Y I N T E R A C T I O N http://www.amiproject.org/ Evaluatio scheme for Trackig i AMI S. Schreiber a D. Gatica-Perez b AMI WP4 Trackig:

More information

Code Review Defects. Authors: Mika V. Mäntylä and Casper Lassenius Original version: 4 Sep, 2007 Made available online: 24 April, 2013

Code Review Defects. Authors: Mika V. Mäntylä and Casper Lassenius Original version: 4 Sep, 2007 Made available online: 24 April, 2013 Code Review s Authors: Mika V. Mätylä ad Casper Lasseius Origial versio: 4 Sep, 2007 Made available olie: 24 April, 2013 This documet cotais further details of the code review defects preseted i [1]. of

More information

Counting the Number of Minimum Roman Dominating Functions of a Graph

Counting the Number of Minimum Roman Dominating Functions of a Graph Coutig the Number of Miimum Roma Domiatig Fuctios of a Graph SHI ZHENG ad KOH KHEE MENG, Natioal Uiversity of Sigapore We provide two algorithms coutig the umber of miimum Roma domiatig fuctios of a graph

More information

Τεχνολογία Λογισμικού

Τεχνολογία Λογισμικού ΕΘΝΙΚΟ ΜΕΤΣΟΒΙΟ ΠΟΛΥΤΕΧΝΕΙΟ Σχολή Ηλεκτρολόγων Μηχανικών και Μηχανικών Υπολογιστών Τεχνολογία Λογισμικού, 7ο/9ο εξάμηνο 2018-2019 Τεχνολογία Λογισμικού Ν.Παπασπύρου, Αν.Καθ. ΣΗΜΜΥ, ickie@softlab.tua,gr

More information

COMPUTER ORGANIZATION AND DESIGN The Hardware/Software Interface. Chapter 4. The Processor. Part A Datapath Design

COMPUTER ORGANIZATION AND DESIGN The Hardware/Software Interface. Chapter 4. The Processor. Part A Datapath Design COMPUTER ORGANIZATION AND DESIGN The Hardware/Software Iterface 5 th Editio Chapter The Processor Part A path Desig Itroductio CPU performace factors Istructio cout Determied by ISA ad compiler. CPI ad

More information

An Improved Shuffled Frog-Leaping Algorithm for Knapsack Problem

An Improved Shuffled Frog-Leaping Algorithm for Knapsack Problem A Improved Shuffled Frog-Leapig Algorithm for Kapsack Problem Zhoufag Li, Ya Zhou, ad Peg Cheg School of Iformatio Sciece ad Egieerig Hea Uiversity of Techology ZhegZhou, Chia lzhf1978@126.com Abstract.

More information

A Generalized Set Theoretic Approach for Time and Space Complexity Analysis of Algorithms and Functions

A Generalized Set Theoretic Approach for Time and Space Complexity Analysis of Algorithms and Functions Proceedigs of the 10th WSEAS Iteratioal Coferece o APPLIED MATHEMATICS, Dallas, Texas, USA, November 1-3, 2006 316 A Geeralized Set Theoretic Approach for Time ad Space Complexity Aalysis of Algorithms

More information

n The C++ template facility provides the ability to define n A generic facility allows code to be written once then

n The C++ template facility provides the ability to define n A generic facility allows code to be written once then UCLA PIC 10 B Problem Solvig usig C++ Programmig Ivo Diov, Asst. Prof. i Mathematics, Neurology, Statistics Istructor: Teachig Assistat: Suzae Nezzar, Mathematics Chapter 13 Templates for More Abstractio

More information

Bezier curves. Figure 2 shows cubic Bezier curves for various control points. In a Bezier curve, only

Bezier curves. Figure 2 shows cubic Bezier curves for various control points. In a Bezier curve, only Edited: Yeh-Liag Hsu (998--; recommeded: Yeh-Liag Hsu (--9; last updated: Yeh-Liag Hsu (9--7. Note: This is the course material for ME55 Geometric modelig ad computer graphics, Yua Ze Uiversity. art of

More information

Minimum Spanning Trees

Minimum Spanning Trees Miimum Spaig Trees Miimum Spaig Trees Spaig subgraph Subgraph of a graph G cotaiig all the vertices of G Spaig tree Spaig subgraph that is itself a (free) tree Miimum spaig tree (MST) Spaig tree of a weighted

More information

Establishing Local Temporal Heap Safety Properties with Applications to Compile-Time Memory Management

Establishing Local Temporal Heap Safety Properties with Applications to Compile-Time Memory Management Establishig Local Temporal Heap Safety Properties with Applicatios to Compile-Time Memory Maagemet Ra Shaham 1,2, Era Yahav 1, Elliot K. Koloder 2, ad Mooly Sagiv 1 1 School of Computer Sciece, Tel-Aviv

More information

top() Applications of Stacks

top() Applications of Stacks CS22 Algorithms ad Data Structures MW :00 am - 2: pm, MSEC 0 Istructor: Xiao Qi Lecture 6: Stacks ad Queues Aoucemets Quiz results Homework 2 is available Due o September 29 th, 2004 www.cs.mt.edu~xqicoursescs22

More information

Neural Networks A Model of Boolean Functions

Neural Networks A Model of Boolean Functions Neural Networks A Model of Boolea Fuctios Berd Steibach, Roma Kohut Freiberg Uiversity of Miig ad Techology Istitute of Computer Sciece D-09596 Freiberg, Germay e-mails: steib@iformatik.tu-freiberg.de

More information

Pattern Recognition Systems Lab 1 Least Mean Squares

Pattern Recognition Systems Lab 1 Least Mean Squares Patter Recogitio Systems Lab 1 Least Mea Squares 1. Objectives This laboratory work itroduces the OpeCV-based framework used throughout the course. I this assigmet a lie is fitted to a set of poits usig

More information

Data Structures Week #9. Sorting

Data Structures Week #9. Sorting Data Structures Week #9 Sortig Outlie Motivatio Types of Sortig Elemetary (O( 2 )) Sortig Techiques Other (O(*log())) Sortig Techiques 21.Aralık.2010 Boraha Tümer, Ph.D. 2 Sortig 21.Aralık.2010 Boraha

More information

Goals of the Lecture UML Implementation Diagrams

Goals of the Lecture UML Implementation Diagrams Goals of the Lecture UML Implemetatio Diagrams Object-Orieted Aalysis ad Desig - Fall 1998 Preset UML Diagrams useful for implemetatio Provide examples Next Lecture Ð A variety of topics o mappig from

More information

A Study on the Performance of Cholesky-Factorization using MPI

A Study on the Performance of Cholesky-Factorization using MPI A Study o the Performace of Cholesky-Factorizatio usig MPI Ha S. Kim Scott B. Bade Departmet of Computer Sciece ad Egieerig Uiversity of Califoria Sa Diego {hskim, bade}@cs.ucsd.edu Abstract Cholesky-factorizatio

More information

Structuring Redundancy for Fault Tolerance. CSE 598D: Fault Tolerant Software

Structuring Redundancy for Fault Tolerance. CSE 598D: Fault Tolerant Software Structurig Redudacy for Fault Tolerace CSE 598D: Fault Tolerat Software What do we wat to achieve? Versios Damage Assessmet Versio 1 Error Detectio Iputs Versio 2 Voter Outputs State Restoratio Cotiued

More information

Massachusetts Institute of Technology Lecture : Theory of Parallel Systems Feb. 25, Lecture 6: List contraction, tree contraction, and

Massachusetts Institute of Technology Lecture : Theory of Parallel Systems Feb. 25, Lecture 6: List contraction, tree contraction, and Massachusetts Istitute of Techology Lecture.89: Theory of Parallel Systems Feb. 5, 997 Professor Charles E. Leiserso Scribe: Guag-Ie Cheg Lecture : List cotractio, tree cotractio, ad symmetry breakig Work-eciet

More information