Enter a description of the language accepted by following Deterministic Finite Automata - finite-automata

I try to minimize it but it didn't help so here is the DFA that tricks my mind:
here are some of the rejected strings but I didn't come up with a solution from that...
1, 00, 000, 001, 010, 100, 0000, 0001, 0010, 0100, 1000, 00000, 00001, 00010, 00100, 01000, 10000

For problems like this, where the DFA has a lot of accepting states, it's often a good idea to reason about what strings the DFA rejects rather than what it accepts.
In this case, only states q2 and q4 reject, and the language described by rejections is more straightforward. To get to q2, you need 000*. To get to q4, you need 000*10* or 0100* or 1000*.
So the strings that are rejected are those have at least 2 0s, and at most one 1.
Ergo, the strings that are accepted are those that have two or more 1s or have at most one 0. Note that this description covers the empty string and short strings like 1, 0, 01, 10 and 11 (they all have at most one 0).

Related

what is Boundary Value Analysis?

In an eCommerce website, the first name text field accepts a maximum of 30 characters, What are the BVA values?
Boundary values are the thresholds where a program behaves differently.
For instance, suppose I am sending messages. Each message must be split into packets of between 1 and 100 bytes. If the message is 100 bytes then one packet should be sent. If the message is 101 bytes then two packets should be sent. There is a boundary between 100 and 101 bytes. Both lengths should be tested.
Bugs typically happen at boundary values because that is where off-by-one errors and similar problems exist. In the message example above, you might find that a 100 byte message gets sent as two packets, or a 101 byte message drops the last byte, because of some subtle bug in the packet logic. This might happen even though shorter or longer messages get sent correctly, which is why it is important to concentrate on boundary values when testing.
Boundary Value Analysis is the process of identifying boundary values, both by inspecting the specification and inspecting the code. Look for conditions on things like length and range. For instance, if a field must be all letters then check values like 'a' (0x61), '`' (backtick, 0x60), 'z' (0x7a) and '{' (0x7b). If a field must not be more than 30 characters, check 30 and 31. And so on.
(Also, don't forget that Unicode is a thing: check non-English and non-Latin characters too).

DFA for odd sequences of 1 and 0

I want to create a DFA for language {1,0} which accepts only words build from sequences of odd 1 and 0.
I've found many examples for DFA with even/odd numbers of 0 and 1 in a string but not in each sequence of that string. I cannot grasp how to create said graph. Should it be build with 4 states or maybe 3?
Just thought about something, is this one correct or am I mistaken here?
Ok, so this one was wrong, but maybe this one?
With this one, however, I fell like you always have to start with either one 1 or one 0 and won't get more in the first sequence so it's not relly perfect...
Kind regards,
Give a deterministic finite automaton accepting those words over the alphabet {0, 1}, where each series of zeros and each series of 1s is of odd length.
Is not 100% unambiguous. I personally understand, that the empty word, and a word consisting solely of 0s or solely of 1s is also part of the language (if it is of odd length). Then something like the following should do the trick.
State 1 is the starting state. The "upper" branch (ie states 2, 3) is for accepting any odd number of 0, the "lower" branch (ie states 4,5) accepts any odd number of 1. You can "enter" the respective branch only by reading a single instance of the respective symbol, either starting from the empty word, or after reading an odd number of the respective other symbol.
For instance the word 1000111110001. After reading a single 1 you are in state 4. By reading a single 0, you switch to the "upper branch" and now can read any even (in this case 2) number of 0, which will always bring you back to the accepting state 2. Reading a 1 in state 3 is not possible (because the word would be invalid). Reading a single 1 in state 2 brings you back to state 4. And from here similar to the above, you can read any even number (in this case 4) of 1 which will always bring you back to the accepting state 4. And so on and so forth. If the symbol changes (or the word ends) after an even number of equal symbols, you are either in state 3 or 5, which are both not accepting, thus the word won't be accepted.

Why is my very small number not being stored precisely?

In an answer on StackOverflow en Español, I showed that Perl 6 avoids the calculation errors of many other languages because it keeps track of the numerators and denominators. That is to say, decimal numbers are actually represented as Ratios. However, it does make a small error with very small numbers:
> 0.000000000000000000071.nude.perl
(71, 1000000000000000000000)
> 0.0000000000000000000071.nude.perl
(71, 10000000000000000000000)
> 0.00000000000000000000071.nude.perl
(71, 99999999999999991611392)
Is this something that will be fixed in future versions?
I get the same answers using perl6/rakudo-star-2015.09 and perl6/rakudo-star-2015.11
Denominators are supposed to be limited to 64-bit - you need a FatRat to go beyond that.
However, said limit does not appear to be enforced in current Rakudo: If you do so manually, it will happily construct your number via Rat.new(71, 10**23).
My guess would be you have uncovered a bug in the handling of rational literals, but it might only trigger in code that is not future-proof anyway.
edit: It is possible to use angle brackets to get an allomorphic value, and this produces the correct value. In fact, regular rational literals are also specced to fall back to RatStr on overflow.
However, this fallback mechanism does not appear to be implemented in Rakudo.

What is 4’d# notation?

In an Atmel datasheet, I see a notation I've never seen before, for example:
Register bits MAX_BE define the maximum value of the backoff exponent in the CSMA- CA algorithm. It equals macMaxBE; refer to section 7.5.1.4 of [2]. Valid values are [4’d8, 4’d7, ... , 4’d3].
How does one interpret/decode the 4’d# values?
That looks like verilog to me (or at least it's the same format as verilog uses).
4'd# means a 4-bit field, with a decimal value of #.
So 4'd8 is binary 1000.
Other number formats can be 'h (hex representation), or 'b (binary representation)
examples:
16'd1 = 0000000000000001
8'hff = 11111111
5'b10101 = 10101
(etc).
I'm not sure what the notation is supposed to mean, but a similar datasheet for an Analog Devices chip lists the valid values as 3 to 8, so I'd guess the actual values this one wants are also 8,7,..3.
Edit
I think Tim is right.

Is this language regular?

Is a language that accepts n(n-1)(n-2)/6+n(n-1)/2+1 many numbers of {0,1}^n for every n is a regular language?
I have a question to draw the dfa of those language, but I'm not even sure whether it is a regular one.
This sounds like homework, and I'm guessing the question is: draw a DFA that accepts exactly n(n-1)(n-2)/6+n(n-1)/2+1 words of length n (over the alphabet {0,1}). Lets construct the automaton as an intersection of two DFAs.
The first automaton accepts words of length n. This is very easy - there is a chain of n+1 states. The first state is the initial state, only the last state is accepting, and every state has a transition labeled 0,1 to the next state in the chain. The accepting state has no outgoing transitions.
The second automaton accepts words in which there is one, two, or three 1s. Also, very easy - we need 4 states: q_0, q_1, q_2, q_sink. The state q_0 is the initial state, the states q_0,q_1,q_2 are accepting, and they have a self loop with 0. There are transitions q_0 --1--> q_1 --1--> q_2 --1--> q_sink. Finally, q_sink is rejecting and it has a self loop with 0,1.
In order to construct the intersection of the automata we need the product of the two automata. This is a general construction which also isn't very hard.