handouts/notation.tex
author Christian Urban <urbanc@in.tum.de>
Tue, 26 Sep 2017 13:46:45 +0100
changeset 502 bf1c472b244e
parent 496 5c9de27a5b30
child 505 5b9cf7fbd51a
permissions -rw-r--r--
updated
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
239
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     1
\documentclass{article}
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     2
\usepackage{../style}
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     3
\usepackage{../langs}
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     4
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     5
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     6
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     7
\begin{document}
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     8
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     9
\section*{A Crash-Course on Notation}
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    10
476
d922cc83b70c updated
Christian Urban <urbanc@in.tum.de>
parents: 404
diff changeset
    11
There are innumerable books available about compilers, automata theory
d922cc83b70c updated
Christian Urban <urbanc@in.tum.de>
parents: 404
diff changeset
    12
and formal languages. Unfortunately, they often use their own
d922cc83b70c updated
Christian Urban <urbanc@in.tum.de>
parents: 404
diff changeset
    13
notational conventions and their own symbols. This handout is meant to
502
bf1c472b244e updated
Christian Urban <urbanc@in.tum.de>
parents: 496
diff changeset
    14
clarify some of the notation I will use. I apologise in advance that
476
d922cc83b70c updated
Christian Urban <urbanc@in.tum.de>
parents: 404
diff changeset
    15
sometimes I will be a bit fuzzy\ldots the problem is that often we
d922cc83b70c updated
Christian Urban <urbanc@in.tum.de>
parents: 404
diff changeset
    16
want to have convenience in our mathematical definitions (to make them
d922cc83b70c updated
Christian Urban <urbanc@in.tum.de>
parents: 404
diff changeset
    17
readable and understandable), but other times we need pedantic
d922cc83b70c updated
Christian Urban <urbanc@in.tum.de>
parents: 404
diff changeset
    18
precision for actual programs.
241
10f02605a46a polished
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 239
diff changeset
    19
239
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    20
\subsubsection*{Characters and Strings}
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    21
241
10f02605a46a polished
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 239
diff changeset
    22
The most important concept in this module are strings. Strings
10f02605a46a polished
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 239
diff changeset
    23
are composed of \defn{characters}. While characters are surely
10f02605a46a polished
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 239
diff changeset
    24
a familiar concept, we will make one subtle distinction in
10f02605a46a polished
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 239
diff changeset
    25
this module. If we want to refer to concrete characters, like
332
4755ad4b457b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
    26
\code{a}, \code{b}, \code{c} and so on, we use a typewriter font.
241
10f02605a46a polished
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 239
diff changeset
    27
Accordingly if we want to refer to the concrete characters of
10f02605a46a polished
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 239
diff changeset
    28
my email address we shall write
239
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    29
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    30
\begin{center}
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    31
\pcode{christian.urban@kcl.ac.uk}
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    32
\end{center}
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    33
241
10f02605a46a polished
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 239
diff changeset
    34
\noindent If we also need to explicitly indicate the ``space''
239
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    35
character, we write \VS{}\hspace{1mm}. For example
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    36
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    37
\begin{center}
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    38
\tt{}hello\VS\hspace{0.5mm}world
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    39
\end{center}
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    40
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    41
241
10f02605a46a polished
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 239
diff changeset
    42
\noindent But often we do not care which particular characters
10f02605a46a polished
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 239
diff changeset
    43
we use. In such cases we use the italic font and write $a$,
332
4755ad4b457b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
    44
$b$, $c$ and so on for characters. Therefore if we need a
239
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    45
representative string, we might write
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    46
404
245d302791c7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 398
diff changeset
    47
\[
239
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    48
abracadabra
404
245d302791c7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 398
diff changeset
    49
\]
239
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    50
241
10f02605a46a polished
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 239
diff changeset
    51
\noindent In this string, we do not really care what the
10f02605a46a polished
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 239
diff changeset
    52
characters stand for, except we do care about the fact that
10f02605a46a polished
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 239
diff changeset
    53
for example the character $a$ is not equal to $b$ and so on.
404
245d302791c7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 398
diff changeset
    54
Why do I make this distinction? Because we often need to
245d302791c7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 398
diff changeset
    55
