Liveness based Garbage Collection

Size: px
Start display at page:

Download "Liveness based Garbage Collection"

Transcription

1 CS738: Advanced Compiler Optimizations Liveness based Garbage Collection Amey Karkare Department of CSE, IIT Kanpur

2 Ideal Garbage Collection... garbage collection (GC) is a form of automatic memory management. The garbage collector, or just collector, attempts to reclaim garbage, or memory occupied by objects that are no longer in use by the program.... From Wikipedia

3 Real Garbage Collection... All garbage collectors use some efficient approximation to liveness. In tracing garbage collection, the approximation is that an object can t be live unless it is reachable.... From Memory Management Glossary

4 Liveness based GC During execution, there are significant amounts of heap allocated data that are reachable but not live.

5 Liveness based GC During execution, there are significant amounts of heap allocated data that are reachable but not live. Current GCs will retain such data.

6 Liveness based GC During execution, there are significant amounts of heap allocated data that are reachable but not live. Current GCs will retain such data. Our idea:

7 Liveness based GC During execution, there are significant amounts of heap allocated data that are reachable but not live. Current GCs will retain such data. Our idea: We do a liveness analysis of heap data and provide GC with its result.

8 Liveness based GC During execution, there are significant amounts of heap allocated data that are reachable but not live. Current GCs will retain such data. Our idea: We do a liveness analysis of heap data and provide GC with its result. Modify GC to mark data for retention only if it is live.

9 Liveness based GC During execution, there are significant amounts of heap allocated data that are reachable but not live. Current GCs will retain such data. Our idea: We do a liveness analysis of heap data and provide GC with its result. Modify GC to mark data for retention only if it is live. Consequences:

10 Liveness based GC During execution, there are significant amounts of heap allocated data that are reachable but not live. Current GCs will retain such data. Our idea: We do a liveness analysis of heap data and provide GC with its result. Modify GC to mark data for retention only if it is live. Consequences: Fewer cells marked.

11 Liveness based GC During execution, there are significant amounts of heap allocated data that are reachable but not live. Current GCs will retain such data. Our idea: We do a liveness analysis of heap data and provide GC with its result. Modify GC to mark data for retention only if it is live. Consequences: Fewer cells marked.

12 Liveness based GC During execution, there are significant amounts of heap allocated data that are reachable but not live. Current GCs will retain such data. Our idea: We do a liveness analysis of heap data and provide GC with its result. Modify GC to mark data for retention only if it is live. Consequences: Fewer cells marked. More garbage collected per collection.

13 Liveness based GC During execution, there are significant amounts of heap allocated data that are reachable but not live. Current GCs will retain such data. Our idea: We do a liveness analysis of heap data and provide GC with its result. Modify GC to mark data for retention only if it is live. Consequences: Fewer cells marked. More garbage collected per collection. Fewer garbage collections.

14 Liveness based GC During execution, there are significant amounts of heap allocated data that are reachable but not live. Current GCs will retain such data. Our idea: We do a liveness analysis of heap data and provide GC with its result. Modify GC to mark data for retention only if it is live. Consequences: Fewer cells marked. More garbage collected per collection. Fewer garbage collections. Programs expected to run faster and with smaller heap.

15 The language analyzed First order eager Scheme-like functional language. In Administrative Normal Form (ANF). p Prog ::= d 1...d n e main

16 The language analyzed First order eager Scheme-like functional language. p Prog ::= d 1...d n e main d Fdef ::= (define (f x 1... x n) e) In Administrative Normal Form (ANF).

17 The language analyzed First order eager Scheme-like functional language. In Administrative Normal Form (ANF). p Prog ::= d 1...d n e main d Fdef ::= (define (f x 1... x n) e) (if x e 1 e 2 ) e Expr ::= (let x a in e) (return x)

18 The language analyzed First order eager Scheme-like functional language. In Administrative Normal Form (ANF). p Prog ::= d 1...d n e main d Fdef ::= (define (f x 1... x n) e) (if x e 1 e 2 ) e Expr ::= (let x a in e) (return x) a App ::= k (cons x 1 x 2 ) (car x) (cdr x) (null? x) (+ x 1 x 2 ) (f x 1... x n)

19 An Example (define (appendl1l2) (if (null?l1)l2 (cons (carl1) (append (cdrl1)l2)))) (letz (cons (cons 4 (cons 5 nil)) (cons 6 nil)) in (lety (cons 3 nil) in (letw (appendyz) in π:(car (cdrw)))))

20 An Example (define (appendl1l2) (if (null?l1)l2 (cons (carl1) (append (cdrl1)l2)))) y 3 w z (letz (cons (cons 4 (cons 5 nil)) (cons 6 nil)) in (lety (cons 3 nil) in (letw (appendyz) in π:(car (cdrw))))) 4 6 5

21 An Example (define (appendl1l2) (if (null?l1)l2 (cons (carl1) (append (cdrl1)l2)))) y 3 w z (letz (cons (cons 4 (cons 5 nil)) (cons 6 nil)) in (lety (cons 3 nil) in (letw (appendyz) in π:(car (cdrw))))) Though all cells are reachable at π, a liveness-based GC will retain only the cells pointed by thick arrows.

22 Liveness Basic Concepts and Notations Access paths: Strings over {0, 1}. 0 access car field 1 access cdr field y z w

23 Liveness Basic Concepts and Notations Access paths: Strings over {0, 1}. 0 access car field 1 access cdr field Denote traversals over the heap graph y z w

24 Liveness Basic Concepts and Notations Access paths: Strings over {0, 1}. 0 access car field 1 access cdr field Denote traversals over the heap graph y z w Liveness environment: Maps root variables to set of access paths. y L i : z {ǫ} w {ǫ, 1, 10, 100} Notation: We write L i (x) as L x i

25 Liveness Basic Concepts and Notations Access paths: Strings over {0, 1}. 0 access car field 1 access cdr field Denote traversals over the heap graph y z w Liveness environment: Alternate representation. L i : {z.ǫ} {w.ǫ, w.1, w.10, w.100} Notation: We write L i (x) as L x i

26 Demand (car (cdrw)) y w z Demand (notation: σ) is a description of intended use of the result of an expression.

27 Demand Demand (notation: σ) is a description of intended use of the result of an expression.

28 Demand Demand (notation: σ) is a description of intended use of the result of an expression. We assume the demand on the main expression to be (0+1), which we call σ all.

29 Demand Demand (notation: σ) is a description of intended use of the result of an expression. We assume the demand on the main expression to be (0+1), which we call σ all. The demands on each function body, σ f, have to be computed.

30 Liveness analysis The big picture π main : (letz... in (lety... in π 9 : (letw (appendyz) in π 10 : (leta (cdrw) in π 11 : (letb (cara) in π 12 : (returnb))))))) (define (appendl1l2) π 1 : (lettest (null?l1) in π 2 : (iftest π 3 :(returnl2) π 4 : (lettl (cdrl1) in π 5 : (letrec (append tl l2) in π 6 : (lethd (carl1) in π 7 : (letans (cons hd rec) in π 8 : (returnans))))))))

31 Liveness analysis The big picture π main : (letz... in (lety... in π 9 : (letw (appendyz) in π 10 : (leta (cdrw) in π 11 : (letb (cara) in π 12 : (returnb))))))) (define (appendl1l2) π 1 : (lettest (null?l1) in π 2 : (iftest π 3 :(returnl2) π 4 : (lettl (cdrl1) in π 5 : (letrec (append tl l2) in π 6 : (lethd (carl1) in π 7 : (letans (cons hd rec) in π 8 : (returnans)))))))) Liveness environments: L 1 =... L 2 = L 9 =... L 10 =...

32 Liveness analysis The big picture π main : (letz... in (lety... in π 9 : (letw (appendyz) in π 10 : (leta (cdrw) in π 11 : (letb (cara) in π 12 : (returnb))))))) (define (appendl1l2) π 1 : (lettest (null?l1) in π 2 : (iftest π 3 :(returnl2) π 4 : (lettl (cdrl1) in π 5 : (letrec (append tl l2) in π 6 : (lethd (carl1) in π 7 : (letans (cons hd rec) in π 8 : (returnans)))))))) Liveness environments: Demand summaries: L 1 =... L 2 = L 9 =... L 10 =... σ main = σ all σ append =...

33 Liveness analysis The big picture π main : (letz... in (lety... in π 9 : (letw (appendyz) in π 10 : (leta (cdrw) in π 11 : (letb (cara) in π 12 : (returnb))))))) (define (appendl1l2) π 1 : (lettest (null?l1) in π 2 : (iftest π 3 :(returnl2) π 4 : (lettl (cdrl1) in π 5 : (letrec (append tl l2) in π 6 : (lethd (carl1) in π 7 : (letans (cons hd rec) in π 8 : (returnans)))))))) Liveness environments: Demand summaries: Function summaries: L 1 =... L 2 = L 9 =... L 10 =... σ main = σ all σ append =...

34 Liveness analysis GOAL: Compute Liveness Environment at various program points, statically.

35 Liveness analysis GOAL: Compute Liveness Environment at various program points, statically. Lapp(a,σ) Liveness environment generated by an application a, given a demand σ. Lexp(e,σ) Liveness environment before an expression e, given a demand σ.

36 Liveness analysis of Expressions Lexp((return x), σ) = {x.σ}

