Give state diagrams of DFAs recognizing the following languages. In all parts the alphabet is {0,1 } - deterministic

Im trying to get the hang of drawing DFAs. I have the following problem to do with my following attempt, was wondering if anyone could tell me if im correct, or if incorrect what im doing wrong. Thanks! Also, if anyone has a good resource to learn more about how to do these, it would be greatly appreciated.
Give state diagrams of DFAs recognizing the following languages. In all parts the alphabet is {0,1 }
{w | the length of w is at most 5}

Here are some clues.
"At most 5": this implies you must do some counting. In state machines, counting is accomplished by the context of each node. In other words, you will require a number of nodes, each with a special meaning, and that meaning will be your "counter value."
"At most 5": This means you must accept words of length 0, 1, 2, 3, 4, and 5. (All of which have unique values, hint hint.)
Your alphabet is {0,1}, but there are no requirements of the language of the frequency, ordering, or anything related to 0 and 1. This means every time there is a transition for 0, the same transition must be available to 1, and vice versa. (Or some equivalent relation that reduces to this rule - but this is in parentheses because it's not something you need to think about.)

Here are your errors:
You have no marked start state.
The strings "0", "" (the empty string), "1" are rejected, but are within the prescribed language. In other words, you are accepting only words that are exactly length 5, not all words that are length 5 and less.
Since the alphabet is {0, 1}, you must specify at EACH state what happens when either a 0 or a 1 is encountered. If you encounter an input character whose edge is NOT specified, by convention you are going to the dead state, a state that always returns to itself and is never accepted, but is left undrawn. This is why your right-most state is unnecessary, but your left states are incomplete.
Final, big hint: You can have more than one "Accept" or "Final" state.

I think the DFA shown above is wrong. It will accept strings up to length 5 so you should make all the first six states to be final states. You are accepting only '1's but it should also accept '0's......so attach 0 with all 1's.

Related

What state will this finite automata go when reading a symbol which is not belong to its alphabet?

As we know, the definition of 'finite state automata' is:
Then we have this finite state automat described as:
Then we have the conclusion:
Question is : Instead of accept an empty string, what if the automat first read string is '2', which is not belong to the alphabet(0,1) of this automata. will this automata still go to accept state?
pics quoted from book <Introduction to the Theory of Computation>
When a machine is defined, one of its items is the alphabet (second one in your definition). We are not allowed to test our machine outside the scope of the alphabet. Therefore, all strings of L (accepted strings) and L-bar (rejected strings) should come out of Sigma-start.

Construct nfa occuring strings over {0,1} such that some two 0's are seperated by a string of length 4i, i>=0

I am trying to solve this problem by first designing an NFA for a string of length 4i, as this is in the form of 0(mod 4).
Number of states = 4 and I just added 2 other states, one on each end of this design, and made a transition on 0, now number of states=6. My solution is wrong when I tried checking. Can someone pls explain where I am going wrong?
The high-level design for this NFA is correct, there are just a few missing details. One strategy I've found helpful when designing NFAs is to first start by coming up with a set of test cases or test strings. That is, if I were writing a program to check whether or not a string met these certain properties, what strings would I test? What would the edge cases be? These can help you spot patterns when you're first designing the NFA and you can use them to check your work afterwards.
For example, here are some of the test cases I would check for this problem:
00 \\ i = 0
010100 \\ i = 1
0101011010 \\ i > 1, handles lengths of larger multiples of 4
011110, 000000 \\ it shouldn't matter what's in between the two 0s
111010100 \\ can have anything before the two 0s
010100111 \\ can have anything after the two 0s
... etc...
You should consider these two in particular:
000000 - in the loop of your NFA that's checking whether or not the length of the string in between the two 0s is a multiple of 4, there is no restriction on the contents of this string. Specifically, there's no reason that the first character of this string cannot be a 0 (the transition from q1 to q5).
010100111 (and/or 0101001110, 0101000) - these are all examples of strings where we have two 0s separated by a string of length 4i, followed by some other characters. These strings should also be accepted by your NFA but currently are not - remember that an NFA accepts if it finishes in an accepting state, and that if an NFA needs to make a transition and no transition exists, it dies and that path rejects.
Do you see what modifications you can make to address these problems?

How to recognize if word has no meaning, maybe some impossible syllables?

Initially, I have m arrays of n characters, where each array contains unknown (for me) character of needed word (condition: word has meaning).
For example, m = 4, n = 3: array0 = {'t', 'e', 'c'}, array1 = {'g' 'o' 'a'}, array2 = {'w' 'd' 'y'}, array3 = {'e' 'o' 's'}. Each array contains only one correct letter: in array0 is first letter, in array1 - second... So, the probable secret word is 'code': array0[2] = 'c', array1[1] = 'o', array2[1] = 'd', array3[0] = 'e'.
I need to find all of existing letter-combinations, i.e. exclude generated meaningless words.
Are there any rules/regularities of 'impossible' syllables/letter-combinations in English?
I'm attacking Vigenere's cipher. So, I know the length of key and its probable characters. I'm shuffling my arrays and getting many meaningless words. Problem is to filter them. As I get it, some conditions can help to recognize incorrect words. For example, if word length is > 4 then all vowel chars, or all consonant chars word is wrong. Some syllables, such as kk *hh* ww, in general, are impossible too. Where can I find such rules?
I'm supposing what you mean by the "word has meaning" is that it is an English dictionary word.
I believe that you should approach the problem from the other direction, as GregS suggests, and go through a dictionary. English has many exceptions when it comes to letters and spelling, and the number of words that look English are much greater than the actual number of English words. You won't be able to cut down your search very much in that way.
But because you know the length and probable characters you are able to quickly throw out many dictionary words. Also, if the message isn't too short, it would also be very fast to attempt a decoding of the message with possible words, and throw out unlikely decodings by letter, digram or trigram frequencies.
I'm not sure I follow your strategy for attacking a Vigenere cipher. However, in response to:
I need to find all of existing letter-combinations, i.e. exclude generated meaningless words. Are there any rules/regularities of 'impossible' syllables/letter-combinations in English?
Yes, indeed there is a plethora of such rules. There are two ways of learning and implementing these rules:
Carefully study the morphology of English, and meticulously implement the rules.
Train a Markov model on a corpus of English text.
1 will be substantially less work for little additional benefit.

How can I construct finite automata

I have to create a deterministic finite automata accepting the set of strings with an even number of 1 and ends with 0.Should I include 0 as a string from this set? and how can I do this?
Should I include 0 as a string from this set?
Yes
And how do I do this?
To construct a finite automaton, you need to identify the states and transitions. The Myhill-Nerode theorem allows you to find the necessary (and sufficient!) states of for a finite automaton if you are able to identify the equivalence classes of "indistinguishable" strings.
Two strings x and y are indistinguishable, in this sense, if for any other string z, either both xz and yz are in the language, or neither is.
In your case, let's try to identify equivalence classes. The empty string is in some equivalence class. The string 0 is in a different equivalent class, since you can add the empty string to 0 and get a string in the language (whereas you can't add the empty string to the empty string to get a string in the language). We have found two distinct equivalence classes so far - one for the empty string, one for 0. Both of these will need different states in our FA.
What about the string 1? It's distinguishable from both 0 and the empty string, since you can add 10 to 1 to get 110, a string in the language, but you can't add it to 0 or the empty string to get a string in the language. So we have yet another state.
What about the string 00? This string is not in the language, and no other string can be added to this string to get a string in the language. This is another equivalence class. It turns out that the next strings, 01 and 10, are also in this class.
The string 11 ends up being in the same class as the empty string: you can add any string in the language to 11 and get another string in the language. If you try all strings of length 3, you will find that all of those already fall into one of the above classes, and you can stop checking at that point.
So we have four states - let's call them [-], [0], [1], and [00]. Now we figure out transitions.
If you get a 0 in [-], you need to go to [0]... and if you get a 1, you need to go to [1]. For the rest, just figure out what string you'd get by adding to the canonical one, and which class the resulting string would be in... and go to that state.
Given Question is to construct a Finite Automata with even number of 1's and ends with 0.
So the alphabet of the language is {0,1}
These are the the strings that are accepted by the language.
The Language always consists of '0' before its final state as it is the end of the string and we reach the final state when we reach the last '0' in the string.
Here in the normal procedure of conversion of it into the finite automata we get NFA
Then we need to convert the NFA to DFA by combining 2 states into single and simplifying them.
New transition diagram
Here we had drawn the new transition diagram based on the states reached by a specific state at a given input. Then the new states formed by joining 2 states [ here {q0,q2} state is formed]
This new state {q0,q1} on 0 as input goes to itself (as q0 on 0 goes to q0 and q2 on 0 goes to q2).
So let us conside this new state {q0,q2} as a new state q2'
So by using the Transition state diagram we can easily make the required DFA
Deterministic Finite Automata
The above diagram is the constructed finite automata accepting the set of strings with an even number of 1's and ending with 0.
q0 - is the Initial state
q2'- is the Final state

What is the technical term for the input used to calculate a checkdigit?

For example:
code = '7777-5';
input = code.substring(0, 4); // Returns '7777'
checkdigit = f(input); // f() produces a checkdigit
assert.areEqual(code, input + "-" + checkdigit)
Is there a technical term for input used above?
Specifically I'm calculating checkdigits for ISBNs, but that shouldn't effect the answer.
Is "original number excluding the check digit" technical enough? :)
Actually, it's often the case, as in the link you posted, that the check digit or checksum ensures a property about the full input:
...[the check digit] must be such that the sum of all the ten digits, each multiplied by the integer weight, descending from 10 to 1, is a multiple of the number 11.
Thus, you'd check the full number and see if it meets this property.
It's "backwards" when you're initially generating the check digit. In that case, the function would be named generate_check_digit or similar, and I'd just name its parameter as "input".
Although I am not sure if there is a well-known specific technical term for the input, what LukeH suggested (message/data) seems common enough.
Wiki for checksum:
With this checksum, any transmission error that flips a single bit of the message, or an odd number of bits, will be detected as an incorrect checksum
Wiki for check digit:
A check digit is a form of redundancy check used for error detection, the decimal equivalent of a binary checksum. It consists of a single digit computed from the other digits in the message.