Make DFA of the set of all strings from {0,1} whose tenth symbol from the right end is a 1 - dfa

What will be the transition diagram of the set of all strings from {0,1} whose tenth symbol from the right end is a 1 ?
I know the regular expression is (0+1)*1(0+1)(0+1)(0+1)(0+1)(0+1)(0+1)(0+1)(0+1)(0+1)
But I couldn't turn it into DFA.

I encountered this question in Introduction to Automata Theory, Languages, and Computations by John E. Hopcroft, Rajeev Motwani, Jeffrey D. Ullman.
First, we need to get hold of the NFA here. This would have 11 states in linear formation with the start having a self loop with 0,1 and a transition to the next state with 1 (not 0). All the other 9 transitions from qi -> qi+1 would have transition for 0,1 both. The last state, q10 will be our accept state.
That was fairly a straightforward approach for the NFA. Now if we convert this NFA to a DFA considering all 211 subsets of set of states of the NFA, we would get the solution.
I will add the NFA Diagram when I get some time. And try to figure out an easy trick to solve the DFA without considering all the possibilities.
You can look at Example 1.30 from Introduction to the Theory of Computation - M. Sipser - 3rd Edition at page 51. There they showed an NFA for strings having 1 at the third position from the end would have 4 states but that corresponding DFA would have 8 states. Not posting the screenshots for copyright issues.

DFA of the set of all strings from {0,1} whose tenth symbol from the right end is a ...
the regular expression for given language is :
(0+1)*1(0+1)(0+1)(0+1)(0+1)(0+1)(0+1)(0+1)(0+1)(0+1)
Hope you got it..!!

Related

Construct a Deterministic Finite Automata (DFA) for the language 1*01 (11)*(0 U 1)*,

Construct a Deterministic Finite Automata (DFA) for the language where the set of all strings are of the form 1*01 (11)*(0 U 1)*, that contain 01 as a substring
Without providing the direct answer, you should know the building blocks to be able to arrive there. Given that you know how finite automata work (otherwise read 'Languages and Machines' by Sudkamp), the DFA has a transitation for every symbol in every state:
Unlike for non-deterministic finite automata or NFA that we encounter in the next section, for a DFA in each state q ∈ Q and for every symbol a ∈ Σ the next state,
which is the state δ(q, a), is determined by the transition function δ. 1
Note: if you are a visual thinker and you wonder how the diagrams in these books are constructed, here is an example visualisation.

DFA of two simple languages and then product construction of those two languages

The language below is the intersection of two simpler languages. First, identify the simpler languages and give the state diagrams of the DFAs that recognize them. Then, use the product construction to build a DFA that recognizes the language specified below; give its state diagram before and after simplification if there are any unneeded states or states that can be combined.
Language: {w is a member of {0,1}* | w contains an odd number of 0s and the sum of its 0s and 1s is equal to 1}
This is my proposed solution: https://imgur.com/a/lh5Hwfr Should the bottom two states be connected with 0s?
Also, what would be the DFA if it was OR instead of AND?
Here's a drawing I hope will help understand how to do this:
Language A is "odd number of zeros". States are labeled Z0 and Z1 indicating even or odd number of zeros.
Language B is "exactly one one" (which is equivalent to "sum of digits equals one"). States are labeled I0, I1 and I2 indicaing zero, one or more ones.
Language A+B can be interpreted as A∩B (ignoring the dotted circles) or AUB (counting the dotted circles). If building A∩B, states Z0I2 and Z1I2 can be joined together.
I hope this gives not only an answer to the exact problem in the question, but also an idea how to build similar answers for similar problems.

NFA to DFA conversion = deterministic?

I am struggling a bit with the meaning of determinism and nondeterminism. I get the difference when it comes to automata, but I can't seem to find an answer for the following: Is a NFA to DFA transformation deterministic?
If multiple DFAs can be constructed for the same regular language, does that mean that the result of a NFA to DFA transformation is not unique? And thus a nondeterministic algorithm?
I'm happy with any information you guys might be able to provide.
Thanks in advance!
There are two different concepts at play here. First, you are correct that there can be many different DFAs equivalent to the same NFA, just as there can be many NFAs that are all equivalent to one another.
Independently, there are several algorithms for converting an NFA into a DFA. The standard algorithm taught in most introductory classes on formal languages is the subset construction (also called the powerset construction). That algorithm is deterministic - there's a specific sequence of steps to follow to convert an NFA to a DFA, and accordingly you'll always get back the same DFA whenever you feed in the same NFA. You could conceivably have a nondeterministic algorithm for converting an NFA to a DFA, where the algorithm might produce one of many different DFAs as output, but to the best of my knowledge there aren't any famous algorithms of this sort.
Hope this helps!
DFA- means deterministic finite automata
Where as NFA- means non deterministic finite automata..
In dfa for every state there is a transition for both the inputs... I we have...{a, b} are the inputs for the given question.. For.. Every state there is a transition for both a and b... That automata is known as deterministic finite automata..
Where as in NDA we need not to have both input transitions for every state... At least one transition... is sufficient...
In NFA Epsilon transition is also accepted.. And dead state is also accepted...
In nfa... No of states required is less.. When compare to dfa.. Every dfa is equivalent to nfa... But every dfa is not equivalent to nfa...

