aesuceahu

This commit is contained in:
NikolajDanger
2022-05-17 17:33:43 +02:00
parent ba22cff91f
commit 1e6d09b384
26 changed files with 2287 additions and 449 deletions

View File

@ -4,6 +4,9 @@
\usepackage[margin=1in]{geometry}
\usepackage{amsmath}
\usepackage{multicol}
\usepackage{tikz}
\usetikzlibrary{automata,positioning}
\renewcommand{\thesection}{Task \arabic{section}}
\renewcommand{\thesubsection}{\arabic{subsection})}
@ -28,6 +31,7 @@
}
\begin{document}
\newgeometry{top=0in}
\maketitle
\section{}
\subsection{}
@ -82,6 +86,8 @@ Like with the previous problem, both the '\textit{a}'s and the '\textit{b}'s are
\end{cases}
\]
\columnbreak
\subsubsection{}
Once again, '\textit{a}'s and '\textit{b}'s are placed at the same time with the starting symbol \textit{T}. Afterwards, any amount of '\textit{a}'s are placed before the '\textit{b}'s.
@ -102,6 +108,7 @@ Once again, '\textit{a}'s and '\textit{b}'s are placed at the same time with the
\end{multicols}
\newpage
\newgeometry{top=1in}
\subsection{}
\subsubsection{}
\texttt{\%nonassoc letprec} designates the \texttt{let} token as being non-associative, which means ambiguous implementations will lead to a syntax error.
@ -141,6 +148,53 @@ CheckExp(exp, vtable, ftable) = case exp of
\newpage
\section{}
The unification graph with the initial R and ID values is as follows:
\begin{tikzpicture}[text width=1cm, align=center]
\node (a) at (0,0) {1,1\\{\Large*}};
\node (b) at (-2,-2) {2,2\\{\Large list}};
\node (c) at (2,-2) {3,3\\{\Large list}};
\node (d) at (-2,-4) {4,4\\{\Large int}};
\node (e) [text width=1.5cm] at (2,-4) {5,5\\{\Large\textit{alpha}}};
\node (f) at (4,0) {6,6\\{\Large*}};
\node (g) at (6,-4) {7,7\\{\Large\textit{beta}}};
\path [->] (a) edge node {} (b);
\path [->] (a) edge node {} (c);
\path [->] (b) edge node {} (d);
\path [->] (c) edge node {} (e);
\path [->] (f) edge node {} (e);
\path [->] (f) edge node {} (g);
\end{tikzpicture}
The R values can then be substituted in the following order:
\begin{itemize}
\item 6 \rightarrow{} 1, Rule (IV)
\item 5 \rightarrow{} 2, Rule (III)
\item 7 \rightarrow{} 3, Rule (III)
\end{itemize}
So the final unification graph looks like this:
\begin{tikzpicture}[text width=1cm, align=center]
\node (a) at (0,0) {1,1\\{\Large*}};
\node (b) at (-2,-2) {2,2\\{\Large list}};
\node (c) at (2,-2) {3,3\\{\Large list}};
\node (d) at (-2,-4) {4,4\\{\Large int}};
\node (e) [text width=1.5cm] at (2,-4) {2,5\\{\Large\textit{alpha}}};
\node (f) at (4,0) {1,6\\{\Large*}};
\node (g) at (6,-4) {3,7\\{\Large\textit{beta}}};
\path [->] (a) edge node {} (b);
\path [->] (a) edge node {} (c);
\path [->] (b) edge node {} (d);
\path [->] (c) edge node {} (e);
\path [->] (f) edge node {} (e);
\path [->] (f) edge node {} (g);
\end{tikzpicture}
Which means the final type is \texttt{list(int) * list(list(int))}.
\end{document}