define functions using variables ranging over characters. We
245d302791c7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 398
diff changeset
    56
need to somehow say this is a variable, say $c$, ranging over
502
bf1c472b244e updated
Christian Urban <urbanc@in.tum.de>
parents: 496
diff changeset
    57
characters, while this is the actual character \pcode{c}.
239
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    58
241
10f02605a46a polished
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 239
diff changeset
    59
An \defn{alphabet} is a (non-empty) finite set of characters.
10f02605a46a polished
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 239
diff changeset
    60
Often the letter $\Sigma$ is used to refer to an alphabet. For
10f02605a46a polished
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 239
diff changeset
    61
example the ASCII characters \pcode{a} to \pcode{z} form an
10f02605a46a polished
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 239
diff changeset
    62
alphabet. The digits $0$ to $9$ are another alphabet. The
10f02605a46a polished
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 239
diff changeset
    63
Greek letters $\alpha$ to $\omega$ also form an alphabet. If
10f02605a46a polished
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 239
diff changeset
    64
nothing else is specified, we usually assume the alphabet
10f02605a46a polished
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 239
diff changeset
    65
consists of just the lower-case letters $a$, $b$, \ldots, $z$.
10f02605a46a polished
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 239
diff changeset
    66
Sometimes, however, we explicitly want to restrict strings to
10f02605a46a polished
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 239
diff changeset
    67
contain only the letters $a$ and $b$, for example. In this
10f02605a46a polished
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 239
diff changeset
    68
case we will state that the alphabet is the set $\{a, b\}$. 
239
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    69
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    70
\defn{Strings} are lists of characters. Unfortunately, there
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    71
are many ways how we can write down strings. In programming
496
5c9de27a5b30 updated
Christian Urban <urbanc@in.tum.de>
parents: 476
diff changeset
    72
languages, they are usually written as \dq{\texttt{hello}} where the
404
245d302791c7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 398
diff changeset
    73
double quotes indicate that we are dealing with a string. In
496
5c9de27a5b30 updated
Christian Urban <urbanc@in.tum.de>
parents: 476
diff changeset
    74
typed programming languages, such as Scala, strings have a special
404
245d302791c7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 398
diff changeset
    75
type---namely \pcode{String} which is different from the type
502
bf1c472b244e updated
Christian Urban <urbanc@in.tum.de>
parents: 496
diff changeset
    76
for lists of characters. This is because strings can be
bf1c472b244e updated
Christian Urban <urbanc@in.tum.de>
parents: 496
diff changeset
    77
efficiently represented in memory, unlike lists. Since
bf1c472b244e updated
Christian Urban <urbanc@in.tum.de>
parents: 496
diff changeset
    78
\code{String} and the type of lists of characters
bf1c472b244e updated
Christian Urban <urbanc@in.tum.de>
parents: 496
diff changeset
    79
(\code{List[Char]}) are not the same, we need to explicitly
404
245d302791c7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 398
diff changeset
    80
coerce elements between the two types, for example
245d302791c7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 398
diff changeset
    81
245d302791c7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 398
diff changeset
    82
\begin{lstlisting}[numbers=none]
245d302791c7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 398
diff changeset
    83
scala> "abc".toList
245d302791c7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 398
diff changeset
    84
res01: List[Char] = List(a, b, c)
245d302791c7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 398
diff changeset
    85
\end{lstlisting}
245d302791c7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 398
diff changeset
    86
502
bf1c472b244e updated
Christian Urban <urbanc@in.tum.de>
parents: 496
diff changeset
    87
\noindent
bf1c472b244e updated
Christian Urban <urbanc@in.tum.de>
parents: 496
diff changeset
    88
However, we do not want to do this kind of explicit coercion in our
bf1c472b244e updated
Christian Urban <urbanc@in.tum.de>
parents: 496
diff changeset
    89
pencil-and-paper, everyday arguments.  So in our (mathematical)
bf1c472b244e updated
Christian Urban <urbanc@in.tum.de>
parents: 496
diff changeset
    90
definitions we regard strings as lists of characters, we will also
bf1c472b244e updated
Christian Urban <urbanc@in.tum.de>
parents: 496
diff changeset
    91
