


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Solutions for practice with automata, specifically focusing on designing DFAs. It includes examples and possible options for designing DFAs for different languages. The document also provides tips and tricks for designing DFAs. The topics covered in this document are automata, DFAs, states, and languages.
Typology: Lecture notes
1 / 4
This page cannot be seen from the preview
Don't miss anything!



CS103A Handout 07S Winter 2020
Because this problem was really designed to get you exploring around with DFAs, we haven't included solu- tions per se. However, here are a few thoughts that we hoped you'd have in the course of working through this problem: ๏ท The language L โ consists of all strings whose length leaves a remainder of three when divided by five. ๏ท For L โ, the DFA needs to remember the remainder of the length of the string when that length is divided by five. It's probably best to make the states correspond to the different remainders. ๏ท For L โ, the DFA needs to remember both the remainder of the number of a's when divided by two and the remainder of the number of b's when divided by three. Each state corresponds to a pair of an โa remainderโ and a โb remainder.โ There are six possible combinations. You can think about building the DFA by having each transition move between states by updating either the number of a's or the number of b's, depending on what was read.
i. Let ฮฃ = {a, b} and let L = {baa}. Design a DFA for L. Here is one possible option: This basically consists of a chain of states leading up to baa with a dead state for any deviations from that string.
ii. Let ฮฃ = {a, b} and let L = { w โ ฮฃ* | w โ ฮต and the first and last character of w are the same }. Design a DFA for L. Here is one possible option: In the start state, we wait to see what the first character is. We then transition either to the top branch (first char- acter a ) or the bottom branch (first character b ). At that point, we just need to remember what the last character we read was and can use that to decide whether to accept. iii. Let ฮฃ = {a, b} and let L = { w โ ฮฃ* | w is a nonempty string whose characters alternate between a's and b's }. Design a DFA whose language is L. Here's one possible option: In the start state, we wait to see what the first character is. We then transition either to the top state (first charac- ter a ) or the bottom state (first character b ). The transitions then permit us to bounce back and forth between the two states as long as we alternate, and if we ever deviate from the rule we enter the dead state on the right. Why we asked this question: There are a couple of canonical tricks in the design of DFAs. Part (i) was a check to make sure you remembered to include a transition on every state/symbol combination. Part (ii) demonstrates how to build an automaton that can remember one of finitely many pieces of information persistently (namely, what the first character is), and part (iii) combines the two.
i. Let ฮฃ = {a, b} and let L = { w โ ฮฃ* | the third-from-last character of w is a }. Design an NFA for L. Your NFA should use at most four states. Along the lines of the โends with cabโ problem, this NFA stays in the start state until it nondeterministically guesses that it's three characters from the end: ii. Using the subset construction, convert your NFA from part (i) into an equivalent DFA. (Although you could just directly design a DFA for this language, we want you to practice using the subset construction to get a sense of how it works.) You may find it useful to construct the transition table for the DFA rather than to write out a state-transition diagram. For readability's sake, we've encoded this one as a transition table. It's shown below: state a b { q โ} { q โ, q โ} { q โ} { q โ, q โ} { q โ, q โ, q โ} { q โ, q โ} { q โ, q โ, q โ} { q โ, q โ, q โ, q โ} { q โ, q โ, q โ} { q โ, q โ} { q โ, q โ, q โ} { q โ, q โ} * { q โ, q โ, q โ, q โ} { q โ, q โ, q โ, q โ} { q โ, q โ, q โ} * { q โ, q โ, q โ} { q โ, q โ, q โ} { q โ, q โ} * { q โ, q โ, q โ} { q โ, q โ, q โ} { q โ, q โ} * { q โ, q โ} { q โ, q โ} { q โ} Why we asked this question: The beauty of the automata transformations we've seen so far is that it lets us study the same class of objects โ the regular languages โ using one of three totally different lenses. The con- structions are a bit tricky, though, and to help you get a handle for how they work, we wanted you to practice working through them on a few special cases. This particular case, in our opinion, wasn't too tough of a sample input.