37 Liveness analysis of Expressions Lexp((return x), σ) = {x.σ} Lexp((if x e 1 e 2 ),σ) = {x.ǫ} Lexp(e 1,σ) Lexp(e 2,σ)

38 Liveness analysis of Expressions Lexp((return x), σ) = {x.σ} Lexp((if x e 1 e 2 ),σ) = {x.ǫ} Lexp(e 1,σ) Lexp(e 2,σ) Lexp((let x s in e),σ) = L\{x. } Lapp(s, L(x)) where L = Lexp(e,σ)

39 Liveness analysis of Expressions Lexp((return x), σ) = {x.σ} Lexp((if x e 1 e 2 ),σ) = {x.ǫ} Lexp(e 1,σ) Lexp(e 2,σ) Lexp((let x s in e),σ) = L\{x. } Lapp(s, L(x)) where L = Lexp(e,σ) Notice the similarity with: live in (B) = live out (B)\kill(B) gen(b) in classical dataflow analysis for imperative languages.

40 Liveness analysis of Primitive Applications x (car x) σ 0

41 Liveness analysis of Primitive Applications x (car x) σ 0 α

42 Liveness analysis of Primitive Applications x (car x) σ 0 Lapp((car x), σ) = {x.ǫ, x.0σ} α

43 Liveness analysis of Primitive Applications (cons x y) σ x y

44 Liveness analysis of Primitive Applications (cons x y) σ x 0 1 y α β

45 Liveness analysis of Primitive Applications (cons x y) σ Lapp((cons x y),σ) = {x.α 0α σ} x 0 1 y {y.β 1β σ} α β

46 Liveness analysis of Primitive Applications (cons x y) σ Lapp((cons x y),σ) = {x.α 0α σ} x 0 1 y {y.β 1β σ} α β 0 Removal of a leading 0 1 Removal of a leading 1 Lapp((cons x y), σ) = x.0σ y.1σ

47 Liveness Analysis of Function Applications (f x y) σ x y Lapp((f x y),σ) =

48 Liveness Analysis of Function Applications (f x y) σ x ψ x ψ y y Lapp((f x y),σ) = x.ψ x σ y.ψ y σ α β

49 Liveness Analysis of Function Applications (f x y) σ x LF 1 f(α) LF 2 f(β) y Lapp((f x y),σ) = x.lf 1 f(σ) y.lf 2 f(σ) We use LF f : context independent summary of f.

50 Liveness Analysis of Function Applications (f x y) σ x LF 1 f(α) LF 2 f(β) y Lapp((f x y),σ) = x.lf 1 f(σ) y.lf 2 f(σ) We use LF f : context independent summary of f. To find LF i f (...): Assume a symbolic demand σ sym. Let e f be the body of f. Set LF i f(σ sym ) to Lexp(e f,σ sym )(x i ).

51 Liveness Analysis of Function Applications (f x y) σ x LF 1 f(α) LF 2 f(β) y Lapp((f x y),σ) = x.lf 1 f(σ) y.lf 2 f(σ) We use LF f : context independent summary of f. To find LF i f (...): Assume a symbolic demand σ sym. Let e f be the body of f. Set LF i f(σ sym ) to Lexp(e f,σ sym )(x i ). How to handle recursive calls?

52 Liveness Analysis of Function Applications (f x y) σ x LF 1 f(α) LF 2 f(β) y Lapp((f x y),σ) = x.lf 1 f(σ) y.lf 2 f(σ) We use LF f : context independent summary of f. To find LF i f (...): Assume a symbolic demand σ sym. Let e f be the body of f. Set LF i f(σ sym ) to Lexp(e f,σ sym )(x i ). How to handle recursive calls? Use LF f with appropriate demand!!

53 Liveness analysis The big picture π main : (letz... in (lety... in π 9 : (letw (appendyz) in π 10 : (leta (cdrw) in π 11 : (letb (cara) in π 12 : (returnb))))))) (define (appendl1l2) π 1 : (lettest (null?l1) in π 2 : (iftest π 3 :(returnl2) π 4 : (lettl (cdrl1) in π 5 : (letrec (append tl l2) in π 6 : (lethd (carl1) in π 7 : (letans (cons hd rec) in π 8 : (returnans)))))))) Liveness environments: L l1 1 = {ǫ} 00σ append 1LF 1 append (1σ append) L l2 1 = σ LF 2 append (1σ append)... L y 9 = LF1 append ({ǫ, 1} 10σ all) Demand summaries: Function summaries: LF 1 append (σ) = {ǫ} 00σ 1LF 1 append (1σ) LF 2 append (σ) = σ LF2 append (1σ)

54 Liveness analysis The big picture π main : (letz... in (lety... in π 9 : (letw (appendyz) in π 10 : (leta (cdrw) in π 11 : (letb (cara) in π 12 : (returnb))))))) (define (appendl1l2) π 1 : (lettest (null?l1) in π 2 : (iftest π 3 :(returnl2) π 4 : (lettl (cdrl1) in π 5 : (letrec (append tl l2) in π 6 : (lethd (carl1) in π 7 : (letans (cons hd rec) in π 8 : (returnans)))))))) σ Liveness environments: L l1 1 = {ǫ} 00σ append 1LF 1 append (1σ append) L l2 1 = σ LF 2 append (1σ append)... L y 9 = LF1 append ({ǫ, 1} 10σ all) Demand summaries: Function summaries: LF 1 append (σ) = {ǫ} 00σ 1LF 1 append (1σ) LF 2 append (σ) = σ LF2 append (1σ)

55 Liveness analysis The big picture π main : (letz... in (lety... in π 9 : (letw (appendyz) in π 10 : (leta (cdrw) in π 11 : (letb (cara) in π 12 : (returnb))))))) (define (appendl1l2) π 1 : (lettest (null?l1) in π 2 : (iftest π 3 :(returnl2) π 4 : (lettl (cdrl1) inσ π 5 : (letrec (append tl l2) in π 6 : (lethd (carl1) in π 7 : (letans (cons hd rec) in π 8 : (returnans)))))))) σ Liveness environments: L l1 1 = {ǫ} 00σ append 1LF 1 append (1σ append) L l2 1 = σ LF 2 append (1σ append)... L y 9 = LF1 append ({ǫ, 1} 10σ all) Demand summaries: Function summaries: LF 1 append (σ) = {ǫ} 00σ 1LF 1 append (1σ) LF 2 append (σ) = σ LF2 append (1σ)

56 Liveness analysis The big picture π main : (letz... in (lety... in π 9 : (letw (appendyz) in π 10 : (leta (cdrw) in π 11 : (letb (cara) in π 12 : (returnb))))))) (define (appendl1l2) π 1 : (lettest (null?l1) in π 2 : (iftest π 3 :(returnl2) π 4 : (lettl (cdrl1) inσ π 5 : (letrec (append tl l2) in π 6 : (lethd (carl1) in π 7 : (letans (cons hd rec) in 1σ π 8 : (returnans)))))))) σ Liveness environments: L l1 1 = {ǫ} 00σ append 1LF 1 append (1σ append) L l2 1 = σ LF 2 append (1σ append)... L y 9 = LF1 append ({ǫ, 1} 10σ all) Demand summaries: Function summaries: LF 1 append (σ) = {ǫ} 00σ 1LF 1 append (1σ) LF 2 append (σ) = σ LF2 append (1σ)

57 Liveness analysis The big picture π main : (letz... in (lety... in π 9 : (letw (appendyz) in π 10 : (leta (cdrw) in π 11 : (letb (cara) in π 12 : (returnb))))))) (define (appendl1l2) π 1 : (lettest (null?l1) in π 2 : (iftest π 3 :(returnl2) π 4 : (lettl (cdrl1) inσ π 5 : (letrec (append tl l2) in π 6 : (lethd (carl1) in π 7 : (letans (cons hd rec) in 1σ π 8 : (returnans)))))))) σ LF 2 append(1σ) Liveness environments: L l1 1 = {ǫ} 00σ append 1LF 1 append (1σ append) L l2 1 = σ LF 2 append (1σ append)... L y 9 = LF1 append ({ǫ, 1} 10σ all) Demand summaries: Function summaries: LF 1 append (σ) = {ǫ} 00σ 1LF 1 append (1σ) LF 2 append (σ) = σ LF2 append (1σ)

58 Liveness analysis The big picture π main : (letz... in (lety... in π 9 : (letw (appendyz) in π 10 : (leta (cdrw) in π 11 : (letb (cara) in π 12 : (returnb))))))) (define (appendl1l2) π 1 : (lettest (null?l1) in π 2 : (iftest π 3 :(returnl2) π 4 : (lettl (cdrl1) inσ π 5 : (letrec (append tl l2) in π 6 : (lethd (carl1) in π 7 : (letans (cons hd rec) in 1σ π 8 : (returnans)))))))) σ LF 2 append(1σ) Liveness environments: L l1 1 = {ǫ} 00σ append 1LF 1 append (1σ append) L l2 1 = σ LF 2 append (1σ append)... L y 9 = LF1 append ({ǫ, 1} 10σ all) Demand summaries: Function summaries: LF 1 append (σ) = {ǫ} 00σ 1LF 1 append (1σ) LF 2 append (σ) = σ LF2 append (1σ)

