SEMANTIC ANALYSIS PRINCIPLES OF PROGRAMMING LANGUAGES. Norbert Zeh Winter Dalhousie University 1/28

Size: px
Start display at page:

Download "SEMANTIC ANALYSIS PRINCIPLES OF PROGRAMMING LANGUAGES. Norbert Zeh Winter Dalhousie University 1/28"

Transcription

1 SEMNTI NLYSIS PRINIPLES OF PROGRMMING LNGUGES Norbert Zeh Winter 2018 Dlhousie University 1/28

2 PROGRM TRNSLTION FLOW HRT Soure progrm (hrter strem) Snner (lexil nlysis) Front end Prse tree Prser (syntti nlysis) Token strem Bk end Modified intermedite form Modified trget lnguge Semnti nlysis nd ode genertion Mhine-independent ode improvement Trget ode genertion Mhine-speifi ode improvement bstrt syntx tree or other intermedite form Trget lnguge (e.g., ssembly) Symbol tble 2/28

3 ROD MP Syntx, semntis, nd semnti nlysis ttribute grmmrs tion routines bstrt syntx trees 3/28

4 ROD MP Syntx, semntis, nd semnti nlysis ttribute grmmrs tion routines bstrt syntx trees 3/28

5 SYNTX ND SEMNTIS Syntx Desribes form of vlid progrm n be desribed by ontext-free grmmr 4/28

6 SYNTX ND SEMNTIS Syntx Desribes form of vlid progrm n be desribed by ontext-free grmmr Semntis Desribes mening of progrm nnot be desribed by ontext-free grmmr 4/28

7 SYNTX ND SEMNTIS Syntx Desribes form of vlid progrm n be desribed by ontext-free grmmr Semntis Desribes mening of progrm nnot be desribed by ontext-free grmmr Some onstrints tht my pper syntti re enfored by semnti nlysis! Exmple: Use of identifier only fter its delrtion 4/28

8 SEMNTI NLYSIS Semnti nlysis Enfores semnti rules Builds intermedite representtion (e.g., bstrt syntx tree) Fills symbol tble Psses results to intermedite ode genertor 5/28

9 SEMNTI NLYSIS Semnti nlysis Enfores semnti rules Builds intermedite representtion (e.g., bstrt syntx tree) Fills symbol tble Psses results to intermedite ode genertor Two pprohes Interleved with syntti nlysis s seprte phse 5/28

10 SEMNTI NLYSIS Semnti nlysis Enfores semnti rules Builds intermedite representtion (e.g., bstrt syntx tree) Fills symbol tble Psses results to intermedite ode genertor Two pprohes Interleved with syntti nlysis s seprte phse Forml mehnism ttribute grmmrs 5/28

11 ENFORING SEMNTI RULES Stti semnti rules Enfored by ompiler t ompile time Exmple: Do not use undelred vrible. 6/28

12 ENFORING SEMNTI RULES Stti semnti rules Enfored by ompiler t ompile time Exmple: Do not use undelred vrible. Dynmi semnti rules ompiler genertes ode for enforement t runtime. Exmples: Division by zero, rry index out of bounds Some ompilers llow these heks to be disbled. 6/28

13 ROD MP Syntx, semntis, nd semnti nlysis ttribute grmmrs tion routines bstrt syntx trees 7/28

14 ROD MP Syntx, semntis, nd semnti nlysis ttribute grmmrs tion routines bstrt syntx trees 7/28

15 TTRIBUTE GRMMRS ttribute grmmr n ugmented ontext-free grmmr: Eh symbol in prodution hs number of ttributes. Eh prodution is ugmented with semnti rules tht opy ttribute vlues between symbols, Evlute ttribute vlues using semnti funtions, Enfore onstrints on ttribute vlues. 8/28

16 TTRIBUTE GRMMR: EXMPLE E E + T E E T E T T T F T T / F T F F F F ( E ) F onst 9/28

17 TTRIBUTE GRMMR: EXMPLE E E + T E E T E T T T F T T / F T F F F F ( E ) F onst E 1 E 2 + T { E 1.vl = dd(e 2.vl, T.vl) } E 1 E 2 T { E 1.vl = sub(e 2.vl, T.vl) } E T { E.vl = T.vl } T 1 T 2 F { T 1.vl = mul(t 2.vl, F.vl) } T 1 T 2 / F { T 1.vl = div(t 2.vl, F.vl) } T F { T.vl = F.vl } F 1 F 2 { F 1.vl = neg(f 2.vl) } F ( E ) { F.vl = E.vl } F onst { F.vl = onst.vl } 9/28

18 SYNTHESIZED ND INHERITED TTRIBUTES Synthesized ttributes ttributes of LHS of prodution re omputed from ttributes of RHS of prodution. 10/28

19 SYNTHESIZED ND INHERITED TTRIBUTES Synthesized ttributes ttributes of LHS of prodution re omputed from ttributes of RHS of prodution. Inherited ttributes ttributes flow from left to right: From LHS to RHS, From symbols on RHS to symbols lter on the RHS. 10/28

20 SYNTHESIZED TTRIBUTES: EXMPLE The lnguge L = { n b n n n > 0} = {b, bb, bbb,...} is not ontext-free but n be defined using n ttribute grmmr: 11/28

21 SYNTHESIZED TTRIBUTES: EXMPLE The lnguge L = { n b n n n > 0} = {b, bb, bbb,...} is not ontext-free but n be defined using n ttribute grmmr: S B {ondition:.ount = B.ount =.ount} {.ount = 1} 1 2 { 1.ount = 2.ount + 1} B b {B.ount = 1} B 1 B 2 b {B 1.ount = B 2.ount + 1} {.ount = 1} 1 2 { 1.ount = 2.ount + 1} 11/28

22 SYNTHESIZED TTRIBUTES: PRSE TREE DEORTION (1) Input: bbb 12/28

23 SYNTHESIZED TTRIBUTES: PRSE TREE DEORTION (1) Input: bbb Prse tree: S B B b B b b 12/28

24 SYNTHESIZED TTRIBUTES: PRSE TREE DEORTION (1) Input: bbb Prse tree: S 3 3 B B b B b 1 b 12/28

25 SYNTHESIZED TTRIBUTES: PRSE TREE DEORTION (1) Input: bbb Prse tree: 3 = 3 = 3 S 3 3 B B b B b 1 b 12/28

26 SYNTHESIZED TTRIBUTES: PRSE TREE DEORTION (2) Input: bb 13/28

27 SYNTHESIZED TTRIBUTES: PRSE TREE DEORTION (2) Input: bb Prse tree: S B B b b 13/28

28 SYNTHESIZED TTRIBUTES: PRSE TREE DEORTION (2) Input: bb Prse tree: S 3 2 B B b 2 1 b 1 13/28

29 SYNTHESIZED TTRIBUTES: PRSE TREE DEORTION (2) Input: bb Prse tree: S 3 2 B B b 2 1 b 1 13/28

30 INHERITED TTRIBUTES: EXMPLE gin, we onsider the lnguge L = { n b n n n > 0} = {b, bb, bbb,...}. 14/28

31 INHERITED TTRIBUTES: EXMPLE gin, we onsider the lnguge L = { n b n n n > 0} = {b, bb, bbb,...}. S B {B.inhount =.ount;.inhount =.ount} {.ount = 1} 1 2 { 1.ount = 2.ount + 1} B b {ondition : B.inhount = 1} B 1 B 2 b {B 2.inhount = B 1.inhount 1} {ondition :.inhount = 1} 1 2 { 2.inhount = 1.inhount 1} 14/28

32 INHERITED TTRIBUTES: PRSE TREE DEORTION (1) Input: bbb 15/28

33 INHERITED TTRIBUTES: PRSE TREE DEORTION (1) Input: bbb Prse tree: S B B b B b b 15/28

