slides5 - Principles of Program Analysis: Type and Effect...

Info iconThis preview shows pages 1–9. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Principles of Program Analysis: Type and Effect Systems Transparencies based on Chapter 5 of the book: Flemming Nielson, Hanne Riis Nielson and Chris Hankin: Principles of Program Analysis . Springer Verlag 2005. c Flemming Nielson & Hanne Riis Nielson & Chris Hankin. PPA Chapter 5 c F.Nielson & H.Riis Nielson & C.Hankin (Dec. 2004) 1 Basic idea: effect systems If an expression e maps entities of type 1 to entities of type 2 e : 1 2 then we can annotate the arrow with properties of the program e : 1 2 Example analysis Choice of the property of a function call Control Flow which function abstractions might arise Side Effect which side effects might be observed Exception which exceptions might be raised Region which regions of data might be effected Communication which temporal behaviour might be observed PPA Section 5.1 c F.Nielson & H.Riis Nielson & C.Hankin (Dec. 2004) 2 The plan a typed functional language with a traditional underlying type system several extensions to effect systems : Analysis characteristica properties Control Flow subeffecting sets Side Effect subtyping sets Exception polymorphism sets Region polymorphic recursion sets Communication polymorphism temporal PPA Section 5.1 c F.Nielson & H.Riis Nielson & C.Hankin (Dec. 2004) 3 Syntax of the Fun language e ::= c | x | fn x => e | fun f x => e | e 1 e 2 program points | if e then e 1 else e 2 | let x = e 1 in e 2 | {z } not polymorphic | e 1 op e 2 Examples: ( fn X x => x ) ( fn Y y => y ) let g = (fun F f x => f (fn Y y => y)) in g (fn Z z => z) PPA Section 5.1 c F.Nielson & H.Riis Nielson & C.Hankin (Dec. 2004) 4 Underlying type system: typing judgements ` UL e : 6 ::= int | bool | 1 2 6 ::= [ ] | [ x 7 ] Assumptions: each constant c has a type c true has type true = bool ; 7 has type 7 = int each operator op expects two arguments of type 1 op and 2 op and gives a result of type op > expects two arguments of type int and gives a result of type bool PPA Section 5.1 c F.Nielson & H.Riis Nielson & C.Hankin (Dec. 2004) 5 Underlying type system: axioms and rules (1) ` UL c : c ` UL x : if ( x ) = [ x 7 x ] ` UL e : ` UL fn x => e : x [ f 7 x ][ x 7 x ] ` UL e : ` UL fun f x => e : x ` UL e 1 : 2 ` UL e 2 : 2 ` UL e 1 e 2 : PPA Section 5.1 c F.Nielson & H.Riis Nielson & C.Hankin (Dec. 2004) 6 Underlying type system: axioms and rules (2) ` UL e : bool ` UL e 1 : ` UL e 2 : ` UL if e then e 1 else e 2 : ` UL e 1 : 1 [ x 7 1 ] ` UL e 2 : 2 ` UL let x = e 1 in e 2 : 2 ` UL e 1 : 1 op ` UL e 2 : 2 op ` UL e 1 op e 2 : op PPA Section 5.1 c F.Nielson & H.Riis Nielson & C.Hankin (Dec. 2004) 7 Example: let g = ( fun F f x => f (fn Y y => y) ) in g (fn Z z => z) Abbreviation: fx = [ f 7 ( )...
View Full Document

Page1 / 93

slides5 - Principles of Program Analysis: Type and Effect...

This preview shows document pages 1 - 9. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online