Steps to creating an NFA from a regular expression

I'm having issues 'describing each step' when creating an NFA from a regular expression. The question is as follows:
Convert the following regular expression to a non-deterministic finite-state automaton (NFA), clearly describing the steps of the algorithm that you use:
(b|a)*b(a|b)
I've made a simple 3-state machine but it's very much from intuition.
This is a question from a past exam written by my lecturer, who also wrote the following explanation of Thompson's algorithm: http://www.cs.may.ie/staff/jpower/Courses/Previous/parsing/node5.html
Can anyone clear up how to 'describe each step clearly'? It just seems like a set of basic rules rather than an algorithm with steps to follow.
Maybe there's an algorithm I've glossed over somewhere but so far I've just created them with an educated guess.
Short version for general approach.
There's an algo out there called the Thompson-McNaughton-Yamada Construction Algorithm or sometimes just "Thompson Construction." One builds intermediate NFAs, filling in the pieces along the way, while respecting operator precedence: first parentheses, then Kleene Star (e.g., a*), then concatenation (e.g., ab), followed by alternation (e.g., a|b).
Here's an in-depth walkthrough for building (b|a)*b(a|b)'s NFA
Building the top level
Handle parentheses. Note: In actual implementation, it can make sense to handling parentheses via a recursive call on their contents. For the sake of clarity, I'll defer evaluation of anything inside of parens.
Kleene Stars: only one * there, so we build a placeholder Kleene Star machine called P (which will later contain b|a).
Intermediate result:
Concatenation: Attach P to b, and attach b to a placeholder machine called Q (which will contain (a|b). Intermediate result:
There's no alternation outside of parentheses, so we skip it.
Now we're sitting on a P*bQ machine. (Note that our placeholders P and Q are just concatenation machines.) We replace the P edge with the NFA for b|a, and replace the Q edge with the NFA for a|b via recursive application of the above steps.
Building P
Skip. No parens.
Skip. No Kleene stars.
Skip. No contatenation.
Build the alternation machine for b|a. Intermediate result:
Integrating P
Next, we go back to that P*bQ machine and we tear out the P edge. We have the source of the P edge serve as the starting state for the P machine, and the destination of the P edge serve as the destination state for the P machine. We also make that state reject (take away its property of being an accept state). The result looks like this:
Building Q
Skip. No parens.
Skip. No Kleene stars.
Skip. No contatenation.
Build the alternation machine for a|b. Incidentally, alternation is commutative, so a|b is logically equivalent to b|a. (Read: skipping this minor footnote diagram out of laziness.)
Integrating Q
We do what we did with P above, except replacing the Q edge with the intermedtae b|a machine we constructed. This is the result:
Tada! Er, I mean, QED.
Want to know more?
All the images above were generated using an online tool for automatically converting regular expressions to non-deterministic finite automata. You can find its source code for the Thompson-McNaughton-Yamada Construction algorithm online.
The algorithm is also addressed in Aho's Compilers: Principles, Techniques, and Tools, though its explanation is sparse on implementation details. You can also learn from an implementation of the Thompson Construction in C by the excellent Russ Cox, who described it some detail in a popular article about regular expression matching.
In the GitHub repository below, you can find a Java implementation of Thompson's construction where first an NFA is being created from the regex and then an input string is being matched against that NFA:
https://github.com/meghdadFar/regex
https://github.com/White-White/RegSwift
No more tedious words. Check out this repo, it translates your regular expression to an NFA and visually shows you the state transitions of an NFA.

NFA to DFA conversion whose language is the complement of L(A)

Can someone please help me with this question?
Describe an algorithm that converts an NFA into a DFA whose language is the complement of L(A). The complement should be taken with respect to the alphabet of A. Given an informal argument for why your construction works. You need not give a formal proof.
Any kind of guidance is appreciated...
You can convert a FA to its complement by turning its accept states into non-accept states, and turning its non-accept states into accept states. Easy!
You can convert a NFA to a DFA by considering that any NFA state is a power of the states: that is, for each state in the NFA, it is either active or not active. You can map each of these states to a state in a DFA, so you end up with at most 2|Q| states for your DFA which represents your NFA.
Edit: this algorithm and its proof do not actually need the details of A, so long as it is a valid Finite State Automaton.

Resources