write \dq{$hello$} as
239
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    92
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    93
\[
404
245d302791c7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 398
diff changeset
    94
[\text{\it h, e, l, l, o}] \qquad\text{or simply}\qquad \textit{hello}
239
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    95
\]
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    96
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    97
\noindent The important point is that we can always decompose
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    98
such strings. For example, we will often consider the first
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    99
character of a string, say $h$, and the ``rest'' of a string
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   100
say \dq{\textit{ello}} when making definitions about strings.
241
10f02605a46a polished
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 239
diff changeset
   101
There are also some subtleties with the empty string,
10f02605a46a polished
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 239
diff changeset
   102
sometimes written as \dq{} but also as the empty list of
10f02605a46a polished
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 239
diff changeset
   103
characters $[\,]$.\footnote{In the literature you can also
10f02605a46a polished
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 239
diff changeset
   104
often find that $\varepsilon$ or $\lambda$ is used to
10f02605a46a polished
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 239
diff changeset
   105
represent the empty string.} 
10f02605a46a polished
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 239
diff changeset
   106
10f02605a46a polished
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 239
diff changeset
   107
Two strings, say $s_1$ and $s_2$, can be \defn{concatenated},
404
245d302791c7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 398
diff changeset
   108
which we write as $s_1 @ s_2$. If we regard $s_1$ and $s_2$ as
245d302791c7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 398
diff changeset
   109
lists of characters, then $@$ is the list-append function.
245d302791c7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 398
diff changeset
   110
Suppose we are given two strings \dq{\textit{foo}} and
502
bf1c472b244e updated
Christian Urban <urbanc@in.tum.de>
parents: 496
diff changeset
   111
\dq{\textit{bar}}, then their concatenation, written
404
245d302791c7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 398
diff changeset
   112
\dq{\textit{foo}} $@$ \dq{\textit{bar}}, gives
245d302791c7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 398
diff changeset
   113
\dq{\textit{foobar}}. But as said above, we will often
245d302791c7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 398
diff changeset
   114
simplify our life and just drop the double quotes whenever it
245d302791c7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 398
diff changeset
   115
is clear we are talking about strings, So we will often just
245d302791c7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 398
diff changeset
   116
write \textit{foo}, \textit{bar}, \textit{foobar} or
245d302791c7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 398
diff changeset
   117
\textit{foo $@$ bar}.
239
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   118
496
5c9de27a5b30 updated
Christian Urban <urbanc@in.tum.de>
parents: 476
diff changeset
   119
Occasionally we will use the notation $a^n$ for strings, which stands
5c9de27a5b30 updated
Christian Urban <urbanc@in.tum.de>
parents: 476
diff changeset
   120
for the string of $n$ repeated $a$s. So $a^{n}b^{n}$ is a string that
502
bf1c472b244e updated
Christian Urban <urbanc@in.tum.de>
parents: 496
diff changeset
   121
has some number of $a$s followed by the same number of $b$s.  A simple
bf1c472b244e updated
Christian Urban <urbanc@in.tum.de>
parents: 496
diff changeset
   122
property of string concatenation is \emph{associativity}, meaning
239
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   123
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   124
\[(s_1 @ s_2) @ s_3 = s_1 @ (s_2 @ s_3)\]  
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   125
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   126
\noindent are always equal strings. The empty string behaves
404
245d302791c7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 398
diff changeset
   127
like a \emph{unit element}, therefore
239
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   128
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   129
\[s \,@\, [] = [] \,@\, s = s\]
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   130
241
10f02605a46a polished
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 239
diff changeset
   131
239
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   132
\subsubsection*{Sets and Languages}
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   133
241
10f02605a46a polished
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 239
diff changeset
   134
We will use the familiar operations $\cup$, $\cap$, $\subset$
10f02605a46a polished
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 239
diff changeset
   135
and $\subseteq$ for sets. For the empty set we will either
10f02605a46a polished
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 239
diff changeset
   136
write $\varnothing$ or $\{\,\}$. The set containing the
10f02605a46a polished
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 239
diff changeset
   137
natural numbers $1$, $2$ and $3$, for example, we will write
10f02605a46a polished
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 239
diff changeset
   138