59 Liveness analysis Demand Summary σ main = σ all π main : (letz... in (lety... in π 9 : (letw (appendyz) in π 10 : (leta (cdrw) in π 11 : (letb (cara) in π 12 : (returnb))))))) (define (appendl1l2) π 1 : (lettest (null?l1) in π 2 : (iftest π 3 :(returnl2) π 4 : (lettl (cdrl1) in π 5 : (letrec (append tl l2) in π 6 : (lethd (carl1) in π 7 : (letans (cons hd rec) in π 8 : (returnans)))))))) Liveness environments: L l1 1 = {ǫ} 00σ append 1LF 1 append (1σ append) L l2 1 = σ LF 2 append (1σ append)... L y 9 = LF1 append ({ǫ, 1} 10σ all) Demand summaries: Function summaries: LF 1 append (σ) = {ǫ} 00σ 1LF 1 append (1σ) LF 2 append (σ) = σ LF2 append (1σ)

60 Liveness analysis Demand Summary σ main = σ all π main : (letz... in (lety... in σ 1 π 9 : (letw (appendyz) in π 10 : (leta (cdrw) in π 11 : (letb (cara) in π 12 : (returnb))))))) (define (appendl1l2) π 1 : (lettest (null?l1) in π 2 : (iftest π 3 :(returnl2) π 4 : (lettl (cdrl1) in π 5 : (letrec (append tl l2) in π 6 : (lethd (carl1) in π 7 : (letans (cons hd rec) in π 8 : (returnans)))))))) Liveness environments: L l1 1 = {ǫ} 00σ append 1LF 1 append (1σ append) L l2 1 = σ LF 2 append (1σ append)... L y 9 = LF1 append ({ǫ, 1} 10σ all) Demand summaries: Function summaries: LF 1 append (σ) = {ǫ} 00σ 1LF 1 append (1σ) LF 2 append (σ) = σ LF2 append (1σ)

61 Liveness analysis Demand Summary σ main = σ all π main : (letz... in (lety... in σ 1 π 9 : (letw (appendyz) in π 10 : (leta (cdrw) in π 11 : (letb (cara) in π 12 : (returnb))))))) σ append = σ 1... (define (appendl1l2) π 1 : (lettest (null?l1) in π 2 : (iftest π 3 :(returnl2) π 4 : (lettl (cdrl1) in π 5 : (letrec (append tl l2) in π 6 : (lethd (carl1) in π 7 : (letans (cons hd rec) in π 8 : (returnans)))))))) Liveness environments: L l1 1 = {ǫ} 00σ append 1LF 1 append (1σ append) L l2 1 = σ LF 2 append (1σ append)... L y 9 = LF1 append ({ǫ, 1} 10σ all) Demand summaries: Function summaries: LF 1 append (σ) = {ǫ} 00σ 1LF 1 append (1σ) LF 2 append (σ) = σ LF2 append (1σ)

62 Liveness analysis Demand Summary σ main = σ all π main : (letz... in (lety... in σ 1 π 9 : (letw (appendyz) in π 10 : (leta (cdrw) in π 11 : (letb (cara) in π 12 : (returnb))))))) σ append = σ 1... (define (appendl1l2) π 1 : (lettest (null?l1) in π 2 : (iftest π 3 :(returnl2) π 4 : (lettl (cdrl1) in σ 2 π 5 : (letrec (append tl l2) in π 6 : (lethd (carl1) in π 7 : (letans (cons hd rec) in π 8 : (returnans)))))))) Liveness environments: L l1 1 = {ǫ} 00σ append 1LF 1 append (1σ append) L l2 1 = σ LF 2 append (1σ append)... L y 9 = LF1 append ({ǫ, 1} 10σ all) Demand summaries: Function summaries: LF 1 append (σ) = {ǫ} 00σ 1LF 1 append (1σ) LF 2 append (σ) = σ LF2 append (1σ)

63 Liveness analysis Demand Summary σ main = σ all π main : (letz... in (lety... in σ 1 π 9 : (letw (appendyz) in π 10 : (leta (cdrw) in π 11 : (letb (cara) in π 12 : (returnb))))))) σ append = σ 1 σ 2 (define (appendl1l2) π 1 : (lettest (null?l1) in π 2 : (iftest π 3 :(returnl2) π 4 : (lettl (cdrl1) in σ 2 π 5 : (letrec (append tl l2) in π 6 : (lethd (carl1) in π 7 : (letans (cons hd rec) in π 8 : (returnans)))))))) Liveness environments: L l1 1 = {ǫ} 00σ append 1LF 1 append (1σ append) L l2 1 = σ LF 2 append (1σ append)... L y 9 = LF1 append ({ǫ, 1} 10σ all) Demand summaries: Function summaries: LF 1 append (σ) = {ǫ} 00σ 1LF 1 append (1σ) LF 2 append (σ) = σ LF2 append (1σ)

64 Liveness analysis Demand Summary π main : (letz... in (lety... in π 9 : (letw (appendyz) in π 10 : (leta (cdrw) in π 11 : (letb (cara) in π 12 : (returnb))))))) (define (appendl1l2) π 1 : (lettest (null?l1) in π 2 : (iftest π 3 :(returnl2) π 4 : (lettl (cdrl1) in π 5 : (letrec (append tl l2) in π 6 : (lethd (carl1) in π 7 : (letans (cons hd rec) in π 8 : (returnans)))))))) Liveness environments: L l1 1 = {ǫ} 00σ append 1LF 1 append (1σ append) L l2 1 = σ LF 2 append (1σ append)... L y 9 = LF1 append ({ǫ, 1} 10σ all) Demand summaries: σ main = σ all σ append = {ǫ, 1} 10σ all 1σ append Function summaries: LF 1 append (σ) = {ǫ} 00σ 1LF 1 append (1σ) LF 2 append (σ) = σ LF2 append (1σ)

65 Obtaining a closed form solution for LF Function summaries will always have the form: LF i f (σ) = Ii f Di f σ

66 Obtaining a closed form solution for LF Function summaries will always have the form: LF i f (σ) = Ii f Di f σ Consider the equation for LF 1 append LF 1 append (σ) = {ǫ} 00σ 1LF1 append (1σ)

67 Obtaining a closed form solution for LF Function summaries will always have the form: LF i f (σ) = Ii f Di f σ Consider the equation for LF 1 append LF 1 append (σ) = {ǫ} 00σ 1LF1 append (1σ) Substitute the assumed form in the equation: I 1 append D1 append σ = {ǫ} 00σ 1(I1 append D1 append 1σ) Equating the terms without and with σ, we get: I 1 append = {ǫ} 1I1 append D 1 append = 00 1D1 append 1

68 Summary of Analysis Results Liveness at program points: Demand summaries: Function summaries: L l1 1 = {ǫ} 00σ 1(I 1 append D1 append 1σ append) L l2 1 = {ǫ} I 2 append D 2 append 1σ append L l1 5 = {ǫ} 00σ append L tl 5 = I 1 append D1 append 1σ append L l2 5 = I 2 append D2 append 1σ append... σ append = {ǫ, 1} 1σ append 10σ all I 1 append = {ǫ} 1I1 append D 1 append = 00 1D1 append 1 I 2 append = I2 append D 2 append = {ǫ} D2 append 0

69 Solution of the equations View the equations as grammar rules: L l1 1 ǫ 00σ 1(I 1 append D1 append 1σ append) I 1 append ǫ 1I 1 append D 1 append 00 1D 1 append 1 The solution of L l1 1 is the language L(L l1 1 ) generated by it.

70 Working of Liveness-based GC (Mark phase) GC invoked at a program point π GC traverses a path α starting from a root variable x. GC consults L x π: Does α L(L x π)? If yes, then mark the current cell

71 Working of Liveness-based GC (Mark phase) GC invoked at a program point π GC traverses a path α starting from a root variable x. GC consults L x π: Does α L(L x π)? If yes, then mark the current cell Note that α is a forward-only access path consisting only of edges 0 and 1, but not 0 or 1 But L(L x π) has access paths marked with 0/1 for 0/1 removal arising from the cons rule.

72 0/1 handling 0 removal from a set of access paths: α 1 00α 2 α 1 α 2 α 1 01α 2 drop α 1 01α 2 from the set 1 removal from a set of access paths: α 1 11α 2 α 1 α 2 α 1 10α 2 drop α 1 10α 2 from the set

73 GC decision problem Deciding the membership in a CFG augmented with a fixed set of unrestricted productions. 00 ǫ 11 ǫ The problem shown to be undecidable 1. Reduction from Halting problem. 1 Prasanna, Sanyal, and Karkare. Liveness-Based Garbage Collection for Lazy Languages, ISMM 2016.

74 Practical 0/1 simplification The simplification is possible to do on a finite state automaton. Over-approximate the CFG by an automaton (Mohri-Nederhoff transformation). Perform 0/1 removal on the automaton.

75 Example Grammar for L y 9 After Mohri-Nederhoff transformation L y 9 I 1 append D1 append (ǫ 1 10σ all) L y 9 I 1 append D1 append (ǫ 1 10σ all) I 1 append ǫ 1I 1 append I 1 append ǫ 1I 1 append D 1 append 00 1D 1 append 1 σ all ǫ 0σ all 1σ all D 1 append D 1 append σ all 00 D 1 append 1D1 append 1 D 1 append ǫ ǫ 0σ all 1σ all

76 Automaton for L y 9 1 L y 9 ǫ 1 1 0/1 ǫ 0 0 ǫ 1 0

77 Automaton for L y 9 1 L y 9 ǫ 1 1 0/1 ǫ 0 0 ǫ /1 L y 9 q 0 0 q 0 1 q 1 2 q 0 3 q 4