34 INHERITED TTRIBUTES: PRSE TREE DEORTION (1) Input: bbb Prse tree: S 3 B 2 B b 1 B b b 15/28

35 INHERITED TTRIBUTES: PRSE TREE DEORTION (1) Input: bbb Prse tree: S 3 3 B 3 2 B b 1 B b b 15/28

36 INHERITED TTRIBUTES: PRSE TREE DEORTION (1) Input: bbb Prse tree: S 3 3 B B b B b 1 b 15/28

37 INHERITED TTRIBUTES: PRSE TREE DEORTION (1) Input: bbb Prse tree: S 3 3 B B b = 1 B b 1 = 1 b 15/28

38 INHERITED TTRIBUTES: PRSE TREE DEORTION (2) Input: bb 16/28

39 INHERITED TTRIBUTES: PRSE TREE DEORTION (2) Input: bb Prse tree: S B B b b 16/28

40 INHERITED TTRIBUTES: PRSE TREE DEORTION (2) Input: bb Prse tree: S 3 B 2 B b 1 b 16/28

41 INHERITED TTRIBUTES: PRSE TREE DEORTION (2) Input: bb Prse tree: S 3 3 B 3 2 B b 1 b 16/28

42 INHERITED TTRIBUTES: PRSE TREE DEORTION (2) Input: bb Prse tree: S 3 3 B B b 2 1 b 1 16/28

43 INHERITED TTRIBUTES: PRSE TREE DEORTION (2) Input: bb Prse tree: S 3 3 B B b 2 1 b 1 = 1 16/28

44 TTRIBUTE FLOW nnottion or deortion of the prse tree: Proess of evluting ttributes 17/28

45 TTRIBUTE FLOW nnottion or deortion of the prse tree: Proess of evluting ttributes Synthesized ttributes: ttributes of LHS of eh prodution re omputed from ttributes of symbols on the RHS of the prodution. ttributes flow bottom-up in the prse tree. 17/28

46 TTRIBUTE FLOW nnottion or deortion of the prse tree: Proess of evluting ttributes Synthesized ttributes: ttributes of LHS of eh prodution re omputed from ttributes of symbols on the RHS of the prodution. ttributes flow bottom-up in the prse tree. Inherited ttributes: ttributes for symbols in the RHS of eh prodution re omputed from ttributes of symbols to their left in the prodution. ttributes flow top-down in the prse tree. 17/28

47 S-TTRIBUTED ND L-TTRIBUTED GRMMRS S-ttributed grmmr ll ttributes re synthesized. ttributes flow bottom-up. 18/28

48 S-TTRIBUTED ND L-TTRIBUTED GRMMRS S-ttributed grmmr ll ttributes re synthesized. ttributes flow bottom-up. L-ttributed grmmr For eh prodution X Y 1 Y 2... Y k, X.syn depends on X.inh nd ll ttributes of Y 1, Y 2,..., Y k. For ll 1 i k, Y i.inh depends on X.inh nd ll ttributes of Y 1, Y 2,..., Y i 1. 18/28

49 S-TTRIBUTED ND L-TTRIBUTED GRMMRS S-ttributed grmmr ll ttributes re synthesized. ttributes flow bottom-up. L-ttributed grmmr For eh prodution X Y 1 Y 2... Y k, X.syn depends on X.inh nd ll ttributes of Y 1, Y 2,..., Y k. For ll 1 i k, Y i.inh depends on X.inh nd ll ttributes of Y 1, Y 2,..., Y i 1. S-ttributed grmmrs re speil se of L-ttributed grmmrs. 18/28

50 LL(1) PRSING, LEFT-SSOITIVITY, ND L-TTRIBUTED GRMMRS (1) simple grmmr for rithmeti expressions using ddition nd subtrtion: E T E ET T n + 19/28

51 LL(1) PRSING, LEFT-SSOITIVITY, ND L-TTRIBUTED GRMMRS (1) simple grmmr for rithmeti expressions using ddition nd subtrtion: E T E ET T n E T E E T T /28

52 LL(1) PRSING, LEFT-SSOITIVITY, ND L-TTRIBUTED GRMMRS (1) simple grmmr for rithmeti expressions using ddition nd subtrtion: E T E ET T n = (10 3) + 5 = (3 + 5) = 2 E E T E T T /28

53 LL(1) PRSING, LEFT-SSOITIVITY, ND L-TTRIBUTED GRMMRS (1) simple grmmr for rithmeti expressions using ddition nd subtrtion: E T E ET T n = (10 3) + 5 = (3 + 5) = 2 E E T E T T This grmmr ptures left-ssoitivity. 19/28

54 LL(1) PRSING, LEFT-SSOITIVITY, ND L-TTRIBUTED GRMMRS (1) simple grmmr for rithmeti expressions using ddition nd subtrtion: E T = (10 3) + 5 = 12 E ET (3 + 5) = 2 T n + 12 E 7 E dd T 5 10 E sub T dd T sub This grmmr ptures left-ssoitivity. 19/28

55 LL(1) PRSING, LEFT-SSOITIVITY, ND L-TTRIBUTED GRMMRS (1) simple grmmr for rithmeti expressions using ddition nd subtrtion: E T E ET T n E T 10 7 sub sub = (10 3) + 5 = (3 + 5) = 2 12 E dd T 5 T dd E Rule R PREDIT(R) E T {n} E ET {n} T n {n} + {+} { } This grmmr ptures left-ssoitivity. 19/28

56 LL(1) PRSING, LEFT-SSOITIVITY, ND L-TTRIBUTED GRMMRS (1) simple grmmr for rithmeti expressions using ddition nd subtrtion: E T E ET T n E T 10 7 sub sub = (10 3) + 5 = (3 + 5) = 2 12 E dd T 5 T dd E Rule R PREDIT(R) E T {n} E ET {n} T n {n} + {+} { } This grmmr ptures left-ssoitivity. It is not LL(1)! 19/28

57 LL(1) PRSING, LEFT-SSOITIVITY, ND L-TTRIBUTED GRMMRS (2) n LL(1) grmmr for the sme lnguge: PREDIT E TE $ {n} E ϵ {$} E TE {+, } T n {n} + {+} { } 20/28

58 LL(1) PRSING, LEFT-SSOITIVITY, ND L-TTRIBUTED GRMMRS (2) n LL(1) grmmr for the sme lnguge: PREDIT E TE $ {n} E ϵ {$} E TE {+, } T n {n} + {+} { } T E $ 10 T 3 E + E T E 5 ϵ 20/28

59 LL(1) PRSING, LEFT-SSOITIVITY, ND L-TTRIBUTED GRMMRS (2) n LL(1) grmmr for the sme lnguge: PREDIT E TE $ {n} E ϵ {$} E TE {+, } T n {n} + {+} { } E T 10 E $ T 3 + E T E 5 ϵ 20/28

60 LL(1) PRSING, LEFT-SSOITIVITY, ND L-TTRIBUTED GRMMRS (2) n LL(1) grmmr for the sme lnguge: PREDIT E TE $ {n} E ϵ {$} E TE {+, } T n {n} + {+} { } E T 10 E $ T sub 3 sub 3 3 T E + 5 ϵ E 20/28

61 LL(1) PRSING, LEFT-SSOITIVITY, ND L-TTRIBUTED GRMMRS (2) n LL(1) grmmr for the sme lnguge: PREDIT E TE $ {n} E ϵ {$} E TE {+, } T n {n} + {+} { } E T 10 E $ T 7 sub 3 sub 3 3 T E + 5 ϵ E 20/28

62 LL(1) PRSING, LEFT-SSOITIVITY, ND L-TTRIBUTED GRMMRS (2) n LL(1) grmmr for the sme lnguge: PREDIT E TE $ {n} E ϵ {$} E TE {+, } T n {n} + {+} { } E T 10 E $ T 7 sub 3 sub 3 3 dd T 5 E + dd 5 5 ϵ E 20/28