with curly braces as
239
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   139
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   140
\[
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   141
\{1, 2, 3\}
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   142
\]
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   143
496
5c9de27a5b30 updated
Christian Urban <urbanc@in.tum.de>
parents: 476
diff changeset
   144
\noindent The notation $\in$ means \emph{element of}, so $1 \in \{1,
502
bf1c472b244e updated
Christian Urban <urbanc@in.tum.de>
parents: 496
diff changeset
   145
2, 3\}$ is true and $4 \in \{1, 2, 3\}$ is false.  Note that the
496
5c9de27a5b30 updated
Christian Urban <urbanc@in.tum.de>
parents: 476
diff changeset
   146
\emph{list} $[1, 2, 3]$ is something different from the \emph{set}
5c9de27a5b30 updated
Christian Urban <urbanc@in.tum.de>
parents: 476
diff changeset
   147
$\{1, 2, 3\}$: in the former we care about the order and potentially
5c9de27a5b30 updated
Christian Urban <urbanc@in.tum.de>
parents: 476
diff changeset
   148
several occurrences of a number; while with the latter we do not.
502
bf1c472b244e updated
Christian Urban <urbanc@in.tum.de>
parents: 496
diff changeset
   149
Also sets can potentially have infinitely many elements, whereas lists
bf1c472b244e updated
Christian Urban <urbanc@in.tum.de>
parents: 496
diff changeset
   150
cannot. For example
496
5c9de27a5b30 updated
Christian Urban <urbanc@in.tum.de>
parents: 476
diff changeset
   151
the set of all natural numbers $\{0, 1, 2, \ldots\}$ is infinite. This
5c9de27a5b30 updated
Christian Urban <urbanc@in.tum.de>
parents: 476
diff changeset
   152
set is often also abbreviated as $\mathbb{N}$. Lists can be very large, but they cannot contain infinitely many elements.
5c9de27a5b30 updated
Christian Urban <urbanc@in.tum.de>
parents: 476
diff changeset
   153
5c9de27a5b30 updated
Christian Urban <urbanc@in.tum.de>
parents: 476
diff changeset
   154
We can define sets by giving all elements, for example $\{0, 1\}$ for
5c9de27a5b30 updated
Christian Urban <urbanc@in.tum.de>
parents: 476
diff changeset
   155
the set containing just $0$ and $1$, but also by \defn{set
5c9de27a5b30 updated
Christian Urban <urbanc@in.tum.de>
parents: 476
diff changeset
   156
  comprehensions}. For example the set of all even natural numbers can
5c9de27a5b30 updated
Christian Urban <urbanc@in.tum.de>
parents: 476
diff changeset
   157
be defined as
239
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   158
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   159
\[
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   160
\{n\;|\;n\in\mathbb{N} \wedge n\;\text{is even}\}
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   161
\]
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   162
  
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   163
\noindent Though silly, but the set $\{0, 1, 2\}$ could also be
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   164
defined by the following set comprehension
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   165
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   166
\[
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   167
\{n\;|\; n^2 < 9 \wedge n \in \mathbb{N}\}
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   168
\]
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   169
496
5c9de27a5b30 updated
Christian Urban <urbanc@in.tum.de>
parents: 476
diff changeset
   170
\noindent Can you see why this defines the set $\{0, 1, 2\}$?  Notice
5c9de27a5b30 updated
Christian Urban <urbanc@in.tum.de>
parents: 476
diff changeset
   171
that set comprehensions could be used to define set union,
5c9de27a5b30 updated
Christian Urban <urbanc@in.tum.de>
parents: 476
diff changeset
   172
intersection and difference:
239
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   173
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   174
\begin{eqnarray*}
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   175
A \cup B & \dn & \{x\;|\; x \in A \vee x \in B\}\\
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   176
A \cap B & \dn & \{x\;|\; x \in A \wedge x \in B\}\\
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   177
A \backslash B & \dn & \{x\;|\; x \in A \wedge x \not\in B\} 
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   178
\end{eqnarray*}
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   179
241
10f02605a46a polished
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 239
diff changeset
   180
\noindent In general set comprehensions are of the form
10f02605a46a polished
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 239
diff changeset
   181