78 Automaton for L y 9 1 L y 9 ǫ 1 1 0/1 ǫ 0 0 ǫ /1 L y 9 q 0 0 q 0 1 q 1 2 q 0 3 q 4 ǫ

79 Automaton for L y 9 1 L y 9 ǫ 1 1 0/1 ǫ 0 0 ǫ /1 L y 9 q 0 0 q 0 1 q 1 2 q 0 3 q 4 ǫ 1 1/1 0/1 L y 9 q 0 0 q 0 1 q 0 5 q 2

80 Automaton for L y 9 1 L y 9 ǫ 1 1 0/1 ǫ 0 0 ǫ /1 L y 9 q 0 0 q 0 1 q 1 2 q 0 3 q 4 ǫ 1 1/1 0/1 L y 9 q 0 0 q 0 1 q 0 5 q 2 ǫ

81 Automaton for L y 9 1 L y 9 ǫ 1 1 0/1 ǫ 0 0 ǫ /1 L y 9 q 0 0 q 0 1 q 1 2 q 0 3 q 4 ǫ 1 1/1 0/1 L y 9 q 0 0 q 0 1 q 0 5 q 2 ǫ 1 0/1 1/1 L y 9 q 0 0 q 0 6 q 5 0

82 Automaton for L y 9 1 L y 9 ǫ 1 1 0/1 ǫ 0 0 ǫ /1 L y 9 q 0 0 q 0 1 q 1 2 q 0 3 q 4 ǫ 1 1/1 0/1 L y 9 q 0 0 q 0 1 q 0 5 q 2 ǫ 1 0/1 1/1 L y 9 q 0 0 q 0 6 q 5 0

83 Automaton for L y 9 1 L y 9 ǫ 1 1 0/1 ǫ 0 0 ǫ /1 L y 9 q 0 0 q 0 1 q 1 2 q 0 3 q 4 ǫ 1 1/1 0/1 L y 9 q 0 0 q 0 1 q 0 5 q 2 ǫ 1 0/1 1 L y 9 q 0 0 q 6 q 5 0

84 Automaton for L y 9 1 L y 9 ǫ 1 1 0/1 ǫ 0 0 ǫ /1 L y 9 q 0 0 q 0 1 q 1 2 q 0 3 q 4 ǫ 1 1/1 0/1 L y 9 q 0 0 q 0 1 q 0 5 q 2 ǫ 1 0/1 1 L y 9 q 0 0 q 6 q 5 1 0/1 L y 9 q 0 0 q 6 0

85 Experimental Setup Built a prototype consisting of: An ANF-scheme interpreter Liveness analyzer A single-generation copying collector. The collector optionally uses liveness Marks a link during GC only if it is live. Benchmark programs are mostly from the no-fib suite.

86 GC behavior as a graph Cells in active semi-space (LGC) 1.89e+06 Cells in active semi-space (RGC) 1.68e e e e No. of reachable cells No. of live cells e+06 6e+06 9e e e+07 nqueens

87 Results as Tables Analysis Performance: Program sudoku lcss gc_bench knightstour treejoin nqueens lambda Time (msec) DFA size Precision(%)

88 Results as Tables Garbage collection performance # Collected MinHeap GC time cells per GC #GCs (#cells) (sec) Program RGC LGC RGC LGC RGC LGC RGC LGC sudoku lcss gc_bench nperm fibheap knightstour treejoin nqueens lambda LGC collects more garbage than RGC.

89 Results as Tables Garbage collection performance # Collected MinHeap GC time cells per GC #GCs (#cells) (sec) Program RGC LGC RGC LGC RGC LGC RGC LGC sudoku lcss gc_bench nperm fibheap knightstour treejoin nqueens lambda # collections of LGC no higher than RGC. Often, smaller.

90 Results as Tables Garbage collection performance # Collected MinHeap GC time cells per GC #GCs (#cells) (sec) Program RGC LGC RGC LGC RGC LGC RGC LGC sudoku lcss gc_bench nperm fibheap knightstour treejoin nqueens lambda Programs require smaller heaps to execute with LGC.

91 Results as Tables Garbage collection performance # Collected MinHeap GC time cells per GC #GCs (#cells) (sec) Program RGC LGC RGC LGC RGC LGC RGC LGC sudoku lcss gc_bench nperm fibheap knightstour treejoin nqueens lambda GC time is smaller for LGC in some cases...

92 Results as Tables Garbage collection performance # Collected MinHeap GC time cells per GC #GCs (#cells) (sec) Program RGC LGC RGC LGC RGC LGC RGC LGC sudoku lcss gc_bench nperm fibheap knightstour treejoin nqueens lambda and larger in some.

93 Lazy evaluation An evaluation strategy in which evaluation of an expression is postponed until its value is needed

94 Lazy evaluation An evaluation strategy in which evaluation of an expression is postponed until its value is needed Binding of a variable to an expression does not force evaluation of the expression

95 Lazy evaluation An evaluation strategy in which evaluation of an expression is postponed until its value is needed Binding of a variable to an expression does not force evaluation of the expression Every expression is evaluated at most once

96 Laziness: Example (define (lengthl) (if (null?l) return 0 return (+ 1 (length (cdrl))))) (define (main) (leta ( a BIG closure ) in (letb (+a1) in (letc (consbnil) in (letw (lengthc) in (returnw))))))

97 Handling lazy semantics: Challenges Laziness complicates liveness analysis itself.

98 Handling lazy semantics: Challenges Laziness complicates liveness analysis itself. Data is made live by evaluation of closures

99 Handling lazy semantics: Challenges Laziness complicates liveness analysis itself. Data is made live by evaluation of closures In lazy languages, the place in the program where this evaluation takes place cannot be statically determined

100 Handling lazy semantics: Challenges Laziness complicates liveness analysis itself. Data is made live by evaluation of closures In lazy languages, the place in the program where this evaluation takes place cannot be statically determined Liveness-based garbage collector significantly more complicated than that for an eager language.

101 Handling lazy semantics: Challenges Laziness complicates liveness analysis itself. Data is made live by evaluation of closures In lazy languages, the place in the program where this evaluation takes place cannot be statically determined Liveness-based garbage collector significantly more complicated than that for an eager language. Need to track liveness of closures

102 Handling lazy semantics: Challenges Laziness complicates liveness analysis itself. Data is made live by evaluation of closures In lazy languages, the place in the program where this evaluation takes place cannot be statically determined Liveness-based garbage collector significantly more complicated than that for an eager language. Need to track liveness of closures But a closure can escape the scope in which it was created

103 Handling lazy semantics: Challenges Laziness complicates liveness analysis itself. Data is made live by evaluation of closures In lazy languages, the place in the program where this evaluation takes place cannot be statically determined Liveness-based garbage collector significantly more complicated than that for an eager language. Need to track liveness of closures But a closure can escape the scope in which it was created Solution: carry the liveness information in the closure itself

104 Handling lazy semantics: Challenges Laziness complicates liveness analysis itself. Data is made live by evaluation of closures In lazy languages, the place in the program where this evaluation takes place cannot be statically determined Liveness-based garbage collector significantly more complicated than that for an eager language. Need to track liveness of closures But a closure can escape the scope in which it was created Solution: carry the liveness information in the closure itself For precision: need to update the liveness information as execution progresses

105 Handling possible non-evaluation Liveness no longer remains independent of demand σ

106 Handling possible non-evaluation Liveness no longer remains independent of demand σ If (carx) is not evaluated at all, it does not generate any liveness forx