63 LL(1) PRSING, LEFT-SSOITIVITY, ND L-TTRIBUTED GRMMRS (2) n LL(1) grmmr for the sme lnguge: PREDIT E TE $ {n} E ϵ {$} E TE {+, } T n {n} + {+} { } E T 10 E $ T 7 sub 3 sub 3 3 dd T 5 12 E + dd 5 5 ϵ E 20/28

64 LL(1) PRSING, LEFT-SSOITIVITY, ND L-TTRIBUTED GRMMRS (2) n LL(1) grmmr for the sme lnguge: PREDIT E TE $ {n} E ϵ {$} E TE {+, } T n {n} + {+} { } E T 10 E $ T 7 sub 3 sub 3 3 dd T 5 12 E + dd 5 5 ϵ E 12 20/28

65 LL(1) PRSING, LEFT-SSOITIVITY, ND L-TTRIBUTED GRMMRS (2) n LL(1) grmmr for the sme lnguge: PREDIT E TE $ {n} E ϵ {$} E TE {+, } T n {n} + {+} { } E T E $ T 7 E sub 3 sub 3 3 dd T 5 12 E + dd 5 5 ϵ 12 20/28

66 LL(1) PRSING, LEFT-SSOITIVITY, ND L-TTRIBUTED GRMMRS (2) n LL(1) grmmr for the sme lnguge: PREDIT E TE $ {n} E ϵ {$} E TE {+, } T n {n} + {+} { } E T 10 E $ T 7 E sub 3 sub 3 3 dd T 5 12 E + dd 5 5 ϵ 12 20/28

67 LL(1) PRSING, LEFT-SSOITIVITY, ND L-TTRIBUTED GRMMRS (2) n LL(1) grmmr for the sme lnguge: 12 PREDIT E E TE $ {n} T 10 E E 12 $ ϵ {$} 10 E TE {+, } T 7 E T n {n} sub 3 + {+} sub 3 3 T E dd { } dd 5 5 ϵ 12 20/28

68 LL(1) PRSING, LEFT-SSOITIVITY, ND L-TTRIBUTED GRMMRS (2) n LL(1) grmmr for the sme lnguge: E TE $ E ϵ E 1 TE 2 T n + {E.in = T.vl; E.vl = E.vl} {E.vl = E.in} {E 2.in =.fun(e 1.in, T.vl); E 1.vl = E 2.vl} {T.vl = n.vl} {T.fun = dd} {T.fun = sub} 20/28

69 ROD MP Syntx, semntis, nd semnti nlysis ttribute grmmrs tion routines bstrt syntx trees 21/28

70 ROD MP Syntx, semntis, nd semnti nlysis ttribute grmmrs tion routines bstrt syntx trees 21/28

71 TION ROUTINES tion routines re instrutions for d-ho trnsltion interleved with prsing. Prser genertors (e.g., bison or y) llow progrmmers to speify tion routines in the grmmr. tion routines n pper nywhere in rule (s long s the grmmr is LL(1)). 22/28

72 TION ROUTINES: EXMPLE Exmple: E T {$3.in = $1.fun($0.in, $2.vl)} E {$0.vl = $3.vl} 23/28

73 TION ROUTINES: EXMPLE Exmple: E T {$3.in = $1.fun($0.in, $2.vl)} E {$0.vl = $3.vl} orresponding prse funtion in reursive desent prser: def prseee(node0): node1 = PrseTreeNode() node2 = PrseTreeNode() node3 = PrseTreeNode() prse(node1) prset(node2) node3.op = node1.fun(node0.in, node2.vl) prseee(node3) node0.vl = node3.vl 23/28

74 ROD MP Syntx, semntis, nd semnti nlysis ttribute grmmrs tion routines bstrt syntx trees 24/28

75 ROD MP Syntx, semntis, nd semnti nlysis ttribute grmmrs tion routines bstrt syntx trees 24/28

76 BSTRT SYNTX TREES Problem with prse trees: They represent the full derivtion of the progrm using grmmr rules. Some grmmr vribles re there only to id in prsing (e.g., to eliminte left-reursion or ommon prefixes). ode genertor is esier to implement if the output of the prser is s ompt s possible. bstrt syntx tree (ST) ompressed prse tree tht represents the progrm struture rther thn the prsing proess. 25/28

77 BSTRT SYNTX TREE: EXMPLE (1) Fun fun id Stmts. Stmts ϵ Stmts Stmt Stmts Stmt... 26/28

78 BSTRT SYNTX TREE: EXMPLE (1) Fun fun id Stmts. Stmts ϵ Stmts Stmt Stmts Stmt... fun foo swp drop +. 26/28

79 BSTRT SYNTX TREE: EXMPLE (1) Fun fun id Stmts. Stmts ϵ Stmts Stmt Stmts Stmt... fun foo swp drop +. Fun fun id Stmts. Stmt (swp) Stmts Stmt (drop) Stmts Stmt (+) Stmts ϵ 26/28

80 BSTRT SYNTX TREE: EXMPLE (1) Fun fun id Stmts. Stmts ϵ Stmts Stmt Stmts Stmt... fun foo swp drop +. Fun fun id Stmts. ST: Stmt (swp) Stmts Fun Stmt (drop) Stmts id Stmts Stmt (+) Stmts Stmt (swp) Stmt (drop) Stmt (+) ϵ 26/28

81 BSTRT SYNTX TREE: EXMPLE (2) def prsefun(node0): node1 = PrseTreeNode() node2 = PrseTreeNode() mthfunkw() prseid(node1) prsesttements(node2) mthendkw() def prsesttements(node0): if next token is.: node0.sttements = [] else: node1 = PrseTreeNode() node2 = PrseTreeNode() prsesttement(node1) prsesttement(node2) node0.sttements = \ [node1.sttement] + \ node2.sttements Fun fun id Stmts. id Stmt (swp) Stmt (drop) Fun Stmts Stmt (+) Stmts Stmts Stmts Stmt (swp) Stmt (drop) Stmt (+) ϵ 27/28

82 SUMMRY Semnti nlysis ugments the prsing proess to represent the mening of the progrm. The output is often n nnotted bstrt syntx tree (ST). ttribute grmmrs nd tion routines re used to onstrut the ST. 28/28

Semantic Analysis. CSCI 3136 Principles of Programming Languages. Faculty of Computer Science Dalhousie University. Winter Reading: Chapter 4

Semantic Analysis. CSCI 3136 Principles of Programming Languages. Faculty of Computer Science Dalhousie University. Winter Reading: Chapter 4 Semnti nlysis SI 16 Priniples of Progrmming Lnguges Fulty of omputer Siene Dlhousie University Winter 2012 Reding: hpter 4 Motivtion Soure progrm (hrter strem) Snner (lexil nlysis) Front end Prse tree

More information

CS 314 Principles of Programming Languages

CS 314 Principles of Programming Languages C 314 Principles of Progrmming Lnguges Lecture 6: LL(1) Prsing Zheng (Eddy) Zhng Rutgers University Ferury 5, 2018 Clss Informtion Homework 2 due tomorrow. Homework 3 will e posted erly next week. 2 Top

More information

CS241 Week 6 Tutorial Solutions

CS241 Week 6 Tutorial Solutions 241 Week 6 Tutoril olutions Lnguges: nning & ontext-free Grmmrs Winter 2018 1 nning Exerises 1. 0x0x0xd HEXINT 0x0 I x0xd 2. 0xend--- HEXINT 0xe I nd ER -- MINU - 3. 1234-120x INT 1234 INT -120 I x 4.

More information

Formal Languages Simplifications of CFGs