$\{a\;|\;P\}$ which stands for the set of all elements $a$
10f02605a46a polished
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 239
diff changeset
   182
(from some set) for which some property $P$ holds.
10f02605a46a polished
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 239
diff changeset
   183
 
10f02605a46a polished
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 239
diff changeset
   184
For defining sets, we will also often use the notion of the
10f02605a46a polished
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 239
diff changeset
   185
``big union''. An example is as follows:
239
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   186
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   187
\begin{equation}\label{bigunion}
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   188
\bigcup_{0\le n}\; \{n^2, n^2 + 1\}
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   189
\end{equation}
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   190
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   191
\noindent which is the set of all squares and their immediate
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   192
successors, so
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   193
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   194
\[
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   195
\{0, 1, 2, 4, 5, 9, 10, 16, 17, \ldots\}
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   196
\]
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   197
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   198
\noindent A big union is a sequence of unions which are 
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   199
indexed typically by a natural number. So the big union in
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   200
\eqref{bigunion} could equally be written as
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   201
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   202
\[
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   203
\{0, 1\} \cup \{1, 2\} \cup \{4, 5\} \cup \{9, 10\} \cup 
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   204
\ldots
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   205
\]
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   206
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   207
\noindent but using the big union notation is more concise.
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   208
502
bf1c472b244e updated
Christian Urban <urbanc@in.tum.de>
parents: 496
diff changeset
   209
As an aside: While this stuff about sets might all look trivial or even needlessly
496
5c9de27a5b30 updated
Christian Urban <urbanc@in.tum.de>
parents: 476
diff changeset
   210
pedantic, \emph{Nature} is never simple. If you want to be amazed how
5c9de27a5b30 updated
Christian Urban <urbanc@in.tum.de>
parents: 476
diff changeset
   211
complicated sets can get, watch out for the last lecture just before
5c9de27a5b30 updated
Christian Urban <urbanc@in.tum.de>
parents: 476
diff changeset
   212
Christmas where I want to convince you of the fact that some sets are
5c9de27a5b30 updated
Christian Urban <urbanc@in.tum.de>
parents: 476
diff changeset
   213
more infinite than others. Yes, you read correctly, there can be sets
5c9de27a5b30 updated
Christian Urban <urbanc@in.tum.de>
parents: 476
diff changeset
   214
that are ``more infinite'' then others. If you think this is obvious:
502
bf1c472b244e updated
Christian Urban <urbanc@in.tum.de>
parents: 496
diff changeset
   215
say you have the infinite set $\mathbb{N}\backslash\{0\} = \{1, 2, 3, 4, \ldots\}$ which is all
496
5c9de27a5b30 updated
Christian Urban <urbanc@in.tum.de>
parents: 476
diff changeset
   216
the natural numbers except $0$, and then compare it to the set
502
bf1c472b244e updated
Christian Urban <urbanc@in.tum.de>
parents: 496
diff changeset
   217
$\{0, 1, 2, 3, 4, \ldots\}$ which contains the $0$. If you think,
bf1c472b244e updated
Christian Urban <urbanc@in.tum.de>
parents: 496
diff changeset
   218
the second must be more infinite\ldots{} well, then think again. Because the two
496
5c9de27a5b30 updated
Christian Urban <urbanc@in.tum.de>
parents: 476
diff changeset
   219
infinite sets
5c9de27a5b30 updated
Christian Urban <urbanc@in.tum.de>
parents: 476
diff changeset
   220
5c9de27a5b30 updated
Christian Urban <urbanc@in.tum.de>
parents: 476
diff changeset
   221
\begin{center}
5c9de27a5b30 updated
Christian Urban <urbanc@in.tum.de>
parents: 476
diff changeset
   222
  $\{1, 2, 3, 4, \ldots\}$ and
5c9de27a5b30 updated
Christian Urban <urbanc@in.tum.de>
parents: 476
diff changeset
   223
  $\{0, 1, 2, 3, 4, \ldots\}$
5c9de27a5b30 updated
Christian Urban <urbanc@in.tum.de>
parents: 476
diff changeset
   224
\end{center}
5c9de27a5b30 updated
Christian Urban <urbanc@in.tum.de>
parents: 476
diff changeset
   225
