├── .gitignore ├── Discrete_Math_Notes.pdf ├── Discrete_Math_Notes.tex ├── Makefile ├── Readme.md └── sections ├── 01-ReviewOfPropositionalLogic.tex ├── 02-PredicateLogicAndQuantifiers.tex ├── 03-SetTheory.tex ├── 04-SetOperations.tex ├── 05-ThePowerSet.tex ├── 06-CartesianProducts.tex ├── 07-Relations.tex ├── 08-EquivalenceRelations.tex ├── 09-EquivalenceRelationsAndPartitions.tex ├── 10-PartialOrders.tex ├── 11-Functions.tex ├── 12-CompositionOfFunctions.tex ├── 13-InvertingFunctions.tex ├── 14-FunctionsDefinedOnFiniteSets.tex ├── 15-MathematicalInduction.tex ├── 16-AbstractAlgebra.tex ├── 17-Inverses.tex ├── 18-HomomorphismsAndIsomorphisms.tex ├── 19-FormalLanguages.tex ├── 20-RegularLanguages.tex ├── 21-RegularGrammars.tex ├── 22-GraphTheory.tex ├── 23-IsomorphismOfGraphs.tex ├── 24-Subgraphs.tex ├── 25-VertexDegrees.tex ├── 26-Walks,TrailsAndPaths.tex ├── 27-ConnectedGraphs.tex ├── 28-ComponentsOfAGraph.tex ├── 29-Circuits.tex ├── 30-EulerianTrailsAndCircuits.tex ├── 31-HamiltonianPathsAndCircuits.tex ├── 32-ForestsAndTrees.tex └── 33-CountabilityOfSets.tex /.gitignore: -------------------------------------------------------------------------------- 1 | *.aux 2 | *.log 3 | *.out 4 | *.gz 5 | *.toc -------------------------------------------------------------------------------- /Discrete_Math_Notes.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Scarlehh/Discrete_Math_Notes/73af28f0043f1fff5504a22d12ec40f98e86cd56/Discrete_Math_Notes.pdf -------------------------------------------------------------------------------- /Discrete_Math_Notes.tex: -------------------------------------------------------------------------------- 1 | \documentclass[10pt]{article} 2 | \usepackage{caption} 3 | \usepackage{multirow} 4 | \usepackage{amsfonts} 5 | \usepackage{amsmath} 6 | \usepackage{amssymb} 7 | 8 | \usepackage{tikz} 9 | \usepackage{tkz-euclide} 10 | \usetikzlibrary{shapes, backgrounds, calc} 11 | \usetkzobj{all} 12 | 13 | \usepackage{subfiles} 14 | 15 | \usepackage{hyperref} 16 | \hypersetup{ 17 | colorlinks = true 18 | } 19 | 20 | \begin{document} 21 | \tableofcontents 22 | \pagebreak 23 | 24 | \subfile{sections/01-ReviewOfPropositionalLogic} 25 | \subfile{sections/02-PredicateLogicAndQuantifiers} 26 | \subfile{sections/03-SetTheory} 27 | \subfile{sections/04-SetOperations} 28 | \subfile{sections/05-ThePowerSet} 29 | \subfile{sections/06-CartesianProducts} 30 | \subfile{sections/07-Relations} 31 | \subfile{sections/08-EquivalenceRelations} 32 | \subfile{sections/09-EquivalenceRelationsAndPartitions} 33 | \subfile{sections/10-PartialOrders} 34 | \subfile{sections/11-Functions} 35 | \subfile{sections/12-CompositionOfFunctions} 36 | \subfile{sections/13-InvertingFunctions} 37 | \subfile{sections/14-FunctionsDefinedOnFiniteSets} 38 | \subfile{sections/15-MathematicalInduction} 39 | \subfile{sections/16-AbstractAlgebra} 40 | \subfile{sections/17-Inverses} 41 | \subfile{sections/18-HomomorphismsAndIsomorphisms} 42 | \subfile{sections/19-FormalLanguages} 43 | \subfile{sections/20-RegularLanguages} 44 | \subfile{sections/21-RegularGrammars} 45 | \subfile{sections/22-GraphTheory} 46 | \subfile{sections/23-IsomorphismOfGraphs} 47 | \subfile{sections/24-Subgraphs} 48 | \subfile{sections/25-VertexDegrees} 49 | \subfile{sections/26-Walks,TrailsAndPaths} 50 | \subfile{sections/27-ConnectedGraphs} 51 | \subfile{sections/28-ComponentsOfAGraph} 52 | \subfile{sections/29-Circuits} 53 | \subfile{sections/30-EulerianTrailsAndCircuits} 54 | \subfile{sections/31-HamiltonianPathsAndCircuits} 55 | \subfile{sections/32-ForestsAndTrees} 56 | \subfile{sections/33-CountabilityOfSets.tex} 57 | 58 | \end{document} 59 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | SRC = Discrete_Math_Notes.tex 2 | 3 | .PHONY: all 4 | all: 5 | pdflatex $(SRC) 6 | pdflatex $(SRC) 7 | 8 | .PHONY: clean 9 | clean: 10 | rm *.log 11 | rm *.aux 12 | rm *.out 13 | rm *.toc 14 | -------------------------------------------------------------------------------- /Readme.md: -------------------------------------------------------------------------------- 1 | # MA2C03 Discrete Mathematics 2 | These are a set of notes for the Trinity College Dublin's Discrete Mathematics module. They are not my own, and were just converted from handwritten format. 3 | 4 | About the module from the course handbook: 5 | 6 | > This module provides students with an introduction to Discrete Mathematics. Students are exposed to diverse course material presented in the formal style and language that is commonplace in contemporary mathematics, with the aim that they should develop the skills required to engage effectively with such material. Students get an introduction to a variety of topics arising from Calculus, Geometry and Discrete Mathematics, that are of relevance in fields such as acoustics, image processing, computer graphics and cryptology. 7 | 8 | ## Requirements 9 | - pdflatex 10 | 11 | ## Contributing 12 | Feel free to submit a pull request if there are any mistakes, or if the notes have been updated. If you are currently taking this module and would like to become a collaborator, let me know. 13 | -------------------------------------------------------------------------------- /sections/01-ReviewOfPropositionalLogic.tex: -------------------------------------------------------------------------------- 1 | \documentclass[../main.tex] 2 | 3 | \begin{document} 4 | \section{Review of Propositional Logic} 5 | \begin{description} 6 | \item[Task:] Recall enough propositional logic to see how it matches up with set theory. 7 | \item[Definition:] A \underline{proposition} is any declarative sentence that is either true or false. 8 | \end{description} 9 | 10 | \subsection{Connectives} 11 | \centerline { 12 | \begin{tabular}{cccc} 13 | \multicolumn{3}{c}{\underline{Connectives}} & \multicolumn{1}{c}{\underline{Notation in Maths}} \\ 14 | and & $\land$ \\ 15 | or & $\lor$ & "Inclusive or"\\ 16 | not & $\lnot$ & Sometimes denoted $\sim$\\ 17 | implies & $\to$ & if/then; called implication & $\Rightarrow$\\ 18 | if and only if & $\leftrightarrow$ & Called equivalence & $\Leftrightarrow$\\ 19 | \end{tabular} 20 | } 21 | 22 | \subsubsection{Truth Table of the Connectives} 23 | Let P, Q be propositions:\\ 24 | 25 | \centerline{ 26 | \begin{tabular}{|c|c|c|} 27 | \cline{1-3} 28 | P & Q & P$\land$Q \\ \cline{1-3} 29 | F & F & F \\ \cline{1-3} 30 | F & T & F \\ \cline{1-3} 31 | T & F & F \\ \cline{1-3} 32 | T & T & T \\ \cline{1-3} 33 | \end{tabular} 34 | \quad 35 | \begin{tabular}{|c|c|c|} 36 | \cline{1-3} 37 | P & Q & P$\lor$Q \\ \cline{1-3} 38 | F & F & F \\ \cline{1-3} 39 | F & T & T \\ \cline{1-3} 40 | T & F & T \\ \cline{1-3} 41 | T & T & T \\ \cline{1-3} 42 | \end{tabular} 43 | \quad 44 | \begin{tabular}{|c|c|} 45 | \cline{1-2} 46 | P & $\lnot$P \\ \cline{1-2} 47 | F & T \\ \cline{1-2} 48 | T & F \\ \cline{1-2} 49 | \end{tabular} 50 | \quad 51 | \begin{tabular}{|c|c|c|} 52 | \cline{1-3} 53 | P & Q & P$\to$Q \\ \cline{1-3} 54 | F & F & T \\ \cline{1-3} 55 | F & T & T \\ \cline{1-3} 56 | T & F & F \\ \cline{1-3} 57 | T & T & T \\ \cline{1-3} 58 | \end{tabular} 59 | \quad 60 | \begin{tabular}{|c|c|c|} 61 | \cline{1-3} 62 | P & Q & P$\leftrightarrow$Q \\ \cline{1-3} 63 | F & F & T \\ \cline{1-3} 64 | F & T & F \\ \cline{1-3} 65 | T & F & F \\ \cline{1-3} 66 | T & T & T \\ \cline{1-3} 67 | \end{tabular} 68 | } 69 | 70 | \subsubsection*{Priority of the Connectives} 71 | \textbf{Highest to Lowest:} $\lnot, \land, \lor, \rightarrow, \leftrightarrow$ 72 | 73 | \subsection{Important Tautologies} 74 | \begin{tabular}{rcll} 75 | $(P \rightarrow Q)$ & $\leftrightarrow$ & $(\lnot P \lor Q)$ \\ 76 | $(P \leftrightarrow Q)$ & $\leftrightarrow$ & $[(P \rightarrow Q) \land (Q \rightarrow P)]$ \\ 77 | $\lnot(P \land Q)$ & $\leftrightarrow$ & $(\lnot P \lor \lnot Q)$ & \multirow{2}{4cm}{\LARGE\} \normalsize De Morgan Laws} \\ 78 | $\lnot(P \lor Q)$ & $\leftrightarrow$ & $(\lnot P \land \lnot Q)$ \\ 79 | \end{tabular} 80 | ~\\~\\~\\ 81 | As a result, $\lnot$ and $\lor$ together can be used to represent all of $\lnot, \land, \lor, \rightarrow, \leftrightarrow$. 82 | 83 | \begin{description} 84 | \item[Less obvious:] One connective called the sheffer stroke P$\mid$Q (which stands for "not both P and Q" or "P nand Q") can be used to represent all of $\lnot$, $\land$, $\lor$, $\rightarrow$, $\leftrightarrow$ since $\lnot$P $\leftrightarrow$ P$\mid$P and P $\lor$ Q $\leftrightarrow$ (P$\mid$P) $\mid$ (Q$\mid$Q). 85 | \item[Recall] if P$\rightarrow$Q is a given implication, Q$\rightarrow$P is called the \underline{converse} or P$\rightarrow$Q. $\lnot$Q $\rightarrow$ $\lnot$P. 86 | \end{description} 87 | 88 | \subsection{Indirect Arguments/Proofs by Contradiction/Reductio as absurdum} 89 | Based on the tautology (P$\rightarrow$Q) $\leftrightarrow$ ($\lnot$Q $\rightarrow$ $\lnot$P) 90 | 91 | \begin{description} 92 | \item[Example:] Famous argument that $\sqrt{2}$ is irrational. 93 | \item[Proof:] 94 | \item \textbf{Suppose} $\sqrt{2}$ is rational, then it can be expressed is fraction form $\frac{a}{b}$. Let us \textbf{assume} that our fraction is in the lowest term, \textbf{i.e.} their only common divisor is 1. 95 | \item Then, \[\sqrt{2}=\frac{a}{b}\] 96 | \item Squaring both sides, we have \[2=\frac{a^2}{b^2}\] 97 | \item Multiplying both sides by $B^2$ yields \[2b^2=a^2\] 98 | \item Since $a^2b^2$, we can conclude that $a^2$ is even because whatever the value of $b^2$ has to be multiplied by 2. If $a^2$ is even, then $a$ is also even. Since $a$ is even, no matter what the value of $a$ is, we can always find an integer that if we divide $a$ by 2, it is equal to that integer. If we let that integer be $k$, then $\frac{a}{b}=k$ which means that $a=2k$. 99 | \item Substituting the value of $2k$ to $a$, we have $2b^2=(2k)^2$ which means that $2b^2=4k^2$. dividing both sides by 2 we have $b^2=2k^2$. That means that the value $b^2$ is even, since whatever the value of $k$ you have to multiply it by 2. Again, is $b^2$ is even, then $b$ is even. 100 | \item This implies that both $a$ and $b$ are even, which means that both the numerator and the denominator of our fraction are divisible by 2. This contradicts our \textbf{assumption} that $\frac{a}{b}$ has no common divisor except 1. Since we found a contradiction, our assumption is, therefore, false. Hence the theorem is true. 101 | \item \textbf{qed} 102 | \end{description} 103 | 104 | 105 | \end{document} -------------------------------------------------------------------------------- /sections/02-PredicateLogicAndQuantifiers.tex: -------------------------------------------------------------------------------- 1 | \documentclass[../main.tex] 2 | 3 | \begin{document} 4 | \section{Predicate logic and Quantifiers} 5 | \begin{description} 6 | \item[Task:] Understand enough predicate logic to make sense of quantified statements. 7 | \item In predicate logic, propositions depend on variable x, y, z, so their truth value may change depending on which values these variables assume: $P(x), Q(x, y), R(x, y, z)$ 8 | \end{description} 9 | 10 | \subsection{Introduce quantifiers} 11 | \subsubsection{$\exists$ existential quantifier} 12 | \begin{description} 13 | \item[Syntax:] $\exists xP(x)$ 14 | \item[Definition:] $\exists xP(x)$ is true if $P(x)$ is true or some value of $x$; it is false otherwise. 15 | \end{description} 16 | 17 | \subsubsection{$\forall$ universal quantifier} 18 | \begin{description} 19 | \item[Syntax:] $\forall xP(x)$ 20 | \item[Definition:] $\forall xP(x)$ is true if $P(x)$ is true for all allowable values of $x$. It is false otherwise. 21 | \end{description} 22 | 23 | \subsubsection{$\exists!$ for one and only one} 24 | \begin{description} 25 | \item[Syntax:] $\exists! xP(x)$ 26 | \item[Definition:] $\exists! xP(x)$ is true if $P(x)$ is true for exactly one value of $x$ and false for all often values of $x$; otherwise, $\exists! xP(x)$ is false. 27 | \end{description} 28 | 29 | \subsection{Alternation of Quantifiers} 30 | \begin{tabular}{lr} 31 | $\forall x\exists y\forall z$ & $P(x, y, z)$ \\ 32 | \end{tabular} 33 | ~\\ 34 | \textbf{NB:} The order \underline{cannot} be exchanged as it might modify the truth values of the statement (think of examples with two quantifiers). 35 | 36 | \subsection{Negation of Quantifiers} 37 | \begin{tabular}{rcl} 38 | $\lnot(\exists xP(x))$ & $\leftrightarrow$ & $\forall x\lnot P(x)$ \\ 39 | $\lnot(\forall xP(x))$ & $\leftrightarrow$ & $\exists x\lnot P(x)$ \\ 40 | \end{tabular} 41 | 42 | 43 | \end{document} -------------------------------------------------------------------------------- /sections/03-SetTheory.tex: -------------------------------------------------------------------------------- 1 | \documentclass[../main.tex] 2 | 3 | \begin{document} 4 | \section{Set Theory} 5 | \begin{description} 6 | \item[Task:] Understand enough set theory to make sense of other mathematical objects in abstract algebra, graph theory, etc. Set theory started around 1870's $\rightarrow$ late development in mathematics but now taught early in one's maths education due to Bourbaki school. 7 | \item[Definition:] A set is a collection of objects. $x\in A$ means the element $X$ is in the set $A$ (\textbf{i.e.} belongs to $A$). 8 | \item[Examples:] 9 | \begin{enumerate} 10 | \item[] 11 | \item All students in a class. 12 | \item $\mathbb{N}$ the set of natural numbers starting at 0. 13 | \begin{enumerate} 14 | \item [$\mathbb{N}$] is defined via the following two axioms: 15 | \item 0 $\in \mathbb{N}$ 16 | \item if $x \in \mathbb{N}$ then $x+1 \in \mathbb{N}$ ($x \in \mathbb{N} \rightarrow X+A \in \mathbb{N}$) 17 | \end{enumerate} 18 | \item $\mathbb{R}$ set of real numbers also introduced axiomatically 19 | \begin{enumerate} 20 | \item[$\mathbb{R}$] the set of real numbers. 21 | \item Additive closure: $\forall x, y \exists z (x+y=z)$ 22 | \item Multiplicative closure: $\forall x, y, \exists z (x \times y=z)$ 23 | \item Additive associativity: $x+(y+z)=(x+y)+z$ 24 | \item Multiplicative associativity: $x \times (y \times z) = (x \times y) \times z$ 25 | \item Additive commutativity: $x+y=y+x$ 26 | \item Multiplicative commutativity: $x \times y = y \times x$ 27 | \item Distributivity: $x \times (y+z) = (x \times y) + (x \times z)$ and $(y+z) \times x = (y \times x) + (z \times x)$ 28 | \item Additive identity: There is a number, denoted 0, such that or all $x, x+0=x$ 29 | \item Multiplicative identity: There is a number, denoted 1, such that for all $x, x \times 1 = 1 \times x = x$ 30 | \item Additive inverses: For every $x$ there is a number, denoted $-x$, such that $x+(-x)=0$ 31 | \item Multiplicative inverses: For every nonzero $x$ there is a number, denoted $x$, such that $x \times x^{-1} = x^{-1} \times x = 1$ 32 | \item $0 \neq 1$ 33 | \item Irreflexivity of $<: \sim (x1$, then the only element of $X$ gets mapped to $x$. It follows that the function $f$ is injective. However it is not surjective, since $x_1$ does not belong to the range of the function. This function $f$ is thus an example of a function from the set $X$ to itself which is injective but not bijective. 40 | \end{description} 41 | 42 | 43 | \end{document} -------------------------------------------------------------------------------- /sections/15-MathematicalInduction.tex: -------------------------------------------------------------------------------- 1 | \documentclass[../main.tex] 2 | 3 | \begin{document} 4 | \section{Mathematical Induction} 5 | \begin{description} 6 | \item[Task:] Understand how to construct a proof using mathematical induction. 7 | \end{description} 8 | $\mathbb{N} = \{0, 1, 2, \dots\}$ set of natural numbers. \\ 9 | Recall that $\mathbb{N}$ is constructed using 2 axioms: 10 | \begin{enumerate} 11 | \item $0 \in \mathbb{N}$ 12 | \item If $n \in \mathbb{N}$, then $n+1 \in \mathbb{N}$ 13 | \end{enumerate} 14 | 15 | \begin{description} 16 | \item[Remarks:] 17 | \begin{enumerate} 18 | \item[] 19 | \item This is exactly the process of counting. 20 | \item If we start at $1$, then we construct $\mathbb{N}* = \{1, 2, 3, 4, \dots\} = \mathbb{N} \backslash \{0\}$ 21 | \end{enumerate} 22 | \item via the axioms 23 | \begin{enumerate} 24 | \item $1 \in \mathbb{N}*$ 25 | \item if $n \in \mathbb{N}*$, then $n+1 \in \mathbb{N}*$ 26 | \end{enumerate} 27 | \item $\mathbb{N}$ or $\mathbb{N}*$ is used for mathematical induction. 28 | \end{description} 29 | 30 | \subsection{Mathematical Induction Consists of Two Steps:} 31 | \begin{description} 32 | \item[Step 1] Prove statements $P(1)$ called \underline{the base case}. 33 | \item[Step 2] For any $n$, assume $P(n)$ and prove $P(n+1)$. This is called \underline{the inductive step}. In other words, step 2 proves the statement $\forall n P(n) \rightarrow P(n+1)$ 34 | \item[Remark:] Step 2 is not just an implication but infinitely many! In logic notation, we have: 35 | \item[Step 1] $P(1)$ 36 | \item[Step 2] $\forall n (P(n) \rightarrow P(n+1))$ \\ 37 | Therefore, $\forall n P(n)$ \\ 38 | Let's see how the argument proceeds: 39 | \begin{enumerate} 40 | \item $P(1)$ \hspace{10mm} Step 1 (base case) 41 | \item $P(1) \rightarrow P(2)$ \hspace{10mm} by Step 2 with $n=1$ 42 | \item $P(2)$ \hspace{10mm} by 1 \& 2 43 | \item $P(2) \rightarrow P(3)$ \hspace{10mm} by Step 2 with $n=2$ 44 | \item $P(3)$ \hspace{10mm} by 3 \& 4 45 | \item $P(3) \rightarrow P(4)$ \hspace{10mm} by Step 2 with $n=3$ 46 | \item $P(4)$ \hspace{10mm} by 5 \& 6 \\ 47 | \vdots 48 | \item $P(n)$ for any $n$. \\ 49 | This is like a row of dominos: knocking over the first one in a row makes all the others fall. Another idea is climbing a ladder. 50 | \end{enumerate} 51 | \item[Examples:] 52 | \begin{enumerate} 53 | \item[] 54 | \item Prove $1+3+5+\dots+(2n-1) = n^2$ by induction. 55 | \begin{description} 56 | \item[Base Case:] Verify statement for $n=1$ 57 | \item When $n=1$, $2n-1 = 2 \times 1 - 1 = 1^2$ 58 | \item[Inductive Step:] Assume $P(n)$, \textbf{i.e.} $1+3+5+\dots+(2n-1)=n^2$ and seek to prove $P(n+1)$, \textbf{i.e.} the statement $1+3+5\dots+(2n-1+2(n+1)-1) = (n+1)^2$ 59 | \item We start with LHS: $1+ \underset{n^2}{\underbrace{3+5+\dots+(2n-1)}}+(2(n+1)-1)=n^2+2n+2-1=n^2+2n+1=(n+1)^2$ 60 | \end{description} 61 | \item Prove $1+2+3+ +n= \frac{n(n+1)}{2}$ by induction. 62 | \begin{description} 63 | \item [Base Case:] Verify statement for $n=1$ 64 | \item When $n=1, 1= \frac{1\times (1+1)}{2}=\frac{1 \times 2}{2} = 1$ 65 | \item[Inductive Step:] Assume $P(n)$, \textbf{i.e.} $1+2+3+\dots+n=\frac{n\times (n+1)}{2}$ and seek to prove $1+2+3+\dots+n= \frac{(n+1)(n+2)}{2}$ 66 | \item $\underset{\frac{n(n+1)}{2}}{\underbrace{1+2+3+\dots+n}}+n+1 = \frac{n(n+1)}{2} + n + 1 = (n+1)(\frac{n}{2} + 1)=(n+1)\frac{n+2}{2} = \frac{(n+1)(n+2)}{2}$ as needed. 67 | \end{description} 68 | \end{enumerate} 69 | \item[Remarks:] 70 | \begin{enumerate} 71 | \item[] 72 | \item For some argument by induction, it might be necessary to assume not just $P(n)$ at the inductive step but also $P(1), P(2), \dots, P(n-1)$. This is called \underline{strong induction}. 73 | \begin{description} 74 | \item[Base Case:] Prove $P(1)$ 75 | \item[Inductive Step:] Assume $P(a), P(2), \dots, P(n)$ and prove $P(n+1)$. 76 | \end{description} 77 | \item[] An example of result requiring the use of strong induction is the \underline{Fundamental Theorem of Arithmetic}: $\forall n \in \mathbb{N}, n \geq 2, n$ can be expressed as a product of one or more prime numbers. 78 | \item One has to be careful with argument involving induction. Here is an illustration why: 79 | \item[] \underline{Polya's argument that all horses are the same colour:} 80 | \begin{description} 81 | \item[Base Case:] $P(1)$ There is only one horse, sot hat has a colour.\item[Inductive Step] Assume any $n$ horses are the same colour. 82 | \item Consider a group of $n+1$ horses. Exclude the first horse and look at the other $n$. All of these are the same colour by our assumption. Now exclude the last horse. The remaining $n$ horses are the same colour by our assumption. Therefore, the first horse, the horses in the middle, and the last horse are all of the same colour. We have established the inductive step. 83 | \item[Q:] Where does the argument fail? 84 | \item[A:] For $n=2, P(2)$ is false because there are no middle horses to compare to. 85 | \end{description} 86 | \item[] \underline{The Grand Hotel Cigar Mystery} 87 | \begin{description} 88 | \item[] Recall Hilbert's hotel - the grand Hotel. Suppose that the Grand Hotel does not allow smoking and no cigars may be taken into the hotel. In spite of the rules, the guest in Room 1 goes to Room 2 to get a cigar. The guest in Room 2 goes to Room 3 to get 2 cigars (one for him and one for the person in room 1), etc. In other words, guest in Room N goes to Room N+1 to get N cigars. They will each get back to their rooms, smoke one cigar, and give the result to the person in Room N-2. 89 | \item[Q:] Where is the fallacy? 90 | \item[A:] This is an induction argument without a base case. No cigars are allowed in the hotel so no guests have cigars. An induction cannot get off the ground without a base case. 91 | \end{description} 92 | \end{enumerate} 93 | \end{description} 94 | 95 | 96 | \end{document} -------------------------------------------------------------------------------- /sections/16-AbstractAlgebra.tex: -------------------------------------------------------------------------------- 1 | \documentclass[../main.tex] 2 | 3 | \begin{document} 4 | \section{Abstract Algebra} 5 | \begin{description} 6 | \item[Task:] Understand binary operators, semigroups, monoids, and groups as well as their properties. 7 | \end{description} 8 | 9 | \subsection{Binary Operations} 10 | \begin{description} 11 | \item[Definition:] Let $A$ be a set. A \underline{binary operation} $*$ on $A$ is an operation applied to any two elements $x, y \in A$ that yields on elements $x*y$ in $A$. In other words, $*$ us a binary operation on $A$ if $\forall x, y \in A, x*y \in A$. 12 | \item[Examples:] 13 | \begin{enumerate} 14 | \item[] 15 | \item $\mathbb{R}, +$ addition on $\mathbb{R}: \forall x, y \in \mathbb{R}, x+y \in \mathbb{R}$ 16 | \item $\mathbb{R}, -$ subtraction on $\mathbb{R}: \forall x, y \in \mathbb{R}, x-y \in \mathbb{R}$ 17 | \item $\mathbb{R}, \times$ multiplication on $\mathbb{R}: \forall x, y \in \mathbb{R}, x \times y \in \mathbb{R}$ 18 | \item $\mathbb{R}, /$, division on $\mathbb{R}$ is \underline{NOT} a binary operation because $\forall x \in \mathbb{R} \exists o \in \mathbb{R}$ s.t. $\frac{x}{o}$ is undefined (not an element of $\mathbb{R}$) 19 | \end{enumerate} 20 | \item[Definition:] A binary operation $*$ on a set $A$ is called \underline{commutative} if $\forall x, y \in A, x*y=y*x$ 21 | \item[Examples:] 22 | \begin{enumerate} 23 | \item[] 24 | \item $\mathbb{R}, +$ is commutative since $\forall x, y \in \mathbb{R}, x+y=y+x$ 25 | \item $\mathbb{R}, \times$ is commutative since $\forall x, y \in \mathbb{R}, x \times y = y \times x$ 26 | \item $\mathbb{R}, -$ is not commutative since $\forall x, y \in \mathbb{R}, x-y \neq y-x$ in general. $x-y=y-x$ only if $x=y$ 27 | \item Let $Mn$ be the set of $n$ by $n$ matrices with entries in $\mathbb{R}$ and let $*$ be matrix multiplication. $\forall A, B \in Mn, A*B \in Mn$, so $*$ is a binary operation, but $AB \neq BA$ in general. Therefore $*$ is not commutative. 28 | \end{enumerate} 29 | \item[Definition:] A binary operation $*$ on a set $A$ is called \underline{associative} if $\forall x, y, z, (x*y)*z = x*(y*z)$ 30 | \item[Examples:] 31 | \begin{enumerate} 32 | \item[] 33 | \item $\mathbb{R}, +$ is associative since $\forall x, y, z \in \mathbb{R}, (x+y)+z=x+(y+z)$ 34 | \item $\mathbb{R}, \times$ is associative since $\forall x, y, z \in \mathbb{R}, (x \times y) \times z = x \times (y \times z)$ 35 | \item Intersection $\cap$ on sets is associative since $\forall A, B, C$ sets $(A \cap B) \cap C = A \cap (B \cap C)$. 36 | \item Union $\cup$ on sets is associative since $\forall A, B, C$ sets $(A \cup B) \cup C = A \cup (B \cup C)$ 37 | \item $\mathbb{R}, -$ is not associative since $(1-3)-5 = -2-5 =-7$ but $1-(3-5)=1-(-2)=1+2=3$ 38 | \end{enumerate} 39 | \item[Remark:] When we are dealing with associative binary operations we can drop the parentheses, \textbf{i.e.} $(x*y)*z$ can be written $x*y*z$. 40 | \end{description} 41 | 42 | \subsection{Semigroups} 43 | \begin{description} 44 | \item[Definition:] A \underline{semigroup} is a set endowed with an associative binary operation. We denote the semigroup $(A, *)$ 45 | \item[Examples:] 46 | \begin{enumerate} 47 | \item[] 48 | \item $(\mathbb{R}, +)$ and $(\mathbb{R}, -)$ are semigroups. 49 | \item Let $A$ be a set and let $P(A)$ be its power set. $(P(A), \cap)$ and $(P(A), \cup)$ are both semigorups. 50 | \item $(Mn, *)$, the set of $n\times n$ matrices with entries in $\mathbb{R}$ with the operation of matrix multiplication (which is associative $\rightarrow$ a bit gory to prove) forms a semigroup. 51 | \item[] Since $*$ is associative on a semigroup, we can define $a^n:$\\ 52 | $a^1 = a$ \\ 53 | $a^2 = a*a$\\ 54 | $a^3 = a*a*a$\\ 55 | \vdots \\ 56 | Recursively, $a^1=1$ and $a^n=a*a^{n-1}, \forall n > 1$ 57 | \item[\textbf{NB:}] In $(\mathbb{R}, \times), \forall a \in \mathbb{R}, a^n = \underset{n\: times}{\underbrace{a \times a \times \dots \times a}}$, whereas in $(\mathbb{R}, +), \forall a \in \mathbb{R}, a^n = \underset{n\: times}{\underbrace{a + a + \dots + a}}=na$. Be careful what $*$ stands for! 58 | \end{enumerate} 59 | \item[Theorem:] Let $(A, *)$ be a semigroup. $\forall a \in A, a^m * a^n = a^{m+n}, \forall m, n \in \mathbb{N*}$. 60 | \begin{description} 61 | \item[Proof:] By induction on $m$. 62 | \item[Base Case:] $m=1 \hspace{10mm} a^1*a^n= a*a^n =a*{1+n}$ 63 | \item[Inductive Step:] Assume the result is true for $m=p$, \textbf{i.e.} $a^p*a^n = a^{p+n}$ and seek to prove that $a^{p+1}*a^n=a^{p+1+n}$ 64 | \item $a^p+1*a^n = (a*a^p)*a^n = a*(a^p*a*n) = a*a^{p+n} =a^{p+1+n}$ 65 | \end{description} 66 | \item[Theorem:] Let$(A, *)$ be a semigroup. $\forall a \in A, (a^m)^n = a^{mn}, \forall m, n \in \mathbb{N}*$ 67 | \begin{description} 68 | \item[Proof:] By induction on $n$. 69 | \item[Base Case:] $n=1 \hspace{10mm} (a^m)^1 = a^m = a^{m \times 1}$ 70 | \item[Inductive Step:] Assume the result if true for $n=p$, \textbf{i.e.} $(a^m)^p = a^{mp}$ and seek to prove that $(a^m)^{p+1}=a^{m(p+1)}$ 71 | \item $(a^m)^{p+1} = (a^m)^p * a^m = a^{mp} * a^m = a^{mp+m} = a^{m(p+1)}$ 72 | \end{description} 73 | \end{description} 74 | 75 | \subsubsection{General Associative Law} 76 | Let $(A, *)$ be a semigroup. $\forall a_1, \dots, a_s \in A, a_1 * a_2 * \dots * a_s$ has the same value regardless of how the product is bracketed. 77 | \begin{description} 78 | \item[Proof] Use associativity of $*$. 79 | \item[qed] 80 | \item[NB:] Unless $(A, *)$ has a commutative binary operation, $a_1 * a_2 * \dots * a_s$ does depend on the \underline{ORDER} in which the $a_j's$ appear in $a_1 * a_2 * \dots * a_s$ 81 | \end{description} 82 | 83 | \subsubsection{Identity Elements} 84 | \begin{description} 85 | \item[Definition:] Let $(A, *)$ be a semigroup. An element $e \in A$ is called an identity element for the binary operation $*$ if $e*x = x*e = x, \forall x \in A$. 86 | \item[Examples:] 87 | \begin{enumerate} 88 | \item[] 89 | \item $(\mathbb{R}, +)$ has 0 as the identity element. 90 | \item $(\mathbb{R}, \times)$ has 1 as the identity element. 91 | \item Given a set $A, (P(A), \cup)$ has $\emptyset$ (the empty set) as its identity elements, whereas $(P(A), \cap)$ has $A$ as its identity element. 92 | \item $(Mn, *)$ has $In$, the identity matrix as its identity element. 93 | \end{enumerate} 94 | \item[Theorem] A binary operation on a set cannot have more than one identity elements, \textbf{i.e.} if an identity element exists, then it is unique. 95 | \begin{description} 96 | \item[Proof:] Assume not (proof by contradiction). Let $e$ and $e'$ both be identity elements for a binary operation on a set $A$. $e=e*e'=e'$ 97 | \item[qed] 98 | \end{description} 99 | \end{description} 100 | 101 | \subsection{Monoids} 102 | \begin{description} 103 | \item[Definition:] A \underline{monoid} is a set $A$ endowed with an associative binary operation $*$ that has an identity element $e$. In other words, a monoid is a semigroup $(A, *)$ where $*$ has an identity element $e$. 104 | \item[Definition:] A monoid $(A, *)$ is called \underline{commutative} (or \underline{Abelian}) if the binary operation $*$ is commutative. 105 | \item[Example:] 106 | \begin{enumerate} 107 | \item[] 108 | \item $(\mathbb{R}, +)$ is a commutative monoid with $e=o$. 109 | \item $(\mathbb{R}, \times)$ is a commutative monoid with $e=1$. 110 | \item Given a set $A$, $(P(A), \cup)$ is a commutative monoid with $e = \emptyset$. 111 | \item $(M,n *)$ is a monoid since $e=In$, but it is not commutative since matrix multiplication is not commutative. 112 | \item $(\mathbb{N}, +)$ is a commutative monoid with $e=o$, whereas $(\mathbb{N}*, +)$ is merely a semigroup (recall $\mathbb{N}* = \mathbb{N} \backslash\{0\}$) 113 | \end{enumerate} 114 | \item[Theorem:] Let $(A, *)$ be a monoid and let $a \in A$. Then $a^m * a^n = a^{m+n}, \forall m, n \in \mathbb{N}$ 115 | \begin{description} 116 | \item[Remark:] Recall that we proved this theorem for semigroups if $m, n \in \mathbb{N}*$. We now need to extend that result. 117 | \item[Proof:] A monoid is a semigroup $\implies \forall a \in A, a^m * a^n = a^{m+n}$ whenever $m, n \in \mathbb{N}*$, \textbf{i.e.} $m > 0$ and $n > 0$. Now let $m = 0$. $a^m * a^n = a^0 * a^n = e * a^n = a^n = a^{0+n}$ \\ 118 | If $n=0, a^m * a^n = a^m * a^0 = a^m* e = a^m = a^{m+0}$ 119 | \item[qed] 120 | \end{description} 121 | \item[Theorem:] Let $A, *)$ be a monoid, $\forall a \in A \forall m, n \in \mathbb{N}, (a^m)^n = a^{mn}$ 122 | \begin{description} 123 | \item[Remark:] Once again, we had this result for semigroups when $m>0$ and $n > 0$ 124 | \item[Proof:] By the remark, we only need to prove the result when $m=0$ or $n=0$. If $m=0, (a^0)^n = (e)^n = e = a^0 = a^{0\times n}$. If $n=0$ then $(a^m)^0 = e = a^0 = a^{0 \times m}$ 125 | \end{description} 126 | \end{description} 127 | 128 | 129 | \end{document} -------------------------------------------------------------------------------- /sections/17-Inverses.tex: -------------------------------------------------------------------------------- 1 | \documentclass[../main.tex] 2 | 3 | \begin{document} 4 | \section{Inverses} 5 | \begin{description} 6 | \item[Task:] Understand what an inverse is and what formal properties it satisfies. 7 | \item[Definition:] Let $(A, *)$ be a monoid with identity element $e$ and let $a \in A$. An element $y$ of $A$ is called the \underline{inverse} of $x$ if $x*y = y*x = e$. If an element $a \in A$ has an inverse, then $a$ is called \underline{invertible}. 8 | \item[Examples:] 9 | \begin{enumerate} 10 | \item[] 11 | \item $(\mathbb{R}, +)$ has identity element 0. $\forall x \in \mathbb{R}, (-x)$ is the inverse of $x$ since $x+(-x)=(-x)=x = 0$. 12 | \item $(\mathbb{R}, \times)$ has identity element 1. $x \in \mathbb{R}$ is invertible only if $x \neq 0$. If $x \neq 0$, the inverse of $x$ is $\frac{1}{x}$ since $x \times \frac{1}{x} = \frac{1}{x} \times x =1$. 13 | \item $(Mn, *)$ the identity element is $In$. $A \in Mn$ is invertible if $det(A) \neq 0$. $A^{-1}$ the inverse is exactly the one you computed in linear algebra. If $det(a) = 0, A$ is \underline{NOT} invertible. 14 | \item Given a set $A, (P(A), \cup)$ has $\emptyset$ as its identity element of all the elements of $P(A)$ only $\emptyset$ is invertible and has itself asits inverse: $\emptyset \cup \emptyset= \emptyset \cup \emptyset = \emptyset$ 15 | \end{enumerate} 16 | \item[Theorem:] Let $(A, *)$ be a monoid. If $a \in A$ has an inverse, then that inverse is unique. 17 | \begin{description} 18 | \item[Proof:] By contradiction: Assume not, then $\exists a \in A$ s.t. both $b$ and $c$ in $A$ are its inverses, \textbf{i.e.} $a*b = b*a = e$, the identity element of $(A, *)$ and $a*c = c*a = e$ and $b \neq c$, then $b = b*e=b*(a*c)=(b*a)*c=e*c=c$. 19 | \item[qed] 20 | \end{description} 21 | \item Since every invertible element of $a$ for $(A, *)$ a monoid has a unique inverse, we can denote the inverse by the more standard notation $a^{-1}$. 22 | \item Next, we need to understand inverses of elements obtained via the binary operation: 23 | \item[Theorem:] Let $(A, *)$ be a monoid and let $a, b$ be invertible elements of $A$. $a*b$ is also invertible and $a*b^{-1} = b^{-1}*a^{-1}$. 24 | \begin{description} 25 | \item[Remark:] You might remember this formula from linear algebra when you looked at the inverse of a product of matrices $AB$. 26 | \item[Proof:] Let $e$ be the identity element of $(A, *) a*a^{-1} = a^{-1}*a = e$ and $b * b^{-1} = b^{-1}*b = e$. We would like to show $b^{-1} * a*{-1}$ is the inverse of $a*b$ by computing $(a*b)*(b^{-1} * a^{-1})$ and $(b^{-1} * a^{-1}) * (a*b)$ and showing both are $e$. 27 | \item $(a*b)*(a^{-1}*b^{-1}) = a*(b*b^{-1})*a^{-1} = a*e*a^{-1} = a*a^{-1} = e$ 28 | \item $(b^{-1}*a^{-1})*(a*b) = b^{-1}*(a^{-1}*a)*b = b^{-1}*e*b = (b^{-1}*e)*b = b^{-1}*b=e$ 29 | \item Thus $b^{-1}*a^{-1}$ satisfies the conditions needed for it to be the inverse of $a*b$.Since an inverse of unique, $a*b$ is invertible and $b^{-1}*a^{-1}$. 30 | \end{description} 31 | \item[Theorem:] Let $(A, *)$ be a monoid, and let $a, b \in A$. Let $x \in A$ be invertible. $a=b*x \Leftrightarrow b = a*x^{-1}$. Similarly, $a=x*b \Leftrightarrow b = x^{-1}*a$ 32 | \begin{description} 33 | \item[Proof:] Let $e$ be the identity element of $(A, *)$. 34 | \item First $a=b*x \Leftrightarrow b = a*x^{-1}$: 35 | \item $\Rightarrow$ Assume $a=b*x. a*x^{-1} = (b*x)*x^{-1} = b*{x*x^{-1}} = b*e = b$ as needed. 36 | \item $\Leftarrow$ Assume $b=a*x^{-1}$. Then $b*x=(a*x^{-1})=a*(x^{-1}*x)=a*e=1$ as needed. 37 | \item Apply the same type of argument to show $a=x*b \Leftrightarrow b=x^{-1}*a$. 38 | \item[qed] 39 | \end{description} 40 | \item Let $(A, *)$ be a monoid. We can now make sense of $a^n$ for $n \in \mathbb{Z}, n < -$ for every $n \in A$ invertible. Since $n$ is a negative integer, $\exists p \in \mathbb{N}$ s.t. $n=-1$. Set $a^n = a^{-p}=(a^p)^{-1}$. 41 | \item[Theorem:] Let $(A, *)$ be a monoid and let $a \in A$ be invertible. Then $a^n * a^m = a^{m+n} \hspace{10mm} \forall m, n \in \mathbb{Z}$. 42 | \begin{description} 43 | \item[Proof:] When $m \geq 0 \land n \geq n$ we have already proven this result. The rest of the proof splits into cases. 44 | \item[Case 1:] $m=n \lor n = 0$ 45 | \item If $m=0, n \in \mathbb{Z}, a^m * a^n = a^0 * a^n = e * a^n = a^n = a^{0+n}$ as needed. 46 | \item If $m \in \mathbb{Z}, n = 0, a^m * a^n = a^m * a^0 = a^m * e = a^m = a^{m+0}$ as needed. 47 | \item[Case 2:] $m < 0 \land n < 0$ 48 | \item $m < 0 \Rightarrow \exists p \in \mathbb{N} \: s.t. \: p = -m. \: n<0 \Rightarrow \exists q \in \mathbb{N} \: s.t. \: q = -n.$ 49 | \item $a^m = a^{-p} = (a^p)^{-1} \land a^n = a^{-q} = (a^q)^{-1}$ 50 | \item $a^m * a^n = (a^p)^{-1} * (a^q)^{-1} = (a^q * a^p)^{-1} = (a^{p+q})^{-1} = a^{-(p+q)} = a^{-q-p} = a^{m+n} = a^{n+m}$ 51 | \item[Case 3:] $m \land n$ have opposite signs.\\ 52 | Without loss of generality, assume $m<0 \land n>0$ (the case $m>0 \land n<0$ is handled by the same argument). Since $m<0, \exists p \in \mathbb{N} \: s.t. \: p = -m.$ This case splits into two subcases: 53 | \begin{description} 54 | \item[Case 3.1:] $m+n \geq 0$ 55 | \item Set $q = m+n$. Then $a^{m+n} = a^q = e*a^q = (a^p)^{-1} * a^p * a^q = (a^p)^{-1} * a^{p+q} = a^{-p} * a^{p+q} = a^m * a^{-m+m+n} = a^m * a^n$ 56 | \item[Case 3.2:] $m+n < 0$ 57 | \item Set $q = -(m+n) = -m-n \in \mathbb{N}^*$. Then $a^{m+n} = a^{-q} = (a^q)^{-1} * e = (a^q)^{-1} * (a^{-n} * a^n) = (a^q)^{-1} * (a^n)^{-1} *a^n = (a^n * a^q)^{-1} * a^n = (a^{n+p})^{-1} * a^n = (a^{n-m-n})^{-1} * a^n = (a^{-m})^{-1} * a^n = (a^p)^{-1} * a^n = a^m * a^n$ 58 | \end{description} 59 | \end{description} 60 | \item[Theorem:] Let $(A, *)$ be a monoid, and let $a$ be an invertible element of $A$. $\forall m, n \in \mathbb{Z}, (a^m)^n = a^{mn}$. 61 | \begin{description} 62 | \item[Proof:] We consider 3 cases: 63 | \item[Case 1:] $n > 0$, \textbf{i.e.} $n \in \mathbb{N}^*. \: m \in \mathbb{Z}$ with no additional restrictions we proceed by induction on $m$. 64 | \begin{description} 65 | \item[Base Case:] $n=1 \hspace{10mm} (a^m)^1 = a^m = a^{m \times 1}$ 66 | \item[Inductive Step:] We assume $(a^m)^n = a^{mn}$ and seek to prove $(a^m)^{n+1} = a^{m(n+1)}$. Start with $(a^m)^{n+1} = (a^m)^n * (a^m)^1 = a^{mn} * a^m = a^{mn+m} = a^{m(n+1)}$ 67 | \end{description} 68 | \item[Case 2:] $n=0$; no restriction on $m \in \mathbb{Z}$ 69 | \item $(a^m)^n = (a^m)^0 = e = a^0 = a^{m \times 0} = a^{mn}$ 70 | \item[Case 3:] $n < 0$; no restriction on $m \in \mathbb{Z}$. 71 | \item Since $n < 0, \exists p \in \mathbb{N} \: s.t. \: p = -n$. By case 1, $(a^m)^p = a^{mp}$ 72 | \item $(a^m)^n = (a^m)^{-p} = ((a^m)^p)^{-1} = (a^{mp})^{-1} = a^{-mp} = ^{m(-p)} = a^{mn}$ 73 | \end{description} 74 | \end{description} 75 | 76 | \subsection{Groups} 77 | A motion formally defined in the 1870's even though theorems about groups proven as early as a century before that. 78 | \begin{description} 79 | \item[Definition:] A group is a monoid in which every element is invertible. In other words, a group is a set $A$ endowed with a binary operation $*$ satisfying the following properties: 80 | \begin{enumerate} 81 | \item $*$ is associative, \textbf{i.e.} $\forall x, y, z \in A, (x*y)*z = x*(y*z)$ 82 | \item There exists an identity element $e \in A$, \textbf{i.e.} $\exists e \in A \: s.t. \: \forall a \in A, a*e = e*a = a$ 83 | \item Every element of $A$ in invertible, \textbf{i.e.} $\forall a \in A \exists a^{-1} \in A \: s.t. \: a * a^{-1} = a^{-1} * a = e$ 84 | \end{enumerate} 85 | \item[Notation for Groups:] $(A, *) \lor (\underset{set}{\underbrace{A}}, \underset{operation}{\underbrace{*}}, \underset{identity}{\underbrace{e}})$ 86 | \item[Remark:] Closure under the operation $*$ is \underline{implicit} in the definition \textbf{i.e.} $\forall a, b \in A, a * b \in A$ 87 | \item[Definition:] A group $(A, *, e)$ is called \underline{commutative} or \underline{Abelian} if its operation $*$ is commutative. 88 | \item[Examples:] 89 | \begin{enumerate} 90 | \item[] 91 | \item $(\mathbb{R}, +, 0)$ is an Abelian group. 92 | \item[] $-x$ is the inverse of $x, \forall x \in \mathbb{R}$ 93 | \item $(\mathbb{Q}^*, \times, 1) \hspace{10mm} \mathbb{Q}^* = \mathbb{Q}^*\backslash\{0\} \hspace{10mm} (\mathbb{Q}^*, \times, 1)$ is Abelian 94 | \item[] $\forall q \in \mathbb{Q}^*, q^{-1} = \frac{1}{q}$ is the inverse. 95 | \item $(\mathbb{R}^3, +, 0)$ vectors in $\mathbb{R}^3$ with vector addition forms an Abelian group. 96 | \item[] $(x, y, z)+(x', y', z') = (x+x', y+y', z+z')$ vector addition. 97 | \item[] $0 = (0, 0, 0)$ is the identity. \hspace{10mm} $(-x, -y, -z) = - (x, y, z)$ is the inverse of $(x, y, z)$. 98 | \item $($\~{M}$m, *, In)$ $n\times n$ invertible matrices with real coefficients under matrix multiplication with $In$ as the identity elements forms a group which is \underline{NOT} Abelian. 99 | \item Set $A = \mathbb{Z}$ and recall the equivalence relation $x \equiv y$ mod $3$ \textbf{i.e.} $x \land y$ have te same remainder under the division by $3$. Recall that $\mathbb{Z} / N = \{0, 1, 2\}$, \textbf{i.e.} the set of equivalence classes under the partition determined by this equivalence relation. We denote $\mathbb{Z} / N \ \{0, 1, 2\} = \mathbb{Z}_3$ 100 | \item[] Consider $(\mathbb{Z}_3, \oplus _3, 0)$ where $\oplus _3$ is the operation of addition modulo $3$, \textbf{i.e.} $1+0=1, 1+1=2, 1+2=3 \equiv 0$ mod $3$. 101 | \item[\textbf{Claim:}] $(\mathbb{Z}_3, \oplus _3, 0)$ is an Abelian group. 102 | \item[\textbf{Proof of Claim:}] Associativity of $\oplus _3$ follows from the associativity of $+$, addition of $\mathbb{Z}$. Clearly, $0$ is the identity (don't forget $0$ stands for all elements with remainder $0$ under division by $3$, \textbf{i.e.} $\{0, 3, -3, 6, -3, \dots\}$). To compute inverses recall that $a \oplus _3 a^{-1} = 0, 0$ is the inverse of $0$ because $0+0=0$. $2$ is he inverse of $1$ because $1+2=3 \equiv 0$ mod $3$, and $1$ is the inverse of $2$ because $2+1=3 \equiv 0$ mod $3$. \\ 103 | More generally, consider the equivalence relation on $\mathbb{Z}$ given by $x \equiv y$ mod $n$ for $n \geq 1. \mathbb{Z} / N = \{0, 1, \dots, n-1\} = \mathbb{Z}_n$. All possible remainders under division by $n$ are the equivalence classes. Let $\oplus _n$ be addition mod $n$. By the same argument as above, $(\mathbb{Z}_n, \oplus _n, 0)$ is an Abelian group. 104 | \item[\textbf{Q:}] What is we consider multiplication mod $n$, \textbf{i.e.} $\otimes _n$. Is $(\mathbb{Z}_n, \otimes _n, 1)$ a group? 105 | \item[\textbf{A:}] No! $(\mathbb{Z}_n, \otimes _n, 1)$ is not even a monoid because $1 \otimes _n 0 = 0 \otimes _n 1 = 0$, so $1$ is not an identity element for $\otimes _n$ on $\mathbb{Z}_n$. 106 | \item[\textbf{Q:}] Can this be fixed? 107 | \item[\textbf{A:}] Troubleshoot how to get rid of 0. \\ 108 | Consider $\mathbb{Z}_n^* = \mathbb{Z}_n \backslash \{0\} = \{1, 2, \dots, n-1\}$ all non-zero elements in $\mathbb{Z}_n^*$. This eliminates 0 as an element, but can 0 arise any other way from the binary operation? It turns out the answer depends on $n$. If $n$ is not prime, say $n=6$, we get two divisors, \textbf{i.e.} elements that yield 0 when multiplied by \underline{precisely} the factors of $n$, for $n=6$, $\mathbb{Z}^*_6 = \{1, 2, 3, 4, 5\}$ \underline{but} $2 \otimes _6 3 = 6 \equiv 0$ mod $6$, so $2 \land 3$ are two divisors. 109 | \item[\textbf{Claim:}] If $n$ is prime, then $(\mathbb{Z}_n^*, \otimes _n, 1)$ is an Abelian group. \\ 110 | Used in cryptology $\rightarrow$ you will see next semester. \\ 111 | As an example, let us look at the multiplication table for $\mathbb{Z}_5^*$ to see the inverse of various elements: $\mathbb{Z}^*_5 = \mathbb{Z}_5 \backslash \{0\} = \{0, 1, 2, 3, 4,\} \backslash \{0\} - \{1, 2, 3, 4\}$ 112 | 113 | \begin{center} 114 | \begin{tabular}[h!]{|c|cccc|rl} 115 | \cline{1-5} 116 | & 1 & 2 & 3 & 4\\ \cline{1-5} 117 | 1 & 1 & 2 & 3 & 4 & \hspace{10mm} $1^{-1} = 1$ & $1 \otimes_5 1 = 1$ \\ 118 | 2 & 2 & 4 & 1 & 2 & \hspace{10mm} $2^{-1} = 3$ & $2 \otimes_5 3 = 6 \equiv 1$ mod $5$ \\ 119 | 3 & 3 & 1 & 4 & 2 & \hspace{10mm} $3^{-1} = 2$ & $3 \otimes_5 2 = 6 \equiv 1$ mod $5$ \\ 120 | 4 & 4 & 3 & 2 & 1 & \hspace{10mm} $4^{-1} = 1$ & $4 \otimes_5 4 = 16 \equiv 1$ mod $5$ \\ 121 | \cline{1-5} 122 | \end{tabular} 123 | \end{center} 124 | The fact that $\mathbb{Z}^*_n, \otimes _n, 1$ is Abelian follows from the commutativity of multiplication on $\mathbb{Z}$. 125 | \item Let $(A, *, e)$ be any group and let $a \in A$. \\ 126 | Consider $A' = \{a^m \mid m \in \mathbb{Z}\}$ all powers of $a$. It turns out $(A', *, e)$ is a group called the \underline{cyclic group} determined by $a$. $(A', *, e)$ is Abelian \underline{regardless} of whether the original group was Abelian or not because of the theorem we proved on powers of $a$: $\forall m, n \in \mathbb{Z} \hspace{10mm} a^m * a^n = a^{m+n} = a^{n+m} = a^n * a^m$. \\ 127 | Cyclic groups come in two flavours: finite ($A'$ is a finite set) and infinite ($A'$ is an infinite set). \\ 128 | For example, let $(A, *, e) = (\mathbb{Q}^*, , \times , 1)$ \\ 129 | If $a=-1 \hspace{10mm} A' = \{(-1)^m \mid m \in \mathbb{Z}\} = \{-1, 1\}$ is finite. \\ 130 | If $a=2 \hspace{10mm} A' = \{2^m \mid m \in \mathbb{Z}\} = \{1, 2, \frac{1}{2}, 4, \frac{1}{4}, \dots\}$ is infinite. 131 | \end{enumerate} 132 | \end{description} 133 | 134 | 135 | \end{document} -------------------------------------------------------------------------------- /sections/18-HomomorphismsAndIsomorphisms.tex: -------------------------------------------------------------------------------- 1 | \documentclass[../main.tex] 2 | 3 | \begin{document} 4 | \section{Homomorphisms and Isomorphisms} 5 | \begin{description} 6 | \item[Task:] Understand the most natural functions between objects in abstract algebra such as semigroups, monoids or groups. 7 | \item[Definition:] Let $(A, *)$ and $(B, *)$ ve vitg semigroups, monoids or groups. A function $f: A \rightarrow B$ is called a \underline{homomorphism} if $f(x * y) = f(x) * f(y) \: \forall x, y \in A$. In other words, if $f$ is a function that respects (behaves well with respect) to the binary operation. 8 | \item[Examples:] 9 | \begin{enumerate} 10 | \item[] 11 | \item Consider $(\mathbb{Z}, +, 0)$ and $(\mathbb{R}^*, \times, 1)$. \\ 12 | Pick $a \in \mathbb{R}^*$, then $f(n) = a^n$ is a homomorphism between $(\mathbb{Z}, +, 0)$ and $(\mathbb{R}^*, \times, 1)$ because $(\mathbb{R}^*, \times, 1)$ is a group, and we proved for groups that $a^{m+n} = f(m+n) = a^m * a^n = f(m) * f(n) \hspace{10mm} \forall m, n \in \mathbb{Z}$. 13 | \item More generally, $\forall a \in A$ invertible, where $(A, *)$ is a monoid with identity element $e$, $f(n) = a^m$ gives a homomorphism between $(\mathbb{Z}, +, 0)$ and $(A', *, e)*$, where as before $A' = \{a^m \mid m \in \mathbb{Z}\} \subset A$. \\ 14 | We get even better behaviour if we require $f:A \rightarrow B$ to be bijective. 15 | \end{enumerate} 16 | \item[Definition:] Let $(A, *)$ and $(B, *)$ both be semigroups, monoids or groups. A function $f:A \rightarrow B$ is called an isomorphism if $f:A \rightarrow B$ is both bijective \underline{AND} a homomorphism. 17 | \item[Examples:] 18 | \begin{enumerate} 19 | \item[] 20 | \item Let $A' = \{2^m \mid m \in \mathbb{Z}\} = \{1, 2, \frac{1}{2}, 4, \frac{1}{4}, \dots\}$ \\ 21 | $f(m) = 2^m$ from $(\mathbb{Z}, +, 0)$ to $(A', \times, 1)$ is an isomorphism since $2^m \neq 2^n$ if $m \neq n$. 22 | \item Let $A' = \{(-1)^m \mid m \in \mathbb{Z} \} = \{-1, 1\}$ \\ 23 | $f(m) = (-1)^m$ from $(\mathbb{Z}, +, 0)$ to $(A', \times, 1)$ is \underline{NOT} an isomorphism since it's not injective $(-1)^2 = (-1)^4 = 1$. 24 | \end{enumerate} 25 | \item[Theorem:] Let $(A, *)$ and $(B, *)$ both be semigroups, monoids or groups. The inverse $f^{-1}: B \rightarrow A$ of any isomorphism $f: A \rightarrow B$ from $A$ to $B$ is itself an isomorphism. 26 | \item[Proof:] If $f: A \rightarrow B$ is an isomorphism $\Rightarrow f:A \rightarrow B$ is bijective $\Rightarrow f^{-1}:B \rightarrow A$ is bijective (proven when we discussed functions). 27 | \item To show $f^{-1} B \rightarrow A$ is a homomorphism, let $u, v \in B$. $\exists x, y \in A$ s.t. $x = f^{-1}(u)$ and $y = f^{-1}(v)$, but then $u = f(x)$ and $v = f(y)$. 28 | \item Since $f: A \rightarrow B$ is a homomorphism, $f(x * y) = f(x) * f(y) = u*v$. Then $f^{-1}(u*v) = f^{-1}(f(x*y)) = x*y = f^{-1}(u)*f^{-1}(v)$ as needed. 29 | \item[qed] 30 | \item[Definition:] Let $(A, *)$ and $(B, *)$ both be semigroups, monoids or groups. If $\exists f:A \rightarrow B$ an isomorphism betwen $A$ and $B$, then $(A, *)$ and $(B, *)$ are said to be isomorphic. 31 | \item[Remark:] "Ismorphic" comes from "iso" same + "morph\'{e}" form same abstract algebra structure on both $(A, *)$ and $(B, *)$ given to you in two different guises. As the French would say: "M\^{e}me Marie, autre chapeau" same Mary, different hat. 32 | \end{description} 33 | 34 | 35 | \end{document} -------------------------------------------------------------------------------- /sections/19-FormalLanguages.tex: -------------------------------------------------------------------------------- 1 | \documentclass[../main.tex] 2 | 3 | \begin{document} 4 | \section{Formal Languages} 5 | \begin{description} 6 | \item[Task:] Use what we learned about structures in abstract algebra in order to make sense of formal languages and grammars. \\ 7 | Let $A$ be a finite set. When studying formal languages, we call $A$ an \underline{alphabet} and the elements of $A$ \underline{letters}. 8 | \item[Examples:] 9 | \begin{enumerate} 10 | \item[] 11 | \item $A = \{0, 1\}$ \hspace{10mm} binary digits 12 | \item $A = \{0, 1, 2, 3, 4, 5, 6, 7, 8, 9\}$ \hspace{10mm} decimal digits 13 | \item $A =$ {letters of the English alphabet} 14 | \end{enumerate} 15 | \item[Definition:] $\forall n \in \mathbb{N}^*$, we define a \underline{word} of length $n$ in the alphabet $A$ as being any string of the form $a_1, a_2, \dots, a_n \: s.t. \: a_i \in A \hspace{5mm} \forall i, 1 \leq i \leq n$. Let $A^n$ be the set of all words of length $n$ over the alphabet $A$. 16 | \item[Remark:] There is a one-to-one correspondence between the string $a_1a_2\dots a_n$ and the ordered n-tuple $(a_1, a_2, \dots, a_n) \in A^n = \underset{n \: times}{\underbrace{A \times \dots \times A}}$ the Cartesian product of $n$ copies of $A$. 17 | \item[Definition:] Let $A^+ = \underset{n=1}{\overset{\infty}{\cup}} A^n = A^1 \cup A^2 \cup A^3 \cup \dots$. $A^+$ is the set of all words of positive length over the alphabet $A$. 18 | \item[Examples:] 19 | \begin{enumerate} 20 | \item[] 21 | \item $A = \{0, 1\}, A^+$ is the set of all binary strings of finite length that is at least on, \textbf{i.e.} $0, 1, 01, 10, 00, 11,$ etc. 22 | \item If $A =$ {letters of the English alphabet}, then $A^+$ consists of all non-empty strings of finite lengths of letters from the English alphabet. \\ 23 | It is useful to also have the empty for $\varepsilon$ in our set of strings. $\varepsilon$ has length 0. Define $A^0 = \{\varepsilon\}$ and then adjoin the empty word $\varepsilon$ to $A^+$. We get $A^* = \{\varepsilon\} \cup A^+ = A^0 \cup \underset{n=1}{\overset{\infty}{\cup}} A^n = \underset{n=0}{\overset{\infty}{\cup}} A^n$. 24 | \end{enumerate} 25 | \item[Notation:] We denote the length of a word $w$ by $\mid w\mid$. Next introduce an operation on $A^*$. 26 | \item[Definition:] Let $A$ be a finite set and let $w_1 \land w_2$ be words in $A^*$. $w_1 = a_1a_2\dots a_m \land w_2 = b_1b_2\dots b_n$. The \underline{concatenation} of $w_1 \land w_2$ is the word $w_1 \circ w_2$, where $w_1 \circ w_2 = a_1a_2\dots a_mb_1b_2\dots b_n$. Sometimes $w_1 \circ w_2$ is denoted as just $w_1w_2$. Note that $\mid w_1 \circ w_2 \mid = \mid w_1 \mid + \mid w_2 \mid$. \\ 27 | Concatenation of words is: 28 | \begin{enumerate} 29 | \item associative 30 | \item \underline{NOT} commutative is $A$ has more than one element. 31 | \end{enumerate} 32 | \begin{description} 33 | \item[Proof of (1):] Let $w_1, w_2, w_3 \in A^*. w_1 = a_1a_2\dots a_m$ for some $m \in \mathbb{N}, w_2=b_1b_2\dots b_n$ for some $m \in \mathbb{N}$ and $w_3 = c_1c_2\dots c_p$ for some $p \in \mathbb{N}$. $w_1 \circ w_2) \circ w_3 = w_1 \circ (w_2 \circ w_3) = a_1a_2\dots a_mb_1b_2\dots b_nc_1c_2\dots c_p$. 34 | \item[qed] 35 | \item[Proof of (2):] Since $A$ has at least two elements, $\exists a, b \in A$ s.t. $a \neq b$. 36 | \item $a \circ b = ab \neq ba = b \circ a$. 37 | \item[qed] 38 | \end{description} 39 | \item $A^*$ is closed under the operation of concatenation $\Rightarrow$ concatenation is a binary operation of $A^*$ as $\forall w_1, w_2 \in A^*, w_1 \circ w_2 \in A^*$. 40 | \item[Theorem] Let $A$ be a finite set. $(A^*, \circ)$ is a monoid with identity element $\varepsilon$. 41 | \item[Proof:] Concatenation $\circ$ is an associative binary operation on $A^*$ as we showed above. Moreover, $\forall w \in A^*, \varepsilon \circ w = w \circ \varepsilon = w$, so $\varepsilon$ is the identity element of $A^*$. 42 | \item[qed] 43 | \item[Definition:] Let $A$ be a finite set. A \underline{language} over $A$ is a subset of $A^*$. A language $L$ over $A$ is called a \underline{formal language} if $\exists$ a finite set of rules of algorithm that generates exactly $L$, \textbf{i.e.} all words that belong to $L$ and no other words. 44 | \item[Theorem:] Let $A$ be a finite set. 45 | \begin{enumerate} 46 | \item If $L_1$ and $L_2$ are languages over $A, L_1 \cup L_2$ is a language over $A$. 47 | \item If $L_1$ and $L_2$ are languages over $A, L_1 \cap L_2$ is a language over $A$. 48 | \item If $L_1$ and $L_2$ are languages over $A$, the concatenation of $L_1 \land L_2$ given by $L_1 \circ L_2 = \{w_1 \circ w_2 \in A^* \mid w_1 \in L_1 \land w_2 \in L_2\}$ is a language over $A$. 49 | \item Let $L$ be a language over $A$. Define $L^1=L$ inductively for and $n\geq 1 \hspace{5mm} L^n = L \circ L^{n-1}$. $L^n$ is a language over $A$. Furthermore, $L^* = \{\varepsilon\} \cup L^1 \cup L^2 \cup L^3 \cup \dots = \underset{n=0}{\overset{\infty}{\cup}} L^n$ is a language over $A$. 50 | \end{enumerate} 51 | \item[Proof:] By definition, a language over $A$ is a subset of $A^*$. Therefore, if $L_1 \subseteq A^* \land L_2 \subseteq A^*$, then $L_1 \cup L_2 \subseteq A^* \land L_1 \cap L_2 \subseteq A^*$. $\forall w_1 \circ w_2 \in L_1 \circ L_2, w_1 \circ w_2 \in A^*$ becomes $w_1 \in A^n$ for some $n$ and $w_2 \in A^m$ for some $m$ so $w_1 \circ w_2 \in A^{m+n} \subseteq A^* = \underset{n=1}{\overset{\infty}{\cup}} A^n$. 52 | \item Applying the same reasoning inductively, we see that $L \subset A^* \Rightarrow L^* \subseteq A^*$ as $L^m \subseteq A^* \: \forall n \geq 0$. 53 | \item[qed] 54 | \item[Remark:] This theorem gives us a theoretic way of building languages, but we need a practical way. The practical way of building a language is through the notion of a grammar. 55 | \item[Definition:] A (formal) grammar is a set of production rules for strings in a language. \\ 56 | To generate a language we use: 57 | \begin{enumerate} 58 | \item $A$ the set, which is the alphabet of the language. 59 | \item A start symbol $\langle s\rangle $ 60 | \item A set of production rules. 61 | \end{enumerate} 62 | \item[Example:] $A = \{0, 1\}$; start symbol $\langle s\rangle $; 2 production rules given by: 63 | \begin{enumerate} 64 | \item $\langle s\rangle $ $\rightarrow$ 0$\langle s\rangle $1 65 | \item $\langle s\rangle $ $\rightarrow$ 01 66 | \end{enumerate} 67 | Let's see what we generate: via rule 2 \hspace{5mm} $\langle s\rangle $ $\rightarrow$ 01, so we get $\langle s\rangle $ $\Rightarrow$ 01 \\ 68 | Via rule 1 \hspace{5mm} $\langle s\rangle $ $\rightarrow$ 0$\langle s\rangle $1, then via rule 2, 0$\langle s\rangle $1 $\rightarrow$ 0011. We write the process as $\langle s\rangle $ $\rightarrow$ 0$\langle s\rangle $1 $\Rightarrow$ 0011. \\ 69 | Via rule 1, $\langle s\rangle $ $\rightarrow$ 0$\langle s\rangle $1, then via rule 1 again 0$\langle s\rangle $1 $\rightarrow$ 00$\langle s\rangle $11, then via rule 2, 00$\langle s\rangle $11 $\rightarrow$ 000111. \\ 70 | We got $\langle s\rangle $ $\Rightarrow$ 0$\langle s\rangle $1 $\Rightarrow$ 00$\langle s\rangle $11 $\Rightarrow$ 000111. \\ 71 | The language $L$ we generated thus consists of all strings of the form $0^m1^m$ ($m$ 0's followed by $m$ 1's) for all $m \geq 1, m \in \mathbb{N}$ \\ 72 | We saw 2 types of strings that appeared in this process of generating $L$: 73 | \begin{enumerate} 74 | \item \underline{terminals}, \textbf{i.e.} the elements of $A$ 75 | \item \underline{nonterminals}, \textbf{i.e.} strings that don't consist solely of 0's and 1's such as $\langle s\rangle $, 0$\langle s\rangle $1, 00$\langle s\rangle $11, etc. 76 | \end{enumerate} 77 | The production rules then have the form: 78 | \begin{description} 79 | \item nonterminal $\rightarrow$ word over the alphabet V = {terminals, non-terminals} 80 | \item $\langle T\rangle $ $\rightarrow$ w 81 | \end{description} 82 | In our notation, the set of nonterminals if $V \backslash A$, so $\langle T\rangle \in V \backslash A \land w \in V^* = \underset{n=0}{\overset{\infty}{\cup}} V^n$. To the production rule $\langle T\rangle \rightarrow w$. \\ 83 | We can associate the ordered pair ($\langle T\rangle , w) \in (V \backslash A) \times V^*$, so the set of production rules, which we will denote by $P$, is a subset of the Cartesian product $(V\backslash A) \times V^*$. \\ 84 | Grammers come in two flavours: 85 | \begin{enumerate} 86 | \item \underline{Context-free grammars} where we can replace \underline{any} occurrence of $\langle T\rangle $ by $w$ if $\langle T\rangle \rightarrow w$ is one of our production rules. 87 | \item \underline{Context-sensitive grammars} only certain replacements of $\langle T\rangle $ by $w$ are allowed, which are governed by the syntax of our language $L$. 88 | \end{enumerate} 89 | The example we have was of a context free grammar. We can now finally define context free grammars. 90 | \item[Definition:] A \underline{context free grammar} $(V, A, \langle s\rangle, P)$ consists of a finite set $V$, a subset $A$ of $V$, an element $\langle s \rangle$ of $V \backslash A$, and a finite subset $P$ of the Cartesian product $V\backslash A \times V^*$. 91 | \item[Notation:] $(\underset{set\:of\:terminals\:and\:non\:terminals}{V}$, $\underset{set\:of\:terminals}{A}$, $\underset{start\:symbol}{\langle s\rangle }$, $\underset{set\:of\:production\:rules}{P})$ 92 | \item[Example:] $A = \{0, 1\}$; start symbol $\langle s\rangle $; 3 production rules given by: 93 | \begin{enumerate} 94 | \item $\langle s\rangle \rightarrow 0 \langle s \rangle 1$ 95 | \item $\langle s\rangle \rightarrow 01 $ 96 | \item $\langle s\rangle \rightarrow 0011$ 97 | \end{enumerate} 98 | We notice here that the word 0011 can be generated in 2 ways in this context free grammar: 99 | \begin{enumerate} 100 | \item[By rule 3,] $\langle s\rangle \rightarrow$ 0011 so $\langle s\rangle \Rightarrow$ 0011 101 | \item[] $\lor$ 102 | \item[By rule 1,] $\langle s\rangle \rightarrow$ 0$\langle s\rangle $1 and by rule 2, 0$\langle s\rangle $1 $\rightarrow$ 0011. Therefore, $\langle s\rangle \Rightarrow$ 0$\langle s\rangle 1 \Rightarrow 0011$. 103 | \end{enumerate} 104 | \item[Definition:] A grammar is called \underline{ambiguous} if it generates the same string in more than one way. \\ 105 | Obviously, we prefer to have unambiguous grammars, else we waste computer operations. \\ 106 | Next, we need to spell out how words \underline{relate} to each other in the production of our language via the grammar: 107 | \item[Definition:] Let $w'$ and $w''$ be words over the alphabet $V$ = {terminals, non-terminals}. We say that \underline{$w'$ directly yields $w''$} if $\exists$ words $u \land v$ over the alphabet $V$ and a production rule $\langle T\rangle \rightarrow w$ of the grammar s.t. $w' = u\langle T\rangle \land w'' = uwv$, where either or both of the words $u$ and $v$ may be the empty word. \\ 108 | In other words, $w'$ directly yields $w'' \Leftrightarrow \exists$ production rule $\langle T\rangle \rightarrow w$ in the grammar s.t. $w''$ may be obtained from $w'$ by replacing a simple occurrence of the nonterminal $\langle T\rangle $ within the word $w'$ by the word $w$. 109 | \item[Notation:] $w'$ directly yields $w''$ is denoted by $w' \Rightarrow w''$ 110 | \item[Definition:] Let $w' \land w''$ be words over the alphabet $V$. We say that $w'$ yields $w''$ if either $w'= w''$ or else $\exists$ words $w_0, w_1, \dots w_n$ over the alphabet $V$ s.t. $w_0=w', w_n = w'', w_{i-1} \Rightarrow w_i$ for all $i, 1 \leq i \leq n$. In other words, $w_0 \Rightarrow w_1 \Rightarrow w_2 \Rightarrow \dots \Rightarrow w_n-1 \Rightarrow w_n$ 111 | \item[Notation:] $w'$ yields $w''$ is denotes by $w' \overset{*}{\Rightarrow} w''$. 112 | \item[Definition:] Let $(V, A, \langle s\rangle , P)$ be a context free grammar. The \underline{language} generated by this grammar is the subset $L$ or $A^*$ defined by $L = \{w \in A^* \mid \langle s\rangle \overset{*}{\Rightarrow} w\}$ \\ 113 | In other words, th language $L$ generated by a context free grammar $(V, A, \langle s\rangle , P)$ consists of the set of all finite strings consisting entirely of terminals that may be obtained from the start symbol $\langle s\rangle $ by applying a finite sequence of production rules of the grammar where the application of one production rule causes \underline{one and only one nonterminal} to be replaced by the string in $V^*$ corresponding of the right hand side of the production rule. 114 | \end{description} 115 | 116 | \subsection{Phrase Structure Grammars} 117 | \begin{description} 118 | \item[Definition:] A phrase structure grammar $(V, A, \langle s\rangle , P)$ consists of a finite set $V$, a subset $A$ of $V$, an element $\langle s\rangle $ of $V \backslash A$, and a finite subset $P$ of $(V^* \backslash A^*) \times V^*$ \\ 119 | In a context free grammar, the set of production rules $P \subset (V \backslash A) \times V^*$. \\ 120 | In a phrase structure grammar, $P \subset (V^* \backslash A^*) \times V^*$. In other words, a production rule in a phrase structure grammar $r \rightarrow w$ has a left hand side $n$ that may contain more than one nonterminal. It is required to contain \underline{at least one} nonterminal. \\ 121 | For example, if $A = \{0, 1\}$ and $\langle s\rangle $ is the start symbol in a phrase grammar grammar, 0$\langle s\rangle $0$\langle s\rangle $0 $\rightarrow$ 00010 would be an acceptable production rule in a phrase structure grammar but not in a context free grammar. \\ 122 | The notions $w' \Rightarrow w''$ ($w'$ directly yields $w''$) and $w' \overset{*}{\Rightarrow} w''$ ($w'$ yields $w''$) are defined the same way as for context free grammars except that our production rules may, of course, be more general as we saw in the example above. 123 | \item[Definition:] Let $(V, A, \langle s\rangle , P)$ be a phrase structure grammar. The language generated by this grammar is the subset $L$ or $A^*$ defined by $L \{w \in A^* \mid \langle s \rangle \overset{*}{\Rightarrow} w \}$ 124 | \item[Remark:] The term phrase structure grammars was introduced by Noam Chomsky. 125 | \item[Definition:] A language $L$ generated by a context-free grammar is called a \underline{context-free language}. 126 | \end{description} 127 | We now want to understand a particularly important subclass of context free languages called regular languages. 128 | 129 | 130 | \end{document} -------------------------------------------------------------------------------- /sections/20-RegularLanguages.tex: -------------------------------------------------------------------------------- 1 | \documentclass[../main.tex] 2 | 3 | \begin{document} 4 | \section{Regular Languages} 5 | \begin{description} 6 | \item[Task:] Understand when a language is regular and how regular languages are produced. Understand basics of automata theory. 7 | \item[History:] The term \underline{regular languages} was introduced by Stephen Kleene in 1951. A more descriptive name is \underline{finite-state languages} as we will see that a language is regular $\Leftrightarrow$ it can be recognised by a finite state acceptor, which is a type of finite state machine. \\ 8 | The definition of a regular language is very abstract, though. First, describe what operations the collection of regular languages is closed under: \\ 9 | Let $A$ be a finite set, and let $A^*$ be the set of all words over the alphabet $A$. The regular language over the alphabet $A$ constitutes the smallest collection $C$ of subsets of $A^*$ satisfying that: 10 | \begin{enumerate} 11 | \item All finite subsets of $A^*$ belong to $C$. 12 | \item $C$ is closed under the Kleene star operation (if $M \subseteq A^*$ is inside $C$, \textbf{i.e.} $M \subseteq C$, then $M^* \subseteq C$) 13 | \item $C$ is closed under concatenation (if $M \subseteq A^*, N \subseteq A^*$ satisfy that $M \subseteq C \land N \subseteq C$, then $M \circ N \subseteq C$) 14 | \item $C$ is closed under union (if $M \subseteq A^* \land N \subseteq A^*$ satisfy that $M \subseteq C \land N \subseteq C$, then $M \cup N \subseteq C$) 15 | \end{enumerate} 16 | \item[Definition:] Let $A$ be a finite set, and let $A^*$ be the set of words over the alphabet $A$. A subset $L$ of $A^*$ is called a \underline{regular language} over the alphabet $A$ if $L = L_m$ for some finite sequence $L_1, L_2,\dots, L_m$ of subsets of $A^*$ with the property that $\forall i, 1 \leq i \leq m, L_i$ satisfies one of the following: 17 | \begin{enumerate} 18 | \item $L_i$ is a finite set 19 | \item $L_i = L_j^*$ for some $j, 1 \leq j \leq i$ (the Kleene star operation applied to one of the previous $L_j's$) 20 | \item $L_i = L_j \circ L_k$ for some $j, k$ such that $1 \leq j, k < i$ ($L_i$ is a concatenation of previous $L_j$'s) 21 | \item $L_i = L_j \cup L_k$ for some $j, k$ such that $1 \leq k, j < i$ ($L_i$ is a union of previous $L_j$'s) 22 | \end{enumerate} 23 | \item[Example 1:] Let $A = \{0, 1\}$. Let $L = \{0^m 1^n \mid m, n \in \mathbb{N} \hspace{5mm} m \geq 0, n \geq 0 \}$ \\ 24 | $L$ is a regular language. Note that $L$ consists of all strings of first 0's, then 1's or the empty string $\varepsilon$. $0^m1^n$ stands for $m$ 0's followed by $n$ 1's, \textbf{i.e.} $0^m \circ 1^n$. Let us examine $L' = \{0^m \mid m \in \mathbb{N}, m \geq 0 \}$ and $L'' = \{1^n \mid n \in \mathbb{N}, n \geq 0 \}$ 25 | \item[Q:] Can we obtain them via operatons listed among 1 -- 4? 26 | \item[A:] Yes! Let $M = \{ 0 \} \hspace{10mm} M \subseteq A \subseteq A^*$ and $M^* = L^1 = \{0^m \mid m \in \mathbb{N} \hspace{5mm} m \geq 0 \}$. Let $N = \{1\} \hspace{5mm} N \subseteq A \subseteq A^*$ and $N^* = L'' = \{1^n \mid n \in \mathbb{N}, n \geq 0 \}$. In other words, we can do $L_1 = \{0\}$, $L_2 = \{1\}$, $L_3 = L_1^*$, $l_4 = L_2^*$, $L_5 = L_4 \circ L_5 = L$. Therefore, $L$ is a regular language. 27 | \item[Example 2] Let $A = \{0, 1\}$. Let $L = \{0^m1^m \mid m \in \mathbb{N}, m \geq 1 \}$. $L$ is the language we used as an example earlier. It turns out $L$ is \underline{NOT} regular. This language consists of strings of 0's followed by an equal number of strings of 1's. For a machine to decide that the string $0^m1^m$ is inside the language is must store the number of 1's, as it examines the number of 0's or vice versa. The number of strings of the type $0^m1^m$ is not finite, however, so a finite-state machine cannot recognise this language. Heuristically, regular languages correspond to problems that can be solved with finite memory, \textbf{i.e.} we only need to remember one of finitely many things. By contrast, nonregular languages correspond to problems that cannot be solved with finite memory. 28 | \item[Theorem:] The collection of regular languages $C$ is also closed under the following two operations: 29 | \begin{enumerate} 30 | \item Intersection, \textbf{i.e.} if $L', L''$ are regular languages (\textbf{i.e.} $L' \cup L'' \in C$) then their intersection $L' \cap L''$ is a regular language. 31 | \item Complement, \textbf{i.e.} if $L$ is a regular language (\textbf{i.e.} $L \in C$), then $A* \backslash L$ is a regular language ($A^* \backslash L \in C$). 32 | \end{enumerate} 33 | \item[Remark:] These two properties did not come into the definition of a regular language, but they are true and often quite useful. 34 | \end{description} 35 | 36 | \subsection{Finite State Acceptors and Automata Theory} 37 | \begin{description} 38 | \item[Definition:] An \underline{automation} is a mathematical model of a computing device. \\ 39 | Plural of automation is \underline{automata}. 40 | \item[Basic idea:] Reason about computability without having to worry about the complexity of actual implementation. \\ 41 | It is most reasonable to consider at the beginning just finite states automata, \textbf{i.e.} machines with a finite number of internal states. The data entered discretely, and each datum causes the machine to either remain in the same internal state or else make the transition to some other state determined solely by 2 pieces of information: 42 | \begin{enumerate} 43 | \item The current state 44 | \item The input datum 45 | \end{enumerate} 46 | In other words, if $S$ is the finite set of all possible states of our finite state machine, then the \underline{transition mapping} $t$ that tells us how the internal state of the machine changes on inputting a datum will depend on the current state $s \in S$ and the imput datum $a$, \textbf{i.e.} the machine will enter a (potentially) new state $s' = t(s, a)$. 47 | \item[Want] to use finite state machines to recognise languages over some alphabet $A$. Let $L$ be our language.\\ 48 | \begin{table}[h!] 49 | \centering 50 | \begin{tabular}{cc} 51 | \underline{Input} & \underline{Output} \\ 52 | Word $w=a_1\dots a_n, a_i \in A \forall i$ & Yes if $w \in L$ \\ 53 | & No if $w \notin L$ 54 | \end{tabular} 55 | \end{table} 56 | Since our finite state machine accepts (\textbf{i.e.} returns \underline{yes} to) $w$ if $w \in L$, we call our machine a \underline{finite state acceptor}. We want to give a rigorous definition of a finite state acceptor. To check $w=a_1 \dots a_n$, we input each $a_i$ starting with $a_1$ and trace how the internal state of the machine changes. $S$ is our set of states of the machine (a finite set). The transition mapping $t$ takes the pair($s, a$) and returns the new state $s'=t(s, a)$ (where $s \in S \land a \in A$) that the machine has reached so $t: S \times A \rightarrow S$. \\ 57 | Some elements and subets of $S$ are important to understand: 58 | \begin{enumerate} 59 | \item The initial state $i \in S$ where the machine starts 60 | \item The subset $F \subseteq S$ of finishing states 61 | \end{enumerate} 62 | It turns out that knowing $S, F, i, t, A$ satisfies a finite state acceptor completely. 63 | \item[Definition:] A finite state acceptor $(S, A, i, t, F)$ consists of a finite set $S$ of states, a finite set $A$ that is the input alphabet, a starting state $i \in S$, a transition mapping $t: S \times A \rightarrow S$, and a set $F$ of finishing states, where $F \subseteq S$. 64 | \item[Definition:] Let $(S, A, i, t, F)$ be a finite state acceptor, and let $A^*$ denote the set of words over the input alphabet $A$. A word $a_1, a_2\dots a_n$ of length $n$ over the alphabet $A$ is said to be \underline{recognised} or \underline{accepted} by the finite state acceptor if $\exists s_0, s_1, \dots, s_n \in S$ states s.t. $s_0 = i$ (the initial state), $s_n \in F$, and $s_i = t(s_{i-1}, a_i) \forall i \hspace{5mm} 1 \leq i \leq n$. 65 | \item[Definition:] Let $(S, A, i, t, F)$ be a finite state acceptor. A language $L$ over the alphabet $A$ is said to be \underline{recognised} or \underline{accepted} by the finite state acceptor. \\ 66 | In the definition of a finite state acceptor, $t$ is the transition mapping, which may or may not be a function (hence the careful terminology). This is because finite state acceptors come in 2 flavours: 67 | \begin{enumerate} 68 | \item \underline{Deterministic:} every state has exactly one transition for each possible input, \textbf{i.e.} $\forall (s, a) \in S \times A$ $\exists!$ $t(s, a) \in S$. In other words, the transition mapping is a function. 69 | \item \underline{Non-deterministic:} an input can lead to one, more than one or no transition for a given state. Some $(s, a) \in S \times A$ might be assigned to more than one element of $S$, \textbf{i.e.} the transition mapping is not a function. 70 | \end{enumerate} 71 | \item[Surprisingly] $\exists$ algorithm that transforms a non deterministic (thought more complex one) using the powerset construction. \\ 72 | As a result, we have the following theorem: 73 | \item[Theorem:] A language $L$ over som alphabet $A$ is a regular language $\Leftrightarrow L$ is recognised by a deterministic finite state acceptor with input alphabet $A \Leftrightarrow L$ is recognised by a nondeterministic finite state acceptor with input alphabet $A$. 74 | \item[Example:] Build a deterministic finite state acceptor for the regular language $L = \{0^m1^n \mid m, n \in \mathbb{N}, m \geq 0, n \geq 0 \}$ \\ 75 | \begin{figure}[h!] 76 | \centering 77 | \begin{tikzpicture} 78 | % Top arrows 79 | \draw[-latex] (-2, 0)--node[above]{start} (-1, 0); 80 | \draw[-latex] (0, 0)--node[above]{0} (1, 0); 81 | % Bottom arrow 82 | \draw[latex-] (0, -2)--node[above]{0} (1, -2); 83 | % Middle arrows 84 | \draw[-latex] (-0.2, -0.375)--node[above]{1} (1.2, -1.6); 85 | \draw[-latex] (1.5, -0.5)--node[right]{1} (1.5, -1.5); 86 | 87 | % Circles 88 | % Top Left 89 | \draw (-0.5, 0) circle [radius=0.5]; 90 | \draw (-0.5, 0) circle [radius=0.3] node{$i$}; 91 | 92 | % Top right 93 | \draw (1.5, 0) circle [radius=0.5]; 94 | \draw (1.5, 0) circle [radius=0.3] node{$s_1$}; 95 | \draw[->] (1.5, 0.5) arc(180:-70:10pt); 96 | \draw (2.5, 0.5) node{0}; 97 | 98 | % Bottom left 99 | \draw (-0.5, -2) circle [radius=0.5] node{$s_3$}; 100 | \draw[->](-0.5, -2.5) arc(0:-250:10pt); 101 | \draw[->](-0.5, -1.5) arc(0:250:10pt); 102 | \draw (-1.5, -2.5) node{1}; 103 | \draw (-1.5, -1.5) node{0}; 104 | 105 | % Bottom right 106 | \draw (1.5, -2) circle [radius=0.5]; 107 | \draw (1.5, -2) circle [radius=0.3] node{$s_2$}; 108 | \draw[->](1.5, -2.5) arc(-180:70:10pt); 109 | \draw (2.5, -2.5) node{1}; 110 | 111 | % Legend 112 | \draw (4, 0) circle [radius=0.5]; 113 | \draw (4, 0) circle [radius=0.3]; 114 | \draw (4.5, 0) node[right]{accepting state output: YES}; 115 | 116 | \draw (4, -2) circle [radius=0.5]; 117 | \draw (4.5, -2) node[right]{non accepting state output: NO}; 118 | \end{tikzpicture} 119 | \end{figure} 120 | ~\\ 121 | Accepting states in this examples: $i, s_1, s_2$ \\ 122 | Non accepting states: $s_3$ \\ 123 | Start states: $i$ \\ 124 | Here $S = \{i, s_1, s_2, s_3\} \hspace{5mm} F = \{i, s_1, s_2\} \hspace{5mm} A = \{0, 1\} \hspace{5mm} t: S \times A \rightarrow S \hspace{5mm} t(i, 0) = s_1 \hspace{5mm} t(i, 1) = s_2 \hspace{5mm} t(s_1, 0) = s_1 \hspace{5mm} t(s_1, 1) = s_2 \hspace{5mm} t(s_2, 0) = s_3 \hspace{5mm} t(s_2, 1) = s_2$ \\ 125 | Let's process some strings: 126 | \begin{table}[h!] 127 | \centering 128 | \begin{tabular}{c|ccc|c|c|c|c|c} 129 | \cline{1-2} \cline{4-9} 130 | String & $\varepsilon$ (empty string) & & String & 0 & 0 & 1 & 1 & 1 \\ \cline{1-2} \cline{4-9} 131 | State (i) & i & & State i & $s_1$ & $s_1$ & $s_2$ & $s_2$ & $s_2$ \\ \cline{1-2} \cline{4-9} 132 | Output & YES & & Output & \multicolumn{5}{c}{YES} \\ \cline{1-2} \cline{4-9} 133 | \end{tabular} 134 | \end{table} 135 | \begin{table}[h!] 136 | \centering 137 | \begin{tabular}{c|c|ccc|ccc|c|c|c|c} 138 | \cline{1-3} \cline{5-6} \cline{8-12} 139 | String & 1 & 1 & & String & 1 & & String & 0 & 1 & 0 & 1 \\ \cline{1-3} \cline{5-6} \cline{8-12} 140 | State i & $s_2$ & $s_2$ & & State i & $s_2$ & & State i & $s_1$ & $s_2$ & $s_3$ & $s_3$ \\ \cline{1-3} \cline{5-6} \cline{8-12} 141 | Output & \multicolumn{2}{c}{YES} & & Output & YES & & Output & \multicolumn{4}{c}{NO} \\ \cline{1-3} \cline{5-6} \cline{8-12} 142 | \end{tabular} 143 | \end{table} 144 | ~\\ 145 | Now that we really understand what a finite state acceptor is, we can develop a criterion for recognised regular languages called the \underline{Myhill-Nerode theorem} based on an equivalence relation we can set up on words in our language over the alphabet $A$. 146 | \item[Definition:] Let $x, y \in L$, a language over the alphabet $A$. We call $x$ and $y$ equivalent over $L$ denoted by $x \equiv_L y$ if $\forall w \in A^*, xw \in L \Leftrightarrow yw \in L$. 147 | \item[Note:] $xw$ means the concatenation $x \circ w$, and $yw$ is the concatenation $y \circ w$. 148 | \item[Idea:] If $x \equiv_L y$, then $x$ and $y$ place our finite state acceptor into the \underline{same state} $s$. 149 | \item[Notation:] Let $L/N$ be the set of equivalence classes determined by the equivalence relation $\equiv_L$. 150 | \item[The Myhill-Nerode Theorem:] Let $L$ be a language over the alphabet $A$. If the set $L/N$ of equivalence classes in $L$ is infinite, then $L$ is not a regular language. 151 | \item[Sketch of Proof:] All element of one equivalence class in $L/N$ place our automation into the same state $s$. Elements of distinct equivalence classes place the automation into distinct state, \textbf{i.e.} if $[x], [y] \in L/N$ and $[x] \neq [y]$, then all elements of $[x]$ place the automation into some state $s$, while all elements of $[y]$ place the automation into some state $s'$, with $s \neq s' \Rightarrow$ an automation that can recognise $L$ has \underline{as many} states at the number of equivalence classes in $L/N$, but $L/N$ is \underline{NOT} finite $\Rightarrow L$ cannot be recognised by a finite state automation $\Rightarrow L$ is not regular by the theorem above. 152 | \item[qed] 153 | \end{description} 154 | 155 | 156 | \end{document} -------------------------------------------------------------------------------- /sections/21-RegularGrammars.tex: -------------------------------------------------------------------------------- 1 | \documentclass[../main.tex] 2 | 3 | \begin{document} 4 | \section{Regular Grammars} 5 | \begin{description} 6 | \item[Task:] Understand what is the form of the production rules of a grammar that generates a regular language. 7 | \item[Recall] that a context-free grammar is given by $(V, A, \langle s\rangle , P)$ where every production rule $\langle T\rangle \rightarrow w$ in $P$ causes \underline{one and only one} nonterminal to be replaced by a string in $V^*$. 8 | \item[Definition:] A context-free grammar $(V, A, \langle s\rangle , P)$ is called a \underline{regular grammar} is every production rule in $P$ is of one of the three forms: 9 | \begin{enumerate} 10 | \item[(i)] $\langle A\rangle \rightarrow$ b$\langle B\rangle $ 11 | \item[(ii)] $\langle A\rangle \rightarrow$ b 12 | \item[(iii)] $\langle A\rangle \rightarrow \varepsilon$ 13 | \end{enumerate} 14 | where $\langle A\rangle $ and $\langle B\rangle $ are nonterminals, $b$ is a terminal, and $\varepsilon$ is the empty word. A regular grammar is said to be in normal form if all its production rules are of types (i) and (iii). 15 | \item[Remark:] In the literature, you often see this definition labelled \underline{left-regular grammar} as opposed to \underline{right-regular grammar}, where the production rules of types 1 have the form $\langle A\rangle \rightarrow \langle B\rangle $b, (\textbf{i.e.} the terminal is one the right of the nonterminal). This distinction is not really important as long as we stick to one type throughout since both \underline{left regular grammars} and \underline{right regular grammars} generate regular languages. 16 | \item[Lemma:] Any language generated by a regular grammar may be generated by a regular grammar in normal form. 17 | \item[Proof:] Let $\langle A\rangle \rightarrow$b be a rule of type (ii). Replace it by two rules: $\langle A\rangle \rightarrow$b$\langle F\rangle $ and $\langle F\rangle \rightarrow \varepsilon$, where $\langle F\rangle $ s a new nonterminal. Add $\langle F\rangle $ to the set $V$. We do the same for every rule of type (ii) obtaining a bigger set $V$, but now our production rules are only of type (i) and (iii) and we are generating the same language. 18 | \item[qed] 19 | \item[Example:] Recall the regular language $L = \{0^m1^n \mid m, n \in \mathbb{N}, m \geq 0, n \geq 0 \}$. We can generate it from the regular grammar in normal gorm given by production rules: 20 | \begin{enumerate} 21 | \item $\langle s\rangle \rightarrow 0\langle A\rangle $ 22 | \item $\langle A\rangle \rightarrow 0\langle A\rangle $ 23 | \item $\langle A\rangle \rightarrow \varepsilon$ 24 | \item $\langle s\rangle \rightarrow \varepsilon$ 25 | \item $\langle A\rangle \rightarrow 1\langle B\rangle $ 26 | \item $\langle B\rangle \rightarrow 1\langle B\rangle $ 27 | \item $\langle s\rangle \rightarrow 1\langle B\rangle $ 28 | \item $\langle B\rangle \rightarrow \varepsilon$ 29 | \end{enumerate} 30 | Rules (1), (2), (5), (6), (7) are of type (i), where rules (3), (4) and (8) are of types (iii). \\ 31 | (1) and (3) gives 0. (1), (2) applied $m-1$ times and (3) gives $0^m$ for $m \geq 2$. \\ 32 | (7) and (8) give 1. (7), (6) applied $n-1$ times and (8) give $1^n$ for $n \geq 2$. \\ 33 | (1), (5) and (8) give 01. (1), (5), (6) applied $n-1$ times and (8) gives $01^n$ for $n \geq 2$. \\ 34 | (1), (2) applied $m-1$ times, (5) and (8) gives $0^m1$ for $m \geq 2$. \\ 35 | (1), (2) applied $m-1$ times, (5), (6) applied $n-1$ times, and (8) gives $0^m1^n$ for $m \geq 2, n \geq 2$. \\ 36 | Rule (4) gives the empty word $\varepsilon = 0^01^0$. 37 | \item[Q:] Why does a regular grammar yield a regular language, \textbf{i.e.} one recognised by a finite state acceptor? 38 | \item[A:] Not obvious from the definition, \underline{but} we can construct the finite state acceptor from the regular grammar as follows: our regular grammar is given by $(V, A, \langle s\rangle , P)$. \underline{Want} a finite state acceptor $(S, A, i, t, F)$. Immediately, we see the alphabet $A$ is the same and $i=\langle s\rangle $. This gives us the idea of associating to every nonterminal symbol in $B \backslash A$ a state. $\langle s\rangle \in V \backslash A$, so that's good. Next we ask: 39 | \item[Q:] Is it sufficient for $S = V \backslash A$? 40 | \item[A:] No! Our set $F$ of finishing/accepting states should be nonempty. So we add an element $\{f\}$ to $V \backslash A$, where our acceptor will end up when a word in our language. Thus, $S = (V \backslash A) \cup \{f\}$ and $F \{f\}$. $F \subseteq S$ as needed. 41 | \item[Q:] How do we define $t$? 42 | \item[A:] Use the production rules in $P$! For every rule of type (i), which is of the form $\langle A\rangle \rightarrow$ b$\langle B\rangle $ set $t(\langle A\rangle $,b$) = \langle B\rangle $. This works out well because our nonterminals $\langle A\rangle $ and $\langle B\rangle $ are states of the acceptor and the terminal $b \in A$ for $t$ takes an element of $S \times A$ to an element of $S$ as needed. Now look at production rules of type (ii), $\langle A\rangle \rightarrow b$ and of types (iii), $\langle A\rangle \rightarrow \varepsilon$. Those are applied when we \underline{finish} constructing a word $w$ in our language $L$, \textbf{i.e.} at the very last step, so our acceptor should end up in the finishing state $f$ whenever a production rule of type (ii) or (iii) is applied. Write a production rule of type (ii) or (iii) as $\langle A\rangle \rightarrow w$, then we can set $t(\langle A\rangle , w) = f$. We have finished constructing $t$ as well. Technically, $t:S \times (A \cup \{ \varepsilon \}) \rightarrow S$ instead of $t:S \times A \rightarrow S$, but we can easily fix the transition function t by combining the last two transitions for each accepted word. 43 | \item[Remark:] The same general principals as we used above allow us to go from a finite state acceptor to a regular grammar. This gives us the following theorem: 44 | \item[Theorem:] A language $L$ is regular $\Leftrightarrow L$ is recognised by a finite state acceptor $\Leftrightarrow L$ is generated by a regular grammar. 45 | \end{description} 46 | 47 | \subsection{Applications of Formal Languages and Grammars as well as Automata Theory} 48 | \begin{enumerate} 49 | \item Compiler architecture uses context-free grammars 50 | \item Parsers - recognise if commands comply with the syntax of a language 51 | \item Pattern matching and data mining - guess the language from a given set of words (applied in CS, etc) 52 | \item Natural language processing - example in David Wilkins' notes pp40-44 53 | \item Checking proofs by computers/automatic theorem proving - simpler example of this kind in David Wilkins' notes pp45-57 that pertains to propositional logic 54 | \item Theory of regular expressions (related to the definition of a regular language that we gave) enables 55 | \begin{enumerate} 56 | \item grep/awk/sed in Unix 57 | \item More efficient coding (avoiding unnecessary detoirs in your code) 58 | \end{enumerate} 59 | \item Biology - John Conway's game of life is a cellular automation 60 | \item Modelling of AI characters in games uses the finite state automation idea. Our character can choose among different behaviours based on stimuli - like a finite state automation reacting to input 61 | \item Strategy and tactics in games - teach the opposition to recognise certain patterns, then suddenly change them to gain an advantage and score - used in football, fencing, etc. 62 | \item Learning a sport/a numerical instrument/a new field or subject - split the information into blocks and learn how to combine them into meaningful patterns - uses notions from context-sensitive grammars. 63 | \item Finite state automata and probability - chaos theory, financial mathematics. 64 | \item[etc\dots] 65 | \end{enumerate} 66 | 67 | 68 | \end{document} -------------------------------------------------------------------------------- /sections/22-GraphTheory.tex: -------------------------------------------------------------------------------- 1 | \documentclass[../main.tex] 2 | 3 | \begin{document} 4 | \section{Graph Theory} 5 | \begin{description} 6 | \item[Task:] Introduce terminology related to graphs; understand different types of graphs; learn how to put together arguments involving graphs. \\ 7 | An \underline{undirected graph} consists of: 8 | \begin{enumerate} 9 | \item A finite set of points $V$ called \underline{vertices} 10 | \item A finite set $E$ of \underline{edges} joining two distinct vertices of the graph. 11 | \end{enumerate} 12 | \item[Understand the meaning of an edge better:] Let $V$ be the set of vertices. Consider $P(V)$, the power set of $V$. Let $V_2 \subseteq P(V)$ consist of all subsets of $V$ containing exactly 2 points, \textbf{i.e.} $V_2 = \{A \in P(V) \mid \#(A)=2 \}$ \\ 13 | Identify each element in $V_2$ with the edge joining the two points. In other words, if $\{a, b\} \in V_2$, then we can let $ab$ be the edge corresponding to $\{1, b\}$. 14 | \item[Examples:] 15 | \begin{enumerate} 16 | \item[] 17 | \item A traingle is an undirected graph. \\ 18 | \begin{figure}[h!] 19 | \centering 20 | \begin{tikzpicture} 21 | \draw (0, 0) node[above]{A} -- (-1, -2); 22 | \draw (0, 0) -- (3, -2) node[right]{C}; 23 | \draw (-1, -2) node[left]{B} -- (3, -2); 24 | \end{tikzpicture} 25 | \end{figure} 26 | $V = \{A, B, C\}$ \\ 27 | 3 possible 2 element subsets of $V$: 28 | $\{A, B\} \rightarrow AB$ \\ 29 | $\{A, C\} \rightarrow AC$ \\ 30 | $\{B, C\} \rightarrow BC$ \\ 31 | $E = \{AB, AC, BC\}$ 32 | \item A pentagram is an example of an undirected graph. \\ 33 | \begin{figure}[h!] 34 | \centering 35 | \begin{tikzpicture} 36 | \coordinate (A) at (0, 0); 37 | \coordinate (B) at (-1.5, -1); 38 | \coordinate (E) at (1.5, -1); 39 | \coordinate (C) at (-1, -3); 40 | \coordinate (D) at (1, -3); 41 | 42 | \draw (A) node[above]{a}--(C) node[below]{c}; 43 | \draw (A)--(D) node[below]{d}; 44 | \draw (C)--(E); 45 | \draw (D)--(B) node[left]{b}; 46 | \draw (B)--(E) node[right]{e}; 47 | \end{tikzpicture} 48 | \end{figure} 49 | $V = {a, b, c, d, e}$ \\ 50 | $E = \{ac, ad, be, ce, bd\}$ 51 | \end{enumerate} 52 | \item[Convention:] The set of vertices cannot be empty, \textbf{i.e.} $V \neq 0$. 53 | \item[Q:] If $V \neq \emptyset$, what is the simplest possible undirected graph? 54 | \item[A:] A graph consisting of a single point, \textbf{i.e.} with one vertex and two edges. 55 | \item[Definition:] A graph is called \underline{trivial} if it consists of one vertex and zero edges. Next, study how vertices and edges relate to each other. 56 | \item[Definition:] If $v$ is a vertex of some graph, if $e$ is an edge of that graph, and it $e = vv'$ for $v'$ another vertex, then the vertex $v$ is called \underline{incident} to the edge $e$ and the edge $e$ is called incident to the vertex $v$. 57 | \item[Example:] ~\\ 58 | $b$ is incident to edges $be$ and $bd$ \\ 59 | $be$ is incident to vertices $b$ and $e$ 60 | \begin{figure}[h!] 61 | \centering 62 | \begin{tikzpicture} 63 | \coordinate (A) at (0, 0); 64 | \coordinate (B) at (-1.5, -1); 65 | \coordinate (E) at (1.5, -1); 66 | \coordinate (C) at (-1, -3); 67 | \coordinate (D) at (1, -3); 68 | 69 | \draw (A) node[above]{a}--(C) node[below]{c}; 70 | \draw (A)--(D) node[below]{d}; 71 | \draw (C)--(E); 72 | \draw (D)--(B) node[left]{b}; 73 | \draw (B)--(E) node[right]{e}; 74 | \end{tikzpicture} 75 | \end{figure} 76 | \item[Definition:] Let $(V,E)$ be an undirected graph. Two vertices $A, B \in V \hspace{5mm} A \neq B$ are called \underline{adjacent} if $\exists$ edge $AB \in E$. \\ 77 | We represent the incidence relations among the vertices $V$ and edges $E$ of an undirected graph via: 78 | \begin{enumerate} 79 | \item An incidence table 80 | \item An incidence matrix 81 | \end{enumerate} 82 | \item[Legend:] ~\\ 83 | 1 an incidence relation holds \\ 84 | 0 an incidene relation does not hold \\ 85 | \item From the pentagram: \\ 86 | $V = \{a, b, c, d, e\}$ \\ 87 | $E = \{ac, ad, be, bd, ce\}$ \\ 88 | \pagebreak 89 | \begin{figure}[h!] 90 | \centering 91 | \begin{tikzpicture} 92 | \coordinate (A) at (0, 0); 93 | \coordinate (B) at (-1.5, -1); 94 | \coordinate (E) at (1.5, -1); 95 | \coordinate (C) at (-1, -3); 96 | \coordinate (D) at (1, -3); 97 | 98 | \draw (A) node[above]{a}--(C) node[below]{c}; 99 | \draw (A)--(D) node[below]{d}; 100 | \draw (C)--(E); 101 | \draw (D)--(B) node[left]{b}; 102 | \draw (B)--(E) node[right]{e}; 103 | \end{tikzpicture} 104 | \end{figure} 105 | \item The indidence table is: 106 | \begin{table}[h!] 107 | \centering 108 | \begin{tabular}{c|ccccc} 109 | & ac & ad & be & bd & ce \\ \cline{1-6} 110 | a & 1 & 1 & 0 & 0 & 0 \\ 111 | b & 0 & 0 & 1 & 1 & 0 \\ 112 | c & 1 & 0 & 0 & 0 & 1 \\ 113 | d & 0 & 1 & 0 & 1 & 0 \\ 114 | e & 0 & 0 & 1 & 0 & 1 \\ 115 | \end{tabular} 116 | \end{table} 117 | \item Correspondingly, the incidence matrix is: 118 | \[ \left( \begin{array}{ccccc} 119 | 1 & 1 & 0 & 0 & 0 \\ 120 | 0 & 0 & 1 & 1 & 0 \\ 121 | 1 & 0 & 0 & 0 & 1 \\ 122 | 0 & 1 & 0 & 1 & 0 \\ 123 | 0 & 0 & 1 & 0 & 1 \end{array} \right)\] 124 | Note that for the incidence matrix to make sense, we need to know that vertices were considered in the order $\{a, b, c, d, e\}$ and edges in the order $\{ac, ad, be, bd, ce\}$. If we shuffle either set, the incidence matrix chances. \\ 125 | With this in mind, we can now rigorously define the incidence matrix: 126 | \item[Definition:] Let $(V, E)$ be an undirected graph with $m$ vertices and $n$ edges. Let vertices be ordered as $v_1, v_2,\dots, v_m$, and let the edges be ordered $e_1, e_2, \dots, e_n$. The \underline{incidence matrix} for such a graph is given by $\left( \begin{array}{cccc} 127 | a_{11} & a_{12} & \dots & a_{1n} \\ 128 | a_{21} & a_{22} & \dots & a_{2n} \\ 129 | \vdots & \vdots & \ddots & \vdots \\ 130 | a_{m1} & a_{m2} & \dots & a_{mn} \end{array} \right)$, where the entry $a_{ij}$ in row $i$ and column $j$ has the value 1 if the $i^{th}$ vertex is incident to the $j^{th}$ edge and has value 0 otherwise. \\ 131 | Similarly, we can define the \underline{adjacency table} and the \underline{adjacency matrix} of a graph: 132 | \item[Definition:] Let $(V,E)$ be an undirected graph with $m$ vertices, and let these vertices be ordered as $v_1, v_2, \dots, v_m$. The \underline{adjacency matrix} for this graph is given by $\left( \begin{array}{cccc} 133 | b_{11} & b_{12} & \dots & b_{1m} \\ 134 | b_{21} & b_{22} & \dots & b_{2m} \\ 135 | \vdots & \vdots & \ddots & \vdots \\ 136 | b_{m1} & b_{m2} & \dots & b_{mm} \end{array} \right)$ where $b_{ij}=1$ if $v_i$ and $v_j$ are adjacent to each other and $b_{ij}=0$ if $v_i$ and $v_j$ are not adjacent to each other. 137 | \item[Remark:] "Being adjacent to" is a symmetric relation on he set of vertices $V$, so the adjacency matrix is symmetric, \textbf{i.e.} $b_{ij}=b_{ji} \hspace{5mm} \forall i, j \hspace{5mm} 1 \leq i, j \leq m$. It is not reflexive so all the entries on the diagonal are zero. 138 | \end{description} 139 | 140 | \subsection{Complete graphs} 141 | \begin{description} 142 | \item[Definition:] A graph $(V, E)$ is called \underline{complete} if $\forall v, v' \in V$ s.t. $v \neq v'$, the edge $vv' \in E$. In other words, a complete grapg has the highest number of edges possible given its number of vertices. 143 | \item[Examples:] ~\\ 144 | \begin{enumerate} 145 | \item The triangle is a complete graph. 146 | \item The pentagram is \underline{not} a complete graph. 147 | \end{enumerate} 148 | \item[Notation:] A complete graph with $n$ vertices is denoted by $K_n$. 149 | \item[Q:] How does the adjacency matrix of a complete graph look like? 150 | \item[A:] All entrices are 1 except on the diagonal, where they are all two. 151 | \item[Definition:] A graph $(V, E)$ is called \underline{bipartite} is $\exists$ subsets $V_1$ and $V_2$ s.t. 152 | \begin{enumerate} 153 | \item $V_1 \cup V_2 = V$ 154 | \item $V_1 \cap V_2 = \emptyset$ 155 | \item Every edge in $E$ is of the form $vw$ with $v \in V_1$ and $w \in V_2$. 156 | \end{enumerate} 157 | A bipartite graph is called a \underline{complete bipartite graph} if $\forall v \in V_1 \hspace{5mm} \forall w \in V_2 \hspace{5mm} \exists vw \in E$. 158 | \item[Notation:] A complete bipartite graph where the set $V_1$ has $p$ elements and the set $V_2$ has $q$ elements is denoted by $K_{p,q}$. 159 | \item[Example:] ~\\ 160 | $V_1 = \{a, b\}$ \\ 161 | $V_2 = \{c, d, e\}$ \\ 162 | $V = \{a, b, c, d, e\}$ \\ 163 | $E = \{ac, ad, ae, bc, bd, be\}$ \\ 164 | \pagebreak 165 | \begin{figure}[h!] 166 | \centering 167 | \begin{tikzpicture} 168 | \coordinate (A) at (0, 0); 169 | \coordinate (B) at (-1.5, -1); 170 | \coordinate (E) at (1.5, -1); 171 | \coordinate (C) at (-1, -3); 172 | \coordinate (D) at (1, -3); 173 | 174 | \draw (A) node[above]{a}--(C) node[below]{c}; 175 | \draw (A)--(D) node[below]{d}; 176 | \draw (A)--(E); 177 | \draw (B)--(C); 178 | \draw (D)--(B) node[left]{b}; 179 | \draw (B)--(E) node[right]{e}; 180 | \end{tikzpicture} 181 | \end{figure} 182 | is a complete bipartite graph. 183 | \item Next, relate graph to each other via functions with special properties. 184 | \end{description} 185 | 186 | 187 | \end{document} -------------------------------------------------------------------------------- /sections/23-IsomorphismOfGraphs.tex: -------------------------------------------------------------------------------- 1 | \documentclass[../main.tex] 2 | 3 | \begin{document} 4 | \section{Isomorphism of Graphs} 5 | \begin{description} 6 | \item[Definition:] An \underline{isomorphism} between two graphs $(V, E)$ and $(V',E')$ is a bijective function $\varphi : V \rightarrow V'$ satisfying that $\forall a, b \in V$ with $a \neq b$ the edge $ab \in E \Leftrightarrow$ the edge $\varphi (a) \varphi (b) \in E'$. 7 | \item[Recall:] A function $\varphi : V \rightarrow V'$ is bijective $\Leftrightarrow$ it has an inverse $\varphi^{-1} : V' \rightarrow V'$. \\ 8 | The bijection $\varphi V \rightarrow V'$ that gives the isomorphism between $(V, E)$ and $(V' E')$ thus sets up the following: 9 | \begin{enumerate} 10 | \item A 1-1 correspondence of the vertices $V$ of $(V,E)$ with the vertices $V'$ of $(V',E') \rightarrow$ comes from $\varphi: V \rightarrow V'$ being bijective. 11 | \item A 1-1 correspondence of the edges $E$ of $(V,E)$ with the edges $E'$ of $(V',E') \rightarrow$ comes from the additional property in the definition of an isomorphism that $\forall a, b \in V$ with $a \neq b, ab \in E \Leftrightarrow \varphi (a) \varphi (b) \in E'$. 12 | \end{enumerate} 13 | \item[Remark:] Just like an isomorphism of groups discussed earlier in the course, an ismorphism of graphs means $(V,E)$ and $(V',E')$ have the same "iso" from "morph\'{e}". "Being isomorphic" is an equivalence relations, so we get classes of graphs that have the same form as our equivalence classes. 14 | \item[Definition:] If there exists an isomorphism $\varphi :V \rightarrow V'$ between two graphs $(V, E)$ and $(V', E')$, then $(V, E)$ and $(V', E')$ are called isomorphic. 15 | \end{description} 16 | 17 | 18 | \end{document} -------------------------------------------------------------------------------- /sections/24-Subgraphs.tex: -------------------------------------------------------------------------------- 1 | \documentclass[../main.tex] 2 | 3 | \begin{document} 4 | \section{Subgraphs} 5 | \begin{description} 6 | \item[Task:] Understand subobjects of a graph. 7 | \item[Definition:] Let $(V, E)$ and $(V', E')$ be graphs. The graph $(V', E')$ is called a subgraph of $(V, E)$ if $V' \subseteq V$ and $E' \subseteq E$, \textbf{i.e.} if $(V', E')$ consists of a subset $V'$ of the vertices of $(V, E)$ and a subset $E'$ of edges $(V, E)$ between vertices in $V'$. 8 | \item[Example:] Star of David on the flag of Israel \\ 9 | $V = \{a, b, c, d, e, f\}$ \\ 10 | $E = \{ac, ce, ae, bf, fd, bd\}$ \\ 11 | \begin{figure}[h!] 12 | \centering 13 | \begin{tikzpicture} 14 | \coordinate (A) at (0, 0); 15 | \coordinate (B) at (-1.5, -1); 16 | \coordinate (C) at (-1.5, -2.5); 17 | \coordinate (D) at (0, -3.5); 18 | \coordinate (E) at (1.5, -2.5); 19 | \coordinate (F) at (1.5, -1); 20 | 21 | \draw (A) node[above]{A} -- (C); 22 | \draw (A) -- (E) node[right]{E}; 23 | \draw (C) node[left]{C} -- (E); 24 | \draw (D) -- (B) node[left]{B}; 25 | \draw (D) node[below]{D} -- (F); 26 | \draw (B) -- (F) node[right]{F}; 27 | \end{tikzpicture} 28 | \end{figure} 29 | \item 2 triangle subgraphs of the star of David: \\ 30 | \begin{tabular}{ll} 31 | $V' = \{a, c, e\}$ & $E' = \{ac, ce, ae\}$ \\ 32 | $V'' = \{b, f, d\}$ & $E'' = \{bf, fd, bd\}$ 33 | \end{tabular} 34 | \end{description} 35 | 36 | 37 | \end{document} -------------------------------------------------------------------------------- /sections/25-VertexDegrees.tex: -------------------------------------------------------------------------------- 1 | \documentclass[../main.tex] 2 | 3 | \begin{document} 4 | \section{Vertex Degrees} 5 | \begin{description} 6 | \item[Task:] Use numbers to understand incidence relationships. 7 | \item[Definition:] Let $(V, E)$ be a graph. The \underline{degree} deg $v$ of a vertex $v \in V$ is defined as the number of edges of the graph that are incidence to $v$, \textbf{i.e.} the number of edge with $v$ as one of their endpoints. 8 | \item[Example:] ~\\ 9 | \begin{figure}[h!] 10 | \centering 11 | \begin{tikzpicture} 12 | \coordinate (A) at (0, 0); 13 | \coordinate (H) at (0, -2); 14 | \coordinate (B) at (-1, -1); 15 | \coordinate (C) at (1, -1); 16 | \coordinate (D) at (-1, -3); 17 | \coordinate (E) at (1, -3); 18 | \coordinate (F) at (-0.5, -2.3); 19 | \coordinate (G) at (0.5, -2.3); 20 | 21 | \draw (A) -- (H); 22 | \draw (H) -- (B); 23 | \draw (H) -- (C); 24 | \draw (B) -- (D); 25 | \draw (C) -- (E); 26 | 27 | \draw[fill=black] (A) circle[radius=0.5mm] node[above]{A}; 28 | \draw[fill=black] (B) circle[radius=0.5mm] node[above left]{B}; 29 | \draw[fill=black] (C) circle[radius=0.5mm] node[above right]{C}; 30 | \draw[fill=black] (D) circle[radius=0.5mm] node[below left]{D}; 31 | \draw[fill=black] (E) circle[radius=0.5mm] node[below right]{E}; 32 | \draw[fill=black] (H) circle[radius=0.5mm] node[below]{H}; 33 | \draw[fill=black] (F) circle[radius=0.5mm] node[below]{F}; 34 | \draw[fill=black] (G) circle[radius=0.5mm] node[below]{G}; 35 | \end{tikzpicture} 36 | \end{figure} 37 | ~\\ 38 | def $f$ = deg $g$ = 0 \\ 39 | deg $d$ = deg $e$ = deg $a$ = 1 \\ 40 | deg $b$ = deg $c$ = 2 \\ 41 | deg $h$ = 3 \\ 42 | \item[Definition:] A vertex of degree 0 is called an \underline{isolated} vertex. 43 | \item[Definition:] A vertex of degree 1 is called a \underline{pendent} vertex. 44 | \item[Theorem:] Let $(V, E)$ be a graph. Then $\sum_{v \in V}$deg $v = 2\#(E)$, where $\sum_{v \in V}$deg $v$ is the sum of the degrees of all the vertices of the graph, and $\#(E)$ is the number of edges of the graph. 45 | \item[Proof:] $\sum_{v \in V}$deg $v$ is the sum of all the entries in the adjacency matrix. Every edge $vv' \in E$ contributes 2 to the sum $\sum_{v \in V}$deg $v$, 1 for the vertex $v$ and 1 for the vertex $v' \Rightarrow$ each edge must be counted twice, so $\sum_{v \in V}$deg $v = 2 \#(E)$. 46 | \item[qed] 47 | \item[Corollary:] $\sum_{v \in V}$deg $v$ is an even integer. 48 | \item[Proof:] Since $\sum_{v \in V}$deg $v = 2 \#(E)$, and $\#(E) \in \mathbb{N}$, the result follows. 49 | \item[qed] 50 | \item[Corollary:] In any graph, the number of vertices of odd degrees must be even. 51 | \item[Proof:] Assume not, then $\sum_{v \in V}$deg $v$ is an odd integer as $odd + even = odd \Rightarrow \Leftarrow$ to the previous corollary. 52 | \item[qed] 53 | \item[Definition:] A graph is called k-regular for some non-negative integer $k$ if every vertex of the graph has degree equal to $k$. 54 | \item[Example:] A rectangle is 2-regular. \\ 55 | \begin{figure}[h!] 56 | \centering 57 | \begin{tikzpicture} 58 | \coordinate (A) at (0, 0); 59 | \coordinate (B) at (4, 0); 60 | \coordinate (D) at (0, -2); 61 | \coordinate (C) at (4, -2); 62 | 63 | \draw (A) node[above left]{A} -- (B); 64 | \draw (A) -- (D) node[below left]{D}; 65 | \draw (B) node[above right]{B} -- (C); 66 | \draw (D) -- (C) node[below right]{C}; 67 | \end{tikzpicture} 68 | \end{figure} 69 | deg $a$ = deg $b$ = deg $c$ = deg $d$ = 2. 70 | \item[Definition:] A graph $(V, E)$ is called \underline{regular} is $\exists k \in \mathbb{N}$ s.t. $(V, E)$ is k-regular. 71 | \item[Corollary:] Let $(V, E)$ be a k-regular graph. Then $k\#(V) = 2\#(E)$ where $\#(V)$ is the number of vertices and $\#(E)$ is the number of edges. 72 | \item[Proof:] By the theorem, $\sum_{v \in V}$deg $v = 2\#(E)$, but $(V, E)$ is k-regular $\Rightarrow$ deg $v = k \forall v \in V$. Therefore $\sum_{v \in V}$deg $v = \#(V).k = 2 \#(E)$. 73 | \item[qed] 74 | \item[Example:] Consider a complete graph $(V, E)$ with $n$ vertices. $(V, E)$ is $(n-1)$-regular because every vertex is adjacent to all the remaining $(n-1)$ vertices. 75 | \item[Corollary:] A complete bipartite graph $k_{p,q}$ is regular $\Leftrightarrow p = q$ 76 | \item[Proof:] Recall that $V=V_1 \cup V_2 \hspace{10mm} V_1 \cap V_2 = \emptyset$ for a bipartite graph. \\ 77 | $\Leftarrow$ is $p=q, \forall v \in V_1$ satisfies that deg $v = p = q$ and $\forall v \in V_2$ satisfies that def $v=p=q$ since the graph is complete $\Rightarrow (V, E)$ is p-regular. \\ 78 | $\Rightarrow \: (V, E)$ is regular $\Rightarrow \forall v \in V_1$ and $\forall v' \in V_2$, deg $v=$ deg $v'$, but $(V, E)$ is complete $\Rightarrow v$ is adjacent to all vertices in $V_2$, \textbf{i.e.} def $v = \#(V_1)$ and $v'$ is adjacent to all vertices in $V_1$, \textbf{i.e.} deg $v' = \#(V_2) \rightarrow \#(V_1) = \#(V_2)$ 79 | \end{description} 80 | 81 | 82 | \end{document} -------------------------------------------------------------------------------- /sections/26-Walks,TrailsAndPaths.tex: -------------------------------------------------------------------------------- 1 | \documentclass[../main.tex] 2 | 3 | \begin{document} 4 | \section{Walks, trails and paths} 5 | \begin{description} 6 | \item[Task:] Make rigorous the notion of traversing parts of a graph in order to understand its structure better. 7 | \item[Definition:] Let $(V, E)$ be a graph. A \underline{walk} $v_0 v_1 v_2 \dots v_n$ of length $n$ in the graph from vertex $a$ to vertex $b$ is determined by a finite sequence $v_0, v_1, v_1, \dots, v_n$ of vertices of the graph s.t. $v_0 = a, v_n = b$ and $v_{i-1} v_i$ is an edge of the graph for $i=1, 2, \dots, n$. 8 | \item[Definition:] A walk $v_0 v_1 v_2 \dots v_n$ in a graph is said to \underline{traverse} the edges $v_{i-1} v_i$ and to \underline{pass through} the vertices $v_0, v_1, \dots, v_n$. Length of walk $= \#$ of edges traversed $\rightarrow$ the smallest possible number is two edges. As a result, we have the following definition: 9 | \item[Definition:] A walk that consists of a single vertex $v \in V$ and has length two is called \underline{trivial}. 10 | \item[Definition:] Let $(V, E)$ be a graph. A \underline{trail} $v_0 v_1 v_2 \dots v_n$ of length $n$ in the graph from some vertex $a$ to some vertex $b$ is a walk of length $n$ from $a$ to $b$ with the property that edges $v_{i-1} v_i$ are distinct for $i-1, 2, \dots , n$. In other words, a trail is a walk in the graph, which traverses edges of the graph at most once. 11 | \item[Definition:] Let $(V, E)$ be a graph. A \underline{path} $v_0 v_1 v_2 \dots v_n$ of length $n$ in the graph from some vertex $a$ to some vertex $b$ is a walk of length $n$ from $a$ to $b$ with the property that vertices $v_0, v_1 \dots v_n$ are distinct. In other words, a path in a graph is a walk in the graph, which passes through the vertices of the graph at most once. 12 | \item[Definition:] A walk, trail or path is a graph is called \underline{trivial} if it is a walk of length two consist of a single vertex $v \in V$; otherwise, the walk, trail, or path is called \underline{non-trivial}. 13 | \item[Example:] ~\\ 14 | \begin{enumerate} 15 | \item $h$ is a trivial walk/trail/path 16 | \item $defd$ is a trail, but not a path because we pass through the vertex $d$ twice. 17 | \item $def$ is a path 18 | \item $gfdefdc$ is a walk but not a trail of a path 19 | \end{enumerate} 20 | \begin{figure}[h!] 21 | \centering 22 | \begin{tikzpicture} 23 | \coordinate (G) at (0, -1); 24 | \coordinate (F) at (3, -3.5); 25 | \coordinate (E) at (1, -3); 26 | \coordinate (D) at (1, -5); 27 | \coordinate (A) at (-2, -3.5); 28 | \coordinate (H) at (-1, -3.2); 29 | \coordinate (B) at (-0.5, -6.2); 30 | \coordinate (C) at (2.7, -7); 31 | 32 | \draw (G) -- (F) -- (D) -- (C) -- (B) -- (A) -- (G); 33 | \draw (D) -- (E) -- (F); 34 | 35 | \draw[fill=black] (A) circle[radius=0.5mm] node[left]{A}; 36 | \draw[fill=black] (B) circle[radius=0.5mm] node[below left]{B}; 37 | \draw[fill=black] (C) circle[radius=0.5mm] node[right]{C}; 38 | \draw[fill=black] (D) circle[radius=0.5mm] node[left]{D}; 39 | \draw[fill=black] (E) circle[radius=0.5mm] node[above]{E}; 40 | \draw[fill=black] (F) circle[radius=0.5mm] node[right]{F}; 41 | \draw[fill=black] (G) circle[radius=0.5mm] node[above]{G}; 42 | \draw[fill=black] (H) circle[radius=0.5mm] node[above]{H}; 43 | \end{tikzpicture} 44 | \end{figure} 45 | \end{description} 46 | 47 | 48 | \end{document} -------------------------------------------------------------------------------- /sections/27-ConnectedGraphs.tex: -------------------------------------------------------------------------------- 1 | \documentclass[../main.tex] 2 | 3 | \begin{document} 4 | \section{Connected Graphs} 5 | \begin{description} 6 | \item[Task:] Use the ideas above related to traversing parts of a graph in order to define a particularly important category of graphs. 7 | \item[Definition:] An undirected graph $(V, E)$ is called \underline{connected} if $\forall u, v \in V$ vertices, $\exists$ path in the graph from $u$ to $v$. 8 | \item[Examples:] 9 | \begin{enumerate} 10 | \item Is not connected as $d$ is not connected to any other vertex. 11 | \begin{figure}[h!] 12 | \centering 13 | \begin{tikzpicture} 14 | \coordinate (A) at (0, 0); 15 | \coordinate (B) at (-1, -2); 16 | \coordinate (C) at (2, -2); 17 | \coordinate (D) at (0, -1); 18 | 19 | \draw (A) -- (B) -- (C) -- (A); 20 | \draw[fill=black] (A) circle[radius=0.5mm] node[above]{A}; 21 | \draw[fill=black] (B) circle[radius=0.5mm] node[left]{B}; 22 | \draw[fill=black] (C) circle[radius=0.5mm] node[right]{C}; 23 | \draw[fill=black] (D) circle[radius=0.5mm] node[above]{D}; 24 | \end{tikzpicture} 25 | \end{figure} 26 | \pagebreak 27 | \item Is connected. $\exists$ path between any two of the vertices. 28 | \begin{figure}[h!] 29 | \centering 30 | \begin{tikzpicture} 31 | \coordinate (A) at (-1, 1); 32 | \coordinate (B) at (1, 1); 33 | \coordinate (C) at (1, -1); 34 | \coordinate (D) at (-1, -1); 35 | 36 | \draw (A) -- (B) -- (C) -- (D) -- (A); 37 | \draw (A) -- (C); 38 | \draw (D) -- (B); 39 | 40 | \draw[fill=black] (A) circle[radius=0.5mm] node[above left]{A}; 41 | \draw[fill=black] (B) circle[radius=0.5mm] node[above right]{B}; 42 | \draw[fill=black] (C) circle[radius=0.5mm] node[below right]{C}; 43 | \draw[fill=black] (D) circle[radius=0.5mm] node[below left]{D}; 44 | \end{tikzpicture} 45 | \end{figure} 46 | \end{enumerate} 47 | \item[Theorem:] Let $(V, E)$ be a undirected graph, and let $u, v \in V. \exists$ path between $u$ and $v$ in the graph $\Leftrightarrow \exists$ walk in the graph between $u$ and $v$. 48 | \item[Proof:] $\Rightarrow$ trivial: A path is a walk. \\ 49 | $\Leftarrow \exists$ walk between $u$ and $v$. Choose the walk of least length between $u$ and $v$, (\textbf{i.e.} $\nexists$ a walk of lower length than this one) and prove it is a path. Let this walk be $a_0 a_1 \dots a_n$ with $a_0 = u$ and $a_n = v$. Assume $\exists j, k$ with $a \leq j, k \leq n$ s.t. $j < k$ and $a_j = a_k$, but then $a_0 a_1 \dots a_j a_k+1 \dots a_n$ would be a walk from $u$ to $v$ of \underline{strictly smaller} length than $a_0 a_1 \dots a_n$. $\Rightarrow \Leftarrow$ as we chose $a_0 a_1 \dots a_n$ to be of minimal length $ \Rightarrow a_i \neq a_j \forall i, j$ s.t. $0 \leq i, j \leq n \Rightarrow a_0 a_1 \dots a_n$ is a path between $u$ and $v$. 50 | \item[qed] 51 | \item[Corollary:] An undirected grapg $(V, E)$ is connected $\Leftrightarrow \forall u, v \in V \exists$ walk in the graph between $u$ and $v$. 52 | \end{description} 53 | 54 | 55 | \end{document} -------------------------------------------------------------------------------- /sections/28-ComponentsOfAGraph.tex: -------------------------------------------------------------------------------- 1 | \documentclass[../main.tex] 2 | 3 | \begin{document} 4 | \section{Components of a graph} 5 | \begin{description} 6 | \item[Task:] Divide a graph into subgraphs that are isolated from each other. 7 | \end{description} 8 | Let $(V, E)$ be an undirected graph. We define a relation $\sim$ on the set of vertices $V$, where $a, b \in V$ satisfy $a \sim b$ iff $\exists$ walk in the graph from $a$ to $b$. 9 | \begin{description} 10 | \item[Lemma:] Let $(V, E)$ be an undirected graph. The relation $a \sim b$ or $a, b \in V$, which holds iff $\exists$ walk in the graph between $a$ and $b$ is an equivalence relation. 11 | \item[Proof:] We must show $\sim$ is reflexive, symmetric, and transitive. 12 | \item[Reflexive:] $\forall v \in V, v \sim v$ since the trivial walk is a walk from $v$ to itself. 13 | \item[Symmetric:] If $a \sim b$ for $a, b \in V$, then $\exists$ walk $v_0 v_1 \dots v_n$ where $v_0 = a$ and $v_n = b$. This walk can be reversed to $v_n v_{n-1} \dots v_1 v_0$, which now goes from $v_n = b$ to $v_0 = a$. Therefore, $b \sim b$ as needed. 14 | \item[Transitive:] If $a \sim b$ and $b \sim c$, for $a, b, c \in V$, there $\exists$ walk $a v_1 v_2 \dots v_{n-1} b$ from $a$ to $b$ and $\exists$ walk $b w_1 w_2 \dots w_{m-1} c$ from $b$ to $c$. We put these two walks together (concatenate them) to yield the walk $a v_1 v_2 \dots v_{n-1} b w_1 w_2 \dots w_{m-1} c$ from $a$ to $c$. Therefore $a \sim c$. 15 | \item[qed] 16 | \end{description} 17 | The equivalence relation $\sim$ on $V$ partitions it into dsjoint subsets $v_1, v_2, \dots v_p$, where 18 | \begin{enumerate} 19 | \item $v_1 \cup v_2 \cup \dots \cup v_p = V$ 20 | \item $v_i \cap v_j = \emptyset$ if $i \neq j$ 21 | \item Two vertices $a, b \in v_i \Leftrightarrow a \sim b$, \textbf{i.e.} $\exists$ walk in $(V, E)$ from $a$ to $b$ 22 | \end{enumerate} 23 | Note that an edge is a walk of length 1, so if $a, b \in V$ satisfy that $\exists ab \in E$, then $a$ and $b$ belong to the same $v_i$. As a result, we can partition the set of edges as follows: 24 | \[E_i \{ab \in E \mid a, b \in v_i \}\] 25 | Clearly, $E_1 \cup E_2 \cup \dots \cup E_p = E \land E_i \cap E_j = \emptyset$ is $i \neq j$. Furthermore, $(V_1, E_1), (V_2, E_2), \dots, (V_p, E_p)$ are subgraphs of $(V, E)$, and these subgraphs are disjoint since $v_i \cap v_j = \emptyset$ and $E_i \cap E_j = \emptyset$ is $i \neq j$. The subgraphs $(V_i, E_i)$ are called the \underline{components} (or \underline{connected components}) of the graph $(V, E)$. 26 | \begin{description} 27 | \item[Lemma:] The vertices and edges of any walk in an undirected graph are all contained in a single component of that graph. 28 | \item[Proof:] Let $v_0 v_1 \dots v_n$ be a walk in a graph $(V, E)$, then $v_0 v_1 \dots v_r$ is a walk in $(V, E) \forall r \hspace{5mm} 1 \leq r \leq n \Rightarrow v_0 \sim v_r \forall r \hspace{5mm} 1 \leq r \leq n \Rightarrow v_r$ belongs to the same component of the graph as $v_0$. The same is true for all the edges $v_{i-1}v_i$ for $1 \leq i \leq n$ 29 | \item[qed] 30 | \item[Lemma:] Each component of an undirected graph is connected. 31 | \item[Proof:] Let $(V, E)$ be a graph and let $(V_1, E_i)$ be any component of $(V, E). \forall u, v \in V_i$, by definition $\exists$ walk in $(V, E)$ between $u$ and $v$. By previous lemma, however, all vertices and edges of this walk are in $(V_i, E_i) \Rightarrow$ the walk between $u$ and $v$ is a walk in $(V_i, E_i)$, but this assertion is true $\forall u, v \in V_i \Rightarrow (V_i, E_i)$ is connected. 32 | \item[qed] 33 | \end{description} 34 | 35 | \subsection{Moral of the story} 36 | Any undirected graph can be represented as a disjoint union of connected subgraphs, namely its components $\Rightarrow$ the study of undirected graphs reduces to the study of connected graphs, as components don't share either vertices or edges. 37 | 38 | 39 | \end{document} -------------------------------------------------------------------------------- /sections/29-Circuits.tex: -------------------------------------------------------------------------------- 1 | \documentclass[../main.tex] 2 | 3 | \begin{document} 4 | \section{Circuits} 5 | \begin{description} 6 | \item[Task:] Use closed walks to understand the structure of graphs better. 7 | \item[Definition:] Let $(V, E)$ be a graph. A walk $v_0 v_1 \dots v_n$ in $(V, E)$ is called \underline{closed} if $v_0 = v_n$, \textbf{i.e.} if it starts and edges at the same vertex. 8 | \item[Definition:] Let $(V, E)$ be a graph. A \underline{circuit} is a nontrivial closed trail in $(V, E)$, \textbf{i.e.} a closed walk with no repeated edges passing through at least two vertices. 9 | \item[Definition:] A circuit is called \underline{simple} if the vertices $v_0, v_1, v_2, \dots v_{n-1}$ are distinct. 10 | \item[NB:] This is the strangest condition regarding vertices tha we can impose ince $v_0 = v_n$. 11 | \item[Alternative terminology:] Some authors use \underline{cycle} to denote a simple circuit, which for ohers \underline{cycle} denotes a circuit regardless of whether it is simple or not. 12 | \item[Q:] When does a graph have simple circuits? 13 | \item[A:] We can give 2 criteria for the existence of simple circuits: 14 | \begin{enumerate} 15 | \item Every vertex has degres $\geq$ 2. 16 | \item $\forall u, v \in V$ s.t. $\exists$ 2 distinct paths from $u$ to $v$. 17 | \end{enumerate} 18 | \item[Theorem:] If $(V, E)$ has no isolated or pendant vertices, \textbf{i.e.} $\forall v \in V$ deg $v \geq$ 2, then $(V, E)$ contains at least one simple circuit. 19 | \item[Proof:] Consider all paths $(V, E)$. The maximum length of a path is $\#(V) - 1$ since a path of length $p$ passed through $p+1$ vertices. Take a path $v_0 v_1 \dots v_m$ is $(V, E)$ of maximum length, \textbf{i.e.} any other path in $(V, E)$ has length $\leq m = $ length of $v_0 v_1 \dots v_m$. Now consider the vertex $v_m$. deg $v_m \geq$ 2 by assumption. We know $v_{m-1}$ is adjacent to $v_m$ since the edge $v_{m-1} v_m$ is part of the path $v_0 v_1 \dots v_m$, but deg $v_m \geq $ 2 means $\exists w \in V$ s.t. $ww_m \in E$. If $w \neq v_i$ for $0 \leq i \leq m-2$, then $v_0 v_1 \dots v_m w$ is a path in $(V, E)$ longer than $v_0 v_1 \dots v_m \Rightarrow \Leftarrow$ to the act that $v_0 v_1 \dots v_m$ was chosen of maximal length. Therefore, $w = v_i$ for some $0 \leq i \leq m-2$, but then $v_i v_{i+1} \dots v_m v_i$ is a simple circuit in the graph. 20 | \item[qed] 21 | \item[Theorem:] Let $(V, E)$ be an undirected graph and let $u, v \in V$ be vertices s.t. $u \neq v$ and $\exists$ at least two distinct paths in $(V, E)$ from $u$ to $v$. Then the graph contains at least one simple circuit. 22 | \item[Proof:] Let $a_0 a_1 a_2 \dots a_m$ and $b_0 b_1 \dots b_n$ be the two distinct paths in the graph between $u$ and $v$, \textbf{i.e.} $a_0 = b_0 = u$ and $a_m = b_m = v$. Let $m \leq n$. Since the paths are distinct $\exists i$ with $0 \leq i \leq m$ s.t. $a_1 \neq b_i$. Choose the smallest $i$ for which $a_i \neq b_i$, \textbf{i.e.} $a_0 = b_0, a_1 = b_1, \dots, a_{i-1} = b_{i-1}$, but $a_i \neq b_i$. We have thus eliminated the redundencies at the beginning of the paths. We now need to eliminate redundencies at the other end of the paths. We know $a_m = b_m$ so $a_j \in \{b_m \mid i-1 < k \leq n \}$ is certainly satisfied for $j=m$, but we want to choose the \underline{smallest} index for which this condition is satisfied. Let this index be $p \Rightarrow a_p \in \{b_k \mid i-1 < k \leq n \}$, \textbf{i.e.} $a_p = b_s$ for some $s$ s.t. $i-1 < s \leq n$. Since $p$ is the smallest index satisfying $a_p \in \{b_k \mid i-1 < k \leq n \}, a_i, a_{i+1}, \dots, a_{p-1} \notin \{b_k \mid i-1 < k \leq n \} \Rightarrow \underset{indices \: running \: in \: increasing \: order}{\underbrace{a_{i-1} a_i \dots a_p}} (= b_s) \underset{indices \: running \: in \: decreasing \: order}{\underbrace{b_{s-1}\dots b_i}} a_{i-1} (=b_{i-1})$ is a simple circuit in $(V, E) \Rightarrow (V, E)$ has at least one simple circuit. 23 | \item[qed] 24 | \end{description} 25 | 26 | 27 | \end{document} -------------------------------------------------------------------------------- /sections/30-EulerianTrailsAndCircuits.tex: -------------------------------------------------------------------------------- 1 | \documentclass[../main.tex] 2 | 3 | \begin{document} 4 | \section{Eulerian trails and circuits} 5 | \begin{description} 6 | \item[Task:] Look at trails and circuits that traverse every edge of a graph. Derive criteria when such trails and circuits exist. 7 | \item[Definition:] An \underline{Eulerian trail} in a graph is a trail that traverses every edge of that graph. In other words, an Eulerian trail is a walk that traverses every edge of the graph exactly once. \\ 8 | Trail $\Rightarrow$ an edge is traversed at most once. \\ 9 | Eulerian $\Rightarrow$ every edge is traversed. 10 | \item[Definition:] An \underline{Eulerian circuit} is a graph is a circuit that traverses every edge of the graph. 11 | \item[Origin of the terminology:] Eurlerian comes from the swiss mathematician Leonhard Euler (1707-1783) who solved the problem of the seven bridges of k\"onigsbey/kaliningrad (Then Prussia, now Russia) over the river Prugal in 1736. His negative sollution is considered the beginning of graph theory as a subfield of mathematics. We will rederive Euler's results shortly. Google to see the configuration of the bridges on the river Prugel. 12 | \item[Examples:] 13 | \begin{enumerate} 14 | \item[] 15 | \item $abc$ is an Eulerian trail and an Eulerian circuit. The triangle is $k_3$. 16 | \begin{figure}[h!] 17 | \centering 18 | \begin{tikzpicture} 19 | \draw (0,0) node[above]{A} -- (-1,-2) node [left]{B} -- (2, -2) node[right]{C} -- (0, 0); 20 | \end{tikzpicture} 21 | \end{figure} 22 | \item Consider $k_5$, the complete graph with 5 vertices. \\ 23 | $eabecdbcade$ is an Eulerian circuit. 24 | \begin{figure}[h!] 25 | \centering 26 | \begin{tikzpicture} 27 | \coordinate (E) at (0, 0); 28 | \coordinate (C) at (1, -1); 29 | \coordinate (D) at (-1, -1); 30 | \coordinate (B) at (0, -2); 31 | \coordinate (A) at (-2, -2); 32 | 33 | \draw (A) node[left]{A} -- (E) node[above]{E} -- (C) node[right]{C} -- (B) node[below]{B} -- (A); 34 | \draw (D) node[above left]{D} -- (B) -- (E) -- (A) -- (C) -- (D); 35 | \end{tikzpicture} 36 | \end{figure} 37 | \end{enumerate} 38 | In both cases, the degree of the vertices is even for all vertices. We'll see this property is important and derive other necessary and sufficient conditions for the existence of Eulerian trails and circuits. 39 | \item[Theorem:] Let $(V, E)$ be a graph, and let $v_0 v_1 \dots v_m$ be a trail in $(V, E)$. Let $v \in V$ be a vertex, then the number of edges of the trail incident to $v$ is even except when the trail is not closed and the trail starts and finishes at $v$, in which case the number of edges of the trail incident to the vertex $v$ is odd. 40 | \item[Proof:] Note that 0 is an even integer as 0 = 2 $\times$ 0. 41 | \begin{description} 42 | \item[Case 1:] $v \neq v_0 \land v \neq v_m$. If the trail does not pass through $v$, the number of dges incident to $v$ belonging to the trail is 0, which is even. \\ 43 | If the trail passes through $v$, then edges of the trail incident to $v$ are of the form $v{i-1} v_i$ and $v_i v_{i+1}$ with $v = v_i$ and $0 < i < m$. Therefore, the number of edges of the trail incident to $v$ equals twice the number of integers $i$ among $1, 2, \dots, m-1 (0 < i < m)$ s.t. $v= v_i \Rightarrow$ the number of even. 44 | \item[Case 2:] $v = v_0$ and the trail is not closed, \textbf{i.e.} $v_m \neq v_0$. The edges incident to $v$ are $v_0 v_1$ along with $v_{i-1} v_i$ and $v_i v_{i+1}$ whenever $v=v_i$, hence 1+2. $\#$(instances when $v=v_i$), which is odd. 45 | \item[Case 3:] $v=v_m$ and the trail is not closed, \textbf{i.e.} $v_m \neq v_0$. Repeat the argument in case 2 with $v_{m-1} v_m$ replacing $v_0 v_1$ to get that the number of edges incident to $v$ is odd. 46 | \item[Case 4:] The trail is closed and $v = v_0 = v_m$. The edges incident to $v$ are $v_0 v_1, v_{m-1} v_m$ as well as $v_{i-1} v_i$ and $v_i v_{i+1}$ for each $i$ s.t. $v=v_i \Rightarrow$ once again, the number of edges incident to $v$ is even. 47 | \item[qed] 48 | \end{description} 49 | \item[Corollary 1:] Let $v$ be a vertex of the graph. Given any circuit in the graph, the number of edges incident to $v$ traversed by that circuit is even. 50 | \item[Proof:] Apply the theorem to $v_0 v_1 \dots v_m$ s.t. $v_0 = v_m$. We deduce that the number of edges incident to $v$ is even. 51 | \item[Corollary 2:] If a graph admits an Eulerian circuit, then the degree of every vertex of that graph must be even. 52 | \item[Proof:] Let $(V, E)$ be the graph. $\forall v \in V$, the number of edges of any Eulerian circuit incident to $v$ is even by the previous corollary. Since an Eulerian circuit by definition traverses every edge of the graph, every edge incident to $v$ is an edge of the Eulerian circuit $\Rightarrow$ deg $v$ is even $\forall v \in V$ (\textbf{NB:} def $v$ could be zero if $v$ is an isolated vertex). 53 | \item[Example:] By the previous corollary, $k_4$, the complete graph on four vertices, cannot have an Eulerian circuit since $\forall v$ in $k_4$, def $v = 3$ ($k_4$ is 3-regular as we bserved in a previous lecture). 54 | \item[Corollary 3:] If a graph admits an Eulerian trail that is not a circuit, then the degrees of exactly two vertices of the graph must be odd, and the degrees of the remaining vertices must be even. The vertices with odd degrees are exactly the initial and final vertices of the Eulerian trail. 55 | \item[Proof:] By the theorem, the initial and final vertices of the Eulerian trail have odd degree, whereas all vertices in between have even degrees. 56 | \item[qed] 57 | \end{description} 58 | Next, prove the \underline{converse} of corollary 2: A non=trivial connected graph has an Eulerian circuit if the deree of each of its vertices is even. The proof is carried out in a series of lemmas: 59 | \begin{description} 60 | \item[Lemma A:] If the degree of each vertex is even, the $\exists$ a circuit. 61 | \item[Lemma B:] If the degree of each vertex is even, if $\exists$ circuit, and if $\exists$ edges not in the circuit incident to a vertex in the circuit, we can construct another circuit. 62 | \item[Lemma C:] If we have two circuits with at least one vertex in common, we can combine them. 63 | \item[Lemma D:] A criterion for when a trail in Eulerian in a connected graph. 64 | \item ~\\ 65 | \item[Lemma A:] Let $vw$ be an edge of a graph in which the degree of every vertex is even, the $\exists$ circuit of the graph that traverses the edge $vw$. 66 | \item[Proof:] We construct the circuit starting with the edge $vw$. Let $v_0 = v$ and $v_1 = w$. Let $v_0 v_1 \dots v_k$ be any trail of length $k \geq 1$ traversing the edge $vw$. Suppose $v_k \neq v = v_0$. As we proved in the previous theorem, since $v_k$ is an endpoint of a non-closed trail, then the number of edges of the trail incident to $v_k$ is odd, but deg $v_k$ is even $\Rightarrow \exists$ edge of the graph incident to $v_k$ that is not traversed by the trail $v_0 v_1 \dots v_k$. Let $v_k v_{k+1}$ be this edge, then $v_0 v_1 \dots v_k v_{k+1}$ is a trail of length $k+1$ that starts at $v$ and traverses $vw$. Since every edge of the graph is traversed at most once by a trail, the length of any trail in the graph cannot be greater than the number of edges of the graph $\#(E)$. We have shown above that if our trail is not closed, then it can be extended. By successive extensions, we will eventually have constructed a trail that cannot be extended (in at most $\#(E)-1$ steps). Therefore, that trail must be closed. As the edge $vw$ is traversed, this trail in nontrivial $\Rightarrow$ it is a circuit. 67 | \item[qed] 68 | \item[Lemma B:] Let $(V, E)$ be a connected graph s.t. $\forall v \in V$, deg $v$ is even, and let some circuit $v_0 v_1 \dots v_{m-1} v_0$, then $\exists$ another circuit in $(V, E)$ passing through $v_i$ that does not traverse any edge traversed by $v_0 v_1 \dots v_{m-1} v_0$. 69 | \item[Proof:] Let $E'$ be the set of edges not traversed by $v_0 v_1 \dots v_{m-1} v_0$. $(V, E'$ is a subgraph of $(V, E). \forall v \in V, \#$ of edges of $v_0 v_1 \dots v_{m-1} v_0$ incident to $v = d(v) - d'(v)$, where $d(v) =$ def$(v) = \#$ of edges in $(V, E)$ incident to $v$ and $d'(v) = \#$ of edges in $(V, E')$ incident to $v$. By Corollary 1, $d(v) - d'(v)$ is even, but by assumption $d(v) =$ deg $v$ is even $\Rightarrow d'(v)$ is even $\Rightarrow$ the degree of every vertex in the subgraph $(V, E')$ is even. Now consider the vertex $v_i$ in the statement of Lemme B. Some but not all edges incident to $v_i$ are traversed by $v_0 v_1 \dots v_{m-1} v_0 \Rightarrow d'(v_i) > 0$, \textbf{i.e.} at least one edge incident to $v_i$ is in the subgraph $(V, E')$. We are now \underline{exactly} in the scenario described by Lemma A $\Rightarrow$ by Lemma A, $\exists$ circuit in $(V, E')$ passing through $v_i$. This circuit is also a circuit in $(V, E)$ as $(V, E')$ is a subgraph of $(V, E)$, and since all of its edges are in $E'$, this other circuit does not traverse any edge traversed by $v_0 v_1 \dots v_{m-1} v_0$ 70 | \item[qed] 71 | \item[Lemma C:] Suppose that a graph contains a circuit of length $m$ and a circuit of length $n$. Suppose also that no edges of the graph is traversed by both circuits, and that at least one vertex of the graph is common to both circuits, then the graph contains a circuit of length $m+n$. 72 | \item[Proof:] Let $v$ be a vertex of the graph that is common to both circuits. We assume both circuits start and finish at the vertex $v$. Let the first circuit be $vv_1 \dots v_{m-1} v$, and let the second circuit be $vw_1 w_2 \dots w_{n-1} v$. We concatenate the two circuits obtaining a circuit $vv_1 \dots v_{m-1}vw_1w_2 \dots w_{n-1}w$ of length $m+n$ 73 | \item[qed] 74 | \item[Lemma D:] Let $(V, E)$ be a connected graph, and let some trail in this graph be given. Suppose that no vertex of the graph has the property that not all the edges of the graph incident to that vertex are traversed by the trail. Then the given trail is an Eulerian trail. 75 | \item[Proof:] Let $v_1$ be the set of vertices through which the trail passes, and let $v_2$ be the set of vertices through which the trail does not pass. $v=v_1 \cup v_2 \land v_1 \cap v_2 = \emptyset$. The conclusion of Lemma D amounts to showing $v_2 = \emptyset. \forall u \in v_1, u$ is incident to at least one edge traversed by the trail. $\Rightarrow$ all edges incident to the vertices in $v_1$ are traversed by the trail, but then every vertex in $v$ adjacent to a vertex in $v_1$ must belong to $v_1 \Rightarrow$ no edge can join a vertex in $v_1$ to a vertex in $v_2$. If $v_2 \neq \emptyset$, then $\exists w \in v_2$, but then $w$ cannot be joined by a path to any vertex in $v_1 \Rightarrow v_1 \land v_2$ are in different connected components of the graph $\Rightarrow \Leftarrow$ since the graph is connected $\Rightarrow$ it has only one connected component. Therefore, $v_2 = \emptyset$. 76 | \item[qed] 77 | \end{description} 78 | Finally, we can prove Euler's theorem: 79 | \begin{description} 80 | \item[Theorem] A non-trivial connected graph contains an Eulerian circuit if the degree of every vertex of the graph is even. 81 | \item[Proof:] Let $(V, E)$ be a non-trivial connected graph s.t. $\forall v \in V$, deg $v$ is even. By Lemma A, $(V, E)$ contains at least one circuit. It therefore contains a circuit of maximal length (\textbf{i.e.} at least as long as any other circuit in the graph). We seek to prove that this circuit of maximal length is indeed Eulerian. \\ 82 | If the graph contains some vertex $v$ s.t. some but not all of the edges of the graph incident to $v$ are traversed by the circuit of maximal length, and $v$ is a vertex on the circuit of maximal length, then by Lemma B $\exists$ a second circuit in $(V, E)$ passing through $v$, which would not traverse any edge traversed by the circuit of maximal length. By Lemma C, however, we can concatenate the two circuits, obtaining a circuit of length strictly greater than the length of the circuit of maximal length $\Rightarrow \Leftarrow$ we conclude no vertex that belongs to the circuit of maximal length has the property that not all edges incident to it are traversed by the circuit of maximal length. Since $(V, E)$ is connected, by Lemma D, the circuit of maximal length must be Eulerian. 83 | \item[qed] 84 | \end{description} 85 | Corollary 2 along with this theorem together gives us: 86 | \begin{description} 87 | \item[Theorem:] A non-trivial connected graph has an Eulerian circuit $\Leftrightarrow$ the degree of each of its vertices is even. 88 | \item[Corollary:] Suppose a connected graph has exactly two vertices whose degree is odd. $\exists$ an Eulerian trail in the graph joining the two vertices with odd degrees. 89 | \item[Proof:] We reduce this case to the previous one by embedding the graph $(V, E)$ with vertices $v, w$ that have odd degree into a graph $(V', E')$ s.t. $v' = v \cup \{u\}$ for $u \notin V$ and $E' = E \cup \{uv, uw\}$. $(V, E)$ is a subgraph of $(V' E')$ and $(V', E')$ is connected and each one of its vertices has even degree by construction. By the theorem we just proved, $(V', E')$ has an Eulerian circuit. We reorder the vertices so that the final two edges are the two added edges $wu$ and $uv$. We now delete the edges $wu$ and $uv$ to obtain an Eulerian trail in the original graph $(V, E)$ from $v$ to $w$. 90 | \item[qed] 91 | \end{description} 92 | 93 | 94 | \end{document} -------------------------------------------------------------------------------- /sections/31-HamiltonianPathsAndCircuits.tex: -------------------------------------------------------------------------------- 1 | \documentclass[../main.tex] 2 | 3 | \begin{document} 4 | \section{Hamiltonian Paths and Circuits} 5 | \begin{description} 6 | \item[Task:] Look at paths and circuits that pass through every vertex of a graph. 7 | \item[Definition:] A \underline{Hamiltonian path} in a graph is a path that passed exactly once through every vertex of a graph. \\ 8 | Path $\Rightarrow$ we pass through a vertex at most once (no repeated vertices) \\ 9 | Hamiltonian $\Rightarrow$ we pass through every vertex. 10 | \item[Definition:] A \underline{Hamiltonian circuit} in a graph is a simple circuit that passes through every vertex of the graph. 11 | \item[Origin of the Terminology:] Named after William Roman Hamilton (1805-1865) who showed in 1856 that such a circuit exists in the graph consisting of the verices and edges of a dodecahedron (see page 88 in David Wilkins' notes for the picture of a Hamiltonian circuit on a dodecahedron). Hamilton developed a game called Hamilton's puzzle of the icosian game in 1857 whom object was to find Hamiltonian circuits in the dodecahedrom (many solutions exist). This game was marketed in Europe as a pigboard with holes for each vertex of the dodecaherdrom. \\ 12 | \textbf{NB:} The dodecahedron is a Platonic solid, and it turns out every Platonic solid has a Hamiltonian circuit. Recall that the Platonic solids are the tetrahedron (4 faces), the cube (6 faces), the octahedron (8 faces), the dodecahedron (12 faces), and the icosahedron (20 faces). Each of these is a regular graph. 13 | \item[Theorem:] Every complete graph $k_n$ for $n \geq 3$ has a Hamiltonian circuit. 14 | \item[Proof:] Let $V = \{v_1, v_2, v_3, \dots v_n\}$ be the set of vertices of $k_n$, then $v_1 v_2 v_3 \dots v_n v_1$ is a Hamiltonian circuit. All edges in this circuit are part of $k_n$ because $k_n$ is complete. 15 | \item[qed] 16 | \end{description} 17 | 18 | 19 | \end{document} -------------------------------------------------------------------------------- /sections/32-ForestsAndTrees.tex: -------------------------------------------------------------------------------- 1 | \documentclass[../main.tex] 2 | 3 | \begin{document} 4 | \section{Forests and Trees} 5 | \begin{description} 6 | \item[Task:] Use the notion of a circuit to define trees. 7 | \item[Definition:] A graph is called acyclic if it contains no circuits (also known as cycles). 8 | \item[Definition:] A \underline{forest} is an acyclic graph. 9 | \item[Definition:] A \underline{tree} is a connected forest. 10 | \item[Examples:] 11 | \begin{enumerate} 12 | \item[] 13 | \item Is a tree and a forest. 14 | \begin{figure}[h!] 15 | \centering 16 | \begin{tikzpicture} 17 | \draw (0, 0) -- (0, -2) -- (-1, -2.5); 18 | \draw (-1, -1.5) -- (0, -1) -- (1, -1.5); 19 | \draw (0, -2) -- (1, -2.5); 20 | \end{tikzpicture} 21 | \end{figure} 22 | \item Is a forest with 2 connected components (\textbf{i.e.} it consists of 2 trees.) 23 | \begin{figure}[h!] 24 | \centering 25 | \begin{tikzpicture} 26 | \coordinate (A) at (-3, 0); 27 | \coordinate (G) at (3, 0); 28 | \coordinate (C) at (-3, 1); 29 | \coordinate (H) at (3, 1); 30 | \coordinate (I) at (2.3, -0.7); 31 | \coordinate (J) at (3.7, -0.7); 32 | \coordinate (D) at (-3.7, 0.5); 33 | \coordinate (E) at (-3.6, -0.7); 34 | \coordinate (F) at (-2.3, -0.7); 35 | \coordinate (B) at (-2.3, 0.5); 36 | 37 | \draw (H) -- (G) -- (I); 38 | \draw (G) -- (J); 39 | 40 | \draw (D) -- (A) -- (C); 41 | \draw (B) -- (A) -- (F); 42 | \draw (A) -- (E); 43 | \end{tikzpicture} 44 | \end{figure} 45 | \end{enumerate} 46 | \item[Theorem:] Every forest contains at least one isolated or pendant vertex. 47 | \item[Proof:] Recall that when we studied circuits we proved a theorem that if $(V, E)$ is a graph s.t. $\forall v \in V$ deg $v \geq 2$ (\textbf{i.e.} $(V, E)$ has no isolated or pendant vertices), then $(V, E)$ contains at least one simple circuit. The graph $(V, E)$ is a forect, \textbf{i.e.} it contains no circuits $\Rightarrow \exists v \in V$ s.t. deg $v = 0$ or deg $v = 1$ 48 | \item[qed] 49 | \item[Theorem:] A non-trivial tree contains at least one pendant vertex. 50 | \item[Proof:] A non-trivial tree $(V, E)$ must contain at least 2 vertices. Assum $\exists v \in V$ s.t. deg $v = 0$,\textbf{i.e.} $v$ is isolated, then $v$ forms a connected component by itself, but then $(V, E)$ has at least 2 connected components as $\#(V) \geq 2 \Rightarrow \Leftarrow$ to the fact that a tree is by definition connected. Therefore, $\forall v \in V,$ deg $v \geq 1$, but by the previous theorem $\exists v \in V$ s.t. $0 \leq$ deg $v \leq 1 \Rightarrow \exists v \in V$ s.t. deg $v = 1$ (since a tree is a forest). 51 | \item[qed] 52 | \item[Theorem:] Let $(V, E)$ be a tree, then $\# (E) = \# (V) - 1$, where $\#(E)$ is the number of edges of the tree and $\#(V)$ is the number of vertices. 53 | \item[Proof:] Use strong induction on $\#(V)$. 54 | \begin{description} 55 | \item[Base Case:] $\#(V) = 1$. The graph is trivial $\Rightarrow \#(E) = 0$, so $0 = 1-1$ as needed. 56 | \item[Inductive Step:] Suppose that every tree with $m$ vertices ($\# (V) = m$) has $m-1 = \#(v) -1 = \#(E)$ edges we seek to prove that if $(V, E)$ is a tree with $m+1$ vertices, then it has $m$ edges. \\ 57 | By the previous theorem, $(V, E)$ has one pendent vertex. Let that vertex be $v$. Since deg $v = 1$, then there is only one edge incident to $v$. Let $vw$ be that edge. $w$ is then the only vertex of $(V, E)$ adjacent to $v$. We wish to reduce to the inductive hypothesis, the most natural way is to delete $w$ from $v$ and $vw$ from $E$. Let $V' = V \backslash \{v\}$ and $E' = E \backslash\{vw\} = \#(E) -1$. To use the inductive hyptohetsis, we must show $(V', E')$ is a tree, \textbf{i.e.} $(V', E')$ is connected and $(V' E')$ contains no circuits. $\forall v_1, v_2 \in V'$, since $(V, E)$ is a tree hence connected, $\exists$ path from $v_1$ to $v_2$ in $(V, E)$. This path cannot pass throgh $v$ because deg $v = 1 \Rightarrow$ is would have to pass through $v$ twice contradicting the fact that is it a path (all vertices are distinct) $\Rightarrow$ this path is in $(V', E') \Rightarrow (V' E')$ is connected. \\ 58 | $(V', E')$ is a subgraph of $(V, E)$, which is a tree, hence does not containa ny circuits, so $(V', E')$ contains no circuits. \\ 59 | $(V', E')$ is thus a tree, $\Rightarrow$ by the inductive hypothetsis, $\# (V') = \# (V) -1 = \# (E') - 1 = \# (E) -1 -1 = \#(E) - 2 \Rightarrow \#(V) -1 = \#(E) - 2 \Leftrightarrow \# (V) = \# (E)-1$ as needed. 60 | \item[qed] 61 | \end{description} 62 | \end{description} 63 | 64 | \end{document} 65 | -------------------------------------------------------------------------------- /sections/33-CountabilityOfSets.tex: -------------------------------------------------------------------------------- 1 | \section{Countability of Sets} 2 | \begin{description} 3 | \item[Task:] Understand what it means for a set to be countable, countably infinite and uncountably infinite. Show that the set of all languages over a finite alphabet is uncountably infinite, wheras the set ofa ll regular languages over a finite alphabet is countably infinite. 4 | \end{description} 5 | We want to understand sizes of sets. 6 | In the unit on functions last term, when we looked at functions defined on finite sets, we wrote down a set A with m elements as $A = \{a_1, \dots, a_n\}$. 7 | This notation \underline{mimics the process of counting:} $a_1$ is the first element of $A$, $a_2$ is the second element of $A$, and so on up to $a_n$ is the $n^th$ element of $A$. 8 | In other words, another way of saying $A$ in a set of $n$ elements is that there exists a bijective function $f: A \rightarrow \{1, 2, \dots, n\}$. 9 | 10 | \begin{description} 11 | \item[Definition:] A set $A$ has $n$ elements $\leftrightarrow \exists f: A \rightarrow J_n$ a bijection. 12 | \item[NB:] This definition works $\forall n \geq 1, n \in \mathbb{N}^\ast$ 13 | \item[Notation:] $\exists f: A \rightarrow J_n$ a bijection is denoted as $A \sim J_n$. 14 | More generally, $A \sim B$ means $\exists f: A \rightarrow B$ a bijection, and it is a relation on sets. 15 | In fact, it is an equivalence relation (check!). $[J_n]$ is the equivalence class of all sets $A$ of size $n$, i.e. $\#(A) = n$. 16 | \end{description} 17 | 18 | \begin{description} 19 | \item[Definition:] A set $A$ is \underline{finite} if $A \sim J_n$ for some $n \in \mathbb{N}^\ast$ or $A = \emptyset$. 20 | \item[Definition:] A set $A$ is \underline{infinite} if $A$ is not finite. 21 | \item[Examples:] $\mathbb{N, Q, R,}$ etc. 22 | \end{description} 23 | 24 | To understand sizes of infinite sets, generalize the construction above. Let $J = \mathbb{N}^\ast = \{1, 2, \dots \}$ 25 | 26 | \begin{description} 27 | \item[Definition:] A set $A$ is \underline{uncountably infinite} if $A$ is neither finite nor countably infinite. 28 | In fact, we often treat together the cases $A$ is finite or $A$ is countably infinite since in both of these cases the counting mechanism that is so familiar to us works. 29 | Therefore, we have the following definition: 30 | \item[Definition:] A set $A$ is \underline{countable} if $A$ is finite ($A \sim J_n$ or $A = \emptyset$) or $A$ is countably infinite ($A \sim J$). 31 | \end{description} 32 | There is a difference in the terminology regarding countability between CS sources (textbooks, articles, etc.) and maths sources. 33 | This is the dictionary: 34 | \centerline{ 35 | \begin{tabular}{|c|c|} 36 | \hline 37 | CS & Maths \\ 38 | \hline 39 | countable & at most countable \\ 40 | \hline 41 | countably infinite & countable \\ 42 | \hline 43 | uncountably infinite & uncountable \\ 44 | \hline 45 | \end{tabular} 46 | } 47 | It's best to double check which terminology a source is using. 48 | 49 | \begin{description} 50 | \item[Goal:] Characterize $[\mathbb{N}]$, the equivalence class of countably infinite set, and $[\mathbb{R}]$, the equivalence class of uncountably infinite sets the same size as $\mathbb{R}$. 51 | \item[Bad news:] Both $[\mathbb{N}]$ and $[\mathbb{R}]$ consist of ininite sets. 52 | \item[Good news:] We only care about these two equivalence classes. 53 | \item[NB:] There are uncountably infinite sets of size bigger than $[\mathbb{R}]$ that can be obtained from the power set construction, but it is unlikely you will see them in your CS coursework. 54 | \end{description} 55 | 56 | To characterize $[\mathbb{N}]$, we need to recall the notion of a sequence: 57 | 58 | \begin{description} 59 | \item[Definition:] A \underline{sequence} is a set of elements $\{x_1, x_2, \dots\}$ indexed by $J$, i.e. $\exists f: \rightarrow \{x_1, x_2, \dots\}$ s.t. $f(n) = x_n \forall n \in J$. 60 | \end{description} 61 | Recall that sequences and their limits are used to define various notions in calculus (differentiation, integration, etc.). 62 | Also, calculators use sequences in order to compute with various rational and irrational numbers. 63 | --------------------------------------------------------------------------------