XML and Databases. Outline. Previous Lecture. XML Type Definition Languages. Sebastian Maneth NICTA and UNSW

Size: px
Start display at page:

Download "XML and Databases. Outline. Previous Lecture. XML Type Definition Languages. Sebastian Maneth NICTA and UNSW"

Transcription

1 Outline XML nd Dtses Lecture 5 XML Vlidtion using Automt Sestin Mneth NICA nd UNSW. Recp: deterministic Reg Expr s / Glushkov Automton. Complexity of DD vlidtion. Beyond DDs: XML Schem nd RELAX NG 4. Sttic Methods, sed on ree Automt CSE@UNSW -- Semester, 009 Previous Lecture XML ype Definition Lnguges 4 XML type definition lnguges wnt to specify certin suset of XML doc s = type of XML documents Rememer he specifiction/type definition should e simple, so tht vlidtor cn e uilt utomticlly (nd efficiently) the vlidtor runs efficient on ny XML input (similr demnds s for prser) DD (Document ype Definition, WC) Originted from SGML. Now prt of XML DD my pper t the eginning of n XML document XML Schem (WC) Now t version. HUGE lnguge, mny uilt-in simple types Schems themselves: written in XML Reg Exprs must e deterministic (=-unmiguous) sme!! Unique Prticle Attriution ype def. lnguge must e SIMPLE! (similrly: prser genertors use EBN or smller suclsses: LL / LR) See the Schem Primer t RELAX NG (Osis) or tree structure definition, more powerful thn Schems&DDs O(n^) prsing XML ype Definition Lnguges 5 XML ype Definition Lnguges 6 DD (Document ype Definition) DD (Document ype Definition) <!DOCYPE root-element [ doctype declrtion ]> <!DOCYPE root-element [ doctype declrtion ]> <!ELEMEN element-nme content-model> content-models EMPY ANY (#PCDAA elem-nme_ elem-nme_n)* deterministic Reg Expr over element nmes <!ELEMEN element-nme content-model> content-models EMPY ANY (#PCDAA elem-nme_ elem-nme_n)* deterministic Reg Expr Most interesting / chllenging spect of DDs <!ALIS element-nme ttr-nme ttr-type ttr-defult..> ypes: CDAA, (v..), ID, IDREs Defults: #REQUIRED, #IMPLIED, vlue, #IXED <!ALIS element-nme ttr-nme ttr-type ttr-defult..> ypes: CDAA, (v..), ID, IDREs Defults: #REQUIRED, #IMPLIED, vlue, #IXED

2 7 8 Summry In order to check whether (lrge) document is vlid wrt to given DD ( it vlidtes ) you need to check if children lists mtch the given Reg Expr s Summry In order to check whether (lrge) document is vlid wrt to given DD ( it vlidtes ) you need to check if children lists mtch the given Reg Expr s his cn e done efficiently, using finite-utomt (As)! his cn e done efficiently, using finite-utomt (As)! o check if Reg Expr e is llowed in DD we hve to construct prticulr finite utomton: the Glushkov utomton. o check if Reg Expr e is llowed in DD we hve to construct prticulr finite utomton: the Glushkov utomton. Glu(e) must e deterministic. Glu(e) Glu(e) must e deterministic. Glu(e) Note If Glu(e) is deterministic, then its size (# trnsitions) is liner in size(e)! Note If Glu(e) is deterministic, then its size (# trnsitions) is liner in size(e)! Cn you explin why this is the cse? 9 0 Summry More Notes In order to check whether (lrge) document is vlid wrt to given DD ( it vlidtes ) you need to check if children lists mtch the given Reg Expr s () rom deterministic A you cnnot necessrily otin deterministic (= -unmiguous) regulr expression!! Exmple: e = ( )* ( ) NO -unmigous reg exp exists for e his cn e done efficiently, using finite-utomt (As)! o check if Reg Expr e is llowed in DD we hve to construct prticulr finite utomton: the Glushkov utomton. o check if Reg Expr e is llowed in DD we hve to construct prticulr finite utomton: the Glushkov utomton. Glu(e) must e deterministic. Glu(e) Glu(e) must e deterministic. Glu(e) Note If Glu(e) is deterministic, then its size (# trnsitions) is liner in size(e)! Note If Glu(e) is deterministic, then its size (# trnsitions) is liner in size(e)! Cn you explin why this is the cse? not correct: liner in size(e) * #letters(e) Cn you explin why this is the cse? not correct: liner in size(e) * #letters(e) More Notes () rom deterministic A you cnnot necessrily otin deterministic (= -unmiguous) regulr expression!! Exmple: e = ( )* ( ) or more detils: See pper y Brüggemnn-Klein, Linked from the course we-pge. NO -unmigous reg exp exists for e () Glu(e) is closely relted to homson(e) [remove ε-trnsitions] nd to Berry/Sethi(e) [sme] nd Brzozowski(e) Glushkov utomton Glu(e) Ech letter-position in the Reg Expr e ecomes one stte of Glu; plus, Glu hs one extr egin stte. IRS( e ) = ll possile egin positions of words mtching e e.g. IRS( R (E G) (EX)* ) = { R } o check if Reg Expr e is llowed in DD we hve to construct prticulr finite utomton: the Glushkov utomton. Glu(e) must e deterministic. Glu(e) Note If Glu(e) is deterministic, then its size (# trnsitions) is liner in size(e)! Cn you explin why this is the cse? not correct: liner in size(e) * #letters(e)

3 4 position position position 5... ollowing slides from: IRS( e )

4 9 0 Glushkov utomton G(e) Ech position in the Reg Expr e ecomes one stte of G; plus, G hs one extr egin stte. IRS( e ) = ll possile egin positions of words mtching e e.g. IRS( R (E G) (EX)* ) = { R } OLLOW( e, x ) = ll possile positions following position x in e e.g. OLLOW( R (E G) (EX)*, R ) = { E, G } rom stte R : dd E-trnsition to E G-trnsition to G OLLOW( e, R ) = OLLOW( e, E ) = 4 OLLOW( e, E 4 ) = OLLOW( e, G ) = 4

5 5 6 Glushkov utomton G(e) Ech position in the Reg Expr e ecomes one stte of G; plus, G hs one extr egin stte. IRS( e ) = ll possile egin positions of words mtching e e.g. IRS( R (E G) (EX)* ) = { R } OLLOW( e, x ) = ll possile positions following position x in e e.g. OLLOW( R (E G) (EX)*, R ) = { E, G } OLLOW( e, X 5 ) = rom stte R : dd E-trnsition to E G-trnsition to G LAS( e ) = ll possile end positions of words mtching e e.g. LAS( R (E G) (EX)* ) = { E, G, X 5 } 7 8 Is this utomton deterministic?? 9 0 Glushkov utomton G(e) Glushkov utomton G(e) Another exmple (* )* his A is deterministic. Ech position in the Reg Expr e ecomes one stte of G; plus, G hs one extr egin stte. IRS( e ) = ll possile egin positions of words mtching e e.g. IRS( R (E G) (EX)* ) = { R } OLLOW( e, x ) = ll possile positions following position x in e LAS( e ) = ll possile end positions of words mtching e Which of these is deterministic? () (c) ( c) ( )*c Nïve implementtion: O(n^) time, where n = size( e ) (for ech position: computing OLLOW goes through every position t ech step, needs to compute union O( n*n*n ) 5

6 Glushkov utomton G(e) Glushkov utomton G(e) Ech position in the Reg Expr e ecomes one stte of G; plus, G hs one extr egin stte. Ech position in the Reg Expr e ecomes one stte of G; plus, G hs one extr egin stte. IRS( e ) = ll possile egin positions of words mtching e IRS( e ) = ll possile egin positions of words mtching e e.g. IRS( R (E G) (EX)* ) = { R } e.g. IRS( R (E G) (EX)* ) = { R } OLLOW( e, x ) = ll possile positions following position x in e OLLOW( e, x ) = ll possile positions following position x in e LAS( e ) = ll possile end positions of words mtching e LAS( e ) = ll possile end positions of words mtching e Nïve implementtion: O(n^) time, where n = size( e ) Nïve implementtion: O(n^) time, where n = size( e ) (for ech position: computing OLLOW goes through every position t ech step, needs to compute union O( n*n*n ) Not relly needed. Cn e improved to O(n^) (for ech position: computing OLLOW goes through every position t ech step, needs to compute union O( n*n*n ) Cn e improved to O( size(e) + size(g(e)) ) Not relly needed. Cn e improved to O(n^) Glushkov utomton G(e) o void these expensive running times DD requires tht A=G(e) must e deterministic! 4 Note If G(e) is deterministic, then its size (# trnsitions) is qudrtic in size(e)! Liner in size(e) * #letters(e), if G(e) is deterministic! O( size(e) * #letters(e) ) n = length(w) m = size(e) otl Running time O(n + m) If s = #letters(e) is ssumed fixed (not prt of the input) Otherwise: O(n + ms) Nïve implementtion: O(n^) time, where n = size( e ) (for ech position: computing OLLOW goes through every position t ech step, needs to compute union O( n*n*n ) Cn e improved to O( size(e) + size(g(e)) ) Not relly needed. Cn e improved to O(n^) How cn you implement regulr expression? Input: Reg Expr e, string w : Does w mtch e? deterministic A: run on w tkes time liner in length(w) Unrestricted Reg Expr e Algorithm A = BuildA(e); DA = BuildDA(A); Size of A is liner in size(e)=m Size of DA is exponentil in m otl Running time O(n + ^m) Other lterntive: O(nm) 5 6 Summry Deterministic (-unmiguous) content models give rise to efficient mtching lgorithms. (they void O(nm) or O(n+^m) complexities) Now tht we know how the check ll the different content-models (in prticulr det. Reg Expr s) how to uild full vlidtor for DD? elem-nme_ RegExpr_ elem-nme_ RegExpr_ elem-nme_k RegExpr_k Automt A_, A_,, A_k Disdvntges Hrd to know whether given reg expr is OK (deterministic) Det. reg exprs re NO closed under union. (not so nice..) Hint: Cn you see why? find det. reg. exprs. e nd e such tht their union is equl to ( )* ( ) he Vlidtion Prolem Given DD nd document D, is D vlid wrt? op-down Implementtion t element node w. lel elem-nme_i, run utomton A_i check ttriute constrints check ID/IDRE constrints otl Running time (Given A_, A_,, A_k) liner in the sum of sizes of the DD nd the document. O( size() + size(d) ) 6

7 DDs hve the 7 Beyond DDs 8 lel-gurded sutree exchnge property: t, t trees in DD lnguge v node in t, leled l v node in t, leled l trees otined y exchnging the sutrees rooted t v nd v re lso in k locl content model only depends on lel of prent Often, the expressive power of DDs is not sufficient. Prolem ech element nme hs precisely one content-model in DD. Would like to distuingish, depending on the context (prent). deler t t cr cr v l v l model yer model cr hs different structure, in different contexts Beyond DDs Specilized DDs Often, the expressive power of DDs is not sufficient. Prolem ech element nme hs precisely one content-model in DD. Would like to distuingish, depending on the context (prent). deler deler, (cr )* (cr )* cr model, yer cr model deler deler speciliztion cr cr model yer model cr cr cr cr cr hs different structure, in different contexts. model yer model model yer model Specilized DDs New nottion. Use cpitlized YPE Nmes 4 New nottion. Use cpitlized YPE Nmes 4 deler, (cr )* (cr )* cr model, yer cr model Deler deler [Used, New] Used [(Cr )*] New [(Cr )*] Cr cr [Model, Yer] Cr cr [Model] Deler deler [Used, New] Used [(Cr )*] New [(Cr )*] Cr cr [Model, Yer] Cr cr [Model] Not locl deler deler Let us cll this concept grmmr. the locl restriction A grmmr G is locl, if for ny lel[regexpr_], lel[regexpr_] present in G it holds tht RegExpr_ = RegExpr_. By definition: Every DD is locl grmmr, nd vice vers. cr cr cr cr model yer model model yer model 7

8 New nottion. Use cpitlized YPE Nmes 4 New nottion. Use cpitlized YPE Nmes 44 Deler deler [Used, New] Used [(Cr )*] New [(Cr )*] Cr cr [Model, Yer] Cr cr [Model] Not locl competing Deler deler [Used, New] Used [(Cr )*] New [(Cr )*] Cr cr [Model, Yer] Cr cr [Model] Let us cll this concept grmmr. the locl restriction A grmmr G is locl, if for ny lel[regexpr_], lel[regexpr_] present in G it holds tht RegExpr_ = RegExpr_. Alterntively: Cll two YPE Nmes nd competing if they hve the sme element nme (ut not identicl rules) By definition: Every DD is locl grmmr, nd vice vers. Clsses of Grmmrs A grmmr G is single-type, if for ny lel[regexpr_], lel[regexpr_] occurring in the sme rule of G it holds tht RegExpr_ = RegExpr_. WRONG the single-type restriction locl no competing YPE nmes! (DDs) single-type YPE nmes in the sme content model do not compete! regulr no restriction (RELAX NG) (XML Schem s) New nottion. Use cpitlized YPE Nmes 45 New nottion. Use cpitlized YPE Nmes 46 competing Deler deler [Used, New] Used [(Cr )*] New [(Cr )*] Cr cr [Model, Yer] Cr cr [Model] competing ut re not in sme content model! Person person [PersonNme, Gender, Spouse?, Pet*] PersonNme nme [irst, Lst] Pet pet [Kind, PetNme] PetNme nme [#PCDAA] Are there single-type grmmrs (XML Schems) which cnnot e expressed y locl grmmrs (DDs). Are there single-type grmmrs (XML Schems) which cnnot e expressed y locl grmmrs (DDs). YES! Clsses of Grmmrs Clsses of Grmmrs locl no competing YPE nmes! (DDs) locl no competing YPE nmes! (DDs) single-type YPE nmes in the sme content model do not compete! (XML Schem s) regulr no restriction (RELAX NG) single-type YPE nmes in the sme content model do not compete! (XML Schem s) regulr no restriction (RELAX NG) New nottion. Use cpitlized YPE Nmes 47 New nottion. Use cpitlized YPE Nmes 48 competing Deler deler [Used, New] Used [(Cr )*] New [(Cr )*] Cr cr [Model, Yer] Cr cr [Model] competing Deler deler [Used, New] Used [(Cr )*] New [(Cr )*] Cr cr [Model, Yer] Cr cr [Model] hrough the use of YPE Nmes (nonterminls / sttes) you cn distinguish deep context! deler hrough the use of YPE Nmes (nonterminls / sttes) you cn distinguish deep context! deler cr Cr cr cr speciliztion through prent Cn we model context tht is fr wy from the specilized node? cr Cr cr cr speciliztion through prent model yer model model yer model 8

9 New nottion. Use cpitlized YPE Nmes competing Deler deler [Used, New] Used [(Cr )*] New [(Cr )*] Cr cr [Model, Yer] Cr cr [Model] d root 49 DB d [Deler, User] Deler deler [Used, New] Used [(Cr )*] New [(Cr )*] Cr cr [Model, Yer] Cr cr [Model] Doc root [DB sdb] sdb d [sdeler, suser] sdeler deler [sused, New] sused [(scr )*] scr cr [Model, Own, Yer] sdeler d root sdb suser 50 hrough the use of YPE Nmes (nonterminls / sttes) you cn user distinguish deep context! deler specil hrough the use of YPE Nmes (nonterminls / sttes) you cn user distinguish deep context! deler specil Cn we model context tht is fr wy from the specilized node? Sure! cr cr My Cr cr speciliztion through following node Cn we model context tht is fr wy from the specilized node? Sure! scr sused cr cr My Cr cr model yer model model yer model #owners #owners DB d [Deler, User] Deler deler [Used, New] Used [(Cr )*] New [(Cr )*] Cr cr [Model, Yer] Cr cr [Model] Doc root [DB sdb] sdb d [sdeler, suser] sdeler deler [sused, New] sused [(scr )*] scr cr [Model, Own, Yer] sdeler d root sdb suser 5 root d root d 5 hrough the use of YPE Nmes (nonterminls / sttes) you cn user distinguish deep context! deler specil Cn we model context tht is fr wy from the specilized node? Sure! scr sused cr cr My Cr cr model yer model Sure this grmmr is not locl (DD). But, is it single-type? specil deler Is this grmmr single-type? deler #owners 5 54 prev. exmple: proly, not expressle in single-type (XML Schem). prev. exmple: proly, not expressle in single-type (XML Schem). Other exmple: Other exmple: competing Reg Expr ut not in content Person MPerson Person MPerson person[nme, gender[mle], Spouse?, Children?] Person person[nme, gender[emle], MSpouse?, Children?] Mle mle[] emle femle[] Spouse spouse[nme, gender[emle]] MSpouse spouse[nme, gender[mle]] Children children[person+] person s spouse must hve opposite gender. Person MPerson Person MPerson person[nme, gender[mle], Spouse?, Children?] Person person[nme, gender[emle], MSpouse?, Children?] Mle mle[] emle femle[] Spouse spouse[nme, gender[emle]] MSpouse spouse[nme, gender[mle]] Children children[person+] person s spouse must hve opposite gender. Note his exmple nd the Pet-exmple re tken from Hosoy s ook (see course we pge). BU, is this even grmmr in our sense? 9

10 prev. exmple: proly, not expressle Other exmple: in single-type (XML Schem). competing Reg Expr in content Person root[mperson Person] MPerson person[nme, gender[mle], Spouse?, Children?] Person person[nme, gender[emle], MSpouse?, Children?] Mle mle[] emle femle[] Spouse spouse[nme, gender[emle]] MSpouse spouse[nme, gender[mle]] Children children[person+] person s spouse must hve opposite gender. BU, is this even grmmr in our sense? NO! Reg Expr only llowed inside content ( under n element nme ). 55 Clsses XML ype ormlisms locl no competing YPE nmes! (DDs) single-type YPE nmes in the sme content model do not compete! regulr no restriction (RELAX NG) Incresing Expressivness of defining sets of trees ( tree lnguges ) s Given two DDs D nd D cn we check if ll documents vlid for D re lso vlid for D? D nd D descrie the sme set of documents? Given Relx NG grmmr G, cn we check if there exists ny document tht is vlid for G? there is document vlid for G nd vlid for G? 56 (XML Schem s) (DD inclusion prolem) (DD equlity prolem) (emptiness prolem) (intersection & emptiness) Clsses XML ype ormlisms locl no competing YPE nmes! (DDs) 57 All of the checks cn e done utomticlly, for regulr tree grmmrs! 58 single-type YPE nmes in the sme content model do not compete! regulr no restriction (RELAX NG) Incresing Expressivness of defining sets of trees ( tree lnguges ) (XML Schem s) ree Automt: very powerful frmework, Hve ll the good properties of string utomt! Yet, they re more expressive! equivlent to tree utomt s s Given two DDs D nd D cn we check if ll documents vlid for D re lso vlid for D? D nd D descrie the sme set of documents? (DD inclusion prolem) (DD equlity prolem) Given two DDs D nd D cn we check if ll documents vlid for D re lso vlid for D? D nd D descrie the sme set of documents? (DD inclusion prolem) (DD equlity prolem) Given Relx NG grmmr G, cn we check if there exists ny document tht is vlid for G? there is document vlid for G nd vlid for G? (emptiness prolem) (intersection & emptiness) Given Relx NG grmmr G, cn we check if there exists ny document tht is vlid for G? there is document vlid for G nd vlid for G? (emptiness prolem) (intersection & emptiness) If we cn do it for regulr tree grmmrs, then lso works for single-type/locl!! If we cn do it for regulr tree grmmrs, then lso works for single-type/locl!! All of the checks cn e done utomticlly, for regulr tree grmmrs! All of the checks cn e done utomticlly, for regulr tree grmmrs! ree Automt: very powerful frmework, Hve ll the good properties of string utomt! Yet, they re more expressive! equivlent to tree utomt constnt memory computtion inite-stte utomt re importnt: equivlent to tree utomt Note String utomt re not sufficient to check DDs / Schems! Even if we only consider well-rcketed strings! Exmple c c[, c, ] empty empty c empty Exmple [ c, ] [, ] / / c empty hink you re in mze, with only fixed memory nd you cn only red the mze (cnnot mrk nything). wll Model y finite utomton. In stte q, (to [N S E W], ) ( q, [N S E W] ) q, (to [N S E W], ) ( q, [N S E W] ) empty q Cn n utomton serch the mze? 0

11 6 6 All of the checks cn e done utomticlly, for regulr tree grmmrs! All of the checks cn e done utomticlly, for regulr tree grmmrs! constnt memory computtion equivlent to tree utomt constnt memory computtion equivlent to tree utomt inite-stte utomt re importnt: inite-stte utomt re importnt: hink you re in mze, with only fixed memory nd you cn only red the mze (cnnot mrk nything). wll Model y finite utomton. In stte q, (to [N S E W], ) ( q, [N S E W] ) q, (to [N S E W], ) ( q, [N S E W] ) empty q Cn n utomton serch the mze? No!! need mrkers ( peles ). How mny? 5?? In our context, e.g., for KMP (efficient string mtching) [Knuth/Morris/Prtt] generliztion using utomt. Used, e.g., in grep Compression Sttic nlysis of schems & queries (= everything you cn do *efore* efore running over the ctul dt ) 4. Sttic Methods, sed on ree Automt 6 4. Sttic Methods, sed on ree Automt 64 Person MPerson Person MPerson person [Nme, gender[mle], Spouse?] Person person [Nme, gender[emle], MSpouse?] Regulr ree Grmmr Rules of the form ypenme ree person Leves my e leled y ypenmes person Given grmmrs D nd D cn we check if ll documents vlid for D re lso vlid for D? (inclusion prolem) D nd D descrie the sme set of documents? (equlity prolem) does there exists ny document tht is vlid for D? (emptiness prolem) there is document vlid for D *nd* vlid for D? (intersection & emptiness) ALL these checks re possile for regulr tree grmmrs!! hence, they re lso solvle for DDs / XML Schems / RELAX NG s Nme gender Spouse Nme gender () use inry tree encodings () trnslte XML ype Definition to ree Grmmr (esy) Mle Mle Alterntively, regulr tree lnguges re defined y ree Automt. stte, element-nme stte, stte conventionlly, defined for inry/rnked trees. Alterntively, regulr tree lnguges re defined y ree Automt. stte, element-nme stte, stte conventionlly, defined for inry/rnked trees. 4. Sttic Methods, sed on ree Automt 65 Automt 66 Given grmmrs D nd D cn we check if ll documents vlid for D re lso vlid for D? D nd D descrie the sme set of documents? does there exists ny document tht is vlid for D? there is document vlid for D *nd* vlid for D? (inclusion prolem) (equlity prolem) (emptiness prolem) (intersection & emptiness) ALL these checks re possile for regulr tree grmmrs!! he checks ove give rise to very powerful optimiztion procedures for XML Dtses! or exmple: documents d_, d_,, d_n re vlid for your schem Smll_xhtml. Are they lso vlid for schem XHML? Check inclusion prolem for Smll_html nd XHML!

12 Automt 67 Automt 68 Automt 69 Automt 70 Expressiveness exp. low-up exp. more succinct deteterministic = nondeterministic left-to-right = right-to-left word is ccepted y the utomton Automt 7 Automt 7 Expressiveness exp. low-up exp. more succinct deteterministic = nondeterministic left-to-right = right-to-left word is ccepted y the utomton Expressiveness exp. low-up exp. more succinct deteterministic = nondeterministic left-to-right = right-to-left word is ccepted y the utomton Automt on trees. ottom-up LABEL( stte, stte ) stte Automt on trees. ottom-up LABEL( stte, stte ) stte AND 0 0 0() () (, ) (, ) AND 0 0 0() () (, ) (, )

13 Automt 7 Automt 74 Expressiveness exp. low-up exp. more succinct deteterministic = nondeterministic left-to-right = right-to-left word is ccepted y the utomton Expressiveness exp. low-up exp. more succinct deteterministic = nondeterministic left-to-right = right-to-left word is ccepted y the utomton Automt on trees AND 0 0. ottom-up LABEL( stte, stte ) stte 0() () (, ) (, ) AND(, ) Automt on trees 0 AND 0. ottom-up LABEL( stte, stte ) stte 0() () (, ) (, ) AND(, ) tree is ccepted y the utomton Accepting Sttes = { } Automt Expressiveness exp. low-up exp. more succinct deteterministic = nondeterministic left-to-right = right-to-left 75 word is ccepted y the utomton How much memory do you need exctly, to run such ottom-up tree utomton? 76 Automt on trees 0 AND 0. ottom-up LABEL( stte, stte ) stte 0() () (, ) (, ) AND(, ) tree is ccepted y the utomton Accepting Sttes = { } his utomton is deterministic. nondeterminism LABEL( st, st ) { st, } Automt on trees 0 AND 0. ottom-up LABEL( stte, stte ) stte 0() () (, ) (, ) AND(, ) tree is ccepted y the utomton Accepting Sttes = { } his utomton is deterministic. nondeterminism LABEL( st, st ) { st, } Similrly s for word utomt: Similrly s for word utomt: or every nondeterministic ottom-up tree utomton there is n equivlent deterministic ottom-up tree utomton. or every nondeterministic ottom-up tree utomton there is n equivlent deterministic ottom-up tree utomton. Agin, the construction cn cuse exponentil size low-up. Agin, the construction cn cuse exponentil size low-up.. top-down stte, LABEL (stte, stte). top-down stte, LABEL (stte, stte), = inry node lels must contin $-lef e,$ = lef node lels top-most -node on the left-most pth must hve right-sutree which contins $-node., = inry node lels must contin $-lef e,$ = lef node lels top-most -node on the left-most pth must hve right-sutree which contins $-node. egin, (ny, find$) egin, (egin, ny) find$, / { (find$, ny), (ny, find$) } find$, $ ACC find$, e REJ ny, / (ny,ny) ny, $/e ACC nondeterministic ccept tree if there exists n ccepting run (= ll leves go to ACC)

14 or every nondeterministic ottom-up tree utomton there is n equivlent deterministic ottom-up tree utomton. Cn you find n equivlent ottom-up utomton for this exmple? 79 or every nondeterministic ottom-up tree utomton there is n equivlent deterministic ottom-up tree utomton, nd there is n equivlent nondeterministic top-down tree utomton. Yes! you cn 80. top-down stte, LABEL (stte, stte), = inry node lels must contin $-lef e,$ = lef node lels top-most -node on the left-most pth must hve right-sutree which contins $-node. egin, (ny, find$) egin, (egin, ny) find$, / { (find$, ny), (ny, find$) } find$, $ ACC find$, e REJ ny, / (ny,ny) ny, $/e ACC nondeterministic ccept tree if there exists n ccepting run. top-down stte, LABEL (stte, stte) must contin $-lef, = inry node lels e,$ = lef node lels top-most -node on the left-most pth must hve right-sutree which contins $-node. egin, (ny, find$) egin, (egin, ny) find$, / { (find$, ny), (ny, find$) } find$, $ ACC find$, e REJ ny, / (ny,ny) ny, $/e ACC nondeterministic ccept tree if there exists n ccepting run or every nondeterministic ottom-up tree utomton there is n equivlent deterministic ottom-up tree utomton, nd there is n equivlent nondeterministic top-down tree utomton. Is there n equivlent deterministic top-down utomton?? 8 or every nondeterministic ottom-up tree utomton there is n equivlent deterministic ottom-up tree utomton, nd there is n equivlent nondeterministic top-down tree utomton. Is there n equivlent deterministic top-down utomton?? NO! 8. top-down stte, LABEL (stte, stte) must contin $-lef, = inry node lels e,$ = lef node lels top-most -node on the left-most pth must hve right-sutree which contins $-node. egin, (ny, find$) egin, (egin, ny) find$, / { (find$, ny), (ny, find$) } find$, $ ACC find$, e REJ ny, / (ny,ny) ny, $/e ACC nondeterministic ccept tree if there exists n ccepting run first nme lst lst nme first his set of two trees cnno e recognized y ny determinstic top-down tree utomton!! Why? or every nondeterministic ottom-up tree utomton there is n equivlent deterministic ottom-up tree utomton, nd there is n equivlent nondeterministic top-down tree utomton. Is there n equivlent deterministic top-down utomton?? NO! 8 or every nondeterministic ottom-up tree utomton there is n equivlent deterministic ottom-up tree utomton, nd there is n equivlent nondeterministic top-down tree utomton. Is there n equivlent deterministic top-down utomton?? NO! 84 s Wht out locl tree lnguges (defined y DDs). Cn they e ccepted y deterministic top-down utomt? Wht out single-type tree lnguges (defined y XML Schem s) Cn they e ccepted y deterministic top-down utomt? s Wht out locl tree lnguges (defined y DDs). Cn they e ccepted y deterministic top-down utomt? Wht out single-type tree lnguges (defined y XML Schem s) Cn they e ccepted y deterministic top-down utomt? Yes! Hence, there is no DD / Schem for { nme[first,lst], nme[lst,first] } 4

15 85 86 or every deterministic ottom-up tree utomton there exists miniml unique equivlent one! or every deterministic ottom-up tree utomton there exists miniml unique equivlent one! Equivlence is decidle Equivlence is decidle In fct, YOU hve lredy produced miniml ottom-up tree utomt! In fct, YOU hve lredy produced miniml ottom-up tree utomt! he miniml DAG of tree t cn e seen s the miniml unique tree utomton tht only ccepts the tree t. he miniml DAG of tree t cn e seen s the miniml unique tree utomton tht only ccepts the tree t. How expensive (complexity) to find mininml one? Sme s for word utomt? ree Automt re very useful concept in CS! 87 XML ree Automt ply crucil rule for 88 Hevily in verifiction Derive property of complex oject from the properties of its constituents h h g g = glue ( g, glue ( h, h ) ) g glue glue h h Do ll grphs / chip-lyouts produced in this wy, hve property P? Use the hierrchicl construction history of n oject, in order to work on prse tree insted of complex grph. rom there, use tree utomt. Mny NP-complete grph prolems ecome trctle on ounded-treewidth grphs! Efficient vlidtors ginst XML ypes Optimiztions If doc is of YPE, then no need to vlidte ginst YPE, if we know YPE included in YPE - if only slightly different then only need to vlidte there - incrementl vlidtion ginst updtes - etc, etc. Efficient query evlutors, use richer utomt which cn select nodes nd produce query nswers Optimiztions If nswer of QUERY is in cche, then no need to evlute QUERY, if included in QUERY. - if every possile nswer set to QUERY (of YPE X) is EMPY, then no need to evlute on the rel dt! XML ype Checking for Progrmming Lnguges he uture In 5-0 yers from now: You cn write function in Progrmming Lnguge X 89 he uture In 5-0 yers from now: You cn write function in Progrmming Lnguge X Experimentl PL s In this direction: CDuce XDuce 90 unction foo(xml document D: YPE): YPE { trverse D & compute output;... return output } unction foo(xml document D: YPE): YPE { trverse D & compute output;... return output } Compiler (XML ype Checker) will complin, if your function does not compute documents of YPE. Compiler (XML ype Checker) will complin, if your function does not compute documents of YPE. If no complint, then gurnteed: ALL outputs re ALWAYS of correct type!!) If no complint, then correct type gurnteed. Compilers will hve to e le to give sttic gurntees out input/output ehviour of progrm! 5

16 9 END Lecture 5 6

XML and Databases. Lecture 5 XML Validation using Automata. Sebastian Maneth NICTA and UNSW

XML and Databases. Lecture 5 XML Validation using Automata. Sebastian Maneth NICTA and UNSW XML nd Dtbses Lecture 5 XML Vlidtion using Automt Sebstin Mneth NICTA nd UNSW CSE@UNSW -- Semester 1, 2009 Outline 2 1. Recp: deterministic Reg Expr s / Glushkov Automton 2. Complexity of DTD vlidtion

More information

Intermediate Math Circles Wednesday, November 14, 2018 Finite Automata II. Nickolas Rollick a b b. a b 4

Intermediate Math Circles Wednesday, November 14, 2018 Finite Automata II. Nickolas Rollick a b b. a b 4 Intermedite Mth Circles Wednesdy, Novemer 14, 2018 Finite Automt II Nickols Rollick nrollick@uwterloo.c Regulr Lnguges Lst time, we were introduced to the ide of DFA (deterministic finite utomton), one

More information

1 Nondeterministic Finite Automata

1 Nondeterministic Finite Automata 1 Nondeterministic Finite Automt Suppose in life, whenever you hd choice, you could try oth possiilities nd live your life. At the end, you would go ck nd choose the one tht worked out the est. Then you

More information

Convert the NFA into DFA

Convert the NFA into DFA Convert the NF into F For ech NF we cn find F ccepting the sme lnguge. The numer of sttes of the F could e exponentil in the numer of sttes of the NF, ut in prctice this worst cse occurs rrely. lgorithm:

More information

CMPSCI 250: Introduction to Computation. Lecture #31: What DFA s Can and Can t Do David Mix Barrington 9 April 2014

CMPSCI 250: Introduction to Computation. Lecture #31: What DFA s Can and Can t Do David Mix Barrington 9 April 2014 CMPSCI 250: Introduction to Computtion Lecture #31: Wht DFA s Cn nd Cn t Do Dvid Mix Brrington 9 April 2014 Wht DFA s Cn nd Cn t Do Deterministic Finite Automt Forml Definition of DFA s Exmples of DFA

More information

CMSC 330: Organization of Programming Languages

CMSC 330: Organization of Programming Languages CMSC 330: Orgniztion of Progrmming Lnguges Finite Automt 2 CMSC 330 1 Types of Finite Automt Deterministic Finite Automt (DFA) Exctly one sequence of steps for ech string All exmples so fr Nondeterministic

More information

CS415 Compilers. Lexical Analysis and. These slides are based on slides copyrighted by Keith Cooper, Ken Kennedy & Linda Torczon at Rice University

CS415 Compilers. Lexical Analysis and. These slides are based on slides copyrighted by Keith Cooper, Ken Kennedy & Linda Torczon at Rice University CS415 Compilers Lexicl Anlysis nd These slides re sed on slides copyrighted y Keith Cooper, Ken Kennedy & Lind Torczon t Rice University First Progrmming Project Instruction Scheduling Project hs een posted

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

Formal languages, automata, and theory of computation

Formal languages, automata, and theory of computation Mälrdlen University TEN1 DVA337 2015 School of Innovtion, Design nd Engineering Forml lnguges, utomt, nd theory of computtion Thursdy, Novemer 5, 14:10-18:30 Techer: Dniel Hedin, phone 021-107052 The exm

More information

Chapter Five: Nondeterministic Finite Automata. Formal Language, chapter 5, slide 1

Chapter Five: Nondeterministic Finite Automata. Formal Language, chapter 5, slide 1 Chpter Five: Nondeterministic Finite Automt Forml Lnguge, chpter 5, slide 1 1 A DFA hs exctly one trnsition from every stte on every symol in the lphet. By relxing this requirement we get relted ut more

More information

3 Regular expressions

3 Regular expressions 3 Regulr expressions Given n lphet Σ lnguge is set of words L Σ. So fr we were le to descrie lnguges either y using set theory (i.e. enumertion or comprehension) or y n utomton. In this section we shll

More information

Homework 3 Solutions

Homework 3 Solutions CS 341: Foundtions of Computer Science II Prof. Mrvin Nkym Homework 3 Solutions 1. Give NFAs with the specified numer of sttes recognizing ech of the following lnguges. In ll cses, the lphet is Σ = {,1}.

More information

Types of Finite Automata. CMSC 330: Organization of Programming Languages. Comparing DFAs and NFAs. NFA for (a b)*abb.

Types of Finite Automata. CMSC 330: Organization of Programming Languages. Comparing DFAs and NFAs. NFA for (a b)*abb. CMSC 330: Orgniztion of Progrmming Lnguges Finite Automt 2 Types of Finite Automt Deterministic Finite Automt () Exctly one sequence of steps for ech string All exmples so fr Nondeterministic Finite Automt

More information

Types of Finite Automata. CMSC 330: Organization of Programming Languages. Comparing DFAs and NFAs. Comparing DFAs and NFAs (cont.) Finite Automata 2

Types of Finite Automata. CMSC 330: Organization of Programming Languages. Comparing DFAs and NFAs. Comparing DFAs and NFAs (cont.) Finite Automata 2 CMSC 330: Orgniztion of Progrmming Lnguges Finite Automt 2 Types of Finite Automt Deterministic Finite Automt () Exctly one sequence of steps for ech string All exmples so fr Nondeterministic Finite Automt

More information

Designing finite automata II

Designing finite automata II Designing finite utomt II Prolem: Design DFA A such tht L(A) consists of ll strings of nd which re of length 3n, for n = 0, 1, 2, (1) Determine wht to rememer out the input string Assign stte to ech of

More information

Foundations of XML Types: Tree Automata

Foundations of XML Types: Tree Automata 1 / 43 Foundtions of XML Types: Tree Automt Pierre Genevès CNRS (slides mostly sed on slides y W. Mrtens nd T. Schwentick) University of Grenole Alpes, 2017 2018 2 / 43 Why Tree Automt? Foundtions of XML

More information

Nondeterminism and Nodeterministic Automata

Nondeterminism and Nodeterministic Automata Nondeterminism nd Nodeterministic Automt 61 Nondeterminism nd Nondeterministic Automt The computtionl mchine models tht we lerned in the clss re deterministic in the sense tht the next move is uniquely

More information

5. (±±) Λ = fw j w is string of even lengthg [ 00 = f11,00g 7. (11 [ 00)± Λ = fw j w egins with either 11 or 00g 8. (0 [ ffl)1 Λ = 01 Λ [ 1 Λ 9.

5. (±±) Λ = fw j w is string of even lengthg [ 00 = f11,00g 7. (11 [ 00)± Λ = fw j w egins with either 11 or 00g 8. (0 [ ffl)1 Λ = 01 Λ [ 1 Λ 9. Regulr Expressions, Pumping Lemm, Right Liner Grmmrs Ling 106 Mrch 25, 2002 1 Regulr Expressions A regulr expression descries or genertes lnguge: it is kind of shorthnd for listing the memers of lnguge.

More information

NFA DFA Example 3 CMSC 330: Organization of Programming Languages. Equivalence of DFAs and NFAs. Equivalence of DFAs and NFAs (cont.

NFA DFA Example 3 CMSC 330: Organization of Programming Languages. Equivalence of DFAs and NFAs. Equivalence of DFAs and NFAs (cont. NFA DFA Exmple 3 CMSC 330: Orgniztion of Progrmming Lnguges NFA {B,D,E {A,E {C,D {E Finite Automt, con't. R = { {A,E, {B,D,E, {C,D, {E 2 Equivlence of DFAs nd NFAs Any string from {A to either {D or {CD

More information

CSE : Exam 3-ANSWERS, Spring 2011 Time: 50 minutes

CSE : Exam 3-ANSWERS, Spring 2011 Time: 50 minutes CSE 260-002: Exm 3-ANSWERS, Spring 20 ime: 50 minutes Nme: his exm hs 4 pges nd 0 prolems totling 00 points. his exm is closed ook nd closed notes.. Wrshll s lgorithm for trnsitive closure computtion is

More information

Minimal DFA. minimal DFA for L starting from any other

Minimal DFA. minimal DFA for L starting from any other Miniml DFA Among the mny DFAs ccepting the sme regulr lnguge L, there is exctly one (up to renming of sttes) which hs the smllest possile numer of sttes. Moreover, it is possile to otin tht miniml DFA

More information

AUTOMATA AND LANGUAGES. Definition 1.5: Finite Automaton

AUTOMATA AND LANGUAGES. Definition 1.5: Finite Automaton 25. Finite Automt AUTOMATA AND LANGUAGES A system of computtion tht only hs finite numer of possile sttes cn e modeled using finite utomton A finite utomton is often illustrted s stte digrm d d d. d q

More information

CHAPTER 1 Regular Languages. Contents

CHAPTER 1 Regular Languages. Contents Finite Automt (FA or DFA) CHAPTE 1 egulr Lnguges Contents definitions, exmples, designing, regulr opertions Non-deterministic Finite Automt (NFA) definitions, euivlence of NFAs nd DFAs, closure under regulr

More information

Anatomy of a Deterministic Finite Automaton. Deterministic Finite Automata. A machine so simple that you can understand it in less than one minute

Anatomy of a Deterministic Finite Automaton. Deterministic Finite Automata. A machine so simple that you can understand it in less than one minute Victor Admchik Dnny Sletor Gret Theoreticl Ides In Computer Science CS 5-25 Spring 2 Lecture 2 Mr 3, 2 Crnegie Mellon University Deterministic Finite Automt Finite Automt A mchine so simple tht you cn

More information

On Determinisation of History-Deterministic Automata.

On Determinisation of History-Deterministic Automata. On Deterministion of History-Deterministic Automt. Denis Kupererg Mich l Skrzypczk University of Wrsw YR-ICALP 2014 Copenhgen Introduction Deterministic utomt re centrl tool in utomt theory: Polynomil

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

Java II Finite Automata I

Java II Finite Automata I Jv II Finite Automt I Bernd Kiefer Bernd.Kiefer@dfki.de Deutsches Forschungszentrum für künstliche Intelligenz Finite Automt I p.1/13 Processing Regulr Expressions We lredy lerned out Jv s regulr expression

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

Chapter 2 Finite Automata

Chapter 2 Finite Automata Chpter 2 Finite Automt 28 2.1 Introduction Finite utomt: first model of the notion of effective procedure. (They lso hve mny other pplictions). The concept of finite utomton cn e derived y exmining wht

More information

1. For each of the following theorems, give a two or three sentence sketch of how the proof goes or why it is not true.

1. For each of the following theorems, give a two or three sentence sketch of how the proof goes or why it is not true. York University CSE 2 Unit 3. DFA Clsses Converting etween DFA, NFA, Regulr Expressions, nd Extended Regulr Expressions Instructor: Jeff Edmonds Don t chet y looking t these nswers premturely.. For ech

More information

CSCI 340: Computational Models. Kleene s Theorem. Department of Computer Science

CSCI 340: Computational Models. Kleene s Theorem. Department of Computer Science CSCI 340: Computtionl Models Kleene s Theorem Chpter 7 Deprtment of Computer Science Unifiction In 1954, Kleene presented (nd proved) theorem which (in our version) sttes tht if lnguge cn e defined y ny

More information

Regular expressions, Finite Automata, transition graphs are all the same!!

Regular expressions, Finite Automata, transition graphs are all the same!! CSI 3104 /Winter 2011: Introduction to Forml Lnguges Chpter 7: Kleene s Theorem Chpter 7: Kleene s Theorem Regulr expressions, Finite Automt, trnsition grphs re ll the sme!! Dr. Neji Zgui CSI3104-W11 1

More information

Finite Automata-cont d

Finite Automata-cont d Automt Theory nd Forml Lnguges Professor Leslie Lnder Lecture # 6 Finite Automt-cont d The Pumping Lemm WEB SITE: http://ingwe.inghmton.edu/ ~lnder/cs573.html Septemer 18, 2000 Exmple 1 Consider L = {ww

More information

Harvard University Computer Science 121 Midterm October 23, 2012

Harvard University Computer Science 121 Midterm October 23, 2012 Hrvrd University Computer Science 121 Midterm Octoer 23, 2012 This is closed-ook exmintion. You my use ny result from lecture, Sipser, prolem sets, or section, s long s you quote it clerly. The lphet is

More information

Regular Expressions (RE) Regular Expressions (RE) Regular Expressions (RE) Regular Expressions (RE) Kleene-*

Regular Expressions (RE) Regular Expressions (RE) Regular Expressions (RE) Regular Expressions (RE) Kleene-* Regulr Expressions (RE) Regulr Expressions (RE) Empty set F A RE denotes the empty set Opertion Nottion Lnguge UNIX Empty string A RE denotes the set {} Alterntion R +r L(r ) L(r ) r r Symol Alterntion

More information

Formal Languages and Automata

Formal Languages and Automata Moile Computing nd Softwre Engineering p. 1/5 Forml Lnguges nd Automt Chpter 2 Finite Automt Chun-Ming Liu cmliu@csie.ntut.edu.tw Deprtment of Computer Science nd Informtion Engineering Ntionl Tipei University

More information

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

The University of Nottingham SCHOOL OF COMPUTER SCIENCE A LEVEL 2 MODULE, SPRING SEMESTER LANGUAGES AND COMPUTATION ANSWERS The University of Nottinghm SCHOOL OF COMPUTER SCIENCE LEVEL 2 MODULE, SPRING SEMESTER 2016 2017 LNGUGES ND COMPUTTION NSWERS Time llowed TWO hours Cndidtes my complete the front cover of their nswer ook

More information

First Midterm Examination

First Midterm Examination Çnky University Deprtment of Computer Engineering 203-204 Fll Semester First Midterm Exmintion ) Design DFA for ll strings over the lphet Σ = {,, c} in which there is no, no nd no cc. 2) Wht lnguge does

More information

Assignment 1 Automata, Languages, and Computability. 1 Finite State Automata and Regular Languages

Assignment 1 Automata, Languages, and Computability. 1 Finite State Automata and Regular Languages Deprtment of Computer Science, Austrlin Ntionl University COMP2600 Forml Methods for Softwre Engineering Semester 2, 206 Assignment Automt, Lnguges, nd Computility Smple Solutions Finite Stte Automt nd

More information

CS103B Handout 18 Winter 2007 February 28, 2007 Finite Automata

CS103B Handout 18 Winter 2007 February 28, 2007 Finite Automata CS103B ndout 18 Winter 2007 Ferury 28, 2007 Finite Automt Initil text y Mggie Johnson. Introduction Severl childrens gmes fit the following description: Pieces re set up on plying ord; dice re thrown or

More information

CS 373, Spring Solutions to Mock midterm 1 (Based on first midterm in CS 273, Fall 2008.)

CS 373, Spring Solutions to Mock midterm 1 (Based on first midterm in CS 273, Fall 2008.) CS 373, Spring 29. Solutions to Mock midterm (sed on first midterm in CS 273, Fll 28.) Prolem : Short nswer (8 points) The nswers to these prolems should e short nd not complicted. () If n NF M ccepts

More information

Lexical Analysis Part III

Lexical Analysis Part III Lexicl Anlysis Prt III Chpter 3: Finite Automt Slides dpted from : Roert vn Engelen, Florid Stte University Alex Aiken, Stnford University Design of Lexicl Anlyzer Genertor Trnslte regulr expressions to

More information

CISC 4090 Theory of Computation

CISC 4090 Theory of Computation 9/6/28 Stereotypicl computer CISC 49 Theory of Computtion Finite stte mchines & Regulr lnguges Professor Dniel Leeds dleeds@fordhm.edu JMH 332 Centrl processing unit (CPU) performs ll the instructions

More information

Some Theory of Computation Exercises Week 1

Some Theory of Computation Exercises Week 1 Some Theory of Computtion Exercises Week 1 Section 1 Deterministic Finite Automt Question 1.3 d d d d u q 1 q 2 q 3 q 4 q 5 d u u u u Question 1.4 Prt c - {w w hs even s nd one or two s} First we sk whether

More information

Scanner. Specifying patterns. Specifying patterns. Operations on languages. A scanner must recognize the units of syntax Some parts are easy:

Scanner. Specifying patterns. Specifying patterns. Operations on languages. A scanner must recognize the units of syntax Some parts are easy: Scnner Specifying ptterns source code tokens scnner prser IR A scnner must recognize the units of syntx Some prts re esy: errors mps chrcters into tokens the sic unit of syntx x = x + y; ecomes

More information

Deterministic Finite Automata

Deterministic Finite Automata Finite Automt Deterministic Finite Automt H. Geuvers nd J. Rot Institute for Computing nd Informtion Sciences Version: fll 2016 J. Rot Version: fll 2016 Tlen en Automten 1 / 21 Outline Finite Automt Finite

More information

Good-for-Games Automata versus Deterministic Automata.

Good-for-Games Automata versus Deterministic Automata. Good-for-Gmes Automt versus Deterministic Automt. Denis Kuperberg 1,2 Mich l Skrzypczk 1 1 University of Wrsw 2 IRIT/ONERA (Toulouse) Séminire MoVe 12/02/2015 LIF, Luminy Introduction Deterministic utomt

More information

Coalgebra, Lecture 15: Equations for Deterministic Automata

Coalgebra, Lecture 15: Equations for Deterministic Automata Colger, Lecture 15: Equtions for Deterministic Automt Julin Slmnc (nd Jurrin Rot) Decemer 19, 2016 In this lecture, we will study the concept of equtions for deterministic utomt. The notes re self contined

More information

Lecture 08: Feb. 08, 2019

Lecture 08: Feb. 08, 2019 4CS4-6:Theory of Computtion(Closure on Reg. Lngs., regex to NDFA, DFA to regex) Prof. K.R. Chowdhry Lecture 08: Fe. 08, 2019 : Professor of CS Disclimer: These notes hve not een sujected to the usul scrutiny

More information

Finite Automata. Informatics 2A: Lecture 3. John Longley. 22 September School of Informatics University of Edinburgh

Finite Automata. Informatics 2A: Lecture 3. John Longley. 22 September School of Informatics University of Edinburgh Lnguges nd Automt Finite Automt Informtics 2A: Lecture 3 John Longley School of Informtics University of Edinburgh jrl@inf.ed.c.uk 22 September 2017 1 / 30 Lnguges nd Automt 1 Lnguges nd Automt Wht is

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

12.1 Nondeterminism Nondeterministic Finite Automata. a a b ε. CS125 Lecture 12 Fall 2014

12.1 Nondeterminism Nondeterministic Finite Automata. a a b ε. CS125 Lecture 12 Fall 2014 CS125 Lecture 12 Fll 2014 12.1 Nondeterminism The ide of nondeterministic computtions is to llow our lgorithms to mke guesses, nd only require tht they ccept when the guesses re correct. For exmple, simple

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

Speech Recognition Lecture 2: Finite Automata and Finite-State Transducers

Speech Recognition Lecture 2: Finite Automata and Finite-State Transducers Speech Recognition Lecture 2: Finite Automt nd Finite-Stte Trnsducers Eugene Weinstein Google, NYU Cournt Institute eugenew@cs.nyu.edu Slide Credit: Mehryr Mohri Preliminries Finite lphet, empty string.

More information

Converting Regular Expressions to Discrete Finite Automata: A Tutorial

Converting Regular Expressions to Discrete Finite Automata: A Tutorial Converting Regulr Expressions to Discrete Finite Automt: A Tutoril Dvid Christinsen 2013-01-03 This is tutoril on how to convert regulr expressions to nondeterministic finite utomt (NFA) nd how to convert

More information

Formal Language and Automata Theory (CS21004)

Formal Language and Automata Theory (CS21004) Forml Lnguge nd Automt Forml Lnguge nd Automt Theory (CS21004) Khrgpur Khrgpur Khrgpur Forml Lnguge nd Automt Tle of Contents Forml Lnguge nd Automt Khrgpur 1 2 3 Khrgpur Forml Lnguge nd Automt Forml Lnguge

More information

Talen en Automaten Test 1, Mon 7 th Dec, h45 17h30

Talen en Automaten Test 1, Mon 7 th Dec, h45 17h30 Tlen en Automten Test 1, Mon 7 th Dec, 2015 15h45 17h30 This test consists of four exercises over 5 pges. Explin your pproch, nd write your nswer to ech exercise on seprte pge. You cn score mximum of 100

More information

Automata Theory 101. Introduction. Outline. Introduction Finite Automata Regular Expressions ω-automata. Ralf Huuck.

Automata Theory 101. Introduction. Outline. Introduction Finite Automata Regular Expressions ω-automata. Ralf Huuck. Outline Automt Theory 101 Rlf Huuck Introduction Finite Automt Regulr Expressions ω-automt Session 1 2006 Rlf Huuck 1 Session 1 2006 Rlf Huuck 2 Acknowledgement Some slides re sed on Wolfgng Thoms excellent

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

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

First Midterm Examination

First Midterm Examination 24-25 Fll Semester First Midterm Exmintion ) Give the stte digrm of DFA tht recognizes the lnguge A over lphet Σ = {, } where A = {w w contins or } 2) The following DFA recognizes the lnguge B over lphet

More information

Theory of Computation Regular Languages. (NTU EE) Regular Languages Fall / 38

Theory of Computation Regular Languages. (NTU EE) Regular Languages Fall / 38 Theory of Computtion Regulr Lnguges (NTU EE) Regulr Lnguges Fll 2017 1 / 38 Schemtic of Finite Automt control 0 0 1 0 1 1 1 0 Figure: Schemtic of Finite Automt A finite utomton hs finite set of control

More information

Table of contents: Lecture N Summary... 3 What does automata mean?... 3 Introduction to languages... 3 Alphabets... 3 Strings...

Table of contents: Lecture N Summary... 3 What does automata mean?... 3 Introduction to languages... 3 Alphabets... 3 Strings... Tle of contents: Lecture N0.... 3 ummry... 3 Wht does utomt men?... 3 Introduction to lnguges... 3 Alphets... 3 trings... 3 Defining Lnguges... 4 Lecture N0. 2... 7 ummry... 7 Kleene tr Closure... 7 Recursive

More information

Fundamentals of Computer Science

Fundamentals of Computer Science Fundmentls of Computer Science Chpter 3: NFA nd DFA equivlence Regulr expressions Henrik Björklund Umeå University Jnury 23, 2014 NFA nd DFA equivlence As we shll see, it turns out tht NFA nd DFA re equivlent,

More information

Thoery of Automata CS402

Thoery of Automata CS402 Thoery of Automt C402 Theory of Automt Tle of contents: Lecture N0. 1... 4 ummry... 4 Wht does utomt men?... 4 Introduction to lnguges... 4 Alphets... 4 trings... 4 Defining Lnguges... 5 Lecture N0. 2...

More information

1 From NFA to regular expression

1 From NFA to regular expression Note 1: How to convert DFA/NFA to regulr expression Version: 1.0 S/EE 374, Fll 2017 Septemer 11, 2017 In this note, we show tht ny DFA cn e converted into regulr expression. Our construction would work

More information

CS 301. Lecture 04 Regular Expressions. Stephen Checkoway. January 29, 2018

CS 301. Lecture 04 Regular Expressions. Stephen Checkoway. January 29, 2018 CS 301 Lecture 04 Regulr Expressions Stephen Checkowy Jnury 29, 2018 1 / 35 Review from lst time NFA N = (Q, Σ, δ, q 0, F ) where δ Q Σ P (Q) mps stte nd n lphet symol (or ) to set of sttes We run n NFA

More information

Lexical Analysis Finite Automate

Lexical Analysis Finite Automate Lexicl Anlysis Finite Automte CMPSC 470 Lecture 04 Topics: Deterministic Finite Automt (DFA) Nondeterministic Finite Automt (NFA) Regulr Expression NFA DFA A. Finite Automt (FA) FA re grph, like trnsition

More information

Theory of Computation Regular Languages

Theory of Computation Regular Languages Theory of Computtion Regulr Lnguges Bow-Yw Wng Acdemi Sinic Spring 2012 Bow-Yw Wng (Acdemi Sinic) Regulr Lnguges Spring 2012 1 / 38 Schemtic of Finite Automt control 0 0 1 0 1 1 1 0 Figure: Schemtic of

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

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

Compiler Design. Fall Lexical Analysis. Sample Exercises and Solutions. Prof. Pedro C. Diniz University of Southern Cliforni Computer Science Deprtment Compiler Design Fll Lexicl Anlysis Smple Exercises nd Solutions Prof. Pedro C. Diniz USC / Informtion Sciences Institute 4676 Admirlty Wy, Suite

More information

1. For each of the following theorems, give a two or three sentence sketch of how the proof goes or why it is not true.

1. For each of the following theorems, give a two or three sentence sketch of how the proof goes or why it is not true. York University CSE 2 Unit 3. DFA Clsses Converting etween DFA, NFA, Regulr Expressions, nd Extended Regulr Expressions Instructor: Jeff Edmonds Don t chet y looking t these nswers premturely.. For ech

More information

Regular Languages and Applications

Regular Languages and Applications Regulr Lnguges nd Applictions Yo-Su Hn Deprtment of Computer Science Yonsei University 1-1 SNU 4/14 Regulr Lnguges An old nd well-known topic in CS Kleene Theorem in 1959 FA (finite-stte utomton) constructions:

More information

NFAs continued, Closure Properties of Regular Languages

NFAs continued, Closure Properties of Regular Languages Algorithms & Models of Computtion CS/ECE 374, Fll 2017 NFAs continued, Closure Properties of Regulr Lnguges Lecture 5 Tuesdy, Septemer 12, 2017 Sriel Hr-Peled (UIUC) CS374 1 Fll 2017 1 / 31 Regulr Lnguges,

More information

CSCI 340: Computational Models. Transition Graphs. Department of Computer Science

CSCI 340: Computational Models. Transition Graphs. Department of Computer Science CSCI 340: Computtionl Models Trnsition Grphs Chpter 6 Deprtment of Computer Science Relxing Restrints on Inputs We cn uild n FA tht ccepts only the word! 5 sttes ecuse n FA cn only process one letter t

More information

Non-deterministic Finite Automata

Non-deterministic Finite Automata Non-deterministic Finite Automt Eliminting non-determinism Rdoud University Nijmegen Non-deterministic Finite Automt H. Geuvers nd T. vn Lrhoven Institute for Computing nd Informtion Sciences Intelligent

More information

Context-Free Grammars and Languages

Context-Free Grammars and Languages Context-Free Grmmrs nd Lnguges (Bsed on Hopcroft, Motwni nd Ullmn (2007) & Cohen (1997)) Introduction Consider n exmple sentence: A smll ct ets the fish English grmmr hs rules for constructing sentences;

More information

Lecture 09: Myhill-Nerode Theorem

Lecture 09: Myhill-Nerode Theorem CS 373: Theory of Computtion Mdhusudn Prthsrthy Lecture 09: Myhill-Nerode Theorem 16 Ferury 2010 In this lecture, we will see tht every lnguge hs unique miniml DFA We will see this fct from two perspectives

More information

CS 310 (sec 20) - Winter Final Exam (solutions) SOLUTIONS

CS 310 (sec 20) - Winter Final Exam (solutions) SOLUTIONS CS 310 (sec 20) - Winter 2003 - Finl Exm (solutions) SOLUTIONS 1. (Logic) Use truth tles to prove the following logicl equivlences: () p q (p p) (q q) () p q (p q) (p q) () p q p q p p q q (q q) (p p)

More information

a,b a 1 a 2 a 3 a,b 1 a,b a,b 2 3 a,b a,b a 2 a,b CS Determinisitic Finite Automata 1

a,b a 1 a 2 a 3 a,b 1 a,b a,b 2 3 a,b a,b a 2 a,b CS Determinisitic Finite Automata 1 CS4 45- Determinisitic Finite Automt -: Genertors vs. Checkers Regulr expressions re one wy to specify forml lnguge String Genertor Genertes strings in the lnguge Deterministic Finite Automt (DFA) re nother

More information

Lecture 3. In this lecture, we will discuss algorithms for solving systems of linear equations.

Lecture 3. In this lecture, we will discuss algorithms for solving systems of linear equations. Lecture 3 3 Solving liner equtions In this lecture we will discuss lgorithms for solving systems of liner equtions Multiplictive identity Let us restrict ourselves to considering squre mtrices since one

More information

Speech Recognition Lecture 2: Finite Automata and Finite-State Transducers. Mehryar Mohri Courant Institute and Google Research

Speech Recognition Lecture 2: Finite Automata and Finite-State Transducers. Mehryar Mohri Courant Institute and Google Research Speech Recognition Lecture 2: Finite Automt nd Finite-Stte Trnsducers Mehryr Mohri Cournt Institute nd Google Reserch mohri@cims.nyu.com Preliminries Finite lphet Σ, empty string. Set of ll strings over

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

12.1 Nondeterminism Nondeterministic Finite Automata. a a b ε. CS125 Lecture 12 Fall 2016

12.1 Nondeterminism Nondeterministic Finite Automata. a a b ε. CS125 Lecture 12 Fall 2016 CS125 Lecture 12 Fll 2016 12.1 Nondeterminism The ide of nondeterministic computtions is to llow our lgorithms to mke guesses, nd only require tht they ccept when the guesses re correct. For exmple, simple

More information

Tutorial Automata and formal Languages

Tutorial Automata and formal Languages Tutoril Automt nd forml Lnguges Notes for to the tutoril in the summer term 2017 Sestin Küpper, Christine Mik 8. August 2017 1 Introduction: Nottions nd sic Definitions At the eginning of the tutoril we

More information

CMSC 330: Organization of Programming Languages. DFAs, and NFAs, and Regexps (Oh my!)

CMSC 330: Organization of Programming Languages. DFAs, and NFAs, and Regexps (Oh my!) CMSC 330: Orgniztion of Progrmming Lnguges DFAs, nd NFAs, nd Regexps (Oh my!) CMSC330 Spring 2018 Types of Finite Automt Deterministic Finite Automt (DFA) Exctly one sequence of steps for ech string All

More information

Faster Regular Expression Matching. Philip Bille Mikkel Thorup

Faster Regular Expression Matching. Philip Bille Mikkel Thorup Fster Regulr Expression Mtching Philip Bille Mikkel Thorup Outline Definition Applictions History tour of regulr expression mtching Thompson s lgorithm Myers lgorithm New lgorithm Results nd extensions

More information

Lecture 9: LTL and Büchi Automata

Lecture 9: LTL and Büchi Automata Lecture 9: LTL nd Büchi Automt 1 LTL Property Ptterns Quite often the requirements of system follow some simple ptterns. Sometimes we wnt to specify tht property should only hold in certin context, clled

More information

Finite-State Automata: Recap

Finite-State Automata: Recap Finite-Stte Automt: Recp Deepk D Souz Deprtment of Computer Science nd Automtion Indin Institute of Science, Bnglore. 09 August 2016 Outline 1 Introduction 2 Forml Definitions nd Nottion 3 Closure under

More information

Non-deterministic Finite Automata

Non-deterministic Finite Automata Non-deterministic Finite Automt From Regulr Expressions to NFA- Eliminting non-determinism Rdoud University Nijmegen Non-deterministic Finite Automt H. Geuvers nd J. Rot Institute for Computing nd Informtion

More information

Let's start with an example:

Let's start with an example: Finite Automt Let's strt with n exmple: Here you see leled circles tht re sttes, nd leled rrows tht re trnsitions. One of the sttes is mrked "strt". One of the sttes hs doule circle; this is terminl stte

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

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

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

State Minimization for DFAs

State Minimization for DFAs Stte Minimiztion for DFAs Red K & S 2.7 Do Homework 10. Consider: Stte Minimiztion 4 5 Is this miniml mchine? Step (1): Get rid of unrechle sttes. Stte Minimiztion 6, Stte is unrechle. Step (2): Get rid

More information

More on automata. Michael George. March 24 April 7, 2014

More on automata. Michael George. March 24 April 7, 2014 More on utomt Michel George Mrch 24 April 7, 2014 1 Automt constructions Now tht we hve forml model of mchine, it is useful to mke some generl constructions. 1.1 DFA Union / Product construction Suppose

More information

Module 9: Tries and String Matching

Module 9: Tries and String Matching Module 9: Tries nd String Mtching CS 240 - Dt Structures nd Dt Mngement Sjed Hque Veronik Irvine Tylor Smith Bsed on lecture notes by mny previous cs240 instructors Dvid R. Cheriton School of Computer

More information

Module 9: Tries and String Matching

Module 9: Tries and String Matching Module 9: Tries nd String Mtching CS 240 - Dt Structures nd Dt Mngement Sjed Hque Veronik Irvine Tylor Smith Bsed on lecture notes by mny previous cs240 instructors Dvid R. Cheriton School of Computer

More information

CHAPTER 1 Regular Languages. Contents. definitions, examples, designing, regular operations. Non-deterministic Finite Automata (NFA)

CHAPTER 1 Regular Languages. Contents. definitions, examples, designing, regular operations. Non-deterministic Finite Automata (NFA) Finite Automt (FA or DFA) CHAPTER Regulr Lnguges Contents definitions, exmples, designing, regulr opertions Non-deterministic Finite Automt (NFA) definitions, equivlence of NFAs DFAs, closure under regulr

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