Formal Languages Simplifications of CFGs Forml Lnguges implifictions of CFGs ubstitution Rule Equivlent grmmr b bc ubstitute b bc bbc b 2 ubstitution Rule b bc bbc ubstitute b bc bbc bc Equivlent grmmr 3 In generl: xz y 1 ubstitute y 1 xz xy1z

More information

Bottom-Up Parsing. Canonical Collection of LR(0) items. Part II

Bottom-Up Parsing. Canonical Collection of LR(0) items. Part II 2 ottom-up Prsing Prt II 1 Cnonil Colletion of LR(0) items CC_LR(0)_I items(g :ugmented_grmmr){ C = {CLOURE({ })} ; repet{ foreh(i C) foreh(grmmr symol X) if(goto(i,x) && GOTO(I,X) C) C = C {GOTO(I,X)};

More information

FABER Formal Languages, Automata and Models of Computation

FABER Formal Languages, Automata and Models of Computation DVA337 FABER Forml Lnguges, Automt nd Models of Computtion Lecture 5 chool of Innovtion, Design nd Engineering Mälrdlen University 2015 1 Recp of lecture 4 y definition suset construction DFA NFA stte

More information

Finite State Automata and Determinisation

Finite State Automata and Determinisation Finite Stte Automt nd Deterministion Tim Dworn Jnury, 2016 Lnguges fs nf re df Deterministion 2 Outline 1 Lnguges 2 Finite Stte Automt (fs) 3 Non-deterministi Finite Stte Automt (nf) 4 Regulr Expressions

More information

The University of Nottingham SCHOOL OF COMPUTER SCIENCE A LEVEL 2 MODULE, SPRING SEMESTER MACHINES AND THEIR LANGUAGES ANSWERS

The University of Nottingham SCHOOL OF COMPUTER SCIENCE A LEVEL 2 MODULE, SPRING SEMESTER MACHINES AND THEIR LANGUAGES ANSWERS The University of ottinghm SCHOOL OF COMPUTR SCIC A LVL 2 MODUL, SPRIG SMSTR 2015 2016 MACHIS AD THIR LAGUAGS ASWRS Time llowed TWO hours Cndidtes my omplete the front over of their nswer ook nd sign their

More information

CS 275 Automata and Formal Language Theory

CS 275 Automata and Formal Language Theory CS 275 Automt nd Forml Lnguge Theory Course Notes Prt II: The Recognition Problem (II) Chpter II.5.: Properties of Context Free Grmmrs (14) Anton Setzer (Bsed on book drft by J. V. Tucker nd K. Stephenson)

More information

Overview HC9. Parsing: Top-Down & LL(1) Context-Free Grammars (1) Introduction. CFGs (3) Context-Free Grammars (2) Vertalerbouw HC 9: Ch.

Overview HC9. Parsing: Top-Down & LL(1) Context-Free Grammars (1) Introduction. CFGs (3) Context-Free Grammars (2) Vertalerbouw HC 9: Ch. Overview H9 Vertlerouw H 9: Prsing: op-down & LL(1) do 3 mei 2001 56 heo Ruys h. 8 - Prsing 8.1 ontext-free Grmmrs 8.2 op-down Prsing 8.3 LL(1) Grmmrs See lso [ho, Sethi & Ullmn 1986] for more thorough

More information

Unit 4. Combinational Circuits

Unit 4. Combinational Circuits Unit 4. Comintionl Ciruits Digitl Eletroni Ciruits (Ciruitos Eletrónios Digitles) E.T.S.I. Informáti Universidd de Sevill 5/10/2012 Jorge Jun 2010, 2011, 2012 You re free to opy, distriute

More information

CS311 Computational Structures Regular Languages and Regular Grammars. Lecture 6

CS311 Computational Structures Regular Languages and Regular Grammars. Lecture 6 CS311 Computtionl Strutures Regulr Lnguges nd Regulr Grmmrs Leture 6 1 Wht we know so fr: RLs re losed under produt, union nd * Every RL n e written s RE, nd every RE represents RL Every RL n e reognized

More information

CSE 401 Compilers. Today s Agenda

CSE 401 Compilers. Today s Agenda CSE 401 Compilers Leture 3: Regulr Expressions & Snning, on?nued Mihel Ringenurg Tody s Agend Lst?me we reviewed lnguges nd grmmrs, nd riefly strted disussing regulr expressions. Tody I ll restrt the regulr

More information

The transformation to right derivation is called the canonical reduction sequence. Bottom-up analysis

The transformation to right derivation is called the canonical reduction sequence. Bottom-up analysis Bottom-up nlysis Shift-reduce prsing. Constructs the derivtion tree from ottom to top. Reduces the string to the strt symol. Produces reverse right derivtion. Exmple: G(E): 1. E E + T 2. T 3. T T * F 4.

More information

CSCI565 - Compiler Design

CSCI565 - Compiler Design CSCI565 - Compiler Deign Spring 6 Due Dte: Fe. 5, 6 t : PM in Cl Prolem [ point]: Regulr Expreion nd Finite Automt Develop regulr expreion (RE) tht detet the longet tring over the lphet {-} with the following

More information

Technische Universität München Winter term 2009/10 I7 Prof. J. Esparza / J. Křetínský / M. Luttenberger 11. Februar Solution

Technische Universität München Winter term 2009/10 I7 Prof. J. Esparza / J. Křetínský / M. Luttenberger 11. Februar Solution Tehnishe Universität Münhen Winter term 29/ I7 Prof. J. Esprz / J. Křetínský / M. Luttenerger. Ferur 2 Solution Automt nd Forml Lnguges Homework 2 Due 5..29. Exerise 2. Let A e the following finite utomton:

More information

q 2 in δ 2. [4: 1 mark q 1 in δ 1 and q 2 and (q 1, q 2 ) (q 1, q 2) whenever q 1 for each component] (b) The resulting DFA:

q 2 in δ 2. [4: 1 mark q 1 in δ 1 and q 2 and (q 1, q 2 ) (q 1, q 2) whenever q 1 for each component] (b) The resulting DFA: Module Title: Informtics 2A Exm Diet (Dec/April/Aug): Aug 2015 Brief notes on nswers: 1. () Lexing: The input is progrm text [1].The output is strem of lexemes pired with their lexicl clsses [1]. For exmple

More information

Parsing and Pattern Recognition

Parsing and Pattern Recognition Topics in IT Prsing nd Pttern Recognition Week Context-Free Prsing College of Informtion Science nd Engineering Ritsumeikn University this week miguity in nturl lnguge in mchine lnguges top-down, redth-first

More information

2.4 Theoretical Foundations

2.4 Theoretical Foundations 2 Progrmming Lnguge Syntx 2.4 Theoretil Fountions As note in the min text, snners n prsers re se on the finite utomt n pushown utomt tht form the ottom two levels of the Chomsky lnguge hierrhy. At eh level

More information

CS 330 Formal Methods and Models Dana Richards, George Mason University, Spring 2016 Quiz Solutions

CS 330 Formal Methods and Models Dana Richards, George Mason University, Spring 2016 Quiz Solutions CS 330 Forml Methods nd Models Dn Richrds, George Mson University, Spring 2016 Quiz Solutions Quiz 1, Propositionl Logic Dte: Ferury 9 1. (4pts) ((p q) (q r)) (p r), prove tutology using truth tles. p

More information

Cyclic Inputs. Surface Generation (Part II) Ambiguity-preserving Generation. Ambiguity-preserving Generation. Ambiguity-preserving Generation

Cyclic Inputs. Surface Generation (Part II) Ambiguity-preserving Generation. Ambiguity-preserving Generation. Ambiguity-preserving Generation Cyli Inputs The set of strings tht grmmr reltes to yli input struture might e non-ontext-free Surfe Genertion (Prt II) Amiguity-preserving Genertion Amiguity-preserving Genertion Motivtion Motivtion ()

More information

, g. Exercise 1. Generator polynomials of a convolutional code, given in binary form, are g. Solution 1.

, g. Exercise 1. Generator polynomials of a convolutional code, given in binary form, are g. Solution 1. Exerise Genertor polynomils of onvolutionl ode, given in binry form, re g, g j g. ) Sketh the enoding iruit. b) Sketh the stte digrm. ) Find the trnsfer funtion T. d) Wht is the minimum free distne of

