Differences

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

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
lfa:2023:lab03 [2023/10/23 17:10]
mihai.udubasa change ex 2.3.5.
lfa:2023:lab03 [2023/10/31 11:43] (current)
alexandra.udrescu01
Line 14: Line 14:
  
  
-/*+
 <​hidden>​ <​hidden>​
  
Line 25: Line 25:
  
 </​hidden>​ </​hidden>​
-*/+
  
  
Line 36: Line 36:
 $ AB = ? $ \\ $ BA = ? $ $ AB = ? $ \\ $ BA = ? $
  
-/*+
 <​hidden>​ <​hidden>​
  
Line 54: Line 54:
  
 </​hidden>​ </​hidden>​
-*/+
  
 **3.1.3.** **3.1.3.**
Line 69: Line 69:
 \\ \\
  
-/*+
 <​hidden>​ <​hidden>​
  
Line 80: Line 80:
  
 </​hidden>​ </​hidden>​
-*/+
  
 **3.1.4** **3.1.4**
Line 90: Line 90:
 $ AB = ? $ \\ $ BA = ? $ $ AB = ? $ \\ $ BA = ? $
  
-/*+
 <​hidden>​ <​hidden>​
  
Line 101: Line 101:
  
 </​hidden>​ </​hidden>​
-*/+
  
 ===== 3.2. Writing Regular Expressions ===== ===== 3.2. Writing Regular Expressions =====
Line 108: Line 108:
 **Hint:** you can abbreviate $ 0 \cup 1 \cup ... \cup 9 $ by $ [0-9] $ **Hint:** you can abbreviate $ 0 \cup 1 \cup ... \cup 9 $ by $ [0-9] $
  
-/*+
 <​hidden>​ <​hidden>​
 We start by defining the regex for a number: We start by defining the regex for a number:
Line 126: Line 126:
  
 </​hidden>​ </​hidden>​
-*/+
  
 **3.2.2.** Write a regular expression for $ L = \{ \omega \text{ in } \text{{0,​1}} ^* \text{ | EVERY sequence of two or more consecutive zeros appears before ANY sequence of two or more consecutive ones} \} $ **3.2.2.** Write a regular expression for $ L = \{ \omega \text{ in } \text{{0,​1}} ^* \text{ | EVERY sequence of two or more consecutive zeros appears before ANY sequence of two or more consecutive ones} \} $
  
-/*+
 <​hidden>​ <​hidden>​
  
Line 142: Line 142:
  
 </​hidden>​ </​hidden>​
-*/+
  
 **3.2.3.** Write a DFA for $ L(( 10 \cup 0) ^* ( 1 \cup \epsilon )) $ **3.2.3.** Write a DFA for $ L(( 10 \cup 0) ^* ( 1 \cup \epsilon )) $
  
-/*+
 <​hidden>​ <​hidden>​
 {{:​lfa:​2022:​lfa2022_lab_3.2.3.png?​300|}} {{:​lfa:​2022:​lfa2022_lab_3.2.3.png?​300|}}
 </​hidden>​ </​hidden>​
-*/+
  
 **3.2.4.** Write a regular expression which generates the accepted language of A. Then try to find the most simple and easy to understand way to write it. **3.2.4.** Write a regular expression which generates the accepted language of A. Then try to find the most simple and easy to understand way to write it.
Line 156: Line 156:
 {{:​lfa:​graf1.png?​400|}} {{:​lfa:​graf1.png?​400|}}
  
-/*+
 <​hidden>​ <​hidden>​
  
Line 178: Line 178:
  
 </​hidden>​ </​hidden>​
-*/ 
  
-**3.2.5.** 
  
 +**3.2.5.**
 Find a regular expression for the set of all binary strings with the property that none of its prefixes has two more 0's than 1's nor two more 1's than 0's. Find a regular expression for the set of all binary strings with the property that none of its prefixes has two more 0's than 1's nor two more 1's than 0's.
 +
 +
  
 <​hidden>​ <​hidden>​
Line 193: Line 194:
  
 </​hidden>​ </​hidden>​
 +
  
 /* this is the old exercise /* this is the old exercise
Line 239: Line 241:
 $ E2 = (a|\epsilon)(b|\epsilon) $ $ E2 = (a|\epsilon)(b|\epsilon) $
  
-/*+
 <​hidden><​note important>​ <​hidden><​note important>​
 We can observe that E2 accepts ε, while E1 does not so they are not equivalent. We can observe that E2 accepts ε, while E1 does not so they are not equivalent.
Line 245: Line 247:
 Another approach is to compute the language of each expression (since they are finite) and check if they are equivalent. Another approach is to compute the language of each expression (since they are finite) and check if they are equivalent.
 </​note></​hidden>​ </​note></​hidden>​
-*/+
  
 ** 3.3.2 ** ** 3.3.2 **
Line 253: Line 255:
 $ E2 = ab(b|c|d|e)|acd|ace $ $ E2 = ab(b|c|d|e)|acd|ace $
  
-/*+
 <​hidden><​note important>​ <​hidden><​note important>​
 Since both E1 and E2 have a finite language, we could just compute the language and check if they are equivalent. Since both E1 and E2 have a finite language, we could just compute the language and check if they are equivalent.
 Language is L = {abb, abc, abd, abe, acd, ace}, therefore they are equivalent. Language is L = {abb, abc, abd, abe, acd, ace}, therefore they are equivalent.
 </​note></​hidden>​ </​note></​hidden>​
-*/+
  
 ** 3.3.3 ** ** 3.3.3 **
Line 266: Line 268:
 $ E2 = (a\mid ba)^*(b\mid ba)^* $ $ E2 = (a\mid ba)^*(b\mid ba)^* $
  
-/*+
 <​hidden><​note important>​ <​hidden><​note important>​
 Both E1 and E2 have an infinite language, so comparing them is not an option. Both E1 and E2 have an infinite language, so comparing them is not an option.
Line 274: Line 276:
 Fun fact: E1 was proposed by a student as a solution for 3.2.2 last year, while E2 is the actual solution. Fun fact: E1 was proposed by a student as a solution for 3.2.2 last year, while E2 is the actual solution.
 </​note></​hidden>​ </​note></​hidden>​
-*/+
  
 ** 3.3.4 ** ** 3.3.4 **
Line 282: Line 284:
 $ E2 = (a(b\mid aa)^*ab)^* $ $ E2 = (a(b\mid aa)^*ab)^* $
  
-/*+
 <​hidden><​note important>​ <​hidden><​note important>​
 Both E1 and E2 have an infinite language, so comparing them is not an option. Both E1 and E2 have an infinite language, so comparing them is not an option.
Line 295: Line 297:
 se. se.
 </​note></​hidden>​ </​note></​hidden>​
-*/+
  
 ==== Conclusion ==== ==== Conclusion ====