Search code examples
finite-automata

Definition of the "DFA for a language"


I just started learning Theory of Computation this semester and a bit confused by the phrase "DFA for a language". If it is asked to construct a DFA for some collection of binary strings L, does it mean to find DFA M with L(M)=L or just $L(M)\supset L$?


Solution

  • Most compiler/theory courses tend to have different styles surrounding teaching definitions of deterministic finite automata and formal languages, but I'll try to make this description as agnostic as possible.

    The phrase "DFA for a language" loosely means: a DFA which accepts every word in the language and rejects every word not in the language. The way I was taught DFAs is to have final/accepting states and regular states which removes the necessity for an implicit error state. This means that a DFA accepts a word if the state it is in at the end of input is accepting and it rejects the word if the state is not accepting.

    Ex:

    Let's define L as the language which contains an even number of 1s. These will be binary strings so the symbols are just 0 and 1. 00, 110, 111, 1111, etc are examples of words in this language. Notice that the empty string is in this language.

    We can have two states in our DFA. The starting state, let's call it even 1s, is also an accepting state because 0 ones is even. The other state is odd 1s, this is not accepting.

    As for transitions, when even 1s receives a 1, it transitions to odd 1s. And when odd 1s receives a 1, it transitions to even 1s. Now, the number of 0s doesn't matter, so in either state, it transitions to itself.

    enter image description here

    Apologies for the double arrow, this website is great but I couldn't figure out how to separate the transitions between even 1s and odd 1s