More information

Metodologie di progetto HW Technology Mapping. Last update: 19/03/09

Metodologie di progetto HW Technology Mapping. Last update: 19/03/09 Metodologie di progetto HW Tehnology Mpping Lst updte: 19/03/09 Tehnology Mpping 2 Tehnology Mpping Exmple: t 1 = + b; t 2 = d + e; t 3 = b + d; t 4 = t 1 t 2 + fg; t 5 = t 4 h + t 2 t 3 ; F = t 5 ; t

More information

I. Theory of Automata II. Theory of Formal Languages III. Theory of Turing Machines

I. Theory of Automata II. Theory of Formal Languages III. Theory of Turing Machines CI 3104 /Winter 2011: Introduction to Forml Lnguges Chpter 16: Non-Context-Free Lnguges Chpter 16: Non-Context-Free Lnguges I. Theory of utomt II. Theory of Forml Lnguges III. Theory of Turing Mchines

More information

For convenience, we rewrite m2 s m2 = m m m ; where m is repeted m times. Since xyz = m m m nd jxyj»m, we hve tht the string y is substring of the fir

For convenience, we rewrite m2 s m2 = m m m ; where m is repeted m times. Since xyz = m m m nd jxyj»m, we hve tht the string y is substring of the fir CSCI 2400 Models of Computtion, Section 3 Solutions to Homework 4 Problem 1. ll the solutions below refer to the Pumping Lemm of Theorem 4.8, pge 119. () L = f n b l k : k n + lg Let's ssume for contrdiction

More information

Parse trees, ambiguity, and Chomsky normal form

Parse trees, ambiguity, and Chomsky normal form Prse trees, miguity, nd Chomsky norml form In this lecture we will discuss few importnt notions connected with contextfree grmmrs, including prse trees, miguity, nd specil form for context-free grmmrs

More information

arxiv: v2 [cs.lo] 24 Feb 2017

arxiv: v2 [cs.lo] 24 Feb 2017 Lol Lexing teven Ou University of dinurgh steven.ou@gmil.om Phil ott University of dinurgh phil.sott@ed..u Jques Fleuriot University of dinurgh jdf@inf.ed..u rxiv:1702.03277v2 [s.lo] 24 Fe 2017 strt We

More information

CS 275 Automata and Formal Language Theory

CS 275 Automata and Formal Language Theory CS 275 utomt nd Forml Lnguge Theory Course Notes Prt II: The Recognition Prolem (II) Chpter II.5.: Properties of Context Free Grmmrs (14) nton Setzer (Bsed on ook drft y J. V. Tucker nd K. Stephenson)

More information

Engr354: Digital Logic Circuits

Engr354: Digital Logic Circuits Engr354: Digitl Logi Ciruits Chpter 4: Logi Optimiztion Curtis Nelson Logi Optimiztion In hpter 4 you will lern out: Synthesis of logi funtions; Anlysis of logi iruits; Tehniques for deriving minimum-ost

More information

Nondeterministic Automata vs Deterministic Automata

Nondeterministic Automata vs Deterministic Automata Nondeterministi Automt vs Deterministi Automt We lerned tht NFA is onvenient model for showing the reltionships mong regulr grmmrs, FA, nd regulr expressions, nd designing them. However, we know tht n

More information

a b b a pop push read unread

a b b a pop push read unread A Finite Automton A Pushdown Automton 0000 000 red unred b b pop red unred push 2 An Exmple A Pushdown Automton Recll tht 0 n n not regulr. cn push symbols onto the stck cn pop them (red them bck) lter

More information

Memory Minimization for Tensor Contractions using Integer Linear Programming.

Memory Minimization for Tensor Contractions using Integer Linear Programming. Memory Minimiztion for Tensor Contrtions using Integer Liner Progrmming A. Allm 1, J. Rmnujm 1, G. Bumgrtner 2, nd P. Sdyppn 3 1 Deprtment of Eletril nd Computer Engineering, Louisin Stte University, USA

More information

Global alignment. Genome Rearrangements Finding preserved genes. Lecture 18

Global alignment. Genome Rearrangements Finding preserved genes. Lecture 18 Computt onl Biology Leture 18 Genome Rerrngements Finding preserved genes We hve seen before how to rerrnge genome to obtin nother one bsed on: Reversls Knowledge of preserved bloks (or genes) Now we re

More information

1.4 Nonregular Languages

1.4 Nonregular Languages 74 1.4 Nonregulr Lnguges The number of forml lnguges over ny lphbet (= decision/recognition problems) is uncountble On the other hnd, the number of regulr expressions (= strings) is countble Hence, ll

More information

RELATIONAL MODEL.

RELATIONAL MODEL. RELATIONAL MODEL Structure of Reltionl Dtbses Reltionl Algebr Tuple Reltionl Clculus Domin Reltionl Clculus Extended Reltionl-Algebr- Opertions Modifiction of the Dtbse Views EXAMPLE OF A RELATION BASIC

More information

Part 4. Integration (with Proofs)

Part 4. Integration (with Proofs) Prt 4. Integrtion (with Proofs) 4.1 Definition Definition A prtition P of [, b] is finite set of points {x 0, x 1,..., x n } with = x 0 < x 1

More information

Non Deterministic Automata. Formal Languages and Automata - Yonsei CS 1

Non Deterministic Automata. Formal Languages and Automata - Yonsei CS 1 Non Deterministic Automt Forml Lnguges nd Automt - Yonsei CS 1 Nondeterministic Finite Accepter (NFA) We llow set of possible moves insted of A unique move. Alphbet = {} Two choices q 1 q2 Forml Lnguges

More information

Instructions. An 8.5 x 11 Cheat Sheet may also be used as an aid for this test. MUST be original handwriting.

Instructions. An 8.5 x 11 Cheat Sheet may also be used as an aid for this test. MUST be original handwriting. ID: B CSE 2021 Computer Orgniztion Midterm Test (Fll 2009) Instrutions This is losed ook, 80 minutes exm. The MIPS referene sheet my e used s n id for this test. An 8.5 x 11 Chet Sheet my lso e used s

More information

TIME AND STATE IN DISTRIBUTED SYSTEMS

TIME AND STATE IN DISTRIBUTED SYSTEMS Distriuted Systems Fö 5-1 Distriuted Systems Fö 5-2 TIME ND STTE IN DISTRIUTED SYSTEMS 1. Time in Distriuted Systems Time in Distriuted Systems euse eh mhine in distriuted system hs its own lok there is

More information

Nondeterministic Finite Automata

Nondeterministic Finite Automata Nondeterministi Finite utomt The Power of Guessing Tuesdy, Otoer 4, 2 Reding: Sipser.2 (first prt); Stoughton 3.3 3.5 S235 Lnguges nd utomt eprtment of omputer Siene Wellesley ollege Finite utomton (F)

More information

Lecture 6 Regular Grammars

Lecture 6 Regular Grammars Lecture 6 Regulr Grmmrs COT 4420 Theory of Computtion Section 3.3 Grmmr A grmmr G is defined s qudruple G = (V, T, S, P) V is finite set of vribles T is finite set of terminl symbols S V is specil vrible

More information

CS375: Logic and Theory of Computing

