Chapter 1 Introduction
|
|
- Lee Lester
- 5 years ago
- Views:
Transcription
1 Chapter 1 Course INF5906 / autum 2017
2 Chapter 1 Learning Targets of Chapter. Apart from a motivational introduction, the chapter gives a high-level overview over larger topics covered in the lecture. They are treated hear just as a teaser and in less depth compared to later but there is already technical content.
3 Chapter 1 Outline of Chapter. Algorithms
4 Section Chapter 1 Course INF5906 / autum 2017
5 : why and what? what static: at compile time : deduction of program properties automatic/decidable formally, based on semantics why error catching catching common stupid errors without bothering the user much spotting errors early certain similarities to model checking examples: type checking, uninitialized variables, potential nil-pointer deref s, unused code optimization: based on, transform the code 1, such the the result is better examples: precalculation of results, optimized register allocation... 1 source code, intermediate code at various levels Control-flow Effect
6 The nature of static compiler with differerent phases corresponding to Chomsky s hierarchy static = in principle: before run-time, but in praxis, context-free 2 since: run-time most often: undecidable static as approximation see also [2, Figure 1.1] L 0 L 1 L 2 L 3 Control-flow 2 lexer parser sa exec. Effect
7 Phases lexer Control-flow Effect
8 Phases lexer parser tokens Control-flow Effect
9 Phases lexer parser tokens SA AST opt. Control-flow Effect
10 Phases lexer parser tokens AST SA opt. IR code gen. IR opt. Control-flow Effect
11 as approximation Control-flow universe unsafe exact safe overapprox. safe underapprox. Effect
12 Optimal compiler? Full employment theorem for compiler writers It s a (mathematically proven!) fact that for any compiler, there exists another one which beats it. slightly more than non-existance of optimal compiler or undecidability of such a compiler theorem just states that there room for improvement is always guaranteed does not say how!. Finding a better one: undecidable Control-flow Effect
13 Section Chapter 1 Course INF5906 / autum 2017
14 While-language simple, prototypical imperative language untyped simple control structure: while, conditional, sequencing simple data (numerals, booleans) abstract syntax concrete syntax disambiguation when needed: (... ), or {... } or begin... end Control-flow Effect
15 Labelling associate flow information labels elementary block = labelled item identify basic building blocks consistent/unique labelling Control-flow Effect
16 syntax a ::= x n a op a a arithm. expressions b ::= true false not b b op b b a op r a boolean expr. S ::= x := a skip S 1 ; S 2 statements if b then S else S while b do S Table: syntax
17 syntax a ::= x n a op a a arithm. expressions b ::= true false not b b op b b a op r a boolean expr. S ::= [x := a] l [skip] l S 1 ; S 2 statements if[b] l then S else S while[b] l do S Table: Labelled abstract syntax
18 Example factorial y := x; z := 1; while y > 1 do(z := z y; y := y 1); y := 0 input variable: x output variable: z [y := x] 0 ; [z := 1] 1 ; while[y > 1] 2 do([z := z y] 3 ; [y := y 1] 4 ); [y := 0] 5 (1) Control-flow Effect
19 CFG factorial l 0 y:=x l 1 z:=1 l 2 y>1 true false l 5 y:=0 Control-flow l 3 z:=z*y y:=y-1 l 4 Effect
20 Factorial: reaching definitions definition of x: assignment to x: x := a better name: reaching assignment first, simple example of data flow Reaching def s An assignment (= definition ) [x := a] l may reach a program point, if there exists an execution where x was last assigned at l, when the mentioned program point is reached. Control-flow Effect
21 Factorial: reaching definitions l 0 y:=x l 1 z:=1 l 3 l 4 l 2 y>1 true z:=z*y y:=y-1 false l 5 y:=0 Control-flow data of interest: tuples of variable label (or node) note: distinguish between the entry and the exit of a node. Effect
22 Factorial: reaching assignments points in the program: entry and exit to elementary blocks/labels?: special label (not occurring otherwise), representing entry to the program, i.e., (x,?) represents initial (uninitialized) value of x full information: pair of functions a tabular form (array): see next slide RD = (RD entry, RD exit ) (2) Control-flow Effect
23 Factorial: reaching assignments table l RD entry RD exit 0 (x,?), (y,?), (z,?) (x,?), (y, 0), (z,?) 1 (x,?), (y, 0), (z,?) (x,?), (y, 0), (z, 1) 2 (x,?), (y, 0), (y, 4), (z, 1), (z, 3) (x,?), (y, 0), (y, 4), (z, 1), (z, 3) 3 (x,?), (y, 0), (y, 4), (z, 1), (z, 3) (x,?), (y, 0), (y, 4), (z, 3) 4 (x,?), (y, 0), (y, 4), (z, 3) (x,?), (y, 4), (z, 3) 5 (x,?), (y, 0), (y, 4), (z, 1), (z, 3) (x,?), (y, 5), (z, 1), (z, 3)
24 Reaching assignments: remarks elementary blocks of the form [b] l : entry/exit information coincides [x := a] l : entry/exit information (in general) different at program exit: (x,?), x is input variable table: best information = smallest sets: additional pairs in the table: still safe removing labels: unsafe note: still an approximation no real (= run time) data, no real execution, only data flow approximate since in concrete runs: at each point in that run, there is exactly one last assignment, not a set label represents (potentially infinitely many) runs e.g.: at program exit in concrete run: either (z, 1) or else (z, 3) Control-flow Effect
25 standard: representation of program as control flow graph (aka flow graph) nodes: elementary blocks with labels (or basic block) edges: flow of control two approaches, both (especially here) quite similar equational approach constraint-based approach Control-flow Effect
26 From flow graphs to equations associate an equation system with the flow graph: describing the flow of information here: the information related to reaching assignments information imagined to flow forwards solutions of the equations describe safe approximations not unique, interest in the least (or largest) solution here: give back RD of equation (2) on slide 22 Control-flow Effect
27 Equations for RD and factorial: intra-block first type: local, intra-block : flow through each individual block relating for each elementary block its exit with its entry elementary block: [y := x] 0 RD exit (0) = RD entry (0) \{(y, l) l Lab} {(y, 0)} Control-flow (3) Effect
28 Equations for RD and factorial: intra-block first type: local, intra-block : flow through each individual block relating for each elementary block its exit with its entry elementary block: [y > 1] 2 RD exit (0) = RD entry (0) \{(y, l) l Lab} {(y, 0)} Control-flow RD exit (2) = RD entry (2) (3) Effect
29 Equations for RD and factorial: intra-block first type: local, intra-block : flow through each individual block relating for each elementary block its exit with its entry all equations with RD exit as left-hand side RD exit (0) = RD entry (0) \{(y, l) l Lab} {(y, 0)} RD exit (1) = RD entry (1) \{(z, l) l Lab} {(z, 1)} RD exit (2) = RD entry (2) RD exit (3) = RD entry (3) \{(z, l) l Lab} {(z, 3)} RD exit (4) = RD entry (4) \{(y, l) l Lab} {(y, 4)} RD exit (5) = RD entry (5) \{(y, l) l Lab} {(y, 5)} (3) Control-flow Effect
30 Inter-block flow second type: global, inter-block flow between the elementary blocks, following the control-flow edges relating the entry of each block with the exits of other blocks, that are connected via an edge (exception: the initial block has no uncoming edge) initial block: mark variables as uninitialized RD entry (1) = RD exit (0) RD entry (3) = RD exit (2) RD entry (4) = RD exit (3) RD entry (5) = RD exit (2) (4) Control-flow Effect
31 Inter-block flow second type: global, inter-block flow between the elementary blocks, following the control-flow edges relating the entry of each block with the exits of other blocks, that are connected via an edge (exception: the initial block has no uncoming edge) initial block: mark variables as uninitialized RD entry (1) = RD exit (0) RD entry (2) = RD exit (1) RD exit (4) RD entry (3) = RD exit (2) RD entry (4) = RD exit (3) RD entry (5) = RD exit (2) (4) Control-flow Effect
32 Inter-block flow second type: global, inter-block flow between the elementary blocks, following the control-flow edges relating the entry of each block with the exits of other blocks, that are connected via an edge (exception: the initial block has no uncoming edge) initial block: mark variables as uninitialized RD entry (1) = RD exit (0) RD entry (2) = RD exit (1) RD exit (4) RD entry (3) = RD exit (2) RD entry (4) = RD exit (3) RD entry (5) = RD exit (2) RD entry (0) = {(x,?), (y,?), (z,?)} (4) Control-flow Effect
33 General scheme (for RD) Intra for assignments [x := a] l Inter RD exit (l) = RD entry (l) \{(x, l ) l Lab} {(x, l)} (5) for other blocks [b] l (side-effect free) RD exit (l) = RD entry (l) (6) RD entry (l) = RD exit (l ) (7) l l Initial l: label of the initial block (isolated entry) RD entry (l) = {(x,?) x is a program variable} (8)
34 The equation system as fix point RD example: solution to the equation system = 12 sets RD entry (0),..., RD exit (5) i.e., the RD entry (l), RD exit (l) are the variables of the equation system, of type: sets of pairs of the form (x, l) domain of the equation system: RD: the mentioned twelve-tuple of variables equation system understood as function F Equations RD = F ( RD) Control-flow Effect
35 The least solution Var = variables of interest (i.e., occurring), Lab : labels of interest here Var = {x, y, z}, Lab = {?, 1,..., 6} F : (2 Var Lab ) 12 (2 Var Lab ) 12 (9) domain (2 Var Lab ) 12 : partially ordered pointwise: RD RD iff i. RD i RD i (10) complete lattice Control-flow Effect
36 next, for DFA: a simple variant of the equational approach rearrangement of the entry-exit relationships instead of equations: inequations (sub-set instead of set-equality) in more complex settings: constraints become more complex, no split in exit- and entry-constraints Control-flow Effect
37 Factorial program: intra-block constraints elementary block: [y := x] 0 RD exit (0) RD entry (0) \{(y, l) l Lab} RD exit (0) {(y, 0)} Control-flow Effect
38 Factorial program: intra-block constraints elementary block: [y > 1] 2 RD exit (2) RD entry (2) Control-flow Effect
39 Factorial program: intra-block constraints all equations with RD exit as left-hand side RD exit (0) RD entry (0) \{(y, l) l Lab} RD exit (0) {(y, 0)} RD exit (1) RD entry (1) \{(z, l) l Lab} RD exit (1) {(z, 1)} RD exit (2) RD entry (2) RD exit (3) RD entry (3) \{(z, l) l Lab} RD exit (3) {(z, 3)} RD exit (4) RD entry (4) \{(y, l) l Lab} RD exit (4) {(y, 4)} RD exit (5) RD entry (5) \{(y, l) l Lab} RD exit (5) {(y, 5)} Control-flow Effect
40 Factorial program: inter-block constraints cf. slide 30 ff.: inter-block equations: RD entry (1) = RD exit (0) RD entry (2) = RD exit (1) RD exit (4) RD entry (3) = RD exit (2) RD entry (4) = RD exit (3) RD entry (5) = RD exit (2) RD entry (0) = {(x,?), (y,?), (z,?)} Control-flow Effect
41 Factorial program: inter-block constraints splitting of composed right-hand sides + using instead of =: RD entry (1) RD exit (0) RD entry (2) RD exit (1) RD entry (2) RD exit (4) RD entry (3) RD exit (2) RD entry (4) RD exit (3) RD entry (5) RD exit (2) RD entry (1) {(x,?), (y,?), (z,?)} Control-flow Effect
42 Least solution revisited instead of F ( RD) = RD clear: solution to the equation system solution to the constraint system important: least solutions coincides! Pre-fixpoint F ( RD) RD (11) Control-flow Effect
43 Section Chapter 1 Course INF5906 / autum 2017
44 Control-flow Goal CFA which elem. blocks lead to which other elem. blocks for while-language: immediate (labelled elem. blocks, resp., graph) complex for: more advanced features, higher-order languages, oo languages... here: prototypical higher-order functional language λ-calculus formulated as constraint based Control-flow Effect
45 Simple example l e t f = f n x => x 1 ; g = f n y => y + 2 ; h = f n z => z + 3 ; i n ( f g ) + ( f h ) higher-order function f for simplicity: untyped local definitions via let-in interesting above: x 1 Goal (more specifically) for each function application, which function may be applied Control-flow Effect
46 Labelling more complex language more complex labelling elem. blocks can be nested all syntactic constructs (expressions) are labelled consider: Unlabelled abstract syntax (fn x x) (fn y y) Control-flow functional language: side effect free no need to distinguish entry and exit of labelled blocks. Effect
47 Labelling more complex language more complex labelling elem. blocks can be nested all syntactic constructs (expressions) are labelled consider: Full labelling [ [fn x [x] 1 ] 2 [fn y [y] 3 ] 4 ] 5 Control-flow functional language: side effect free no need to distinguish entry and exit of labelled blocks. Effect
48 Data of the Data of the : Pairs (Ĉ, ˆρ) of mappings: abstract cache: Ĉ(l): set of values/function abstractions, the subexpression labelled l may evaluate to abstract env.: ˆρ: values, x may be bound to Control-flow Effect
49 The constraint system ignoring let here: three syntactic constructs three kinds of constraints relating Ĉ, ˆρ, and the program in form of subset constraints (subsets, order-relation) Control-flow Effect
50 The constraint system ignoring let here: three syntactic constructs three kinds of constraints relating Ĉ, ˆρ, and the program in form of subset constraints (subsets, order-relation) 3 syntactic classes function abstraction: [fn x x] l variables: [x] l application: [f g] l Control-flow Effect
51 Constraint system for the small example Labelled example [ [fn x [x] 1 ] 2 [fn y [y] 3 ] 4 ] 5 Control-flow Effect
52 Constraint system for the small example Labelled example [ [fn x [x] 1 ] 2 [fn y [y] 3 ] 4 ] 5 function abstractions {fn x [x] 1 } Ĉ(2) {fn y [y] 3 } Ĉ(4) Control-flow Effect
53 Constraint system for the small example Labelled example [ [fn x [x] 1 ] 2 [fn y [y] 3 ] 4 ] 5 variables (occurrences of use) ˆρ(x) Ĉ(1) ˆρ(y) Ĉ(3) Control-flow Effect
54 Constraint system for the small example Labelled example [ [fn x [x] 1 ] 2 [fn y [y] 3 ] 4 ] 5 application: connecting function entry and (body) exit with the argument Ĉ(4) ˆρ(x) Ĉ(1) Ĉ(5) Control-flow Effect
55 Constraint system for the small example Labelled example [ [fn x [x] 1 ] 2 [fn y [y] 3 ] 4 ] 5 application: connecting function entry and (body) exit with the argument but: also [fn y [y] 3 ] 4 is a candidate at 2! (according to Ĉ(2)) Ĉ(4) ˆρ(x) Ĉ(1) Ĉ(5) Ĉ(4) ˆρ(y) Ĉ(3) Ĉ(5) Control-flow Effect
56 Constraint system for the small example Labelled example [ [fn x [x] 1 ] 2 [fn y [y] 3 ] 4 ] 5 {fn x [x] 1 } Ĉ(2) Ĉ(4) ˆρ(x) {fn x [x] 1 } Ĉ(2) Ĉ(1) Ĉ(5) {fn y [y] 3 } Ĉ(2) Ĉ(4) ˆρ(y) {fn y [y] 3 } Ĉ(2) Ĉ(3) Ĉ(5) Control-flow Effect
57 The least (= best) solution Ĉ(1) = {fn y [y] 3 } Ĉ(2) = {fn x [x] 1 } Ĉ(3) = Ĉ(4) = {fn y [y] 3 } Ĉ(5) = {fn y [y] 3 } ˆρ(x) = {fn y [y] 3 } ˆρ(y) = One interesting bit here in the solution is: ˆρ(y) = : that means, the variable y never evaluated, i.e., the function is not applied at all. Control-flow Effect
58 Section Chapter 1 Course INF5906 / autum 2017
59 general framework calculating analyses, not specifying and validating a posteriori goes back to Cousot and Cousot [1] example here: reaching definitions once again Control-flow Effect
60 Calculating reaching definitions starting point collecting semantics (a) collecting semantics a reference point for the not computable (in general) soundness easily established collects sets of traces for a given program point superset of possible traces Control-flow Effect
61 Collecting semantics and semantically reaching def s traces tr Trace = (Var Lab) (12) sets of traces reaching a given point factorial example: e.g., reaching exit of l = 5 (=exit of program) ((x,?), (y,?), (y,?), (y, 1), (z, 2), (z, 4), (y, 5), (z, 4), (y, 5), (y, 6)) semantically reaching definitions whether an assignment is reaching as read off per trace Control-flow Effect
62 Semantically reaching definitions relates CS and RD, i.e., core of α and γ example: tr = (x,?) : (y,?) : (z,?) : (y, 1) : (z, 2) SRD(tr) = {(x,?), (y, 1), (z, 2)} for sets of traces: X = {(x,?) : (y,?) : (z,?) : (y, 1) : (z, 2), (x,?) : (y,?) : (z,?) : (y, 1) : (z, 2) : (z, 4) : (y, 5)} Control-flow may reach: combining results of both traces via SRD(X) = {(x,?), (y, 1), (z, 2), (z, 4), (y, 5)} Effect
63 Collecting semantics: equationally specified much like equations for RD cf. slide 18 intra-block equations + inter-block equations CS exit (1) = {tr : (y, 1) tr CS entry (1)} CS exit (2) = {tr : (z, 2) tr CS entry (2)} CS exit (3) = CS entry (3) CS exit (4) = {tr : (z, 4) tr CS entry (4)} CS exit (5) = {tr : (y, 5) tr CS entry (5)} CS exit (6) = {tr : (y, 6) tr CS entry (6)} (13) Control-flow Effect
64 Collecting semantics: equationally specified much like equations for RD cf. slide 18 intra-block equations + inter-block equations CS entry (1) = {((x,?) : (y,?) : (z,?))} CS entry (2) = CS exit (1) CS entry (3) = CS exit (2) CS exit (5) CS entry (4) = CS exit (3) CS entry (5) = CS exit (4) CS entry (6) = CS exit (5) (13) Control-flow Effect
65 Collecting semantics: least fixpoint as for RD: equation system as fixpoint equation function G : (2 Trace ) 12 (2 Trace ) 12 CS: twelve-tuple of sets of traces CS = G( CS) (14) of interest: least solution: lfp(g) now: technically more advanced than for RD fix-point iteration does not terminate Control-flow Effect
66 ion and concretization 2 levels concrete : collecting semantics abstract : reaching assignments (here) related by 2 functions: abstraction α and concretization γ α 2 Trace 2 Var Lab γ Control-flow α: extract reachability of def s from the traces α(x) = SRD(X) (15) γ: yield all traces, consistent with reachability γ(y ) = {tr SRD(tr) Y } (16) Effect
67 Galois connection γ and α are not unrelated α and γ are not inverses of each other, but almost so (α, γ) form a Galois connection Galois connection X γ(y ) iff α(x) Y (17) γ(y ) γ Y Control-flow X α α(x) Effect
68 Inducing RD known G exit (4) defined on s Trace Galois connection (α, γ) calculate F exit (4) defined on 2 Var Lab F exit (4) = α G exit (4) γ Control-flow Effect
69 Section Chapter 1 Course INF5906 / autum 2017
70 Effects: Intro type system: classical static : t : T judgment: term or program phrase has type T in general: context-sensitive judgments (remember Chomsky... ) Judgement : Γ t : T Γ: assumption or context here: non-standard type : effects and annotations natural setting: typed languages, here: trivial! setting (while-language) Control-flow Effect
71 Trival type system setting: while-language each statement maps: state to states Σ: type of states judgement S : Σ Σ (18) Control-flow specified as a derivation system note: partial correctness assertion Effect
72 Trival type system: rules [x := a] l : Σ Σ Ass [skip] l : Σ Σ Skip S 1 : Σ Σ S 1 ; S 2 : Σ Σ S 2 : Σ Σ Seq S : Σ Σ While while[b] l do S : Σ Σ S 1 : Σ Σ S 2 : Σ Σ if[b] l then S 1 else S 2 : Σ Σ Cond Control-flow Effect
73 Types, effects, and annotations annot. type system S : Σ 1 Σ 2 (19) effect system S : Σ ϕ Σ (20) type and effect system (TES) effect system + annotated type system borderline fuzzy annotated type system Σ i : property of state ( Σ i Σ ) abstract properties: invariants, a variable is positive, etc. effect system statement S maps state to state, with (potential... ) effect ϕ effect ϕ: e.g.: errors, exceptions, file/resource access,... Control-flow Effect
74 example again: reaching definitions for while-language 2 flavors 1. annotated base types: S : RD 1 RD 2 2. annotated type : S : Σ X Σ RD Control-flow Effect
75 RD with annotated base types judgement S : RD 1 RD 2 (21) RD 2 Var Lab auxiliary functions note: every S has one initial elementary block, potentially more than one at the end init(s): the (unique) label at the entry of S final(s): the set of labels at the exits of S meaning of judgment S : RD 1 RD 2 RD 1 is the set of var/label reaching the entry of S and RD 2 the corresponding set at the exit(s) of S : RD 1 = RD entry (init(s)) RD 2 = {RD exit (l) l final(s)} Control-flow Effect
76 [x := a] l : RD RD \{(x, l) l Lab} {(x, l )} ass [skip] l : RD RD skip S 1 : RD 1 RD 2 S 2 : RD 2 RD 3 Seq S 1 ; S 2 : RD 1 RD 3 S 1 : RD 1 RD 2 S 2 : RD 1 RD 2 If if[b] l then S 1 else S 2 : RD 1 RD 2 S : RD RD While while[b] l do S : RD RD S : RD 1 RD 2 RD 1 RD 1 RD 2 RD 2 Sub S : RD 1 RD 2 Control-flow Effect
77 Meaning of annotated judgments Meaning of judgment S : RD 1 RD 2 : RD 1 is the set of var/label reaching the entry of S and RD 2 the corresponding set at the exit(s) of S : RD 1 = RD entry (init(s)) RD 2 = {RD exit l l final(s)} Be careful: more concretely if[b] l then S 1 else S 2 if[b] l then [x := y] l 1 else [y := x] l 2 Control-flow Effect
78 Meaning of annotated judgments Once again: Meaning of judgment S : RD 1 RD 2 : if RD 1 is a set of var/label reaching the entry of S, then RD 2 is a corresponding set at the exit(s) of S : if RD 1 RD entry (init(s)) then l final(s). RD exit (l) RD 2 Control-flow Effect
79 Derivation [z := 1] 1 : {? x, 0,? z} {? x, 0, 1} f 3 : {? x, 0, 1} RD final [y := x] 0 : RD 0 {? x, 0,? z} f 2 : {? x, 0,? z} RD final f : RD 0 RD final RD 0 = {? x,? y,? z} RD final = {? x, 5, 1, 3} type sub-derivation for the rest f 3 = while... ; [y := 0] 5 loop invariant [z := ] 3 : RD body {? x, 0, 4, 3, 1} [y := ] 4 : {? x, 0, 4, 3} {? x, 4, 3} RD body = {? x, 0, 4, 1, 3} f body : RD body {? x, 4, 3} Sub f body : RD body RD body f while : RD body RD body Sub f while : {? x, 0, 1} RD body [y := 0] 5 : RD body RD final
80 alternative approach of annotated type arrow constructor itself annotated annotion of : flavor of effect system judgment S : Σ RD Σ annotation with RD (corresponding to the post-condition from above) alone is not enough Control-flow Effect
81 alternative approach of annotated type arrow constructor itself annotated annotion of : flavor of effect system judgment S : Σ X Σ RD annotation with RD (corresponding to the post-condition from above) alone is not enough also needed: the variables being changed Intended meaning S maps states to states, where RD is the set of reaching definition, S may produce and X the set of var s S must (= unavoidably) assign. Control-flow Effect
82 [x := a] l : Σ {x} Σ Ass {(x,l)} [skip]l : Σ Σ Skip S 1 : Σ X1 Σ S 2 : Σ X2 RD1 RD2 S 1 ; S 2 : Σ X 1 X 2 Σ RD 1 \ X 2 RD 2 S 1 : Σ X Σ S 2 : Σ X RD RD Σ Σ if[b] l then S 1 else S 2 : Σ X Σ RD S : Σ X Σ RD while[b] l do S : Σ Σ RD While Seq If S : Σ X Σ X X RD RD RD S : Σ X Σ RD Sub Control-flow Effect
83 Effect this time: back to the functional language starting point: simple type system judgment: Γ e : τ Γ: type environment (or context), mapping from variable to types types: bool, int, and τ τ Control-flow Effect
84 Γ(x) = τ Γ x : τ Var Γ, x:τ 1 e : τ 2 Abs Γ fn π x e : τ 1 τ 2 Γ e 1 : τ 1 τ 2 Γ e 2 : τ 1 App Γ e 1 e 2 : τ 2 Control-flow Effect
85 Effects: Call tracking Call tracking : Determine: for each subexpression: which function abstractions may be applied, i.e., called, during the subexpression s evaluation. set of function names annotate: function type with latent effect annotated types: ˆτ: base types as before, arrow types: ˆτ 1 ϕ ˆτ2 (22) functions from τ 1 to τ 2, where in the execution, functions from set ϕ are called. Judgment Control-flow ˆΓ e : ˆτ & ϕ (23) Effect
86 ˆΓ(x) = ˆτ Var ˆΓ x : ˆτ & Γ, x:ˆτ 1 e : ˆτ 2 & ϕ Abs ϕ {π} Γ fn π x e : ˆτ 1 ˆτ 2 & ˆΓ e 1 : ˆτ 1 ϕ ˆτ2 & ϕ 1 ˆΓ e2 : ˆτ 1 & ϕ 2 App ˆΓ e 1 e 2 : ˆτ 2 & ϕ ϕ 1 ϕ 2 Control-flow Effect
87 Call tracking: example x:int {Y } int x:int {Y } int & (fn X x x) : (int {Y } int) {X} (int {Y } int) & (fn Y y y) : int {Y } int & (fn X x x) (fn Y y y) : int {Y } int & {X}
88 Section Chapter 1 Course INF5906 / autum 2017
89 : often not interesting per se used for optimizations here: constant folding Judgement RD S Ś (24) Intended meaning Given the (hopefully safe) RD, the statement S can be transformed one step into Ś core idea: replace variable /known to carry the same value in all runs additionally (independent from RD): expressions without var s: evaluated immediately Control-flow Effect
90 y fv(a) (y,?) / RD entry (l) (z, l ) RD entry (l). z = y [...] l is [x := n] l Ass 1 [x := a] l [x := a[n/y]] l fv(a) = a / Num a evaluates to n Ass 2 RD [x := a] l [x := n] l RD S 1 S 1 RD S 2 S 2 Seq 1 Seq 1 RD S 1 ; S 2 S 1, S 2 RD S 1 ; S 2 S 1 ; S 2 Control-flow Effect
91 Section Algorithms Chapter 1 Course INF5906 / autum 2017
92 Chaotic iteration back to data flow/reaching def s goal: solve RD = F (RD) or RD F ( RD) F : monotone, finite domain straightforward approach init RD0 = F 0 ( ) iterate RD n+1 = F ( RD n ) = F n+1 ( ) until stabilization approach to implement that: chaotic iteration non-deterministic stategy abbreviate: RD = (RD 1,..., RD 12 ) Control-flow Effect
93 Chaotic iteration (for RD) I n p u t : e q u a t i o n s f o r r e a c h i n g d e f s f o r the g i v e n program Output : l e a s t s o l u t i o n : RD = (RD1,..., RD 12 ) I n i t i a l i z a t i o n : RD 1 := ;... ; RD 12 := I t e r a t i o n : w h i l e RD j F j (RD 1,..., RD 12 ) f o r some j do RD j := F j (RD 1,..., RD 12 )
94 Chapter 2 References Course INF5906 / autum 2017
95 References I Bibliography [1] Cousot, P. and Cousot, R. (1977). : A unified lattice model for static of programs by construction or approximation of fixpoints. In 4th POPL, Los Angeles, CA. ACM. [2] Nielson, F., Nielson, H.-R., and Hankin, C. L. (1999). Principles of Program Analysis. Springer Verlag. 2-2
Static analysis and all that
Static analysis and all that Martin Steffen IfI UiO Spring 2014 uio Static analysis and all that Martin Steffen IfI UiO Spring 2014 uio Plan approx. 15 lectures, details see web-page flexible time-schedule,
More informationPrinciples of Program Analysis: A Sampler of Approaches
Principles of Program Analysis: A Sampler of Approaches Transparencies based on Chapter 1 of the book: Flemming Nielson, Hanne Riis Nielson and Chris Hankin: Principles of Program Analysis Springer Verlag
More informationPROGRAM ANALYSIS & SYNTHESIS
Lecture 02 Structural Operational Semantics (SOS) PROGRAM ANALYSIS & SYNTHESIS EranYahav 1 Previously static analysis over-approximation of program behavior abstract interpretation abstraction, transformers,
More informationProgramming Languages Lecture 14: Sum, Product, Recursive Types
CSE 230: Winter 200 Principles of Programming Languages Lecture 4: Sum, Product, Recursive Types The end is nigh HW 3 No HW 4 (= Final) Project (Meeting + Talk) Ranjit Jhala UC San Diego Recap Goal: Relate
More informationLecture 6. Abstract Interpretation
Lecture 6. Abstract Interpretation Wei Le 2014.10 Outline Motivation History What it is: an intuitive understanding An example Steps of abstract interpretation Galois connection Narrowing and Widening
More information1 Introduction. 3 Syntax
CS 6110 S18 Lecture 19 Typed λ-calculus 1 Introduction Type checking is a lightweight technique for proving simple properties of programs. Unlike theorem-proving techniques based on axiomatic semantics,
More informationCS 6110 S11 Lecture 25 Typed λ-calculus 6 April 2011
CS 6110 S11 Lecture 25 Typed λ-calculus 6 April 2011 1 Introduction Type checking is a lightweight technique for proving simple properties of programs. Unlike theorem-proving techniques based on axiomatic
More informationProgramming Languages
CSE 230: Winter 2008 Principles of Programming Languages Ocaml/HW #3 Q-A Session Push deadline = Mar 10 Session Mon 3pm? Lecture 15: Type Systems Ranjit Jhala UC San Diego Why Typed Languages? Development
More informationA Gentle Introduction to Program Analysis
A Gentle Introduction to Program Analysis Işıl Dillig University of Texas, Austin January 21, 2014 Programming Languages Mentoring Workshop 1 / 24 What is Program Analysis? Very broad topic, but generally
More informationAdvanced Programming Methods. Introduction in program analysis
Advanced Programming Methods Introduction in program analysis What is Program Analysis? Very broad topic, but generally speaking, automated analysis of program behavior Program analysis is about developing
More informationIntra-procedural Data Flow Analysis Introduction
The Setting: Optimising Compilers The Essence of Program Analysis Reaching Definitions Analysis Intra-procedural Data Flow Analysis Introduction Hanne Riis Nielson and Flemming Nielson email: {riis,nielson}@immdtudk
More informationApplication: Programming Language Semantics
Chapter 8 Application: Programming Language Semantics Prof. Dr. K. Madlener: Specification and Verification in Higher Order Logic 527 Introduction to Programming Language Semantics Programming Language
More informationThursday, December 23, The attack model: Static Program Analysis
The attack model: Static Program Analysis How making SPA? DFA - Data Flow Analysis CFA - Control Flow Analysis Proving invariance: theorem proving Checking models: model checking Giaco & Ranzato DFA:
More informationFlow Analysis. Data-flow analysis, Control-flow analysis, Abstract interpretation, AAM
Flow Analysis Data-flow analysis, Control-flow analysis, Abstract interpretation, AAM Helpful Reading: Sections 1.1-1.5, 2.1 Data-flow analysis (DFA) A framework for statically proving facts about program
More informationStatic Program Analysis
Static Program Analysis Thomas Noll Software Modeling and Verification Group RWTH Aachen University https://moves.rwth-aachen.de/teaching/ss-18/spa/ Preliminaries Outline of Lecture 1 Preliminaries Introduction
More informationStatic Program Analysis
Static Program Analysis Lecture 1: Introduction to Program Analysis Thomas Noll Lehrstuhl für Informatik 2 (Software Modeling and Verification) noll@cs.rwth-aachen.de http://moves.rwth-aachen.de/teaching/ws-1415/spa/
More informationType Checking. Outline. General properties of type systems. Types in programming languages. Notation for type rules.
Outline Type Checking General properties of type systems Types in programming languages Notation for type rules Logical rules of inference Common type rules 2 Static Checking Refers to the compile-time
More informationOutline. General properties of type systems. Types in programming languages. Notation for type rules. Common type rules. Logical rules of inference
Type Checking Outline General properties of type systems Types in programming languages Notation for type rules Logical rules of inference Common type rules 2 Static Checking Refers to the compile-time
More informationCS 6110 S14 Lecture 38 Abstract Interpretation 30 April 2014
CS 6110 S14 Lecture 38 Abstract Interpretation 30 April 2014 1 Introduction to Abstract Interpretation At this point in the course, we have looked at several aspects of programming languages: operational
More informationProgramming Languages Lecture 15: Recursive Types & Subtyping
CSE 230: Winter 2008 Principles of Programming Languages Lecture 15: Recursive Types & Subtyping Ranjit Jhala UC San Diego News? Formalize first-order type systems Simple types (integers and booleans)
More informationImplementation of Constraint Systems for Useless Variable Elimination
Research Science Institute 1998, Intel STS 1999 Implementation of Constraint Systems for Useless Variable Elimination Daniel M. Roy under the direction of Prof. Mitchell Wand Northeastern University Abstract
More informationCSCE 314 Programming Languages
CSCE 314 Programming Languages Syntactic Analysis Dr. Hyunyoung Lee 1 What Is a Programming Language? Language = syntax + semantics The syntax of a language is concerned with the form of a program: how
More informationCOS 320. Compiling Techniques
Topic 5: Types COS 320 Compiling Techniques Princeton University Spring 2016 Lennart Beringer 1 Types: potential benefits (I) 2 For programmers: help to eliminate common programming mistakes, particularly
More informationInduction and Semantics in Dafny
15-414 Lecture 11 1 Instructor: Matt Fredrikson Induction and Semantics in Dafny TA: Ryan Wagner Encoding the syntax of Imp Recall the abstract syntax of Imp: a AExp ::= n Z x Var a 1 + a 2 b BExp ::=
More informationCS152: Programming Languages. Lecture 11 STLC Extensions and Related Topics. Dan Grossman Spring 2011
CS152: Programming Languages Lecture 11 STLC Extensions and Related Topics Dan Grossman Spring 2011 Review e ::= λx. e x e e c v ::= λx. e c τ ::= int τ τ Γ ::= Γ, x : τ (λx. e) v e[v/x] e 1 e 1 e 1 e
More informationCS-XXX: Graduate Programming Languages. Lecture 9 Simply Typed Lambda Calculus. Dan Grossman 2012
CS-XXX: Graduate Programming Languages Lecture 9 Simply Typed Lambda Calculus Dan Grossman 2012 Types Major new topic worthy of several lectures: Type systems Continue to use (CBV) Lambda Caluclus as our
More informationLecture Notes on Program Equivalence
Lecture Notes on Program Equivalence 15-312: Foundations of Programming Languages Frank Pfenning Lecture 24 November 30, 2004 When are two programs equal? Without much reflection one might say that two
More informationProgram Analysis: Lecture 02 Page 1 of 32
Program Analysis: Lecture 02 Page 1 of 32 Program Analysis/ Mooly Sagiv Lecture 1, 31/10/2012 Operational Semantics Notes by: Kalev Alpernas As background to the subject of Program Analysis, we will first
More informationStatic Analysis: Overview, Syntactic Analysis and Abstract Interpretation TDDC90: Software Security
Static Analysis: Overview, Syntactic Analysis and Abstract Interpretation TDDC90: Software Security Ahmed Rezine IDA, Linköpings Universitet Hösttermin 2014 Outline Overview Syntactic Analysis Abstract
More informationPrinciples of Program Analysis: Data Flow Analysis
Principles of Program Analysis: Data Flow Analysis Transparencies based on Chapter 2 of the book: Flemming Nielson, Hanne Riis Nielson and Chris Hankin: Principles of Program Analysis. Springer Verlag
More information3.7 Denotational Semantics
3.7 Denotational Semantics Denotational semantics, also known as fixed-point semantics, associates to each programming language construct a well-defined and rigorously understood mathematical object. These
More informationCOMP 181 Compilers. Administrative. Last time. Prelude. Compilation strategy. Translation strategy. Lecture 2 Overview
COMP 181 Compilers Lecture 2 Overview September 7, 2006 Administrative Book? Hopefully: Compilers by Aho, Lam, Sethi, Ullman Mailing list Handouts? Programming assignments For next time, write a hello,
More informationLambda Calculus and Type Inference
Lambda Calculus and Type Inference Björn Lisper Dept. of Computer Science and Engineering Mälardalen University bjorn.lisper@mdh.se http://www.idt.mdh.se/ blr/ October 13, 2004 Lambda Calculus and Type
More informationIntroduction to Lexical Analysis
Introduction to Lexical Analysis Outline Informal sketch of lexical analysis Identifies tokens in input string Issues in lexical analysis Lookahead Ambiguities Specifying lexical analyzers (lexers) Regular
More informationCMSC 330: Organization of Programming Languages. Formal Semantics of a Prog. Lang. Specifying Syntax, Semantics
Recall Architecture of Compilers, Interpreters CMSC 330: Organization of Programming Languages Source Scanner Parser Static Analyzer Operational Semantics Intermediate Representation Front End Back End
More informationDenotational Semantics. Domain Theory
Denotational Semantics and Domain Theory 1 / 51 Outline Denotational Semantics Basic Domain Theory Introduction and history Primitive and lifted domains Sum and product domains Function domains Meaning
More informationStatic Program Analysis CS701
Static Program Analysis CS701 Thomas Reps [Based on notes taken by Aditya Venkataraman on Oct 6th, 2015] Abstract This lecture introduces the area of static program analysis. We introduce the topics to
More informationA CRASH COURSE IN SEMANTICS
LAST TIME Recdef More induction NICTA Advanced Course Well founded orders Slide 1 Theorem Proving Principles, Techniques, Applications Slide 3 Well founded recursion Calculations: also/finally {P}... {Q}
More informationFormal semantics of loosely typed languages. Joep Verkoelen Vincent Driessen
Formal semantics of loosely typed languages Joep Verkoelen Vincent Driessen June, 2004 ii Contents 1 Introduction 3 2 Syntax 5 2.1 Formalities.............................. 5 2.2 Example language LooselyWhile.................
More informationProgram Static Analysis. Overview
Program Static Analysis Overview Program static analysis Abstract interpretation Data flow analysis Intra-procedural Inter-procedural 2 1 What is static analysis? The analysis to understand computer software
More informationSémantique des Langages de Programmation (SemLP) DM : Region Types
Sémantique des Langages de Programmation (SemLP) DM : Region Types I) Submission Submission Date : 21/05/2017 Submission Format : Submit a virtual machine (.ova) 1 with 1. an executable of the interpreter,
More informationRecursive Types and Subtyping
Recursive Types and Subtyping #1 One-Slide Summary Recall: Recursive types (e.g., τ list) make the typed lambda calculus as powerful as the untyped lambda calculus. If τ is a subtype of σ then any expression
More informationPrinciples of Programming Languages
Principles of Programming Languages Lesson 14 Type Checking Collaboration and Management Dana Fisman www.cs.bgu.ac.il/~ppl172 1 Type Checking We return to the issue of type safety we discussed informally,
More informationLecture #13: Type Inference and Unification. Typing In the Language ML. Type Inference. Doing Type Inference
Lecture #13: Type Inference and Unification Typing In the Language ML Examples from the language ML: fun map f [] = [] map f (a :: y) = (f a) :: (map f y) fun reduce f init [] = init reduce f init (a ::
More informationIntroduction to Machine-Independent Optimizations - 4
Introduction to Machine-Independent Optimizations - 4 Department of Computer Science and Automation Indian Institute of Science Bangalore 560 012 NPTEL Course on Principles of Compiler Design Outline of
More informationLambda Calculus and Type Inference
Lambda Calculus and Type Inference Björn Lisper Dept. of Computer Science and Engineering Mälardalen University bjorn.lisper@mdh.se http://www.idt.mdh.se/ blr/ August 17, 2007 Lambda Calculus and Type
More informationVariables. Substitution
Variables Elements of Programming Languages Lecture 4: Variables, binding and substitution James Cheney University of Edinburgh October 6, 2015 A variable is a symbol that can stand for another expression.
More informationNote that in this definition, n + m denotes the syntactic expression with three symbols n, +, and m, not to the number that is the sum of n and m.
CS 6110 S18 Lecture 8 Structural Operational Semantics and IMP Today we introduce a very simple imperative language, IMP, along with two systems of rules for evaluation called small-step and big-step semantics.
More informationCompilers and computer architecture: Semantic analysis
1 / 1 Compilers and computer architecture: Semantic analysis Martin Berger Alex Jeffery October 2018 Recall the function of compilers 2 / 1 3 / 1 Recall the structure of compilers Source program Lexical
More informationPrinciples of Program Analysis. Lecture 1 Harry Xu Spring 2013
Principles of Program Analysis Lecture 1 Harry Xu Spring 2013 An Imperfect World Software has bugs The northeast blackout of 2003, affected 10 million people in Ontario and 45 million in eight U.S. states
More informationCompiler Construction 2009/2010 SSA Static Single Assignment Form
Compiler Construction 2009/2010 SSA Static Single Assignment Form Peter Thiemann March 15, 2010 Outline 1 Static Single-Assignment Form 2 Converting to SSA Form 3 Optimization Algorithms Using SSA 4 Dependencies
More informationMore Lambda Calculus and Intro to Type Systems
More Lambda Calculus and Intro to Type Systems Plan Heavy Class Participation Thus, wake up! Lambda Calculus How is it related to real life? Encodings Fixed points Type Systems Overview Static, Dyamic
More informationProgramming Languages and Compilers (CS 421)
Programming Languages and Compilers (CS 421) Elsa L Gunter 2112 SC, UIUC http://courses.engr.illinois.edu/cs421 Based in part on slides by Mattox Beckman, as updated by Vikram Adve and Gul Agha 10/3/17
More informationFlang typechecker Due: February 27, 2015
CMSC 22610 Winter 2015 Implementation of Computer Languages I Flang typechecker Due: February 27, 2015 Project 3 February 9, 2015 1 Introduction The third project is to implement a type checker for Flang,
More informationHierarchical Pointer Analysis for Distributed Programs
Hierarchical Pointer Analysis for Distributed Programs Amir Kamil Computer Science Division, University of California, Berkeley kamil@cs.berkeley.edu April 14, 2006 1 Introduction Many distributed, parallel
More informationFormal Syntax and Semantics of Programming Languages
Formal Syntax and Semantics of Programming Languages Mooly Sagiv Reference: Semantics with Applications Chapter 2 H. Nielson and F. Nielson http://www.daimi.au.dk/~bra8130/wiley_book/wiley.html The While
More informationMore Lambda Calculus and Intro to Type Systems
More Lambda Calculus and Intro to Type Systems #1 One Slide Summary The lambda calculus is a model of computation or a programming language that is as expressive as a Turing machine. The lambda calculus
More informationCompiler Structure. Data Flow Analysis. Control-Flow Graph. Available Expressions. Data Flow Facts
Compiler Structure Source Code Abstract Syntax Tree Control Flow Graph Object Code CMSC 631 Program Analysis and Understanding Fall 2003 Data Flow Analysis Source code parsed to produce AST AST transformed
More informationCSCE 314 Programming Languages. Type System
CSCE 314 Programming Languages Type System Dr. Hyunyoung Lee 1 Names Names refer to different kinds of entities in programs, such as variables, functions, classes, templates, modules,.... Names can be
More informationCMSC 336: Type Systems for Programming Languages Lecture 5: Simply Typed Lambda Calculus Acar & Ahmed January 24, 2008
CMSC 336: Type Systems for Programming Languages Lecture 5: Simply Typed Lambda Calculus Acar & Ahmed January 24, 2008 Contents 1 Solution to the Exercise 1 1.1 Semantics for lambda calculus.......................
More informationSemantics of programming languages
Semantics of programming languages Informatics 2A: Lecture 27 John Longley School of Informatics University of Edinburgh jrl@inf.ed.ac.uk 21 November, 2011 1 / 19 1 2 3 4 2 / 19 Semantics for programming
More informationCMSC 330: Organization of Programming Languages. OCaml Expressions and Functions
CMSC 330: Organization of Programming Languages OCaml Expressions and Functions CMSC330 Spring 2018 1 Lecture Presentation Style Our focus: semantics and idioms for OCaml Semantics is what the language
More informationFinite Automata Theory and Formal Languages TMV027/DIT321 LP4 2016
Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2016 Lecture 15 Ana Bove May 23rd 2016 More on Turing machines; Summary of the course. Overview of today s lecture: Recap: PDA, TM Push-down
More informationMore Lambda Calculus and Intro to Type Systems
#1 More Lambda Calculus and Intro to Type Systems #2 Plan Heavy Class Participation Thus, wake up! (not actually kidding) Lambda Calculus How is it related to real life? Encodings Fixed points Type Systems
More informationMore Dataflow Analysis
More Dataflow Analysis Steps to building analysis Step 1: Choose lattice Step 2: Choose direction of dataflow (forward or backward) Step 3: Create transfer function Step 4: Choose confluence operator (i.e.,
More informationAlgebraic Program Analysis
Introduction to Algebraic Program Analysis Zachary Kincaid 1 Thomas Reps 2,3 1 Princeton University 2 University of Wisconsin-Madison 3 GrammaTech, Inc. January 8, 2018 1 Program analysis Design algorithms
More informationSimply-Typed Lambda Calculus
#1 Simply-Typed Lambda Calculus #2 Back to School What is operational semantics? When would you use contextual (small-step) semantics? What is denotational semantics? What is axiomatic semantics? What
More informationFlow Logic: A Multi-paradigmatic Approach to Static Analysis
Flow Logic: A Multi-paradigmatic Approach to Static Analysis Hanne Riis Nielson and Flemming Nielson Informatics and Mathematical Modelling Technical University of Denmark {riis,nielson}@@imm.dtu.dk Abstract.
More informationData Flow Analysis using Program Graphs
Data Flow Analysis using Program Graphs Michal Terepeta Supervised by Professor Hanne Riis Nielson Professor Andrzej Napieralski Kongens Lyngby 2010 Technical University of Denmark Informatics and Mathematical
More informationWriting Evaluators MIF08. Laure Gonnord
Writing Evaluators MIF08 Laure Gonnord Laure.Gonnord@univ-lyon1.fr Evaluators, what for? Outline 1 Evaluators, what for? 2 Implementation Laure Gonnord (Lyon1/FST) Writing Evaluators 2 / 21 Evaluators,
More informationError Handling Syntax-Directed Translation Recursive Descent Parsing
Announcements rror Handling Syntax-Directed ranslation Lecture 6 PA1 & WA1 Due today at midnight PA2 & WA2 Assigned today Prof. Aiken CS 143 Lecture 6 1 Prof. Aiken CS 143 Lecture 6 2 Outline xtensions
More informationCS 360 Programming Languages Interpreters
CS 360 Programming Languages Interpreters Implementing PLs Most of the course is learning fundamental concepts for using and understanding PLs. Syntax vs. semantics vs. idioms. Powerful constructs like
More informationCompiler Passes. Optimization. The Role of the Optimizer. Optimizations. The Optimizer (or Middle End) Traditional Three-pass Compiler
Compiler Passes Analysis of input program (front-end) character stream Lexical Analysis Synthesis of output program (back-end) Intermediate Code Generation Optimization Before and after generating machine
More informationCompilers and computer architecture From strings to ASTs (2): context free grammars
1 / 1 Compilers and computer architecture From strings to ASTs (2): context free grammars Martin Berger October 2018 Recall the function of compilers 2 / 1 3 / 1 Recall we are discussing parsing Source
More informationFoundations: Syntax, Semantics, and Graphs
Foundations: Syntax, Semantics, and Graphs Testing, Quality Assurance, and Maintenance Winter 2018 Prof. Arie Gurfinkel based on slides by Ruzica Pizkac, Claire Le Goues, Lin Tan, Marsha Chechik, and others
More informationType Checking and Type Inference
Type Checking and Type Inference Principles of Programming Languages CSE 307 1 Types in Programming Languages 2 Static Type Checking 3 Polymorphic Type Inference Version: 1.8 17:20:56 2014/08/25 Compiled
More informationIntroduction to Lexical Analysis
Introduction to Lexical Analysis Outline Informal sketch of lexical analysis Identifies tokens in input string Issues in lexical analysis Lookahead Ambiguities Specifying lexers Regular expressions Examples
More informationError Handling Syntax-Directed Translation Recursive Descent Parsing
Announcements rror Handling Syntax-Directed ranslation Lecture 6 PA1 & WA1 Due today at midnight PA2 & WA2 Assigned today Prof. Aiken CS 14 Lecture 6 1 Prof. Aiken CS 14 Lecture 6 2 Outline xtensions of
More informationIn Our Last Exciting Episode
In Our Last Exciting Episode #1 Lessons From Model Checking To find bugs, we need specifications What are some good specifications? To convert a program into a model, we need predicates/invariants and
More informationLambda Calculus. Type Systems, Lectures 3. Jevgeni Kabanov Tartu,
Lambda Calculus Type Systems, Lectures 3 Jevgeni Kabanov Tartu, 13.02.2006 PREVIOUSLY ON TYPE SYSTEMS Arithmetical expressions and Booleans Evaluation semantics Normal forms & Values Getting stuck Safety
More informationAn Approach to Behavioral Subtyping Based on Static Analysis
TACoS 04 Preliminary Version An Approach to Behavioral Subtyping Based on Static Analysis Francesco Logozzo 1 STIX - École Polytechnique F-91128 Palaiseau, France Abstract In mainstream object oriented
More informationTopic 3: Syntax Analysis I
Topic 3: Syntax Analysis I Compiler Design Prof. Hanjun Kim CoreLab (Compiler Research Lab) POSTECH 1 Back-End Front-End The Front End Source Program Lexical Analysis Syntax Analysis Semantic Analysis
More informationSpecifying Syntax. An English Grammar. Components of a Grammar. Language Specification. Types of Grammars. 1. Terminal symbols or terminals, Σ
Specifying Syntax Language Specification Components of a Grammar 1. Terminal symbols or terminals, Σ Syntax Form of phrases Physical arrangement of symbols 2. Nonterminal symbols or syntactic categories,
More informationA Type System for Object Initialization In the Java TM Bytecode Language
Electronic Notes in Theoretical Computer Science 10 (1998) URL: http://www.elsevier.nl/locate/entcs/volume10.html 7 pages A Type System for Object Initialization In the Java TM Bytecode Language Stephen
More informationLecture 6: The Declarative Kernel Language Machine. September 13th, 2011
Lecture 6: The Declarative Kernel Language Machine September 13th, 2011 Lecture Outline Computations contd Execution of Non-Freezable Statements on the Abstract Machine The skip Statement The Sequential
More informationAssignment 4: Semantics
Assignment 4: Semantics 15-411: Compiler Design Jan Hoffmann Jonathan Burns, DeeDee Han, Anatol Liu, Alice Rao Due Thursday, November 3, 2016 (9:00am) Reminder: Assignments are individual assignments,
More informationReview. CS152: Programming Languages. Lecture 11 STLC Extensions and Related Topics. Let bindings (CBV) Adding Stuff. Booleans and Conditionals
Review CS152: Programming Languages Lecture 11 STLC Extensions and Related Topics e ::= λx. e x ee c v ::= λx. e c (λx. e) v e[v/x] e 1 e 2 e 1 e 2 τ ::= int τ τ Γ ::= Γ,x : τ e 2 e 2 ve 2 ve 2 e[e /x]:
More informationCS415 Compilers. Syntax Analysis. These slides are based on slides copyrighted by Keith Cooper, Ken Kennedy & Linda Torczon at Rice University
CS415 Compilers Syntax Analysis These slides are based on slides copyrighted by Keith Cooper, Ken Kennedy & Linda Torczon at Rice University Limits of Regular Languages Advantages of Regular Expressions
More informationError Handling Syntax-Directed Translation Recursive Descent Parsing
Error Handling Syntax-Directed Translation Recursive Descent Parsing Lecture 6 by Professor Vijay Ganesh) 1 Outline Recursive descent Extensions of CFG for parsing Precedence declarations Error handling
More informationCS558 Programming Languages
CS558 Programming Languages Winter 2017 Lecture 7b Andrew Tolmach Portland State University 1994-2017 Values and Types We divide the universe of values according to types A type is a set of values and
More informationTypes. Type checking. Why Do We Need Type Systems? Types and Operations. What is a type? Consensus
Types Type checking What is a type? The notion varies from language to language Consensus A set of values A set of operations on those values Classes are one instantiation of the modern notion of type
More informationλ calculus is inconsistent
Content Rough timeline COMP 4161 NICTA Advanced Course Advanced Topics in Software Verification Gerwin Klein, June Andronick, Toby Murray λ Intro & motivation, getting started [1] Foundations & Principles
More informationLECTURE 3. Compiler Phases
LECTURE 3 Compiler Phases COMPILER PHASES Compilation of a program proceeds through a fixed series of phases. Each phase uses an (intermediate) form of the program produced by an earlier phase. Subsequent
More informationSoftwaretechnik. Lecture 03: Types and Type Soundness. Peter Thiemann. University of Freiburg, Germany SS 2008
Softwaretechnik Lecture 03: Types and Type Soundness Peter Thiemann University of Freiburg, Germany SS 2008 Peter Thiemann (Univ. Freiburg) Softwaretechnik SWT 1 / 35 Table of Contents Types and Type correctness
More information6.001 Notes: Section 6.1
6.001 Notes: Section 6.1 Slide 6.1.1 When we first starting talking about Scheme expressions, you may recall we said that (almost) every Scheme expression had three components, a syntax (legal ways of
More informationLecture Notes on Aggregate Data Structures
Lecture Notes on Aggregate Data Structures 15-312: Foundations of Programming Languages Frank Pfenning Lecture 8 September 23, 2004 In this lecture we discuss various language extensions which make MinML
More informationPart VI. Imperative Functional Programming
Part VI Imperative Functional Programming Chapter 14 Mutable Storage MinML is said to be a pure language because the execution model consists entirely of evaluating an expression for its value. ML is
More informationCSE505, Fall 2012, Midterm Examination October 30, 2012
CSE505, Fall 2012, Midterm Examination October 30, 2012 Rules: The exam is closed-book, closed-notes, except for one side of one 8.5x11in piece of paper. Please stop promptly at Noon. You can rip apart
More informationFall Compiler Principles Lecture 5: Intermediate Representation. Roman Manevich Ben-Gurion University of the Negev
Fall 2016-2017 Compiler Principles Lecture 5: Intermediate Representation Roman Manevich Ben-Gurion University of the Negev Tentative syllabus Front End Intermediate Representation Optimizations Code Generation
More informationConditional Elimination through Code Duplication
Conditional Elimination through Code Duplication Joachim Breitner May 27, 2011 We propose an optimizing transformation which reduces program runtime at the expense of program size by eliminating conditional
More information