170 likes | 258 Views
CSE 105 Theory of Computation. Alexander Tsiatas Spring 2012. Theory of Computation Lecture Slides by Alexander Tsiatas is licensed under a Creative Commons Attribution- NonCommercial - ShareAlike 3.0 Unported License. Based on a work at http://peerinstruction4cs.org.
E N D
CSE 105Theory of Computation Alexander Tsiatas Spring 2012 Theory of Computation Lecture Slides by Alexander Tsiatas is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License. Based on a work at http://peerinstruction4cs.org. Permissions beyond the scope of this license may be available at http://peerinstruction4cs.org.
If a language isn’t regular, it just might be one of the… Context-Free LanguagesPDA
Understanding Pushdown Automata The edge from q0 to q1 does what? • Lets you go to q1 without reading any input (on ε) • Lets you go to q1 on εor ‘$’ • Lets you go to q1 on ‘$’
Understanding Pushdown Automata In addition to what we said in the last question, the edge from q0 to q1 does what else? Pushes one entry onto the stack (ε) Pushes one entry onto the stack (‘$’) Pushes two entries onto the stack (ε and ‘$’) Pops two entries off the stack (ε and ‘$’)
Tracing in a Pushdown Automaton b Input “aabb” into this PDA. After “aa” has been read, what is on the stack? top of stack bottom of stack
Language of a Pushdown Automaton b Which is the bestdescription of the language of the given PDA? • { w | number of b’s in w >= number of a’s in w} • {w | w = anbn+1for some n>=0} • { w | w = anbn+2 for some n>=0} • { w | w = anb2nfor some n>=0} • {w | w = 0anb2n0 for some n>=0}
Tracing in a Pushdown Automaton e • Which string is NOT accepted by this PDA? • aabb • abbbc • abbccc • aabcc • None or more than one of the above
Tracing in a Pushdown Automaton c • Which choice depicts a stack state that occurs at some point during the successful* processing of the string “aaabbbc” on the given PDA? top of stack bottom of stack • None of the above * Ignore all nondeterministic paths that end in rejecting/getting stuck.
Why did we push ‘#’ onto the stack? e • We didn’t have to, because we already “counted” the a’s by pushing them on the stack • It’s something we do because of convention, but it isn’t necessary to correctness • We did it to make sure that we didn’t cause a crash/error by trying to pop something off an empty stack • It is necessary for correctness • None or more than one of the above
CFLs! The Class of Context-Free Languages
Which Venn diagram best represents the classes of languages we have studied? (a) (b) CFLs CFLs RLs RLs (c) (d) (e) None of the above Note: CFLs = Context-Free Languages, RLs = Regular Languages CFLs = RLs RLs CFLs
What methods can we use to prove/disprove each of these? (a) (b) CFLs CFLs RLs RLs (c) (d) Note: CFLs = Context-Free Languages, RLs = Regular Languages CFLs = RLs RLs CFLs
Closure properties of context-free languages? • Remember the direction: • If L1 and L2 are context-free languages, thenL1 U L2 is a context-free language. • Are context-free languages closed under union? • Yes • No
Closure under union: CFG’s Grammar for L1: Grammar for L2: S1 → Stuff S2 → Other stuff More stuff Even more stuff Construct a grammar for L1 U L2?
Closure under concatenation: CFG’s Grammar for L1: Grammar for L2: S1 → Stuff S2 → Other stuff More stuff Even more stuff Construct a grammar for L1 L2?
Closure under intersection…? • Think about it for next class!