CS375: Logic and Theory of Computing CS375: Logic nd Theory of Computing Fuhu (Frnk) Cheng Deprtment of Computer Science University of Kentucky 1 Tble of Contents: Week 1: Preliminries (set lgebr, reltions, functions) (red Chpters 1-4) Weeks

More information

CS 330 Formal Methods and Models

CS 330 Formal Methods and Models CS 330 Forml Methods nd Models Dn Richrds, George Mson University, Spring 2017 Quiz Solutions Quiz 1, Propositionl Logic Dte: Ferury 2 1. Prove ((( p q) q) p) is tutology () (3pts) y truth tle. p q p q

More information

System Validation (IN4387) November 2, 2012, 14:00-17:00

System Validation (IN4387) November 2, 2012, 14:00-17:00 System Vlidtion (IN4387) Novemer 2, 2012, 14:00-17:00 Importnt Notes. The exmintion omprises 5 question in 4 pges. Give omplete explntion nd do not onfine yourself to giving the finl nswer. Good luk! Exerise

More information

Alpha Algorithm: A Process Discovery Algorithm

Alpha Algorithm: A Process Discovery Algorithm Proess Mining: Dt Siene in Ation Alph Algorithm: A Proess Disovery Algorithm prof.dr.ir. Wil vn der Alst www.proessmining.org Proess disovery = Ply-In Ply-In event log proess model Ply-Out Reply proess

More information

AVL Trees. D Oisín Kidney. August 2, 2018

AVL Trees. D Oisín Kidney. August 2, 2018 AVL Trees D Oisín Kidne August 2, 2018 Astrt This is verified implementtion of AVL trees in Agd, tking ides primril from Conor MBride s pper How to Keep Your Neighours in Order [2] nd the Agd stndrd lirr

More information

Unfoldings of Networks of Timed Automata

Unfoldings of Networks of Timed Automata Unfolings of Networks of Time Automt Frnk Cssez Thoms Chtin Clue Jr Ptrii Bouyer Serge H Pierre-Alin Reynier Rennes, Deemer 3, 2008 Unfolings [MMilln 93] First efine for Petri nets Then extene to other

More information

INTEGRATION. 1 Integrals of Complex Valued functions of a REAL variable

INTEGRATION. 1 Integrals of Complex Valued functions of a REAL variable INTEGRATION NOTE: These notes re supposed to supplement Chpter 4 of the online textbook. 1 Integrls of Complex Vlued funtions of REAL vrible If I is n intervl in R (for exmple I = [, b] or I = (, b)) nd

More information

Closure Properties of Regular Languages

Closure Properties of Regular Languages Closure Properties of Regulr Lnguges Regulr lnguges re closed under mny set opertions. Let L 1 nd L 2 e regulr lnguges. (1) L 1 L 2 (the union) is regulr. (2) L 1 L 2 (the conctention) is regulr. (3) L

More information

CS 275 Automata and Formal Language Theory

CS 275 Automata and Formal Language Theory CS 275 Automt nd Forml Lnguge Theory Course Notes Prt II: The Recognition Problem (II) Chpter II.6.: Push Down Automt Remrk: This mteril is no longer tught nd not directly exm relevnt Anton Setzer (Bsed

More information

Compiler Design. Spring Lexical Analysis. Sample Exercises and Solutions. Prof. Pedro C. Diniz

Compiler Design. Spring Lexical Analysis. Sample Exercises and Solutions. Prof. Pedro C. Diniz University of Southern Cliforni Computer Siene Deprtment Compiler Design Spring 7 Lexil Anlysis Smple Exerises nd Solutions Prof. Pedro C. Diniz USC / Informtion Sienes Institute 47 Admirlty Wy, Suite

More information

Chapter 4 Regular Grammar and Regular Sets. (Solutions / Hints)

Chapter 4 Regular Grammar and Regular Sets. (Solutions / Hints) C K Ngpl Forml Lnguges nd utomt Theory Chpter 4 Regulr Grmmr nd Regulr ets (olutions / Hints) ol. (),,,,,,,,,,,,,,,,,,,,,,,,,, (),, (c) c c, c c, c, c, c c, c, c, c, c, c, c, c c,c, c, c, c, c, c, c, c,

More information

5. Every rational number have either terminating or repeating (recurring) decimal representation.

5. Every rational number have either terminating or repeating (recurring) decimal representation. CHAPTER NUMBER SYSTEMS Points to Rememer :. Numer used for ounting,,,,... re known s Nturl numers.. All nturl numers together with zero i.e. 0,,,,,... re known s whole numers.. All nturl numers, zero nd

More information

Pre-Lie algebras, rooted trees and related algebraic structures

Pre-Lie algebras, rooted trees and related algebraic structures Pre-Lie lgers, rooted trees nd relted lgeri strutures Mrh 23, 2004 Definition 1 A pre-lie lger is vetor spe W with mp : W W W suh tht (x y) z x (y z) = (x z) y x (z y). (1) Exmple 2 All ssoitive lgers

More information

Non-Deterministic Finite Automata

Non-Deterministic Finite Automata Non-Deterministic Finite Automt http://users.comlb.ox.c.uk/luke. ong/teching/moc/nf2up.pdf 1 Nondeterministic Finite Automton (NFA) Alphbet ={} q1 q2 2 Alphbet ={} Two choices q1 q2 3 Alphbet ={} Two choices

More information

Languages and Computation (G52LAC) Lecture notes Spring 2018

Languages and Computation (G52LAC) Lecture notes Spring 2018 Lnguges nd Computtion (G52LAC) Leture notes Spring 28 Thorsten Altenkirh, Vennzio Cprett, nd Henrik Nilsson Contents Ferury 2, 28 Introdution 4. Exmple: Vlid Jv progrms................... 4.2 Exmple: The

More information

Review of CFGs and Parsing I Context-free Languages and Grammars. Winter 2014 Costas Busch - RPI 1

Review of CFGs and Parsing I Context-free Languages and Grammars. Winter 2014 Costas Busch - RPI 1 Review of CFGs d Prsig I Cotext-free Lguges d Grmmrs Witer 2014 Costs Busch - RPI 1 Cotext-Free Lguges { b : { ww } 0} R Regulr Lguges *b* ( b) * Witer 2014 Costs Busch - RPI 2 Cotext-Free Lguges Cotext-Free

More information

Linear Algebra Introduction

Linear Algebra Introduction Introdution Wht is Liner Alger out? Liner Alger is rnh of mthemtis whih emerged yers k nd ws one of the pioneer rnhes of mthemtis Though, initilly it strted with solving of the simple liner eqution x +

More information

Bisimulation, Games & Hennessy Milner logic

Bisimulation, Games & Hennessy Milner logic Bisimultion, Gmes & Hennessy Milner logi Leture 1 of Modelli Mtemtii dei Proessi Conorrenti Pweł Soboiński Univeristy of Southmpton, UK Bisimultion, Gmes & Hennessy Milner logi p.1/32 Clssil lnguge theory

More information

1 PYTHAGORAS THEOREM 1. Given a right angled triangle, the square of the hypotenuse is equal to the sum of the squares of the other two sides.

1 PYTHAGORAS THEOREM 1. Given a right angled triangle, the square of the hypotenuse is equal to the sum of the squares of the other two sides. 1 PYTHAGORAS THEOREM 1 1 Pythgors Theorem In this setion we will present geometri proof of the fmous theorem of Pythgors. Given right ngled tringle, the squre of the hypotenuse is equl to the sum of the

More information

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018 Finite Automt Theory nd Forml Lnguges TMV027/DIT321 LP4 2018 Lecture 10 An Bove April 23rd 2018 Recp: Regulr Lnguges We cn convert between FA nd RE; Hence both FA nd RE ccept/generte regulr lnguges; More

More information

Non Deterministic Automata. Linz: Nondeterministic Finite Accepters, page 51

Non Deterministic Automata. Linz: Nondeterministic Finite Accepters, page 51 Non Deterministic Automt Linz: Nondeterministic Finite Accepters, pge 51 1 Nondeterministic Finite Accepter (NFA) Alphbet ={} q 1 q2 q 0 q 3 2 Nondeterministic Finite Accepter (NFA) Alphbet ={} Two choices

More information

CS 573 Automata Theory and Formal Languages

CS 573 Automata Theory and Formal Languages Non-determinism Automt Theory nd Forml Lnguges Professor Leslie Lnder Leture # 3 Septemer 6, 2 To hieve our gol, we need the onept of Non-deterministi Finite Automton with -moves (NFA) An NFA is tuple

More information

Lecture Notes No. 10

Lecture Notes No. 10 2.6 System Identifition, Estimtion, nd Lerning Leture otes o. Mrh 3, 26 6 Model Struture of Liner ime Invrint Systems 6. Model Struture In representing dynmil system, the first step is to find n pproprite

More information

SWEN 224 Formal Foundations of Programming WITH ANSWERS

SWEN 224 Formal Foundations of Programming WITH ANSWERS T E W H A R E W Ā N A N G A O T E Ū P O K O O T E I K A A M Ā U I VUW V I C T O R I A UNIVERSITY OF WELLINGTON Time Allowed: 3 Hours EXAMINATIONS 2011 END-OF-YEAR SWEN 224 Forml Foundtions of Progrmming

More information

XML and Databases. Exam Preperation Discuss Answers to last year s exam. Sebastian Maneth NICTA and UNSW

XML and Databases. Exam Preperation Discuss Answers to last year s exam. Sebastian Maneth NICTA and UNSW XML n Dtses Exm Prepertion Disuss Answers to lst yer s exm Sestin Mneth NICTA n UNSW CSE@UNSW -- Semester 1, 2008 (1) For eh of the following, explin why it is not well-forme XML (is WFC or the XML grmmr

More information

XML and Databases. Outline. 1. Top-Down Evaluation of Simple Paths. 1. Top-Down Evaluation of Simple Paths. 1. Top-Down Evaluation of Simple Paths

XML and Databases. Outline. 1. Top-Down Evaluation of Simple Paths. 1. Top-Down Evaluation of Simple Paths. 1. Top-Down Evaluation of Simple Paths Outline Leture Effiient XPth Evlution XML n Dtses. Top-Down Evlution of simple pths. Noe Sets only: Core XPth. Bottom-Up Evlution of Core XPth. Polynomil Time Evlution of Full XPth Sestin Mneth NICTA n

More information

Solving Fixed-Point Equations by Derivation Tree Analysis

Solving Fixed-Point Equations by Derivation Tree Analysis Solving Fixed-Point Equtions by Derivtion Tree Anlysis Jvier Esprz nd Mihel Luttenberger Institut für Informtik, Tehnishe Universität Münhen, 85748 Grhing, Germny {esprz,luttenbe}@in.tum.de Abstrt. Systems

More information

Matrices SCHOOL OF ENGINEERING & BUILT ENVIRONMENT. Mathematics (c) 1. Definition of a Matrix

Matrices SCHOOL OF ENGINEERING & BUILT ENVIRONMENT. Mathematics (c) 1. Definition of a Matrix tries Definition of tri mtri is regulr rry of numers enlosed inside rkets SCHOOL OF ENGINEERING & UIL ENVIRONEN Emple he following re ll mtries: ), ) 9, themtis ), d) tries Definition of tri Size of tri

