Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
lfa:2025:lab01 [2025/10/05 23:26]
tpruteanu created
lfa:2025:lab01 [2025/10/07 12:02] (current)
tpruteanu
Line 13: Line 13:
 === 2.1. Write DFAs for the following languages: === === 2.1. Write DFAs for the following languages: ===
  
-**2.1.1.** $ L=\{w \in \{0,1\}^* \text{ | w contains an odd number of ones} \} $.+ 
 +**2.1.1.** The language of binary words which encode odd numbers (the last digit is least significative). 
 + 
 + 
 +/​*<​hidden>​ 
 +{{:​lfa:​2022:​lfa2022_lab2_ex3.png?​300|}} 
 +  * We pass through the word, marking the parity of the last character that we have read. 
 +</​hidden>​*/​ 
 + 
 +**2.1.2.** $ L=\{w \in \{0,1\}^* \text{ | w contains an odd number of ones} \} $.
  
  
Line 27: Line 36:
  
  
-**2.1.2.** The language of binary words which contain **exactly** two ones. +**2.1.3.** The language of binary words which contain **exactly** two ones.
  
 /​*<​hidden>​ /​*<​hidden>​
Line 39: Line 47:
  
  
-**2.1.3.** The language of binary ​words which encode ​odd numbers ​(the last digit is least significative).+**2.1.4.** (*) The language of words which encode ​binary ​numbers ​divisible by 3.
  
 +**2.1.5.** (* *) The language of words which encode binary numbers divisible by 3, represented in reverse order (the least significant digit is first).
  
-/​*<​hidden>​ +**2.1.6.** (*) The language of quaternary words (base 4), that follow the rule that every zero is immediately followed by a sequence of at least 2 consecutive threes and every one is immediately followed by a sequence of at most 2 consecutive twos.
-{{:​lfa:​2022:​lfa2022_lab2_ex3.png?​300|}} +
-  * We pass through the word, marking the parity of the last character that we have read. +
-</​hidden>​*/​ +
- +
- +
-**2.1.4.** (*) The language of words which encode numbers divisible by 3. +
- +
-/* +
-<​hidden>​ +
-{{:​lfa:​2022:​lfa2022_lab2_ex4.png?​400|}} +
-  * State 0: 3k [initial state and final state] +
-  * State 1: 3k + 1 +
-  * State 2: 3k + 2 +
-  * When we read a 0, the number we had so far is multiplied by 2:  +
-      * $ 3k \overset{*2}{\longrightarrow} 3k $ +
-      * $ 3k + 1 \overset{*2}{\longrightarrow} 3k + 2 $ +
-      * $ 3k + 2 \overset{*2}{\longrightarrow} 3k + 1 $ +
-  * When we read a 1, the number we had so far is multiplied by 2 and we also add 1:  +
-      * $ 3k \overset{*2}{\longrightarrow} 3k \overset{+1}{\longrightarrow} 3k + 1 $ +
-      * $ 3k + 1 \overset{*2}{\longrightarrow} 3k + 2 \overset{+1}{\longrightarrow} 3k $ +
-      * $ 3k + 2 \overset{*2}{\longrightarrow} 3k + 1 \overset{+1}{\longrightarrow} 3k + 2 $ +
-</​hidden>​ +
-*/ +
- +
-**2.1.5.** (*) The language of quaternary words (base 4), that follow the rule that every zero is immediately followed by a sequence of at least 2 consecutive threes and every one is immediately followed by a sequence of at most 2 consecutive twos} $. +
- +
-/* +
-<​hidden>​ +
- +
-{{:​lfa:​2022:​lfa2022_lab2_ex6_v2.png?​400|}} +
-  * injuraturile redirectati-le catre AU :)) (si MP) +
-  * All missing transitions lead to a sink state (where there is a transition that loops in that state for any character) +
-</​hidden>​ +
-*/ +
- +
- +
-**2.1.6.** The set of all binary strings having the substring 00101.+
  
 +**2.1.7.** The language of all binary words having the substring 00101.
  
 /​*<​hidden>​ /​*<​hidden>​
Line 87: Line 60:
   * Analyze how each incoming character changes the current available sequence. For example, if we are in state **E** and we read character **1** we reach a final state, but if we read **0** we go back to state **C** since the available seq will be **00** ​   * Analyze how each incoming character changes the current available sequence. For example, if we are in state **E** and we read character **1** we reach a final state, but if we read **0** we go back to state **C** since the available seq will be **00** ​
 </​hidden>​*/​ </​hidden>​*/​
 +
 +**2.1.8.** The language of binary words that start and end with different digits.
  
 /​*<​hidden>​ /​*<​hidden>​
Line 105: Line 80:
 **2.2.1** **2.2.1**
  
-{{:​lfa:​2024:​lab1-2_2_1.png?500|}} +{{:​lfa:​2024:​lab1-2_2_2.png?300|}} 
-/* Cuvinte nevide în care după un grup de 0-uri consecutive urmează fie nimic, fie un număr impar de 1-uri consecutive,​  +/* Cel puțin ​un grup deurmat de un număr impar de 1-uri urmat de un număr par de 0-uri */
-   și după un grup consecutiv ​de 1-uri urmează fie nimic, fie un număr par de 0-uri consecutive ​*/+
  
 **2.2.2** **2.2.2**
  
-{{:​lfa:​2024:​lab1-2_2_2.png?300|}} +{{:​lfa:​2024:​lab1-2_2_1.png?500|}} 
-/* Cel puțin ​un grup deurmat de un număr impar de 1-uri urmat de un număr par de 0-uri */+/* Cuvinte nevide în care după un grup de 0-uri consecutive urmează fie nimic, fie un număr impar de 1-uri consecutive,​  
 +   și după un grup consecutiv ​de 1-uri urmează fie nimic, fie un număr par de 0-uri consecutive ​*/
  
 **2.2.3** **2.2.3**
Line 136: Line 111:
    iar dacă începe cu b. prima secvență este de al doilea tip */    iar dacă începe cu b. prima secvență este de al doilea tip */
        
 +
 ---- ----
  
  
 +**2.3.1** What happens if we switch all final states to non-final states and vice-versa in a DFA?
 +
 +**2.3.2** Prove that if L(M) is infinite, there has to be some cycle in the states graph, such that there is a path from the initial state to the cycle, and from the cycle to a final state.
 +
 +**2.3.3** If no such cycle described above exist, L(M) is finite.
 +
 +**2.3.4** Show that if you can construct a DFA to accept L, than you can also construct a DFA to accept $ L \cup \{a\}, \forall a \in \Sigma $.