Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
lfa:2024:lab03 [2024/10/20 12:58] cata_chiru |
lfa:2024:lab03 [2024/10/22 08:13] (current) cata_chiru |
||
---|---|---|---|
Line 127: | Line 127: | ||
</hidden> | </hidden> | ||
- | ** 3.2.5 ** | + | |
+ | ===== 3.3 Regex Equivalence ===== | ||
+ | |||
+ | Are the following regex pair equivalent? | ||
+ | |||
+ | ** 3.3.1 ** | ||
+ | |||
+ | $ E1 = ab|a|b $ | ||
+ | \\ | ||
+ | $ E2 = (a|\epsilon)(b|\epsilon) $ | ||
+ | |||
+ | |||
+ | <hidden 3.3.1><note important> | ||
+ | We can observe that E2 accepts ε, while E1 does not so they are not equivalent. | ||
+ | \\ | ||
+ | Another approach is to compute the language of each expression (since they are finite) and check if they are equivalent. | ||
+ | </note></hidden> | ||
+ | |||
+ | |||
+ | ** 3.3.2 ** | ||
+ | |||
+ | $ E1 = a(b|c)(d|e)|abb|abc $ | ||
+ | \\ | ||
+ | $ E2 = ab(b|c|d|e)|acd|ace $ | ||
+ | |||
+ | |||
+ | <hidden 3.3.2><note important> | ||
+ | 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. | ||
+ | </note></hidden> | ||
+ | |||
+ | |||
+ | ** 3.3.3 ** | ||
$ E1 = (a\mid b)^*aa^* \mid \epsilon $ | $ E1 = (a\mid b)^*aa^* \mid \epsilon $ | ||
Line 134: | Line 166: | ||
- | <hidden 3.2.5><note important> | + | <hidden 3.3.3><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. | ||
We can see that for example E2 accepts b, while E1 does not accept it, so the expressions are not equivalent. | We can see that for example E2 accepts b, while E1 does not accept it, so the expressions are not equivalent. | ||
- | 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.4.1 some year ago, while E2 is the actual solution. |
</note></hidden> | </note></hidden> | ||
- | ** 3.2.6 ** | + | ** 3.3.4 ** |
$ E1 = ((ab^*a)^+b)^* $ | $ E1 = ((ab^*a)^+b)^* $ | ||
Line 150: | Line 182: | ||
- | <hidden 3.2.6><note important> | + | <hidden 3.3.4><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 162: | Line 194: | ||
se. | se. | ||
</note></hidden> | </note></hidden> | ||
- | |||
Line 248: | Line 279: | ||
==== Conclusion ==== | ==== Conclusion ==== | ||
- | <hidden><note important> | + | <hidden Conclusion ><note important> |
What have we learned today? | What have we learned today? | ||