More information

Refined interfaces for compositional verification

Refined interfaces for compositional verification Refined interfces for compositionl verifiction Frédéric Lng INRI Rhône-lpes http://www.inrilpes.fr/vsy Motivtion Enumertive verifiction of concurrent systems Prllel composition of synchronous processes

More information

arxiv: v1 [math.ca] 21 Aug 2018

arxiv: v1 [math.ca] 21 Aug 2018 rxiv:1808.07159v1 [mth.ca] 1 Aug 018 Clulus on Dul Rel Numbers Keqin Liu Deprtment of Mthemtis The University of British Columbi Vnouver, BC Cnd, V6T 1Z Augest, 018 Abstrt We present the bsi theory of

More information

Tutorial Worksheet. 1. Find all solutions to the linear system by following the given steps. x + 2y + 3z = 2 2x + 3y + z = 4.

Tutorial Worksheet. 1. Find all solutions to the linear system by following the given steps. x + 2y + 3z = 2 2x + 3y + z = 4. Mth 5 Tutoril Week 1 - Jnury 1 1 Nme Setion Tutoril Worksheet 1. Find ll solutions to the liner system by following the given steps x + y + z = x + y + z = 4. y + z = Step 1. Write down the rgumented mtrix

More information

CSC 473 Automata, Grammars & Languages 11/9/10

