Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
lfa:2022:lab06-dfa-to-regex [2022/11/14 00:31] mihai.udubasa unhide solutions temp |
lfa:2022:lab06-dfa-to-regex [2022/11/19 10:34] (current) alexandra.udrescu01 |
||
---|---|---|---|
Line 5: | Line 5: | ||
Consider the following DFAs: | Consider the following DFAs: | ||
- | **DFA1** | + | ^ **DFA1** ^ **DFA2** ^ |
+ | |{{ :lfa:screenshot_2021-11-04_at_15.33.10.png?400 |}}| {{ :lfa:2022:lfa2022_lab5_ex2_4_cerinta.png?300 |}} | | ||
- | {{ :lfa:screenshot_2021-11-04_at_15.33.10.png?400 |}} | ||
- | |||
- | **DFA2** | ||
- | |||
- | {{ :lfa:2022:lfa2022_lab5_ex2_4_cerinta.png?300 |}} | ||
Convert the given DFAs to a Regex (using the state-elimination strategy). | Convert the given DFAs to a Regex (using the state-elimination strategy). | ||
Line 168: | Line 164: | ||
</hidden> | </hidden> | ||
- | */ | + | |
==== 6.2. Brzozowsky's algebraic method ==== | ==== 6.2. Brzozowsky's algebraic method ==== | ||
Line 182: | Line 178: | ||
=== Dfa to regex conversion === | === Dfa to regex conversion === | ||
- | For each state $math[q], build an equation of the form: $math[q = c_1 q_1 \cup c_2 q_2 \ldots c_n q_n], such that: $math[\delta(q,c_i) = q_i]. Here $math[c_i\in\Sigma], thus $math[q_i] are the $math[c_i]-successors of $math[q]. Additionally, if $math[q] is a final state, and an $math[\epsilon]: $math[q = c_1 q_1 \cup c_2 q_2 \ldots c_n q_n \cup \epsilon]. | + | For each state $math[q], build an equation of the form: $math[q = c_1 q_1 \cup c_2 q_2 \ldots c_n q_n], such that: $math[\delta(q,c_i) = q_i]. Here $math[c_i\in\Sigma], thus $math[q_i] are the $math[c_i]-successors of $math[q]. Additionally, if $math[q] is a final state, add an $math[\epsilon]: $math[q = c_1 q_1 \cup c_2 q_2 \ldots c_n q_n \cup \epsilon]. |
^ ^ ^ | ^ ^ ^ | ||
Line 195: | Line 191: | ||
=== Reducing the system of equations === | === Reducing the system of equations === | ||
- | We can choose *any** equation **except** that corresponding to the initial state, and eliminate it, by exploiting **Arden's Lemma**: | + | We can choose **any** equation **except** that corresponding to the initial state, and eliminate it, by exploiting **Arden's Lemma**: |
* the solution to any equation of the form $math[q = e\cdot q \cup e'] is $math[q = e^*e']. | * the solution to any equation of the form $math[q = e\cdot q \cup e'] is $math[q = e^*e']. | ||
**Example** | **Example** | ||
- | Goind back to the previous system of equations, we can find the solution to $math[q_2] which is: $math[(A \cup B)^*]. Next, we can replace the solution to $math[q_2] in $math[q_1] which yields: | + | Going back to the previous system of equations, we can find the solution to $math[q_2] which is: $math[(A \cup B)^*]. Next, we can replace the solution to $math[q_2] in $math[q_1] which yields: |
* $math[q_1 = A q_1 \cup B(A\cup B)^*]. | * $math[q_1 = A q_1 \cup B(A\cup B)^*]. | ||
* We apply Arden's Lemma one more time and yield: $math[q_1 = A^*B(A \cup B)^*]. | * We apply Arden's Lemma one more time and yield: $math[q_1 = A^*B(A \cup B)^*]. | ||
Line 221: | Line 217: | ||
^ {{ :lfa:2022:screenshot_2022-11-09_at_15.46.23.png?200 |}} ^ | ^ {{ :lfa:2022:screenshot_2022-11-09_at_15.46.23.png?200 |}} ^ | ||
- | /* | + | |
<hidden Solution> | <hidden Solution> | ||
Line 271: | Line 267: | ||
</hidden> | </hidden> | ||
- | */ | + | |