5c9de27a5b30 updated
Christian Urban <urbanc@in.tum.de>
parents: 476
diff changeset
   226
\noindent
5c9de27a5b30 updated
Christian Urban <urbanc@in.tum.de>
parents: 476
diff changeset
   227
contain actually the same number of elements. Does this make sense?
5c9de27a5b30 updated
Christian Urban <urbanc@in.tum.de>
parents: 476
diff changeset
   228
Though this might all look strange this about infinite sets will be a
5c9de27a5b30 updated
Christian Urban <urbanc@in.tum.de>
parents: 476
diff changeset
   229
topic that is very relevant to the material of this module. It tells
5c9de27a5b30 updated
Christian Urban <urbanc@in.tum.de>
parents: 476
diff changeset
   230
us what we can compute with a computer (actually algorithm) and what
502
bf1c472b244e updated
Christian Urban <urbanc@in.tum.de>
parents: 496
diff changeset
   231
we cannot. But during the first 9 lectures we can go by without this
bf1c472b244e updated
Christian Urban <urbanc@in.tum.de>
parents: 496
diff changeset
   232
``weird'' stuff.
404
245d302791c7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 398
diff changeset
   233
245d302791c7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 398
diff changeset
   234
Another important notion in this module are \defn{languages}, which
398
c8ce95067c1a updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 332
diff changeset
   235
are sets of strings. One of the main goals for us will be how to
239
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   236
(formally) specify languages and to find out whether a string
241
10f02605a46a polished
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 239
diff changeset
   237
is in a language or not.\footnote{You might wish to ponder
10f02605a46a polished
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 239
diff changeset
   238
whether this is in general a hard or easy problem, where
10f02605a46a polished
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 239
diff changeset
   239
hardness is meant in terms of Turing decidable, for example.}
10f02605a46a polished
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 239
diff changeset
   240
Note that the language containing the empty string $\{\dq{}\}$
10f02605a46a polished
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 239
diff changeset
   241
is not equal to $\varnothing$, the empty language (or empty
10f02605a46a polished
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 239
diff changeset
   242
set): The former contains one element, namely \dq{} (also
10f02605a46a polished
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 239
diff changeset
   243
written $[\,]$), but the latter does not contain any
10f02605a46a polished
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 239
diff changeset
   244
element.
239
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   245
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   246
For languages we define the operation of \defn{language
241
10f02605a46a polished
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 239
diff changeset
   247
concatenation}, written like in the string case as $A @ B$:
239
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   248
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   249
\begin{equation}\label{langconc}
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   250
A @ B \dn \{s_1 @ s_2\;|\; s_1\in A \wedge s_2\in B\}
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   251
\end{equation}
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   252
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   253
\noindent Be careful to understand the difference: the $@$
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   254
in $s_1 @ s_2$ is string concatenation, while $A @ B$ refers 
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   255
to the concatenation of two languages (or sets of strings).
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   256
As an example suppose $A=\{ab, ac\}$ and $B=\{zzz, qq, r\}$,
241
10f02605a46a polished
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 239
diff changeset
   257
then $A \,@\, B$ is the language
239
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   258
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   259
\[
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   260
\{abzzz, abqq, abr, aczzz, acqq, acr\}
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   261
\] 
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   262
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   263
\noindent Recall the properties for string concatenation. For
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   264
language concatenation we have the following properties
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   265
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   266
\begin{center}
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   267
\begin{tabular}{ll}
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   268
associativity: & $(A @ B) @ C = A @ (B @ C)$\\
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   269
unit element:  & $A \,@\, \{[]\} = \{[]\} \,@\, A = A$\\
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   270
zero element:  & $A \,@\, \varnothing = \varnothing \,@\, A = 
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   271
\varnothing$
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   272
\end{tabular}
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   273
\end{center}
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   274
241
10f02605a46a polished
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 239
diff changeset
   275
\noindent Note the difference in the last two lines: the empty
10f02605a46a polished
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 239
diff changeset
   276
set behaves like $0$ for multiplication and the set $\{[]\}$
242
35104ee14f87 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 241
diff changeset
   277
like $1$ for multiplication ($n * 1 = n$ and $n * 0 = 0$).
239
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   278
502
bf1c472b244e updated
Christian Urban <urbanc@in.tum.de>
parents: 496
diff changeset
   279