CSC 473 Automata, Grammars & Languages 11/9/10 CSC 473 utomt, Grmmrs & Lnguges 11/9/10 utomt, Grmmrs nd Lnguges Discourse 06 Decidbility nd Undecidbility Decidble Problems for Regulr Lnguges Theorem 4.1: (embership/cceptnce Prob. for DFs) = {, w is

More information

Automatic Verification of Pointer Programs Using Grammar-Based Shape Analysis

Automatic Verification of Pointer Programs Using Grammar-Based Shape Analysis Automti Verifition of Pointer Progrms Using Grmmr-Bsed Shpe Anlysis Oukseh Lee 1, Hongseok Yng 2, nd Kwngkeun Yi 3 1 Dept. of Computer Siene & Engineering, Hnyng University, Kore 2 ERC-ACI, Seoul Ntionl

More information

1.3 Regular Expressions

1.3 Regular Expressions 56 1.3 Regulr xpressions These hve n importnt role in describing ptterns in serching for strings in mny pplictions (e.g. wk, grep, Perl,...) All regulr expressions of lphbet re 1.Ønd re regulr expressions,

More information

Greedy regular expression matching

Greedy regular expression matching Alin Frisch INRIA Luc Crdelli MSRC 2004-05-15 ICALP The mtching prolem The prolem Project the structure of regulr expression on flt sequence. R = ( ) w = 1 2 1 2 3 v = [1 : [ 1 ; 2 ]; 2 : 1 ; 2 : 2 ; 1

More information

Non-Deterministic Finite Automata. Fall 2018 Costas Busch - RPI 1

Non-Deterministic Finite Automata. Fall 2018 Costas Busch - RPI 1 Non-Deterministic Finite Automt Fll 2018 Costs Busch - RPI 1 Nondeterministic Finite Automton (NFA) Alphbet ={} q q2 1 q 0 q 3 Fll 2018 Costs Busch - RPI 2 Nondeterministic Finite Automton (NFA) Alphbet

More information

Review: The Riemann Integral Review: The definition of R b

Review: The Riemann Integral Review: The definition of R b eview: The iemnn Integrl eview: The definition of b f (x)dx. For ontinuous funtion f on the intervl [, b], Z b f (x) dx lim mx x i!0 nx i1 f (x i ) x i. This limit omputes the net (signed) re under the

More information

Nondeterminism. Nondeterministic Finite Automata. Example: Moves on a Chessboard. Nondeterminism (2) Example: Chessboard (2) Formal NFA

Nondeterminism. Nondeterministic Finite Automata. Example: Moves on a Chessboard. Nondeterminism (2) Example: Chessboard (2) Formal NFA Nondeterminism Nondeterministic Finite Automt Nondeterminism Subset Construction A nondeterministic finite utomton hs the bility to be in severl sttes t once. Trnsitions from stte on n input symbol cn

More information

Lecture 6. Notes. Notes. Notes. Representations Z A B and A B R. BTE Electronics Fundamentals August Bern University of Applied Sciences

Lecture 6. Notes. Notes. Notes. Representations Z A B and A B R. BTE Electronics Fundamentals August Bern University of Applied Sciences Lecture 6 epresenttions epresenttions TE52 - Electronics Fundmentls ugust 24 ern University of pplied ciences ev. c2d5c88 6. Integers () sign-nd-mgnitude representtion The set of integers contins the Nturl

More information

KNOWLEDGE-BASED AGENTS INFERENCE

KNOWLEDGE-BASED AGENTS INFERENCE AGENTS THAT REASON LOGICALLY KNOWLEDGE-BASED AGENTS Two components: knowledge bse, nd n inference engine. Declrtive pproch to building n gent. We tell it wht it needs to know, nd It cn sk itself wht to

More information

Review for the Midterm

Review for the Midterm Review for the Midterm Stephen A. Edwrds Columi University Fll 2018 The Midterm Structure of Compiler Scnning Lnguges nd Regulr Expressions NFAs Trnslting REs into NFAs: Thompson s Construction Building

More information

Algorithms & Data Structures Homework 8 HS 18 Exercise Class (Room & TA): Submitted by: Peer Feedback by: Points:

Algorithms & Data Structures Homework 8 HS 18 Exercise Class (Room & TA): Submitted by: Peer Feedback by: Points: Eidgenössishe Tehnishe Hohshule Zürih Eole polytehnique fédérle de Zurih Politenio federle di Zurigo Federl Institute of Tehnology t Zurih Deprtement of Computer Siene. Novemer 0 Mrkus Püshel, Dvid Steurer

More information

Prefix-Free Regular-Expression Matching

Prefix-Free Regular-Expression Matching Prefix-Free Regulr-Expression Mthing Yo-Su Hn, Yjun Wng nd Derik Wood Deprtment of Computer Siene HKUST Prefix-Free Regulr-Expression Mthing p.1/15 Pttern Mthing Given pttern P nd text T, find ll sustrings

More information

Lecture 3 Gaussian Probability Distribution

Lecture 3 Gaussian Probability Distribution Introduction Lecture 3 Gussin Probbility Distribution Gussin probbility distribution is perhps the most used distribution in ll of science. lso clled bell shped curve or norml distribution Unlike the binomil

More information

Petri Nets. Rebecca Albrecht. Seminar: Automata Theory Chair of Software Engeneering

Petri Nets. Rebecca Albrecht. Seminar: Automata Theory Chair of Software Engeneering Petri Nets Ree Alreht Seminr: Automt Theory Chir of Softwre Engeneering Overview 1. Motivtion: Why not just using finite utomt for everything? Wht re Petri Nets nd when do we use them? 2. Introdution:

More information

Normal Forms for Context-free Grammars

Normal Forms for Context-free Grammars Norml Forms for Context-free Grmmrs 1 Linz 6th, Section 6.2 wo Importnt Norml Forms, pges 171--178 2 Chomsky Norml Form All productions hve form: A BC nd A vrile vrile terminl 3 Exmples: S AS S AS S S

More information

8 THREE PHASE A.C. CIRCUITS

8 THREE PHASE A.C. CIRCUITS 8 THREE PHSE.. IRUITS The signls in hpter 7 were sinusoidl lternting voltges nd urrents of the so-lled single se type. n emf of suh type n e esily generted y rotting single loop of ondutor (or single winding),

More information

Electromagnetism Notes, NYU Spring 2018

Electromagnetism Notes, NYU Spring 2018 Eletromgnetism Notes, NYU Spring 208 April 2, 208 Ation formultion of EM. Free field desription Let us first onsider the free EM field, i.e. in the bsene of ny hrges or urrents. To tret this s mehnil system

More information

Automata and Languages

Automata and Languages Automt nd Lnguges Prof. Mohmed Hmd Softwre Engineering Lb. The University of Aizu Jpn Grmmr Regulr Grmmr Context-free Grmmr Context-sensitive Grmmr Regulr Lnguges Context Free Lnguges Context Sensitive

More information

NFAs continued, Closure Properties of Regular Languages

NFAs continued, Closure Properties of Regular Languages lgorithms & Models of omputtion S/EE 374, Spring 209 NFs continued, losure Properties of Regulr Lnguges Lecture 5 Tuesdy, Jnury 29, 209 Regulr Lnguges, DFs, NFs Lnguges ccepted y DFs, NFs, nd regulr expressions

More information

Physics 116C Solution of inhomogeneous ordinary differential equations using Green s functions

Physics 116C Solution of inhomogeneous ordinary differential equations using Green s functions Physics 6C Solution of inhomogeneous ordinry differentil equtions using Green s functions Peter Young November 5, 29 Homogeneous Equtions We hve studied, especilly in long HW problem, second order liner

More information

Informatics 2A: Lecture 20. Shay Cohen. 31 October 2017

Informatics 2A: Lecture 20. Shay Cohen. 31 October 2017 Informtics 2: Lecture 20 Shy Cohen 31 October 2017 1 / 32 Lst Clss Constituents nd Phrses: phrse inherits the ctegory of its hed. mbiguity: sentence cn hve multiple prse trees (or multiple POS nlyses)

More information

Formal Methods for XML: Algorithms & Complexity

Formal Methods for XML: Algorithms & Complexity Forml Methods for XML: Algorithms & Complexity S. Mrgherit di Pul August 2004 Thoms Shwentik Shwentik XML: Algorithms & Complexity Introdution 1 XML Exmple Doument Composer Nme Clude Debussy /Nme Vit Born

More information

Math 32B Discussion Session Week 8 Notes February 28 and March 2, f(b) f(a) = f (t)dt (1)

Math 32B Discussion Session Week 8 Notes February 28 and March 2, f(b) f(a) = f (t)dt (1) Green s Theorem Mth 3B isussion Session Week 8 Notes Februry 8 nd Mrh, 7 Very shortly fter you lerned how to integrte single-vrible funtions, you lerned the Fundmentl Theorem of lulus the wy most integrtion

More information

A Functorial Query Language

A Functorial Query Language A Funtoril Query Lnguge Ryn Wisnesky, Dvid Spivk Deprtment of Mthemtis Msshusetts Institute of Tehnology {wisnesky, dspivk}@mth.mit.edu Presented t Boston Hskell April 16, 2014 Outline Introdution to FQL.

More information

where the box contains a finite number of gates from the given collection. Examples of gates that are commonly used are the following: a b

where the box contains a finite number of gates from the given collection. Examples of gates that are commonly used are the following: a b CS 294-2 9/11/04 Quntum Ciruit Model, Solovy-Kitev Theorem, BQP Fll 2004 Leture 4 1 Quntum Ciruit Model 1.1 Clssil Ciruits - Universl Gte Sets A lssil iruit implements multi-output oolen funtion f : {0,1}

More information

Project 6: Minigoals Towards Simplifying and Rewriting Expressions

Project 6: Minigoals Towards Simplifying and Rewriting Expressions MAT 51 Wldis Projet 6: Minigols Towrds Simplifying nd Rewriting Expressions The distriutive property nd like terms You hve proly lerned in previous lsses out dding like terms ut one prolem with the wy

More information

Where did dynamic programming come from?

Where did dynamic programming come from? Where did dynmic progrmming come from? String lgorithms Dvid Kuchk cs302 Spring 2012 Richrd ellmn On the irth of Dynmic Progrmming Sturt Dreyfus http://www.eng.tu.c.il/~mi/cd/ or50/1526-5463-2002-50-01-0048.pdf

More information

Intermediate Math Circles Wednesday 17 October 2012 Geometry II: Side Lengths

Intermediate Math Circles Wednesday 17 October 2012 Geometry II: Side Lengths Intermedite Mth Cirles Wednesdy 17 Otoer 01 Geometry II: Side Lengths Lst week we disussed vrious ngle properties. As we progressed through the evening, we proved mny results. This week, we will look t

More information