Skip to content

Commit 8810ae8

Browse files
committed
LR(0) automaton redrawn
1 parent a9ac33c commit 8810ae8

13 files changed

+617
-588
lines changed
Binary file not shown.

tex/FormalLanguageConstrainedReachabilityLectureNotes.tex

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -147,26 +147,28 @@
147147
\tableofcontents
148148
\newpage
149149
150-
\input{List_of_contributors}
151-
\input{Introduction}
152-
%\input{LinearAlgebra}
153-
\input{GraphTheoryIntro}
154-
\input{FormalLanguageTheoryIntro}
155-
\input{FLPQ}
156-
%\input{RegularLanguages}
157-
\input{Context-Free_Languages}
158-
\input{CYK_for_CFPQ}
159-
\input{Matrix-based_CFPQ}
160-
\input{TensorProduct}
161-
\input{SPPF}
162-
\input{GLL-based_CFPQ}
163150
\input{GLR-based_CFPQ}
164-
%\input{CombinatorsForCFPQ}
165-
%\input{DerivativesForCFPQ}
166-
%\input{CFPQ_to_Datalog}
167-
%\input{Multiple_Context-Free_Languages}
168-
%\input{ConjunctiveAndBooleanLanguages}
169-
%\input{Conclusion}
151+
152+
% \input{List_of_contributors}
153+
% \input{Introduction}
154+
% %\input{LinearAlgebra}
155+
% \input{GraphTheoryIntro}
156+
% \input{FormalLanguageTheoryIntro}
157+
% \input{FLPQ}
158+
% %\input{RegularLanguages}
159+
% \input{Context-Free_Languages}
160+
% \input{CYK_for_CFPQ}
161+
% \input{Matrix-based_CFPQ}
162+
% \input{TensorProduct}
163+
% \input{SPPF}
164+
% \input{GLL-based_CFPQ}
165+
% \input{GLR-based_CFPQ}
166+
% %\input{CombinatorsForCFPQ}
167+
% %\input{DerivativesForCFPQ}
168+
% %\input{CFPQ_to_Datalog}
169+
% %\input{Multiple_Context-Free_Languages}
170+
% %\input{ConjunctiveAndBooleanLanguages}
171+
% %\input{Conclusion}
170172
171173
\bibliographystyle{abbrv}
172174
\bibliography{FormalLanguageConstrainedReachabilityLectureNotes}