Using the operation of language concatenation, we can define a
239
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   280
\defn{language power} operation as follows:
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   281
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   282
\begin{eqnarray*}
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   283
A^0     & \dn & \{[]\}\\
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   284
A^{n+1} & \dn & A \,@\, A^n
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   285
\end{eqnarray*}
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   286
241
10f02605a46a polished
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 239
diff changeset
   287
\noindent This definition is by recursion on natural numbers.
239
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   288
Note carefully that the zero-case is not defined as the empty
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   289
set, but the set containing the empty string. So no matter
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   290
what the set $A$ is, $A^0$ will always be $\{[]\}$. (There is
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   291
another hint about a connection between the $@$-operation and
502
bf1c472b244e updated
Christian Urban <urbanc@in.tum.de>
parents: 496
diff changeset
   292
multiplication: How is $x^n$ defined in mathematics and what is
242
35104ee14f87 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 241
diff changeset
   293
$x^0$?)
239
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   294
242
35104ee14f87 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 241
diff changeset
   295
Next we can define the \defn{star operation} for languages:
404
245d302791c7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 398
diff changeset
   296
$A\star$ is the union of all powers of $A$, or short
239
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   297
241
10f02605a46a polished
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 239
diff changeset
   298
\begin{equation}\label{star}
404
245d302791c7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 398
diff changeset
   299
A\star \dn \bigcup_{0\le n}\; A^n
241
10f02605a46a polished
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 239
diff changeset
   300
\end{equation}
239
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   301
241
10f02605a46a polished
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 239
diff changeset
   302
\noindent This star operation is often also called
10f02605a46a polished
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 239
diff changeset
   303
\emph{Kleene-star}. Unfolding the definition in \eqref{star}
10f02605a46a polished
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 239
diff changeset
   304
gives
239
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   305
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   306
\[
502
bf1c472b244e updated
Christian Urban <urbanc@in.tum.de>
parents: 496
diff changeset
   307
A\star \dn A^0 \cup A^1 \cup A^2 \cup A^3 \cup \ldots
239
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   308
\]
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   309
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   310
\noindent
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   311
which is equal to 
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   312
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   313
\[
502
bf1c472b244e updated
Christian Urban <urbanc@in.tum.de>
parents: 496
diff changeset
   314
A\star \dn \{[]\} \,\cup\, A \,\cup\, A @ A \,\cup\, A @ A @ A \,\cup\, \ldots
239
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   315
\]
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   316
404
245d302791c7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 398
diff changeset
   317
\noindent We can see that the empty string is always in $A\star$,
239
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   318
no matter what $A$ is. This is because $[] \in A^0$. To make
241
10f02605a46a polished
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 239
diff changeset
   319
sure you understand these definitions, I leave you to answer
404
245d302791c7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 398
diff changeset
   320
what $\{[]\}\star$ and $\varnothing\star$ are?
239
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   321
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   322
Recall that an alphabet is often referred to by the letter
404
245d302791c7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 398
diff changeset
   323
$\Sigma$. We can now write for the set of \emph{all} strings
502
bf1c472b244e updated
Christian Urban <urbanc@in.tum.de>
parents: 496
diff changeset
   324
over this alphabet as $\Sigma\star$. In doing so we also include the
404
245d302791c7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 398
diff changeset
   325
empty string as a possible string over $\Sigma$. So if $\Sigma
245d302791c7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 398
diff changeset
   326
= \{a, b\}$, then $\Sigma\star$ is
239
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   327
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   328
\[
246
baf41b05210f updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 242
diff changeset
   329
\{[], a, b, aa, ab, ba, bb, aaa, aab, aba, abb, baa, bab, \ldots\}
239
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   330
\]
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   331
246
baf41b05210f updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 242
diff changeset
   332
\noindent or in other words all strings containing $a$s and
baf41b05210f updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 242
diff changeset
   333
$b$s only, plus the empty string.
239
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   334
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   335
\end{document}
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   336
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   337
%%% Local Variables: 
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   338
%%% mode: latex
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   339
%%% TeX-master: t
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   340
%%% End: