Języki, automaty i obliczenia/Ćwiczenia 7: Twierdzenie Kleene'ego. Własności języków i gramatyk regularnych: Różnice pomiędzy wersjami
m Zastępowanie tekstu – „,</math>” na „</math>,” |
m Zastępowanie tekstu – „.</math>” na „</math>” |
||
(Nie pokazano 4 pośrednich wersji utworzonych przez tego samego użytkownika) | |||
Linia 12: | Linia 12: | ||
\hline a & s_2 & s_1 & s_2 \\ \hline b & s_1 & s_1 & s_2\\ | \hline a & s_2 & s_1 & s_2 \\ \hline b & s_1 & s_1 & s_2\\ | ||
\hline \end{array} \begin{array} {c|c|c|} f_{\mathcal C} &s_{\mathcal C} &s \\ \hline a & s & s \\ | \hline \end{array} \begin{array} {c|c|c|} f_{\mathcal C} &s_{\mathcal C} &s \\ \hline a & s & s \\ | ||
\hline b & s_{\mathcal C} & s_{\mathcal C} \\ \hline \end{array} | \hline b & s_{\mathcal C} & s_{\mathcal C} \\ \hline \end{array}</math></center> | ||
skonstruuj automat <math>\mathcal A</math> taki, że <center><math>L({\mathcal A}) = L({\mathcal B}) \cap L({\mathcal C})</math>,</center> | skonstruuj automat <math>\mathcal A</math> taki, że <center><math>L({\mathcal A}) = L({\mathcal B}) \cap L({\mathcal C})</math>,</center> | ||
Linia 39: | Linia 39: | ||
<center><math>\begin{array} {c|c|c|c|} f_{\mathcal B} &s_{\mathcal B} &s_1 & s_2 \\ | <center><math>\begin{array} {c|c|c|c|} f_{\mathcal B} &s_{\mathcal B} &s_1 & s_2 \\ | ||
\hline a & s_1 & s_2 & s_2 \\ \hline b & s_1 & s_{\mathcal{B}} & s_1\\ | \hline a & s_1 & s_2 & s_2 \\ \hline b & s_1 & s_{\mathcal{B}} & s_1\\ | ||
\hline \end{array} | \hline \end{array}</math></center> | ||
skonstruuj automat deterministyczny <math>\mathcal A</math> taki, że | skonstruuj automat deterministyczny <math>\mathcal A</math> taki, że | ||
Linia 74: | Linia 74: | ||
Dane są dwa automaty nad tym samym alfabetem <math>A</math><br> | Dane są dwa automaty nad tym samym alfabetem <math>A</math><br> | ||
<math>\mathcal{A}=(S,f,s_{0},T)</math> i <math>\mathcal{B}=(Q,g,t_{0},F)</math>. Udowodnij, | <math>\mathcal{A}=(S,f,s_{0},T)</math> i <math>\mathcal{B}=(Q,g,t_{0},F)</math>. Udowodnij, | ||
że istnieje liczba <math> p\in{\Bbb N}_{0}</math> taka, że jeśli dla każdego słowa <math>w</math> o długości <math>|w|\leq p</math> spełniona jest implikacja | że istnieje liczba <math>p\in{\Bbb N}_{0}</math> taka, że jeśli dla każdego słowa <math>w</math> o długości <math>|w|\leq p</math> spełniona jest implikacja | ||
<math>w\in L(\mathcal{A})\Rightarrow w\in L(\mathcal{B})</math>, | <math>w\in L(\mathcal{A})\Rightarrow w\in L(\mathcal{B})</math>, | ||
to | to | ||
Linia 93: | Linia 93: | ||
# Jeśli <math>|w|>p</math>, to z lematu o pompowaniu wynika, że <math>\exists v_1 v_2 \in A^*</math>, <math>\exists u \in A^+</math> takie, że <math>w=v_1 uv_2</math>, <math>v_1 v_2 \in L(\mathcal{C})</math> i <math>|v_1v_2|<|w|</math>. | # Jeśli <math>|w|>p</math>, to z lematu o pompowaniu wynika, że <math>\exists v_1 v_2 \in A^*</math>, <math>\exists u \in A^+</math> takie, że <math>w=v_1 uv_2</math>, <math>v_1 v_2 \in L(\mathcal{C})</math> i <math>|v_1v_2|<|w|</math>. | ||
<center><math>(f\times g)((s_0,t_0),w) = (f\times g)((s_0,t_0),v_1 v_2)=(f(s_0,v_1v_2),g(t_0,v_1v_2)) | <center><math>(f\times g)((s_0,t_0),w) = (f\times g)((s_0,t_0),v_1 v_2)=(f(s_0,v_1v_2),g(t_0,v_1v_2)) | ||
\in S\times F \cup T\times Q | \in S\times F \cup T\times Q </math></center> | ||
Mamy dwie możliwości: | Mamy dwie możliwości: | ||
Linia 99: | Linia 99: | ||
L(\mathcal{B})</math>, | L(\mathcal{B})</math>, | ||
:(b) <math> f(s_0,v_1v_2)\in T</math>, co oznacza <math>v_1v_2 \in L(\mathcal{A})</math>. <br> | :(b) <math>f(s_0,v_1v_2)\in T</math>, co oznacza <math>v_1v_2 \in L(\mathcal{A})</math>. <br> | ||
: Jeśli <math>|v_1v_2|<p</math>, to <math>v_1v_2 \in L(\mathcal{B})</math>, <math>w \in L(\mathcal{B})</math>.<br> | : Jeśli <math>|v_1v_2|<p</math>, to <math>v_1v_2 \in L(\mathcal{B})</math>, <math>w \in L(\mathcal{B})</math>.<br> | ||
: Jeśli <math>|v_1v_2|>p</math>, to powtarzamy punkt 2. | : Jeśli <math>|v_1v_2|>p</math>, to powtarzamy punkt 2. | ||
Linia 124: | Linia 124: | ||
Udowodnij, że następujące języki nie są regularne: | Udowodnij, że następujące języki nie są regularne: | ||
# <math>L = \{a^n : n \; \text{nie jest liczbą pierwszą;} \}</math>, | # <math>L = \{a^n : n \; \text{nie jest liczbą pierwszą;} \}</math>, | ||
# <math>L=\left\{ a^{n}b^{m}:0\leq n,m;\;n\neq m\right\} </math>. | # <math>L=\left\{ a^{n}b^{m}:0\leq n,m;\;n\neq m\right\}</math>. | ||
}} | }} | ||
Linia 132: | Linia 132: | ||
\; \text{ jest liczbą pierwszą;} \}</math> nie jest akceptowany ( | \; \text{ jest liczbą pierwszą;} \}</math> nie jest akceptowany ( | ||
ćwiczenie 8), a więc nie jest regularny. | ćwiczenie 8), a więc nie jest regularny. | ||
<center><math>a^*=L \cup L', L\cap L' = \emptyset, \;\text {a więc}\;L'=\overline{L} | <center><math>a^*=L \cup L', L\cap L' = \emptyset, \;\text {a więc}\;L'=\overline{L}</math></center> | ||
Ponieważ klasa języków regularnych jest zamknięta ze względu na | Ponieważ klasa języków regularnych jest zamknięta ze względu na | ||
uzupełnienie, to <math> L \notin \mathcal{REG}</math>. | uzupełnienie, to <math>L \notin \mathcal{REG}</math>. | ||
</div></div> | </div></div> | ||
<div class="mw-collapsible mw-made=collapsible mw-collapsed"><span class="mw-collapsible-toogle mw-collapsible-toogle-default style="font-variant:small-caps">Rozwiązanie punktu 2</span><div class="mw-collapsible-content" style="display:none"> | <div class="mw-collapsible mw-made=collapsible mw-collapsed"><span class="mw-collapsible-toogle mw-collapsible-toogle-default style="font-variant:small-caps">Rozwiązanie punktu 2</span><div class="mw-collapsible-content" style="display:none"> | ||
Język <math>L'=\left\{ a^{n}b^{n}:0\leq n \right\} </math> nie jest akceptowany | Język <math>L'=\left\{ a^{n}b^{n}:0\leq n \right\}</math> nie jest akceptowany | ||
(patrz [[Języki, automaty i obliczenia/Wykład 6: Automat niedeterministyczny. Lemat o pompowaniu#przyklad_3_1|3.1. z wykładu 6]]), a więc nie jest regularny. | (patrz [[Języki, automaty i obliczenia/Wykład 6: Automat niedeterministyczny. Lemat o pompowaniu#przyklad_3_1|3.1. z wykładu 6]]), a więc nie jest regularny. | ||
<center><math>a^*b^* =L \cup L',L\cap L' = \emptyset,\;\text {a więc}\;L'=a^* b^* \cap\overline{L}</math>.</center> | <center><math>a^*b^* =L \cup L',L\cap L' = \emptyset,\;\text {a więc}\;L'=a^* b^* \cap\overline{L}</math>.</center> | ||
Ponieważ klasa języków regularnych jest zamknięta ze względu na | Ponieważ klasa języków regularnych jest zamknięta ze względu na | ||
uzupełnienie i przecięcie, to <math> L \notin \mathcal{REG}</math>. | uzupełnienie i przecięcie, to <math>L \notin \mathcal{REG}</math>. | ||
</div></div> | </div></div> | ||
<center>ZADANIA DOMOWE</center> | <center>ZADANIA DOMOWE</center> | ||
Linia 161: | Linia 161: | ||
\hline a & s_2 & s_1 & s_2 \\ \hline b & s_1 & s_1 & s_2\\ \hline \end{array} | \hline a & s_2 & s_1 & s_2 \\ \hline b & s_1 & s_1 & s_2\\ \hline \end{array} | ||
\begin{array} {c|c|c|c|} f_{\mathcal C} &s_{\mathcal C} &{s'}_1&{s'}_2 \\ \hline a & {s'}_1 & {s'}_1& {s'}_2 \\ | \begin{array} {c|c|c|c|} f_{\mathcal C} &s_{\mathcal C} &{s'}_1&{s'}_2 \\ \hline a & {s'}_1 & {s'}_1& {s'}_2 \\ | ||
\hline b & {s'}_2 & {s'}_1& {s'}_2 \\ \hline \end{array} | \hline b & {s'}_2 & {s'}_1& {s'}_2 \\ \hline \end{array}</math></center> | ||
2. <math>L({\mathcal A}) = L({\mathcal B})^*</math>, gdzie <center><math>{\mathcal B} = | 2. <math>L({\mathcal A}) = L({\mathcal B})^*</math>, gdzie <center><math>{\mathcal B} = | ||
(S_{\mathcal B},A,f_{\mathcal B},s_{\mathcal B},F_{\mathcal B})</math>,</center> | (S_{\mathcal B},A,f_{\mathcal B},s_{\mathcal B},F_{\mathcal B})</math>,</center> | ||
Linia 170: | Linia 170: | ||
<center><math>\begin{array} {c|c|c|c|c|} f_{\mathcal B} &s_{\mathcal B} &s_1 & s_2 & s_3\\ \hline a & s_1 & s_3 & s_3 & s_3 \\ | <center><math>\begin{array} {c|c|c|c|c|} f_{\mathcal B} &s_{\mathcal B} &s_1 & s_2 & s_3\\ \hline a & s_1 & s_3 & s_3 & s_3 \\ | ||
\hline b & s_3 & s_2 & s_3 &s_3\\ \hline \end{array} | \hline b & s_3 & s_2 & s_3 &s_3\\ \hline \end{array}</math></center> | ||
Podaj dwie konstrukcje: | Podaj dwie konstrukcje: | ||
Linia 195: | Linia 195: | ||
}} | }} | ||
<div class="mw-collapsible mw-made=collapsible mw-collapsed"><span class="mw-collapsible-toogle mw-collapsible-toogle-default style="font-variant:small-caps">Wskazówka do punktu 2 </span><div class="mw-collapsible-content" style="display:none"> | <div class="mw-collapsible mw-made=collapsible mw-collapsed"><span class="mw-collapsible-toogle mw-collapsible-toogle-default style="font-variant:small-caps">Wskazówka do punktu 2 </span><div class="mw-collapsible-content" style="display:none"> | ||
Wykorzystaj fakt, że język <math>\left\{ a^{n}b^{n}:n \geq 0\right\} </math> nie jest regularny oraz | Wykorzystaj fakt, że język <math>\left\{ a^{n}b^{n}:n \geq 0\right\}</math> nie jest regularny oraz | ||
domkniętość klasy języków regularnych ze względu na homomorfizm. | domkniętość klasy języków regularnych ze względu na homomorfizm. | ||
</div></div> | </div></div> |
Aktualna wersja na dzień 11:25, 5 wrz 2023
Ćwiczenia 7
Ćwiczenie 1
gdzie
Ćwiczenie 2
gdzie
a funkcja przejść zdefiniowana jest następująco:
skonstruuj automat deterministyczny taki, że
Ćwiczenie 3
Dane są dwa automaty nad tym samym alfabetem
i . Udowodnij,
że istnieje liczba taka, że jeśli dla każdego słowa o długości spełniona jest implikacja
,
to
Ćwiczenie 4
Niech będzie dowolnym alfabetem, a językiem regularnym. Udowodnij, że język jest też językiem regularnym.
Ćwiczenie 5
Udowodnij, że następujące języki nie są regularne:
- ,
- .
Ćwiczenie 6
Niech . Skonstruuj automat , taki że
1. , gdzie
Podaj dwie konstrukcje:
- opartą na dowodzie twierdzenia Kleene'ego,
- z wykorzystaniem automatu z pustymi przejściami.
Ćwiczenie 7
Skonstruuj minimalny automat , taki że , gdzie opisany jest
poniższym grafem:
Ćwiczenie 8
Udowodnij, że następujące języki nie są regularne:
- ,
- .
Ćwiczenie 9
Zbuduj automat akceptujący język będący ogółem skończonych sekwencji binarnych, w których liczba zer jest podzielna przez dwa, a liczba jedynek przez 3, a następnie gramatykę generującą ten język.