diff --git a/automaton.pdf b/automaton.pdf new file mode 100644 index 0000000..4c4775e --- /dev/null +++ b/automaton.pdf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:12e29fde5fda9296f17f51f1f0e344c0c356f7fe0371b4002ee93cd844dc774a +size 19132 diff --git a/content/chapters/include.tex b/content/chapters/include.tex index 7922d7d..173bbbf 100755 --- a/content/chapters/include.tex +++ b/content/chapters/include.tex @@ -15,4 +15,4 @@ % \includechapters{part2}{2} -% \includechapters{part3}{1} \ No newline at end of file +% \includechapters{part3}{1} diff --git a/content/chapters/part1/0.tex b/content/chapters/part1/0.tex index e69de29..5dfa3d4 100755 --- a/content/chapters/part1/0.tex +++ b/content/chapters/part1/0.tex @@ -0,0 +1,58 @@ +\chapter{Back to basics} + +\begin{algorithm} + \caption{Search an element in an array} + \begin{algorithmic}[1] + \Function{Search}{$A$: Array($n$), $E$: element} + \For {($i = 0$; $i < n$; $i++$)} + \If {$A[i] = E$} + \State \Return \True + \EndIf + \EndFor + \State \Return \False + \EndFunction + \end{algorithmic} +\end{algorithm} + +\begin{algorithm} + \caption{Search an element in an array using a while loop} + \begin{algorithmic}[1] + \Function{Search}{$A$: Array($n$), $E$: element} + \State $i \gets 0$ + \While {$i < n$} + \If {$A[i] = E$} + \State \Return \True + \EndIf + \State $i \gets i + 1$ + \EndWhile + \State + \Return + \False + \EndFunction + \end{algorithmic} +\end{algorithm} + +\begin{algorithm} + \caption{Search an element in an array using a while loop (bis)} + \begin{algorithmic}[1] + \Function{Search}{$A$: Array($n$), $E$: element} + % \Comment{Version ``preffered" by the professor} + \State $i \gets 0$ + \While {$i < n$ and $A[i] \neq E$} + \State $i \gets i + 1$ + \EndWhile + \If {$i = n$} + \State + \Return \False \Else \State \Return \True \EndIf + \EndFunction + \end{algorithmic} +\end{algorithm} + +\begin{algorithm} + \caption{Count the occurrences of an element in an array} + \begin{algorithmic}[1] + \Function{Search}{$A$: Array($n$), $E$: element} \State $c \gets 0$ + \For{($i = 0$; $i < n$; $i++$)} \If {A[i] $ = $ E} \State $c \gets c + 1$ \EndIf + \EndFor \State \Return $c$ \EndFunction + \end{algorithmic} +\end{algorithm} diff --git a/content/chapters/part1/1.tex b/content/chapters/part1/1.tex old mode 100755 new mode 100644 index a10765b..25be6e7 --- a/content/chapters/part1/1.tex +++ b/content/chapters/part1/1.tex @@ -1,90 +1,29 @@ -\chapter{Back to basics} - -\begin{algorithm} - \caption{Search an element in an array} - \begin{algorithmic}[1] - \Function{Search}{A: Array(n), E: element} - \For {(i=0; i < n; i++)} - \If {A[i] $ = $ E} - \State \Return \True - \EndIf - \EndFor - \State \Return \False - \EndFunction - \end{algorithmic} -\end{algorithm} - -\begin{algorithm} - \caption{Search an element in an array using a while loop} - \begin{algorithmic}[1] - \Function{Search}{A: Array(n), E: element} - \State $i \gets 0$ - \While {$i < n$} - \If {A[i] $ = $ E} - \State \Return \True - \EndIf - \State $i \gets i + 1$ - \EndWhile - \State \Return \False - \EndFunction - \end{algorithmic} -\end{algorithm} - -\begin{algorithm} - \caption{Search an element in an array using a while loop (bis)} - \begin{algorithmic}[1] - \Function{Search}{A: Array(n), E: element} - \Comment{Version ``preffered" by the professor} - \State $i \gets 0$ - \While {$i < n$ and $A[i] \neq E$} - \State $i \gets i + 1$ - \EndWhile - \If {$i = n$} - \State \Return \False - \Else - \State \Return \True - \EndIf - \EndFunction - \end{algorithmic} -\end{algorithm} - -\begin{algorithm} - \caption{Count the occurences of an element in an array} - \begin{algorithmic}[1] - \Function{Search}{A: Array(n), E: element} - \State $c \gets 0$ - \For{$i = 0$; $i < n$; $i++$} - \If {A[i] $ = $ E} - \State $c \gets c + 1$ - \EndIf - \EndFor - \State \Return $c$ - \EndFunction - \end{algorithmic} -\end{algorithm} - \chapter{Motif} \begin{algorithm} \caption{Brute-force search of a motif in a sequence} \begin{algorithmic}[1] - \Function{FindMotif}{S: Array(n), M: Array(m)} - \Returns{list of position} - \State $pos \gets $ empty list - \State $i \gets 0$ - \While {$i < n - m + 1$} - \State $j \gets 0$ - \While {$j < m$ and S[i+j] $ = $ M[j]} - \State $j++$ - \EndWhile - \If {$j = m$} - \State add $i$ to $pos$ - \EndIf - \State $i++$ - \EndWhile - \State \Return $pos$ + \Function{FindMotif}{S: Array(n), M: Array(m)} { + \Returns{list of position} + \State $pos \gets \{\}$ + \State $i \gets 0$ + \While {$i < n - m + 1$} { + \State $j \gets 0$ + \While {$j < m$ and S[i+j] $ = $ M[j]} { + \State $j++$ + } + \EndWhile + \If {$j = m$} + \State $pos \gets pos \cup \{i\}$ + \EndIf + \State $i++$ + } + \EndWhile + \State \Return $pos$ + } \EndFunction \end{algorithmic} + \label{alg:naive-motif-matching} \end{algorithm} \begin{algorithm} diff --git a/references.bib b/content/chapters/part1/2.tex similarity index 100% rename from references.bib rename to content/chapters/part1/2.tex diff --git a/content/chapters/part1/3.tex b/content/chapters/part1/3.tex new file mode 100644 index 0000000..5a05edb --- /dev/null +++ b/content/chapters/part1/3.tex @@ -0,0 +1,289 @@ +\chapter{Matrices} + +Let $S_{1}$ and $S_{2}$ be two sequences. + +$S_{1} = $ ACGUUCC +$S_{2} = $ GUU + +\begin{table} + \centering + \begin{tabular}{c|ccccccc} + & A & C & G & U & U & C & C \\ + \hline + G & 0 & 0 & 1 & 0 & 0 & 0 & 0 \\ + U & 0 & 0 & 0 & 1 & 1 & 0 & 0 \\ + U & 0 & 0 & 0 & 1 & 1 & 0 & 0 + \end{tabular} + \caption{Comparison matrix} +\end{table} + + +Let $n = |S_{1}|$, $m = |S_{2}|$ +The complexity of this algorithm is $\mathcal{O}(n \cdot m)$ to build the matrix, and it requires also to find the diagonals and thus it is a bit less efficient than the \autoref{alg:naive-motif-matching}. + + +To find repetitions, we can use a comparison matrix with a single sequence against itself. A repetition would appear as a diagonal of ones, not on the main diagonal. + +Let $S = $ ACGUUACGUU. Let's write the comparison matrix. + + +\begin{table} + \includegraphics{figures/part1/comparison_matrix_repetitions.pdf} + \caption{Comparison matrix for seq="ACGUUACGUUGUU"} +\end{table} + + + +\begin{algorithm} + \caption{Construct a comparison matrix} + \begin{algorithmic}[1] + \Function{ComparisonMatrix}{S: Array(n)} + \State $M \gets Array(n, n)$ + \For{$i = 0$; $i < n$; $i++$} + \For{$j=0$; $j < n$; $j++$} + \If {S[i] $ = $ S[j]} + \State $M[i][j] = 1$ + \Else + \State $M[i][j] = 0$ + \EndIf + \EndFor + \EndFor + \State \Return $M$ + \EndFunction + \end{algorithmic} + +\end{algorithm} +\begin{algorithm} + \caption{Construct the top half of comparison matrix} + \begin{algorithmic}[1] + \Function{ComparisonMatrix}{S: Array(n)} + \State $M \gets Array(n,n)$ + \For{i = 0; i < n; i++} + \For{j=i; j < n; j++} + \If {S[i] = S[j]} + \State M[i][j] = 1 + \Else + \State M[i][j] = 0 + \EndIf + \EndFor + \EndFor + \State \Return M + \EndFunction + \end{algorithmic} +\end{algorithm} + + + +\begin{algorithm} + \caption{Find repetitions (with the set of visited segments)} + \begin{algorithmic}[1] + \Function{FindRepetions}{S: Array(n)} + \Returns{A list of start and end positions for repeted sequences} + \State M = \Call{ComparisonMatrix}{S} + \State pos = \{\} + \State visited = \{\} + \For {i_{start} = 0; i_{start} < n; i_{start}++} + \For {j_{start} = i_{start}+1; j_{start} < n; j_{start}++} + \If{M[i_{start}][j_{start}] = 1 and (i_{start}, j_{start}) \notin visited} + \State i = i_{start} + \State j = j_{start} + \While {M[i][j] = 1} + \State i++ + \State j++ + \State visited = visited \cup \{(i, j)\} + \EndWhile + \State pos = pos \cup \{(i_{start}, i), (j_{start},j)\} + \EndIf + \EndFor + \EndFor + \EndFunction + \end{algorithmic} +\end{algorithm} + + +\begin{algorithm} + \caption{Find repetitions with an exploration of diagonals} + \begin{algorithmic}[1] + \Function{FindRepetions}{S: Array(n)} + \Returns{A list of start and end positions for repeted sequences} + \State M = \Call{ComparisonMatrix}{S} + \State $pos = \{\}$ + \For {diag = 1; diag < n; diag++} + \State j = diag + \State i = 0 + \While {i < n and j < n} + \If {M[i][j] = 1} + \State $i_{start} = i$ + \State $j_{start} = j$ + \While {i < n and j < n and M[i][j] = 1 } + \State i++ + \State j++ + \EndWhile + \State $pos = pos \cup \{((i_{start},i-1),(j_{start},j-1)\}$ + \EndIf + \State i++ + \State j++ + \State + \EndWhile + \EndFor + \EndFunction + \end{algorithmic} +\end{algorithm} + +\begin{algorithm} + \caption{Find repetitions with an exploration of diagonals, without nested while} + \begin{algorithmic}[1] + \Function{FindRepetions}{S: Array(n)} + \Returns{A list of start positions for repeted sequences and match length} + \State M = \Call{ComparisonMatrix}{S} + \State $pos = \{\}$ + \For {diag = 1; diag < n; diag++} + \State j = diag + \State i = 0 + \State l = 0 + \While {i < n and j < n} + \If {M[i][j] = 1} + \State l++ + \Else + \If {l > 0} + \State $pos = pos \cup \{((i-l,j-l,l)\}$ + \State l = 0 + \EndIf + \EndIf + \State i++ + \State j++ + \EndWhile + \If {$l > 0$} + \State $pos = pos \cup \{((i-l,j-l,l)\}$ + \EndIf + \EndFor + \State \Return pos + \EndFunction + \end{algorithmic} +\end{algorithm} + + +\begin{algorithm} + \caption{Find repetitions} + \begin{algorithmic}[1] + \Function{FindRepetions}{S: Array(n)} + \Returns{A list of start and end positions for repeted sequences} + \State M = \Call{ComparisonMatrix}{S} + \State pos = \{\} + \For {$i_{start} = 0$; $i_{start} < n$; $i_{start}++$} + \For {$j_{start} = i_{start}+1$; $j_{start} < n$; $j_{start}++$} + \If{$M[i_{start}][j_{start}] = 1$} + \State $i = i_{start}$ + \State $j = j_{start}$ + \While {M[i][j] = 1} + \State M[i][j] = 0 \Comment{Ensure that the segment is not explored again} + \State i++ + \State j++ + \EndWhile + \State $pos = pos \cup \{((i_{start}, i-1), (j_{start},j-1))\}$ + \EndIf + \EndFor + \EndFor + \EndFunction + \end{algorithmic} +\end{algorithm} + + +\section{Automata} + + +An automaton is a tuple $\langle S, s_{0}, T, \Sigma,f\langle$ +\begin{itemize} + \item $S$ the set of states + \item $s_{0}$ the initial state + \item $T$ the set of terminal states + \item $\Sigma$ the alphabet + \item $f$ the transition function $f: (s_{1}, c) \to s_{2}$ +\end{itemize} + +\paragraph{Example} Given the language $L$ on the alphabet $\Sigma = \{A, C, T\}$, $L = \{A^{*}, CTT, CA^{*}\}$ + +\begin{definition}[Deterministic automaton] + An automaton is deterministic, if for each couple $(p, a) \in S \times \Sigma$ it exists at most a state $q$ such as $f(p, q) = q$ +\end{definition} + +\begin{definition}[Complete automaton] + An automaton is complete, if for each couple $(p, a) \in S \times \Sigma$ it exists at least a state $q$ such as $f(p, q) = q$. +\end{definition} +\begin{algorithm} + \caption{Check wether a word belong to a language for which we have an automaton} + \begin{algorithmic}[1] + \Function{WordInLanguage}{W: Array(n), A: $\langle S, s_{0}, T, \Sigma,f \rangle$} + \Returns{A Boolean valued to \True{} if the word is recognized by the language automaton} + \State $s \gets s_{0}$ + \State $i \gets 0$ + \While {i < n} { + + \State $a \gets W[i]$ + \If {$\exists f(s, a)$} { + \State $s \gets f(s, a)$ + \Else + \State \Return \False + } + \EndIf + \State i++ + } + \EndWhile + \If {$s \in T$} { + \State \Return \True + } + \Else { + + \State \Return \False + } + \EndIf + \EndFunction + \end{algorithmic} +\end{algorithm} + +\section{Suffix Automaton} + +Let $S = $ AACTACT + +A suffix automata recognize all suffix of a given sequence. + + +The suffix language of $S$ is $\{S, ACTACT, CTACT, TACT, ACT, CT, T\}$. + + +\begin{figure} + \centering + \includegraphics{figures/part1/minimal_suffix_automaton_exercise.pdf} + \caption{Suffix automaton for $S = $ AACTACT} +\end{figure} + +\begin{figure} + \centering + \includegraphics{figures/part1/minimal_suffix_automaton_exercise_bis.pdf} + \caption{Suffix automaton for $S = $ TCATCATT} +\end{figure} + +\end{definition} +\begin{algorithm} + \begin{algorithm} + \caption{Check if a sequences matches a motif, from a suffix automaton $\mathcal{O}(m)$} + \begin{algorithmic}[1] + \Function{CheckMotifInSuffixAutomaton}{W: Array(m), A: $\langle S, s_{0}, T, \Sigma,f \rangle$} + \Returns{Boolean valued to \True{} if the motif is in the sequence} + \State $s \gets s_{0}$ + \State $i \gets 0$ + \While {i < m and $\exists f(s, W[i])$} + \State $s \gets f(s, W[i])$ + \State i++ + \EndWhile + \If {i=n} + \State \Return \True + \Else + \State \Return \False + \EndIf + \EndFunction + \end{algorithmic} + \end{algorithm} + + The complexity of the pattern matching algorithm is $\mathcal{O}(n + m)$, because building the automaton is $\mathcal{O}(m)$ +\end{algorithm} diff --git a/definitions.tex b/definitions.tex index 108cd26..5ca6ee1 100755 --- a/definitions.tex +++ b/definitions.tex @@ -1,3 +1,3 @@ \newcommand{\Returns}[1]{ - \State \textbf{Returns} #1 + \State \textbf{returns} #1 } diff --git a/figures/part1/automaton.pdf b/figures/part1/automaton.pdf new file mode 100644 index 0000000..78af65c --- /dev/null +++ b/figures/part1/automaton.pdf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c245c8025ddbd76e06fed3985358cffd5090cc6a419a928d21cebdfb1303dd20 +size 19132 diff --git a/figures/part1/automaton.tex b/figures/part1/automaton.tex new file mode 100644 index 0000000..c418dab --- /dev/null +++ b/figures/part1/automaton.tex @@ -0,0 +1,21 @@ +\documentclass[tikz]{standalone} + +\usepackage{tikz} + +\begin{document} +\usetikzlibrary{automata,positioning} + +\begin{tikzpicture}[shorten >=1pt,node distance=2cm,on grid, auto] + + \node[state, initial] (q_0) {$q_{0}$}; + \node[state,right=of q_0] (q_1) {$q_{1}$}; + \node[state,below=of q_0] (q_2) {$q_{2}$}; + \node[state,accepting, right=of q_2] (q_3) {$q_{3}$}; + + \path[->] (q_0) edge node {A} (q_1) + edge node {G} (q_3) + (q_0) edge node {C} (q_2) + (q_2) edge node {C} (q_3); +\end{tikzpicture} + +\end{document} diff --git a/figures/part1/comparison_matrix_repetitions.lua b/figures/part1/comparison_matrix_repetitions.lua new file mode 100644 index 0000000..614dad9 --- /dev/null +++ b/figures/part1/comparison_matrix_repetitions.lua @@ -0,0 +1,69 @@ +function comparison_matrix(seq) + matrix = {} + for i=1,#seq do + matrix[i] = {} + for j=1,#seq do + if seq[i] == seq[j] then + matrix[i][j] = 1 + else + matrix[i][j] = 0 + end + end + end + return matrix +end + +function split_char(seq) + t = {} + seq:gsub(".",function(c) table.insert(t,c) end) + return t +end + +function repr_matrix(matrix) + repr = "" + for i=1,#matrix do + for j=1,#matrix do + repr = repr .. matrix[i][j] .. " " + end + repr = repr .. "\n" + end + return repr +end +function comparison_matrix_tabular(matrix, seq1, seq2) + seq2 = seq2 or seq1 + n=#seq1 + m=#seq2 + repr = [[\begin{tabular}{]] .. string.rep("c", n+1) .. "} \n" + repr = repr .. " " + for i=1,n do + repr = repr .. "& " .. seq1[i] .. " " + end + repr = repr .. "\\\\ \n " + for j=1,m do + repr = repr .. seq2[j] .. " " + for i=1,n do + repr = repr .. "& " .. matrix[i][j] .. " " + end + repr = repr .. " \\\\ \n " + end + repr = repr .. [[\end{tabular}]] + return repr +end + +function main() + seq = split_char("ACGUUACGUUGUU") + + matrix = comparison_matrix(seq) + + print(comparison_matrix_tabular(matrix, seq)) +end + +function repr_comparison_matrix(seq) + seq = split_char(seq) + matrix = comparison_matrix(seq) + return comparison_matrix_tabular(matrix, seq) +end + +main() + +return { comparison_matrix=comparison_matrix, comparison_matrix_tabular, repr_comparison_matrix=repr_comparison_matrix } diff --git a/figures/part1/comparison_matrix_repetitions.pdf b/figures/part1/comparison_matrix_repetitions.pdf new file mode 100644 index 0000000..2fc321a --- /dev/null +++ b/figures/part1/comparison_matrix_repetitions.pdf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f50a5da2b860ec2915ce42234bf6c5bd9d6609c522679f328432042f65dbf537 +size 3420 diff --git a/figures/part1/comparison_matrix_repetitions.tex b/figures/part1/comparison_matrix_repetitions.tex new file mode 100644 index 0000000..601c7c2 --- /dev/null +++ b/figures/part1/comparison_matrix_repetitions.tex @@ -0,0 +1,14 @@ +\documentclass[tikz]{standalone} + +\usepackage{tikz} +\usepackage{luatextra} + +\begin{document} + +\directlua{ + lib = require("comparison_matrix_repetitions") + seq="ACGUUACGUUGUU" + tex.print(lib.repr_comparison_matrix(seq)) +} + +\end{document} diff --git a/figures/part1/language_exercise_automaton.tex b/figures/part1/language_exercise_automaton.tex new file mode 100644 index 0000000..7e893aa --- /dev/null +++ b/figures/part1/language_exercise_automaton.tex @@ -0,0 +1,24 @@ +\documentclass[tikz]{standalone} + +\usepackage{tikz} + +\begin{document} +\usetikzlibrary{automata,positioning} + +\iffalse + $\Sigma = \{A, C, T\}$, $L = \{A^{*}, CTT, CA^{*}\}$ + \fi +\begin{tikzpicture}[shorten >=1pt,node distance=2cm,on grid, auto] +% TODO + \node[state, initial] (q_0) {$q_{0}$}; + \node[state,right=of q_0] (q_1) {$q_{1}$}; + \node[state,below=of q_0] (q_2) {$q_{2}$}; + \node[state,accepting, right=of q_2] (q_3) {$q_{3}$}; + + \path[->] (q_0) edge node {A} (q_1) + edge node {G} (q_3) + (q_0) edge node {C} (q_2) + (q_2) edge node {C} (q_3); +\end{tikzpicture} + +\end{document} diff --git a/figures/part1/minimal_suffix_automaton_exercise.pdf b/figures/part1/minimal_suffix_automaton_exercise.pdf new file mode 100644 index 0000000..bdea112 --- /dev/null +++ b/figures/part1/minimal_suffix_automaton_exercise.pdf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:825f2a65c741e64136887bd476ca76700a17e4912024abc657c82ee4f22c3a7c +size 21540 diff --git a/figures/part1/minimal_suffix_automaton_exercise.tex b/figures/part1/minimal_suffix_automaton_exercise.tex new file mode 100644 index 0000000..92ab124 --- /dev/null +++ b/figures/part1/minimal_suffix_automaton_exercise.tex @@ -0,0 +1,62 @@ +\documentclass[tikz]{standalone} + +\usepackage{tikz} + +\begin{document} +\usetikzlibrary{automata,positioning} + +\iffalse + $S = $ AACTACT +The suffix language of $S$ is $\{S, ACTACT, CTACT, TACT, ACT, CT, T\}$. + + \fi +\begin{tikzpicture}[shorten >=1pt,node distance=2cm,on grid, auto] +% TODO + \node[state, initial] (q_0) {$q_{0}$}; + \node[state,right=of q_0] (q_1) {$q_{1}$}; + \node[state,right=of q_1] (q_2) {$q_{2}$}; + \node[state,right=of q_2] (q_3) {$q_{3}$}; + \node[state,right=of q_3] (q_4) {$q_{4}$}; + \node[state,right=of q_4] (q_5) {$q_{5}$}; + \node[state,right=of q_5] (q_6) {$q_{6}$}; + \node[state,accepting,right=of q_6] (q_7) {$q_{7}$}; + + % Fix for CT + \node[state,below=of q_2] (q_8) {$q_{8}$}; + \node[state,right=of q_8,accepting,yshift=-2cm] (q_9) {$q_{9}$}; + + % Fix for T +% \node[state,above=of q_2,yshift=2cm,accepting] (q_10) {$q_{10}$}; + % S itself + \path[->] (q_0) edge node {A} (q_1) + (q_1) edge node {A} (q_2) + (q_2) edge node {C} (q_3) + (q_3) edge node {T} (q_4) + (q_4) edge node {A} (q_5) + (q_5) edge node {C} (q_6) + (q_6) edge node {T} (q_7); + + % First suffix: ACTACT + \path[->] (q_1) edge[bend left=30] node {C} (q_8) + (q_9) edge[bend right=30] node {A} (q_5); + + % Second suffix: CTACT + \path[->] (q_0) edge[bend right=30] node {C} (q_8) + (q_8) edge node {T} (q_9); + + % Third suffix: TACT + % \path[->] (q_0) edge[bend left=30] node {T} (q_10) + %(q_10) edge[bend left=30] node {A} (q_5); + + + % Fourth suffix: ACT + % \path[->] (q_) + + % Fifth suffix: CT + + % Fix for T + \path[->] (q_0) edge[bend right=40] node {T} (q_9); + +\end{tikzpicture} + +\end{document} diff --git a/figures/part1/minimal_suffix_automaton_exercise_bis.pdf b/figures/part1/minimal_suffix_automaton_exercise_bis.pdf new file mode 100644 index 0000000..c4b0527 --- /dev/null +++ b/figures/part1/minimal_suffix_automaton_exercise_bis.pdf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a1a8f46341591c1999c80983d259ceb0784e51537ead8cc8af9783bf6b4a190c +size 21174 diff --git a/figures/part1/minimal_suffix_automaton_exercise_bis.tex b/figures/part1/minimal_suffix_automaton_exercise_bis.tex new file mode 100644 index 0000000..1609ab2 --- /dev/null +++ b/figures/part1/minimal_suffix_automaton_exercise_bis.tex @@ -0,0 +1,50 @@ +\documentclass[tikz]{standalone} + +\usepackage{tikz} + +\begin{document} +\usetikzlibrary{automata,positioning} + +\iffalse + $S = $ TCATCATT +The suffix language of $S$ is $\{TCATCATT, CATCATT, ATCATT, TCATT, CATT, ATT, AT, T\}$. + \fi +\begin{tikzpicture}[shorten >=1pt,node distance=2cm,on grid, auto] + \node[state, initial] (q_0) {$q_{0}$}; + \node[state,right=of q_0,accepting] (q_1) {$q_{1}$}; + \node[state,right=of q_1] (q_2) {$q_{2}$}; + \node[state,right=of q_2] (q_3) {$q_{3}$}; + \node[state,right=of q_3] (q_4) {$q_{4}$}; + \node[state,right=of q_4] (q_5) {$q_{5}$}; + \node[state,right=of q_5] (q_6) {$q_{6}$}; + \node[state,right=of q_6] (q_7) {$q_{7}$}; + \node[state,right=of q_7,accepting] (q_8) {$q_{8}$}; + + \path[->] (q_0) edge node {T} (q_1) + (q_1) edge node {C} (q_2) + (q_2) edge node {A} (q_3) + (q_3) edge node {T} (q_4) + (q_4) edge node {C} (q_5) + (q_5) edge node {A} (q_6) + (q_6) edge node {T} (q_7) + (q_7) edge node {T} (q_8); + + % CATCATT + \path[->] (q_0) edge[bend right=40] node {C} (q_2); + + % ATCATT + \path[->] (q_0) edge[bend right=50] node {A} (q_3); + + % TCATT + \path[->] (q_4) edge[bend right=30] node {T} (q_8); + + % CATT + + % ATT + %\path[->] (q_0) edge[bend right=50] node {A} (q_6); + + % TT + \path[->] (q_1) edge[bend left=30] node {T} (q_8); + +\end{tikzpicture} +\end{document} diff --git a/figures/part1/test.svg b/figures/part1/test.svg new file mode 100644 index 0000000..29ce2ba --- /dev/null +++ b/figures/part1/test.svg @@ -0,0 +1,657 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/localSettings.yaml b/localSettings.yaml new file mode 100644 index 0000000..baac0e3 --- /dev/null +++ b/localSettings.yaml @@ -0,0 +1,15 @@ +defaultIndent: " " +specialBeginEnd: + If: + begin: '\\If' + middle: '\\ElsIf' + end: '\\EndIf' + lookForThis: 1 + While: + begin: '\\While' + end: '\\EndWhile' + lookForThis: 1 + For: + begin: '\\For' + end: '\\EndFor' + specialBeforeCommand: 1 diff --git a/main.pdf b/main.pdf index 2c11a42..de53674 100644 --- a/main.pdf +++ b/main.pdf @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:8fec11218cec71edc91fd51b23fbb6e7cac1d271570125d0bf14f587e3aa18c8 -size 125055 +oid sha256:72df819d0cd0479f67c00c86ad5d71b147b11557800bd742185e3cca24100218 +size 128613 diff --git a/tmp.pdf b/tmp.pdf new file mode 100644 index 0000000..130f8e5 --- /dev/null +++ b/tmp.pdf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:94c2912fea2b02c615c3534646b4496fc2f622a9af88a4f87602c7e6c772ad2e +size 49570 diff --git a/tmp.tex b/tmp.tex new file mode 100644 index 0000000..d2cc0fb --- /dev/null +++ b/tmp.tex @@ -0,0 +1,15 @@ +\documentclass{scrartcl} +\RequirePackage{algorithm} +\RequirePackage{algorithmicx} +\RequirePackage[noEnd=false]{algpseudocodex} +\newcommand{\algorithmautorefname}{Algorithm} % Allow autoref. +% Define macros to typeset boolean in pseudocode environments +\algnewcommand{\True}{\textbf{\texttt{true}}} +\algnewcommand{\False}{\textbf{\texttt{false}}} +\algnewcommand{\NIL}{\textbf{\texttt{NIL}}} +\algnewcommand{\NULL}{\textbf{\texttt{null}}} +\input{definitions.tex} + +\begin{document} + +\end{document}