107 Handling possible non-evaluation Liveness no longer remains independent of demand σ If (carx) is not evaluated at all, it does not generate any liveness forx Require a new terminal 2 with following semantics { if σ = 2σ {ǫ} otherwise Lapp((carx),σ) =x.{2, 0}σ

108 Scope for future work Reducing GC-time.

109 Scope for future work Reducing GC-time. Reducing re-visits to heap nodes.

110 Scope for future work Reducing GC-time. Reducing re-visits to heap nodes. Basing the implementation on full Scheme, not ANF-Scheme

111 Scope for future work Reducing GC-time. Reducing re-visits to heap nodes. Basing the implementation on full Scheme, not ANF-Scheme Increasing the scope of the method.

112 Scope for future work Reducing GC-time. Reducing re-visits to heap nodes. Basing the implementation on full Scheme, not ANF-Scheme Increasing the scope of the method. Lazy languages. (ISMM 2016)

113 Scope for future work Reducing GC-time. Reducing re-visits to heap nodes. Basing the implementation on full Scheme, not ANF-Scheme Increasing the scope of the method. Lazy languages. (ISMM 2016) Higher order functions.

114 Scope for future work Reducing GC-time. Reducing re-visits to heap nodes. Basing the implementation on full Scheme, not ANF-Scheme Increasing the scope of the method. Lazy languages. (ISMM 2016) Higher order functions. Specialize all higher order functions (Firstification)

115 Scope for future work Reducing GC-time. Reducing re-visits to heap nodes. Basing the implementation on full Scheme, not ANF-Scheme Increasing the scope of the method. Lazy languages. (ISMM 2016) Higher order functions. Specialize all higher order functions (Firstification) Analysis on the firstified program

116 Scope for future work Reducing GC-time. Reducing re-visits to heap nodes. Basing the implementation on full Scheme, not ANF-Scheme Increasing the scope of the method. Lazy languages. (ISMM 2016) Higher order functions. Specialize all higher order functions (Firstification) Analysis on the firstified program For partial applications, carry information about the base function

117 Scope for future work Reducing GC-time. Reducing re-visits to heap nodes. Basing the implementation on full Scheme, not ANF-Scheme Increasing the scope of the method. Lazy languages. (ISMM 2016) Higher order functions. Specialize all higher order functions (Firstification) Analysis on the firstified program For partial applications, carry information about the base function Using the notion of demand for other analysis.

118 Scope for future work Reducing GC-time. Reducing re-visits to heap nodes. Basing the implementation on full Scheme, not ANF-Scheme Increasing the scope of the method. Lazy languages. (ISMM 2016) Higher order functions. Specialize all higher order functions (Firstification) Analysis on the firstified program For partial applications, carry information about the base function Using the notion of demand for other analysis. Program Slicing (Under Review as of September 2016)

119 Scope for future work Reducing GC-time. Reducing re-visits to heap nodes. Basing the implementation on full Scheme, not ANF-Scheme Increasing the scope of the method. Lazy languages. (ISMM 2016) Higher order functions. Specialize all higher order functions (Firstification) Analysis on the firstified program For partial applications, carry information about the base function Using the notion of demand for other analysis. Program Slicing (Under Review as of September 2016) Strictness Analysis

120 Scope for future work Reducing GC-time. Reducing re-visits to heap nodes. Basing the implementation on full Scheme, not ANF-Scheme Increasing the scope of the method. Lazy languages. (ISMM 2016) Higher order functions. Specialize all higher order functions (Firstification) Analysis on the firstified program For partial applications, carry information about the base function Using the notion of demand for other analysis. Program Slicing (Under Review as of September 2016) Strictness Analysis All path problem, requires doing intersection of demands

121 Scope for future work Reducing GC-time. Reducing re-visits to heap nodes. Basing the implementation on full Scheme, not ANF-Scheme Increasing the scope of the method. Lazy languages. (ISMM 2016) Higher order functions. Specialize all higher order functions (Firstification) Analysis on the firstified program For partial applications, carry information about the base function Using the notion of demand for other analysis. Program Slicing (Under Review as of September 2016) Strictness Analysis All path problem, requires doing intersection of demands intersection of CFGs under-approximation

122 Conclusions Proposed a liveness-based GC scheme. Not covered in this talk: The soundness of liveness analysis. Details of undecidability proof. Details of handling lazy languages. A prototype implementation to demonstrate: the precision of the analysis. reduced heap requirement. reduced GC time for a majority of programs. Unfinished agenda: Improving GC time for a larger fraction of programs. Extending scope of the method.

Liveness based Garbage Collection

Liveness based Garbage Collection CS618: Program Analsis 2016-17 I st Semester Ideal Garbage Collection Liveness based Garbage Collection Ame Karkare karkare@cse.iitk.ac.in karkare@cse.iitb.ac.in Department of CSE, IIT Kanpur/Bomba...

More information

Decidability (intro.)

Decidability (intro.) CHAPTER 4 Decidability Contents Decidable Languages decidable problems concerning regular languages decidable problems concerning context-free languages The Halting Problem The diagonalization method The

More information

Great Theoretical Ideas in Computer Science. Lecture 4: Deterministic Finite Automaton (DFA), Part 2

Great Theoretical Ideas in Computer Science. Lecture 4: Deterministic Finite Automaton (DFA), Part 2 5-25 Great Theoretical Ideas in Computer Science Lecture 4: Deterministic Finite Automaton (DFA), Part 2 January 26th, 27 Formal definition: DFA A deterministic finite automaton (DFA) M =(Q,,,q,F) M is

More information

Computability Theory

Computability Theory CS:4330 Theory of Computation Spring 2018 Computability Theory Decidable Problems of CFLs and beyond Haniel Barbosa Readings for this lecture Chapter 4 of [Sipser 1996], 3rd edition. Section 4.1. Decidable

More information

Static Analysis of Programs: A Heap-Centric View

Static Analysis of Programs: A Heap-Centric View Static Analysis of Programs: A Heap-Centric View (www.cse.iitb.ac.in/ uday) Department of Computer Science and Engineering, Indian Institute of Technology, Bombay 5 April 2008 Part 1 Introduction ETAPS

More information

Theory Bridge Exam Example Questions

Theory Bridge Exam Example Questions Theory Bridge Exam Example Questions Annotated version with some (sometimes rather sketchy) answers and notes. This is a collection of sample theory bridge exam questions. This is just to get some idea

More information

Computational Models - Lecture 4

Computational Models - Lecture 4 Computational Models - Lecture 4 Regular languages: The Myhill-Nerode Theorem Context-free Grammars Chomsky Normal Form Pumping Lemma for context free languages Non context-free languages: Examples Push

More information

CS5371 Theory of Computation. Lecture 14: Computability V (Prove by Reduction)

CS5371 Theory of Computation. Lecture 14: Computability V (Prove by Reduction) CS5371 Theory of Computation Lecture 14: Computability V (Prove by Reduction) Objectives This lecture shows more undecidable languages Our proof is not based on diagonalization Instead, we reduce the problem

More information

Parsing Algorithms. CS 4447/CS Stephen Watt University of Western Ontario

Parsing Algorithms. CS 4447/CS Stephen Watt University of Western Ontario Parsing Algorithms CS 4447/CS 9545 -- Stephen Watt University of Western Ontario The Big Picture Develop parsers based on grammars Figure out properties of the grammars Make tables that drive parsing engines

More information

CS 301. Lecture 18 Decidable languages. Stephen Checkoway. April 2, 2018

CS 301. Lecture 18 Decidable languages. Stephen Checkoway. April 2, 2018 CS 301 Lecture 18 Decidable languages Stephen Checkoway April 2, 2018 1 / 26 Decidable language Recall, a language A is decidable if there is some TM M that 1 recognizes A (i.e., L(M) = A), and 2 halts

More information

Computability and Complexity

Computability and Complexity Computability and Complexity Decidability, Undecidability and Reducibility; Codes, Algorithms and Languages CAS 705 Ryszard Janicki Department of Computing and Software McMaster University Hamilton, Ontario,

More information

THEORY OF COMPUTATION (AUBER) EXAM CRIB SHEET

THEORY OF COMPUTATION (AUBER) EXAM CRIB SHEET THEORY OF COMPUTATION (AUBER) EXAM CRIB SHEET Regular Languages and FA A language is a set of strings over a finite alphabet Σ. All languages are finite or countably infinite. The set of all languages

More information

UNIT-VIII COMPUTABILITY THEORY

UNIT-VIII COMPUTABILITY THEORY CONTEXT SENSITIVE LANGUAGE UNIT-VIII COMPUTABILITY THEORY A Context Sensitive Grammar is a 4-tuple, G = (N, Σ P, S) where: N Set of non terminal symbols Σ Set of terminal symbols S Start symbol of the

More information

Theory of Computation (IX) Yijia Chen Fudan University

Theory of Computation (IX) Yijia Chen Fudan University Theory of Computation (IX) Yijia Chen Fudan University Review The Definition of Algorithm Polynomials and their roots A polynomial is a sum of terms, where each term is a product of certain variables and

More information

Abstracting Definitional Interpreters. David Van Horn

Abstracting Definitional Interpreters. David Van Horn Abstracting Definitional Interpreters David Van Horn Abstracting Definitional Interpreters David Van Horn Northeastern University Definitional interpreters written in monadic style can express a wide variety

More information

Opleiding Informatica

Opleiding Informatica Opleiding Informatica Tape-quantifying Turing machines in the arithmetical hierarchy Simon Heijungs Supervisors: H.J. Hoogeboom & R. van Vliet BACHELOR THESIS Leiden Institute of Advanced Computer Science

More information

CS5371 Theory of Computation. Lecture 12: Computability III (Decidable Languages relating to DFA, NFA, and CFG)

CS5371 Theory of Computation. Lecture 12: Computability III (Decidable Languages relating to DFA, NFA, and CFG) CS5371 Theory of Computation Lecture 12: Computability III (Decidable Languages relating to DFA, NFA, and CFG) Objectives Recall that decidable languages are languages that can be decided by TM (that means,

More information

Computability Theory

Computability Theory CS:4330 Theory of Computation Spring 2018 Computability Theory Decidable Languages Haniel Barbosa Readings for this lecture Chapter 4 of [Sipser 1996], 3rd edition. Section 4.1. Decidable Languages We

More information

Decidability (What, stuff is unsolvable?)

Decidability (What, stuff is unsolvable?) University of Georgia Fall 2014 Outline Decidability Decidable Problems for Regular Languages Decidable Problems for Context Free Languages The Halting Problem Countable and Uncountable Sets Diagonalization

More information

CSE 105 THEORY OF COMPUTATION

CSE 105 THEORY OF COMPUTATION CSE 105 THEORY OF COMPUTATION Spring 2017 http://cseweb.ucsd.edu/classes/sp17/cse105-ab/ Review of CFG, CFL, ambiguity What is the language generated by the CFG below: G 1 = ({S,T 1,T 2 }, {0,1,2}, { S

More information

Final exam study sheet for CS3719 Turing machines and decidability.

Final exam study sheet for CS3719 Turing machines and decidability. Final exam study sheet for CS3719 Turing machines and decidability. A Turing machine is a finite automaton with an infinite memory (tape). Formally, a Turing machine is a 6-tuple M = (Q, Σ, Γ, δ, q 0,

More information

Chapter 5. Finite Automata

Chapter 5. Finite Automata Chapter 5 Finite Automata 5.1 Finite State Automata Capable of recognizing numerous symbol patterns, the class of regular languages Suitable for pattern-recognition type applications, such as the lexical

More information

Deterministic Finite Automaton (DFA)

Deterministic Finite Automaton (DFA) 1 Lecture Overview Deterministic Finite Automata (DFA) o accepting a string o defining a language Nondeterministic Finite Automata (NFA) o converting to DFA (subset construction) o constructed from a regular

More information

SYLLABUS. Introduction to Finite Automata, Central Concepts of Automata Theory. CHAPTER - 3 : REGULAR EXPRESSIONS AND LANGUAGES

SYLLABUS. Introduction to Finite Automata, Central Concepts of Automata Theory. CHAPTER - 3 : REGULAR EXPRESSIONS AND LANGUAGES Contents i SYLLABUS UNIT - I CHAPTER - 1 : AUT UTOMA OMATA Introduction to Finite Automata, Central Concepts of Automata Theory. CHAPTER - 2 : FINITE AUT UTOMA OMATA An Informal Picture of Finite Automata,

More information

Theory of Computation p.1/?? Theory of Computation p.2/?? We develop examples of languages that are decidable

Theory of Computation p.1/?? Theory of Computation p.2/?? We develop examples of languages that are decidable Decidable Languages We use languages to represent various computational problems because we have a terminology for dealing with languages Definition: A language is decidable if there is an algorithm (i.e.

More information

FORMAL LANGUAGES, AUTOMATA AND COMPUTATION

FORMAL LANGUAGES, AUTOMATA AND COMPUTATION FORMAL LANGUAGES, AUTOMATA AND COMPUTATION DECIDABILITY ( LECTURE 15) SLIDES FOR 15-453 SPRING 2011 1 / 34 TURING MACHINES-SYNOPSIS The most general model of computation Computations of a TM are described

More information

Context-Free Languages (Pre Lecture)

Context-Free Languages (Pre Lecture) Context-Free Languages (Pre Lecture) Dr. Neil T. Dantam CSCI-561, Colorado School of Mines Fall 2017 Dantam (Mines CSCI-561) Context-Free Languages (Pre Lecture) Fall 2017 1 / 34 Outline Pumping Lemma

More information

CSE 105 THEORY OF COMPUTATION

CSE 105 THEORY OF COMPUTATION CSE 105 THEORY OF COMPUTATION Spring 2016 http://cseweb.ucsd.edu/classes/sp16/cse105-ab/ Today's learning goals Sipser Ch 2 Design a PDA and a CFG for a given language Give informal description for a PDA,

More information

MA/CSSE 474 Theory of Computation

MA/CSSE 474 Theory of Computation MA/CSSE 474 Theory of Computation CFL Hierarchy CFL Decision Problems Your Questions? Previous class days' material Reading Assignments HW 12 or 13 problems Anything else I have included some slides online

More information

λ S : A Lambda Calculus with Side-effects

λ S : A Lambda Calculus with Side-effects L14-1 λ S : A Lambda Calculus with Side-effects delivered by Jacob Schwartz Laboratory for Computer Science M.I.T. Lecture 14 M-Structures and Barriers L14-2 Some problems cannot be expressed functionally

More information

Computability and Complexity

Computability and Complexity Computability and Complexity Lecture 5 Reductions Undecidable problems from language theory Linear bounded automata given by Jiri Srba Lecture 5 Computability and Complexity 1/14 Reduction Informal Definition

More information

A Functional Perspective

A Functional Perspective A Functional Perspective on SSA Optimization Algorithms Patryk Zadarnowski jotly with Manuel M. T. Chakravarty Gabriele Keller 19 April 2004 University of New South Wales Sydney THE PLAN ➀ Motivation an

More information

Depending on equations

Depending on equations Depending on equations A proof-relevant framework for unification in dependent type theory Jesper Cockx DistriNet KU Leuven 3 September 2017 Unification for dependent types Unification is used for many

More information

CS 301. Lecture 17 Church Turing thesis. Stephen Checkoway. March 19, 2018

CS 301. Lecture 17 Church Turing thesis. Stephen Checkoway. March 19, 2018 CS 301 Lecture 17 Church Turing thesis Stephen Checkoway March 19, 2018 1 / 17 An abridged modern history of formalizing algorithms An algorithm is a finite, unambiguous sequence of steps for solving a

More information

Regular Expressions and Language Properties

Regular Expressions and Language Properties Regular Expressions and Language Properties Mridul Aanjaneya Stanford University July 3, 2012 Mridul Aanjaneya Automata Theory 1/ 47 Tentative Schedule HW #1: Out (07/03), Due (07/11) HW #2: Out (07/10),

More information

Chapter 4: Computation tree logic

Chapter 4: Computation tree logic INFOF412 Formal verification of computer systems Chapter 4: Computation tree logic Mickael Randour Formal Methods and Verification group Computer Science Department, ULB March 2017 1 CTL: a specification

More information

Let us first give some intuitive idea about a state of a system and state transitions before describing finite automata.

Let us first give some intuitive idea about a state of a system and state transitions before describing finite automata. Finite Automata Automata (singular: automation) are a particularly simple, but useful, model of computation. They were initially proposed as a simple model for the behavior of neurons. The concept of a

More information

Static Program Analysis

Static Program Analysis Static Program Analysis Xiangyu Zhang The slides are compiled from Alex Aiken s Michael D. Ernst s Sorin Lerner s A Scary Outline Type-based analysis Data-flow analysis Abstract interpretation Theorem

More information

Theory of computation: initial remarks (Chapter 11)

Theory of computation: initial remarks (Chapter 11) Theory of computation: initial remarks (Chapter 11) For many purposes, computation is elegantly modeled with simple mathematical objects: Turing machines, finite automata, pushdown automata, and such.

More information

Finite Automata. Dr. Neil T. Dantam. Fall CSCI-561, Colorado School of Mines. Dantam (Mines CSCI-561) Finite Automata Fall / 35

Finite Automata. Dr. Neil T. Dantam. Fall CSCI-561, Colorado School of Mines. Dantam (Mines CSCI-561) Finite Automata Fall / 35 Finite Automata Dr. Neil T. Dantam CSCI-561, Colorado School of Mines Fall 2017 Dantam (Mines CSCI-561) Finite Automata Fall 2017 1 / 35 Outline Dantam (Mines CSCI-561) Finite Automata Fall 2017 2 / 35

More information

PROOFS IN PREDICATE LOGIC AND COMPLETENESS; WHAT DECIDABILITY MEANS HUTH AND RYAN 2.3, SUPPLEMENTARY NOTES 2

PROOFS IN PREDICATE LOGIC AND COMPLETENESS; WHAT DECIDABILITY MEANS HUTH AND RYAN 2.3, SUPPLEMENTARY NOTES 2 PROOFS IN PREDICATE LOGIC AND COMPLETENESS; WHAT DECIDABILITY MEANS HUTH AND RYAN 2.3, SUPPLEMENTARY NOTES 2 Neil D. Jones DIKU 2005 12 September, 2005 Some slides today new, some based on logic 2004 (Nils

More information

Closure Properties of Regular Languages. Union, Intersection, Difference, Concatenation, Kleene Closure, Reversal, Homomorphism, Inverse Homomorphism

Closure Properties of Regular Languages. Union, Intersection, Difference, Concatenation, Kleene Closure, Reversal, Homomorphism, Inverse Homomorphism Closure Properties of Regular Languages Union, Intersection, Difference, Concatenation, Kleene Closure, Reversal, Homomorphism, Inverse Homomorphism Closure Properties Recall a closure property is a statement

More information

Theory of Computation Turing Machine and Pushdown Automata

Theory of Computation Turing Machine and Pushdown Automata Theory of Computation Turing Machine and Pushdown Automata 1. What is a Turing Machine? A Turing Machine is an accepting device which accepts the languages (recursively enumerable set) generated by type

More information

Administrivia. Test I during class on 10 March. Bottom-Up Parsing. Lecture An Introductory Example

Administrivia. Test I during class on 10 March. Bottom-Up Parsing. Lecture An Introductory Example Administrivia Test I during class on 10 March. Bottom-Up Parsing Lecture 11-12 From slides by G. Necula & R. Bodik) 2/20/08 Prof. Hilfinger CS14 Lecture 11 1 2/20/08 Prof. Hilfinger CS14 Lecture 11 2 Bottom-Up

More information

CSE 105 THEORY OF COMPUTATION

CSE 105 THEORY OF COMPUTATION CSE 105 THEORY OF COMPUTATION Spring 2016 http://cseweb.ucsd.edu/classes/sp16/cse105-ab/ Today's learning goals Sipser Ch 4.1, 5.1 Define reductions from one problem to another. Use reductions to prove

More information

CMPSCI 250: Introduction to Computation. Lecture #22: From λ-nfa s to NFA s to DFA s David Mix Barrington 22 April 2013

CMPSCI 250: Introduction to Computation. Lecture #22: From λ-nfa s to NFA s to DFA s David Mix Barrington 22 April 2013 CMPSCI 250: Introduction to Computation Lecture #22: From λ-nfa s to NFA s to DFA s David Mix Barrington 22 April 2013 λ-nfa s to NFA s to DFA s Reviewing the Three Models and Kleene s Theorem The Subset

More information

Foundations of Informatics: a Bridging Course

Foundations of Informatics: a Bridging Course Foundations of Informatics: a Bridging Course Week 3: Formal Languages and Semantics Thomas Noll Lehrstuhl für Informatik 2 RWTH Aachen University noll@cs.rwth-aachen.de http://www.b-it-center.de/wob/en/view/class211_id948.html

More information

Formal Languages, Automata and Compilers

Formal Languages, Automata and Compilers Formal Languages, Automata and Compilers Lecure 4 2017-18 LFAC (2017-18) Lecture 4 1 / 31 Curs 4 1 Grammars of type 3 and finite automata 2 Closure properties for type 3 languages 3 Regular Expressions

More information

A Short Introduction to Hoare Logic

A Short Introduction to Hoare Logic A Short Introduction to Hoare Logic Supratik Chakraborty I.I.T. Bombay June 23, 2008 Supratik Chakraborty (I.I.T. Bombay) A Short Introduction to Hoare Logic June 23, 2008 1 / 34 Motivation Assertion checking

More information

Compiling Techniques

Compiling Techniques Lecture 6: 9 October 2015 Announcement New tutorial session: Friday 2pm check ct course webpage to find your allocated group Table of contents 1 2 Ambiguity s Bottom-Up Parser A bottom-up parser builds

More information

Chapter Two: Finite Automata

Chapter Two: Finite Automata Chapter Two: Finite Automata In theoretical computer science, automata theory is the study of abstract machines (or more appropriately, abstract 'mathematical' machines or systems) and the computational

More information

Chapter 2: Finite Automata

Chapter 2: Finite Automata Chapter 2: Finite Automata 2.1 States, State Diagrams, and Transitions Finite automaton is the simplest acceptor or recognizer for language specification. It is also the simplest model of a computer. A

More information

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018 Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018 Lecture 14 Ana Bove May 14th 2018 Recap: Context-free Grammars Simplification of grammars: Elimination of ǫ-productions; Elimination of

More information

Finite Automata. Dr. Neil T. Dantam. Fall CSCI-561, Colorado School of Mines. Dantam (Mines CSCI-561) Finite Automata Fall / 43

Finite Automata. Dr. Neil T. Dantam. Fall CSCI-561, Colorado School of Mines. Dantam (Mines CSCI-561) Finite Automata Fall / 43 Finite Automata Dr. Neil T. Dantam CSCI-561, Colorado School of Mines Fall 2018 Dantam (Mines CSCI-561) Finite Automata Fall 2018 1 / 43 Outline Languages Review Traffic Light Example Deterministic Finite

More information

CISC 4090 Theory of Computation

CISC 4090 Theory of Computation 9/2/28 Stereotypical computer CISC 49 Theory of Computation Finite state machines & Regular languages Professor Daniel Leeds dleeds@fordham.edu JMH 332 Central processing unit (CPU) performs all the instructions

More information

Lecture Notes on Emptiness Checking, LTL Büchi Automata

Lecture Notes on Emptiness Checking, LTL Büchi Automata 15-414: Bug Catching: Automated Program Verification Lecture Notes on Emptiness Checking, LTL Büchi Automata Matt Fredrikson André Platzer Carnegie Mellon University Lecture 18 1 Introduction We ve seen

More information

Lecture VII Part 2: Syntactic Analysis Bottom-up Parsing: LR Parsing. Prof. Bodik CS Berkley University 1

Lecture VII Part 2: Syntactic Analysis Bottom-up Parsing: LR Parsing. Prof. Bodik CS Berkley University 1 Lecture VII Part 2: Syntactic Analysis Bottom-up Parsing: LR Parsing. Prof. Bodik CS 164 -- Berkley University 1 Bottom-Up Parsing Bottom-up parsing is more general than topdown parsing And just as efficient

More information

Theory of Computer Science. Theory of Computer Science. D7.1 Introduction. D7.2 Turing Machines as Words. D7.3 Special Halting Problem

Theory of Computer Science. Theory of Computer Science. D7.1 Introduction. D7.2 Turing Machines as Words. D7.3 Special Halting Problem Theory of Computer Science May 2, 2018 D7. Halting Problem and Reductions Theory of Computer Science D7. Halting Problem and Reductions Gabriele Röger University of Basel May 2, 2018 D7.1 Introduction

More information

C4.1 Closure Properties

C4.1 Closure Properties Theory of Computer Science April 4, 2016 C4. Regular Languages: Closure Properties and Decidability Theory of Computer Science C4. Regular Languages: Closure Properties and Decidability C4.1 Closure Properties

More information

Decidability. Linz 6 th, Chapter 12: Limits of Algorithmic Computation, page 309ff

Decidability. Linz 6 th, Chapter 12: Limits of Algorithmic Computation, page 309ff Decidability Linz 6 th, Chapter 12: Limits of Algorithmic Computation, page 309ff 1 A property P of strings is said to be decidable if the set of all strings having property P is a recursive set; that

More information

Roy L. Crole. Operational Semantics Abstract Machines and Correctness. University of Leicester, UK

Roy L. Crole. Operational Semantics Abstract Machines and Correctness. University of Leicester, UK Midlands Graduate School, University of Birmingham, April 2008 1 Operational Semantics Abstract Machines and Correctness Roy L. Crole University of Leicester, UK Midlands Graduate School, University of

More information

EXAM. CS331 Compiler Design Spring Please read all instructions, including these, carefully

EXAM. CS331 Compiler Design Spring Please read all instructions, including these, carefully EXAM Please read all instructions, including these, carefully There are 7 questions on the exam, with multiple parts. You have 3 hours to work on the exam. The exam is open book, open notes. Please write

More information

DM17. Beregnelighed. Jacob Aae Mikkelsen

DM17. Beregnelighed. Jacob Aae Mikkelsen DM17 Beregnelighed Jacob Aae Mikkelsen January 12, 2007 CONTENTS Contents 1 Introduction 2 1.1 Operations with languages...................... 2 2 Finite Automata 3 2.1 Regular expressions/languages....................

More information

Decidability. Human-aware Robotics. 2017/10/31 Chapter 4.1 in Sipser Ø Announcement:

Decidability. Human-aware Robotics. 2017/10/31 Chapter 4.1 in Sipser Ø Announcement: Decidability 2017/10/31 Chapter 4.1 in Sipser Ø Announcement: q q q Slides for this lecture are here: http://www.public.asu.edu/~yzhan442/teaching/cse355/lectures/decidability.pdf Happy Hollaween! Delayed

More information

Syntax Directed Transla1on

Syntax Directed Transla1on Syntax Directed Transla1on Syntax Directed Transla1on CMPT 379: Compilers Instructor: Anoop Sarkar anoopsarkar.github.io/compilers-class Syntax directed Translation Models for translation from parse trees

More information

Recursive descent for grammars with contexts

Recursive descent for grammars with contexts 39th International Conference on Current Trends in Theory and Practice of Computer Science Špindleruv Mlýn, Czech Republic Recursive descent parsing for grammars with contexts Ph.D. student, Department

More information

6.001 Recitation 22: Streams

6.001 Recitation 22: Streams 6.001 Recitation 22: Streams RI: Gerald Dalley, dalleyg@mit.edu, 4 May 2007 http://people.csail.mit.edu/dalleyg/6.001/sp2007/ The three chief virtues of a programmer are: Laziness, Impatience and Hubris

More information

Computational Models - Lecture 3

Computational Models - Lecture 3 Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 1 Computational Models - Lecture 3 Equivalence of regular expressions and regular languages (lukewarm leftover

More information

Automatic Verification of Parameterized Data Structures

Automatic Verification of Parameterized Data Structures Automatic Verification of Parameterized Data Structures Jyotirmoy V. Deshmukh, E. Allen Emerson and Prateek Gupta The University of Texas at Austin The University of Texas at Austin 1 Outline Motivation

More information

CSCE 551 Final Exam, April 28, 2016 Answer Key

CSCE 551 Final Exam, April 28, 2016 Answer Key CSCE 551 Final Exam, April 28, 2016 Answer Key 1. (15 points) Fix any alphabet Σ containing the symbol a. For any language L Σ, define the language a\l := {w Σ wa L}. Show that if L is regular, then a\l

More information

CSE 105 THEORY OF COMPUTATION

CSE 105 THEORY OF COMPUTATION CSE 105 THEORY OF COMPUTATION Spring 2016 http://cseweb.ucsd.edu/classes/sp16/cse105-ab/ Today's learning goals Sipser Ch 2 Define push down automata Trace the computation of a push down automaton Design

More information

Complexity Theory Part II

Complexity Theory Part II Complexity Theory Part II Time Complexity The time complexity of a TM M is a function denoting the worst-case number of steps M takes on any input of length n. By convention, n denotes the length of the

More information

ACS2: Decidability Decidability

ACS2: Decidability Decidability Decidability Bernhard Nebel and Christian Becker-Asano 1 Overview An investigation into the solvable/decidable Decidable languages The halting problem (undecidable) 2 Decidable problems? Acceptance problem

More information

Introduction to Kleene Algebras

Introduction to Kleene Algebras Introduction to Kleene Algebras Riccardo Pucella Basic Notions Seminar December 1, 2005 Introduction to Kleene Algebras p.1 Idempotent Semirings An idempotent semiring is a structure S = (S, +,, 1, 0)

More information

Data flow analysis. DataFlow analysis

Data flow analysis. DataFlow analysis Data flow analysis DataFlow analysis compile time reasoning about the runtime flow of values in the program represent facts about runtime behavior represent effect of executing each basic block propagate

More information

Properties of Context-Free Languages. Closure Properties Decision Properties

Properties of Context-Free Languages. Closure Properties Decision Properties Properties of Context-Free Languages Closure Properties Decision Properties 1 Closure Properties of CFL s CFL s are closed under union, concatenation, and Kleene closure. Also, under reversal, homomorphisms

More information

Properties of Context-Free Languages

Properties of Context-Free Languages Properties of Context-Free Languages Seungjin Choi Department of Computer Science and Engineering Pohang University of Science and Technology 77 Cheongam-ro, Nam-gu, Pohang 37673, Korea seungjin@postech.ac.kr

More information

Notes on State Minimization

Notes on State Minimization U.C. Berkeley CS172: Automata, Computability and Complexity Handout 1 Professor Luca Trevisan 2/3/2015 Notes on State Minimization These notes present a technique to prove a lower bound on the number of

More information

CS5371 Theory of Computation. Lecture 7: Automata Theory V (CFG, CFL, CNF)

CS5371 Theory of Computation. Lecture 7: Automata Theory V (CFG, CFL, CNF) CS5371 Theory of Computation Lecture 7: Automata Theory V (CFG, CFL, CNF) Announcement Homework 2 will be given soon (before Tue) Due date: Oct 31 (Tue), before class Midterm: Nov 3, (Fri), first hour

More information

CPSC 421: Tutorial #1

CPSC 421: Tutorial #1 CPSC 421: Tutorial #1 October 14, 2016 Set Theory. 1. Let A be an arbitrary set, and let B = {x A : x / x}. That is, B contains all sets in A that do not contain themselves: For all y, ( ) y B if and only

More information

Part I: Definitions and Properties

Part I: Definitions and Properties Turing Machines Part I: Definitions and Properties Finite State Automata Deterministic Automata (DFSA) M = {Q, Σ, δ, q 0, F} -- Σ = Symbols -- Q = States -- q 0 = Initial State -- F = Accepting States

More information

6.001 SICP September? Procedural abstraction example: sqrt (define try (lambda (guess x) (if (good-enuf? guess x) guess (try (improve guess x) x))))

6.001 SICP September? Procedural abstraction example: sqrt (define try (lambda (guess x) (if (good-enuf? guess x) guess (try (improve guess x) x)))) September? 600-Introduction Trevor Darrell trevor@csail.mit.edu -D5 6.00 web page: http://sicp.csail.mit.edu/ section web page: http://www.csail.mit.edu/~trevor/600/ Abstractions Pairs and lists Common

More information

The Post Correspondence Problem

The Post Correspondence Problem The Post Correspondence Problem - Given a set, P of pairs of strings: where t i, b i Σ P = {[ t 1 b 1 ], t 2 b 2 ],, t k b k ]} - Question: Does there exist a sequence i 1, i 2, i n such that: t i1 t i2

More information

This lecture covers Chapter 7 of HMU: Properties of CFLs

This lecture covers Chapter 7 of HMU: Properties of CFLs This lecture covers Chapter 7 of HMU: Properties of CFLs Chomsky Normal Form Pumping Lemma for CFs Closure Properties of CFLs Decision Properties of CFLs Additional Reading: Chapter 7 of HMU. Chomsky Normal

More information

Automata Theory. CS F-10 Non-Context-Free Langauges Closure Properties of Context-Free Languages. David Galles

Automata Theory. CS F-10 Non-Context-Free Langauges Closure Properties of Context-Free Languages. David Galles Automata Theory CS411-2015F-10 Non-Context-Free Langauges Closure Properties of Context-Free Languages David Galles Department of Computer Science University of San Francisco 10-0: Fun with CFGs Create

More information

Certification of Safe Polynomial Memory Bounds (Extended Version)

Certification of Safe Polynomial Memory Bounds (Extended Version) Certification of Safe Polynomial Memory Bounds (Extended Version) Javier de Dios and Ricardo Peña Departamento de Sistemas Informáticos y Computación Universidad Complutense de Madrid, Spain jdcastro@aventia.com,

More information

CMSC 330: Organization of Programming Languages. Pushdown Automata Parsing

CMSC 330: Organization of Programming Languages. Pushdown Automata Parsing CMSC 330: Organization of Programming Languages Pushdown Automata Parsing Chomsky Hierarchy Categorization of various languages and grammars Each is strictly more restrictive than the previous First described

More information

The View Over The Horizon

The View Over The Horizon The View Over The Horizon enumerable decidable context free regular Context-Free Grammars An example of a context free grammar, G 1 : A 0A1 A B B # Terminology: Each line is a substitution rule or production.

More information

More About Methods. Hsuan-Tien Lin. Deptartment of CSIE, NTU. OOP Class, March 8-9, 2010

More About Methods. Hsuan-Tien Lin. Deptartment of CSIE, NTU. OOP Class, March 8-9, 2010 More About Methods Hsuan-Tien Lin Deptartment of CSIE, NTU OOP Class, March 8-9, 2010 H.-T. Lin (NTU CSIE) More About Methods OOP 03/08-09/2010 0 / 24 Methods: the Basic Method (1/2, Callee s View) 1 p

More information

CSCE 551: Chin-Tser Huang. University of South Carolina

CSCE 551: Chin-Tser Huang. University of South Carolina CSCE 551: Theory of Computation Chin-Tser Huang huangct@cse.sc.edu University of South Carolina Church-Turing Thesis The definition of the algorithm came in the 1936 papers of Alonzo Church h and Alan

More information

Theory of computation: initial remarks (Chapter 11)

Theory of computation: initial remarks (Chapter 11) Theory of computation: initial remarks (Chapter 11) For many purposes, computation is elegantly modeled with simple mathematical objects: Turing machines, finite automata, pushdown automata, and such.

More information

Push Down Automaton. Announcement. Puzzle of the day. Last lecture. Running Example. 10/2 things Chomsky hates about CFGs

Push Down Automaton. Announcement. Puzzle of the day. Last lecture. Running Example. 10/2 things Chomsky hates about CFGs Announcement Push Down Automaton Mid term If you have not collected yours yet, see me after/before class. Atri Rudra May 10 A. Rudra, CSE322 2 Puzzle of the day Last lecture Design a context free grammar

More information

Meta-Circularity, and Vice-Versa

Meta-Circularity, and Vice-Versa 1/60, and Vice-Versa didier@lrde.epita.fr http://www.lrde.epita.fr/ didier ACCU 2011 Thursday, April 14th 2/60 Table of contents 1 2 Symbolic Expressions 3 The of LISP 4 5 6 7 8 Dynamic 9 4/60 circularity

More information

The Turing machine model of computation

The Turing machine model of computation The Turing machine model of computation For most of the remainder of the course we will study the Turing machine model of computation, named after Alan Turing (1912 1954) who proposed the model in 1936.

More information

Context Free Languages. Automata Theory and Formal Grammars: Lecture 6. Languages That Are Not Regular. Non-Regular Languages

Context Free Languages. Automata Theory and Formal Grammars: Lecture 6. Languages That Are Not Regular. Non-Regular Languages Context Free Languages Automata Theory and Formal Grammars: Lecture 6 Context Free Languages Last Time Decision procedures for FAs Minimum-state DFAs Today The Myhill-Nerode Theorem The Pumping Lemma Context-free

More information

Interoperation for Lazy and Eager Evaluation

Interoperation for Lazy and Eager Evaluation Interoperation for Lazy and Eager Evaluation 1 Matthews & Findler New method of interoperation Type safety, observational equivalence & transparency Eager evaluation strategies Lazy vs. eager 2 Lambda

More information

Automata & languages. A primer on the Theory of Computation. Laurent Vanbever. ETH Zürich (D-ITET) October,

Automata & languages. A primer on the Theory of Computation. Laurent Vanbever.   ETH Zürich (D-ITET) October, Automata & languages A primer on the Theory of Computation Laurent Vanbever www.vanbever.eu ETH Zürich (D-ITET) October, 19 2017 Part 5 out of 5 Last week was all about Context-Free Languages Context-Free

More information

Computation Tree Logic (CTL) & Basic Model Checking Algorithms

Computation Tree Logic (CTL) & Basic Model Checking Algorithms Computation Tree Logic (CTL) & Basic Model Checking Algorithms Martin Fränzle Carl von Ossietzky Universität Dpt. of Computing Science Res. Grp. Hybride Systeme Oldenburg, Germany 02917: CTL & Model Checking

More information

Undecidable Problems. Z. Sawa (TU Ostrava) Introd. to Theoretical Computer Science May 12, / 65

Undecidable Problems. Z. Sawa (TU Ostrava) Introd. to Theoretical Computer Science May 12, / 65 Undecidable Problems Z. Sawa (TU Ostrava) Introd. to Theoretical Computer Science May 12, 2018 1/ 65 Algorithmically Solvable Problems Let us assume we have a problem P. If there is an algorithm solving

More information

Solutions to Old Final Exams (For Fall 2007)

Solutions to Old Final Exams (For Fall 2007) Solutions to Old Final Exams (For Fall 2007) CS 381 (Fall 2002, Fall 2004, Fall 2005, Fall 2006) Yogi Sharma Disclaimer: I, Yogi Sharma, do not claim these solution to be complete, or even to be absolutely

More information