tex/FormalLanguageTheoryIntro.tex

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ \chapter{Общие сведения теории формальных язык
1313
\begin{itemize}
1414
\item Латинский алфавит $\Sigma = \{ a, b, c, \dots, z\}$
1515
\item Кириллический алфавит $\Sigma = \{ \text{а, б, в, \dots, я}\}$
16-
\item Алфавит чисел в шестнадцатеричной записи
16+
\item Алфавит чисел в шестнадцатеричной записи
1717
$$\Sigma = \{0, 1, 2, 3, 4, 5, 6, 7 ,8,9, A, B, C, D, E, F \}$$
1818
\end{itemize}
1919
\end{example}
@@ -56,11 +56,11 @@ \chapter{Общие сведения теории формальных язык
5656
\begin{itemize}
5757
\item Перечислить все элементы. Такой способ работает только для конечных языков. Перечислить бесконечное множество не получится.
5858
\item Задать генератор --- процедуру, которая возвращает очередное слово языка.
59-
\item Задать распознователь --- процедуру, которая по данному слову может определить, принадлежит оно заданному языку или нет.
59+
\item Задать распознаватель --- процедуру, которая по данному слову может определить, принадлежит оно заданному языку или нет.
6060
\end{itemize}
6161

6262

63-
%Теоретико-множественные задачи над языками и их применение.
63+
%Теоретико-множественные задачи над языками и их применение.
6464
%О том, что моногое --- про пересечение, проверку пустоты, вложенность.
6565

6666

@@ -69,6 +69,6 @@ \chapter{Общие сведения теории формальных язык
6969

7070
%\section{Вопросы и задачи}
7171
%\begin{enumerate}
72-
% \item !!!
72+
% \item !!!
7373
% \item !!!
7474
%\end{enumerate}

tex/GLR-based_CFPQ.tex

Lines changed: 217 additions & 564 deletions
Large diffs are not rendered by default.

tex/Introduction.tex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ \chapter*{Введение}
1414
Одна из классических задач, связанных с анализом графов --- это поиск путей в графе.
1515
Возможны различные формулировки этой задачи.
1616
В некоторых случаях необходимо выяснить, существует ли путь с определёнными свойствами между двумя выбранными вершинами.
17-
В других же ситуациях необходимо найти все пути в графе, удовлетворяющие некоторым свойствам или ограничениям.
17+
В других же ситуациях необходимо найти все пути в графе, удовлетворяющие некоторым свойствам или ограничениям.
1818
Например, в качестве ограничений можно указать, что искомый путь должен быть простым, кратчайшим, гамильтоновым и так далее.
1919

2020
Один из способов задавать ограничения на пути в графе основан на использовании формальных языков.

tex/figures/GLR/CLR_example.tex

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
\begin{tikzpicture}[> = stealth,node distance=3.25cm, on grid, scale=0.8, every node/.style={scale=0.8}]
2+
\node[draw=none, fill=none] at (-1.4, 1.2) {0};
3+
\node[draw=none, fill=none] at (3.1, 0.55) {3};
4+
\node[draw=none, fill=none] at (-1.4, -1.3) {1};
5+
\node[draw=none, fill=none] at (-1.4, -3.8) {2};
6+
\node[draw=none, fill=none] at (2.9, -1.95) {4};
7+
\node[draw=none, fill=none] at (2.9, -4.45) {5};
8+
\node[draw=none, fill=none] at (6.7, -1.3) {6};
9+
\node[draw=none, fill=none] at (6.7, -3.8) {7};
10+
\node[draw=none, fill=none] at (11, -1.95) {8};
11+
\node[draw=none, fill=none] at (11, -4.45) {9};
12+
\node[r_state] (s_0)
13+
{
14+
$
15+
\begin{aligned}
16+
S' &\to \cdot S, \{\$\} \\
17+
S &\to \cdot a S b S, \{\$\} \\
18+
S &\to \cdot, \{\$\}
19+
\end{aligned}
20+
$
21+
};
22+
\node[r_state] (s_1) [below=2cm of s_0]
23+
{
24+
$
25+
\begin{aligned}
26+
S &\to a \cdot S b S, \{\$\} \\
27+
S &\to \cdot a S b S, \{b\} \\
28+
S &\to \cdot, \{b\}
29+
\end{aligned}
30+
$
31+
};
32+
\node[r_state] (s_2) [below=2cm of s_1]
33+
{
34+
$
35+
\begin{aligned}
36+
S &\to a \cdot S b S, \{b\} \\
37+
S &\to \cdot a S b S, \{b\} \\
38+
S &\to \cdot, \{b\}
39+
\end{aligned}
40+
$
41+
};
42+
\node[r_state] (s_3) [right=of s_0]
43+
{
44+
$ S' \to S \cdot, \{\$\} $
45+
};
46+
\node[r_state] (s_4) [right=of s_1]
47+
{
48+
$ S \to a S \cdot b S, \{\$\} $
49+
};
50+
\node[r_state] (s_5) [right=of s_2]
51+
{
52+
$ S \to a S \cdot b S, \{b\} $
53+
};
54+
\node[r_state] (s_6) [right=of s_4]
55+
{
56+
$
57+
\begin{aligned}
58+
S &\to a S b \cdot S, \{\$\} \\
59+
S &\to \cdot a S b S, \{\$\} \\
60+
S &\to \cdot, \{\$\}
61+
\end{aligned}
62+
$
63+
};
64+
\node[r_state] (s_7) [right=of s_5]
65+
{
66+
$
67+
\begin{aligned}
68+
S &\to a S b \cdot S, \{b\} \\
69+
S &\to \cdot a S b S, \{b\} \\
70+
S &\to \cdot , \{b\}
71+
\end{aligned}
72+
$
73+
};
74+
\node[r_state] (s_8) [right=of s_6]
75+
{
76+
$ S \to a S b S \cdot, \{\$\} $
77+
};
78+
\node[r_state] (s_9) [right=of s_7]
79+
{
80+
$ S \to a S b S \cdot, \{b\} $
81+
};
82+
83+
\path[->]
84+
(s_0) edge [left] node {$a$} (s_1)
85+
edge [above] node {$S$} (s_3)
86+
(s_1) edge [left] node {$a$} (s_2)
87+
edge [above] node {$S$} (s_4)
88+
(s_2) edge [loop below] node {$a$} ()
89+
edge [above] node {$S$} (s_5)
90+
(s_4) edge [above] node {$b$} (s_6)
91+
(s_5) edge [above] node {$b$} (s_7)
92+
(s_6) edge [above] node {$S$} (s_8)
93+
edge [above, bend right=20] node {$a$} (s_1)
94+
(s_7) edge [above] node {$S$} (s_9)
95+
edge [below, bend left=20] node {$a$} (s_2)
96+
;
97+
\end{tikzpicture}

tex/figures/GLR/LR0/complete.tex

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
\begin{tikzpicture}[> = stealth,node distance=3.25cm, on grid, scale=0.8, every node/.style={scale=0.8}]
2+
\node[draw=none, fill=none] at (-1.4, 1.2) {0};
3+
\node[draw=none, fill=none] at (3.1, 0.55) {1};
4+
\node[draw=none, fill=none] at (7.1, 0.55) {2};
5+
\node[draw=none, fill=none] at (-1.4, -1.8) {3};
6+
\node[draw=none, fill=none] at (2.9, -2.5) {4};
7+
\node[draw=none, fill=none] at (6.7, -1.8) {5};
8+
\node[draw=none, fill=none] at (11, -2.5) {6};
9+
\node[r_state] (s_0)
10+
{
11+
$
12+
\begin{aligned}
13+
S' &\to \cdot S \$ \\
14+
S &\to \cdot a S b S \\
15+
S &\to \cdot
16+
\end{aligned}
17+
$
18+
};
19+
\node[r_state] (s_1) [right=of s_0]
20+
{
21+
$ S' \to S \cdot \$ $
22+
};
23+
\node[r_state] (s_2) [right=of s_1]
24+
{
25+
$ S' \to S \$ \cdot $
26+
};
27+
\node[r_state] (s_3) [below=2.5cm of s_0]
28+
{
29+
$
30+
\begin{aligned}
31+
S &\to a \cdot S b S \\
32+
S &\to \cdot a S b S \\
33+
S &\to \cdot
34+
\end{aligned}
35+
$
36+
};
37+
\node[r_state] (s_4) [right=of s_3]
38+
{
39+
$ S \to a S \cdot b S$
40+
};
41+
\node[r_state] (s_5) [right=of s_4]
42+
{
43+
$
44+
\begin{aligned}
45+
S &\to a S b \cdot S \\
46+
S &\to \cdot a S b S \\
47+
S &\to \cdot
48+
\end{aligned}
49+
$
50+
};
51+
\node[r_state] (s_6) [right=of s_5]
52+
{
53+
$ S \to a S b S \cdot$
54+
};
55+
56+
\path[->]
57+
(s_0) edge [left] node {$a$} (s_3)
58+
edge [above] node {$S$} (s_1)
59+
(s_1) edge [above] node {$\$$} (s_2)
60+
(s_3) edge [above] node {$S$} (s_4)
61+
edge [loop below] node {$a$} ()
62+
(s_4) edge [above] node {$b$} (s_5)
63+
(s_5) edge [above] node {$S$} (s_6)
64+
edge [above, bend right=20] node {$a$} (s_3)
65+
;
66+
\end{tikzpicture}

tex/figures/GLR/LR0/state0.tex

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
\begin{tikzpicture}[> = stealth,node distance=3.25cm, on grid, scale=0.8, every node/.style={scale=0.8}]
2+
\node[draw=none, fill=none] at (-1.4, 1.2) {0};
3+
\node[r_state] (s_0)
4+
{
5+
$
6+
\begin{aligned}
7+
S' &\to \cdot S \$ \\
8+
S &\to \cdot a S b S \\
9+
S &\to \cdot
10+
\end{aligned}
11+
$
12+
};
13+
\end{tikzpicture}

tex/figures/GLR/LR0/state1.tex

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
\begin{tikzpicture}[> = stealth,node distance=3.25cm, on grid, scale=0.8, every node/.style={scale=0.8}]
2+
\node[draw=none, fill=none] at (-1.4, 1.2) {0};
3+
\node[draw=none, fill=none] at (3.1, 0.55) {1};
4+
\node[r_state] (s_0)
5+
{
6+
$
7+
\begin{aligned}
8+
S' &\to \cdot S \$ \\
9+
S &\to \cdot a S b S \\
10+
S &\to \cdot
11+
\end{aligned}
12+
$
13+
};
14+
\node[r_state] (s_1) [right=of s_0]
15+
{
16+
$ S' \to S \cdot \$ $
17+
};
18+
19+
\path[->]
20+
(s_0) edge [above] node {$S$} (s_1)
21+
;
22+
\end{tikzpicture}

tex/figures/GLR/LR0/state2.tex

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
\begin{tikzpicture}[> = stealth,node distance=3.25cm, on grid, scale=0.8, every node/.style={scale=0.8}]
2+
\node[draw=none, fill=none] at (-1.4, 1.2) {0};
3+
\node[draw=none, fill=none] at (3.1, 0.55) {1};
4+
\node[draw=none, fill=none] at (7.1, 0.55) {2};
5+
\node[r_state] (s_0)
6+
{
7+
$
8+
\begin{aligned}
9+
S' &\to \cdot S \$ \\
10+
S &\to \cdot a S b S \\
11+
S &\to \cdot
12+
\end{aligned}
13+
$
14+
};
15+
\node[r_state] (s_1) [right=of s_0]
16+
{
17+
$ S' \to S \cdot \$ $
18+
};
19+
\node[r_state] (s_2) [right=of s_1]
20+
{
21+
$ S' \to S \$ \cdot $
22+
};
23+
24+
\path[->]
25+
(s_0) edge [above] node {$S$} (s_1)
26+
(s_1) edge [above] node {$\$$} (s_2)
27+
;
28+
\end{tikzpicture}

0 commit comments

Comments
 (0)