handouts/notation.tex
author Christian Urban <urbanc@in.tum.de>
Tue, 01 Oct 2019 23:49:39 +0100
changeset 643 08375ca3874e
parent 550 71fc4a7a7039
child 736 d3e477fe6c66
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}
550
71fc4a7a7039 updated
Christian Urban <urbanc@in.tum.de>
parents: 505
diff changeset
     8
\fnote{\copyright{} Christian Urban, King's College London, 2014, 2015, 2016, 2017, 2018}
505
5b9cf7fbd51a updated
Christian Urban <urbanc@in.tum.de>
parents: 502
diff changeset
     9
239
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    10
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    11
\section*{A Crash-Course on Notation}
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    12
476
d922cc83b70c updated
Christian Urban <urbanc@in.tum.de>
parents: 404
diff changeset
    13
There are innumerable books available about compilers, automata theory
d922cc83b70c updated
Christian Urban <urbanc@in.tum.de>
parents: 404
diff changeset
    14
and formal languages. Unfortunately, they often use their own
d922cc83b70c updated
Christian Urban <urbanc@in.tum.de>
parents: 404
diff changeset
    15
notational conventions and their own symbols. This handout is meant to
502
bf1c472b244e updated
Christian Urban <urbanc@in.tum.de>
parents: 496
diff changeset
    16
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
    17
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
    18
want to have convenience in our mathematical definitions (to make them
d922cc83b70c updated
Christian Urban <urbanc@in.tum.de>
parents: 404
diff changeset
    19
readable and understandable), but other times we need pedantic
d922cc83b70c updated
Christian Urban <urbanc@in.tum.de>
parents: 404
diff changeset
    20
precision for actual programs.
241
10f02605a46a polished
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 239
diff changeset
    21
239
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    22
\subsubsection*{Characters and Strings}
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    23
241
10f02605a46a polished
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 239
diff changeset
    24
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
    25
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
    26
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
    27
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
    28
\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
    29
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
    30
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
    31
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    32
\begin{center}
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    33
\pcode{christian.urban@kcl.ac.uk}
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    34
\end{center}
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    35
241
10f02605a46a polished
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 239
diff changeset
    36
\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
    37
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
    38
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    39
\begin{center}
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    40
\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
    41
\end{center}
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    42
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    43
241
10f02605a46a polished
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 239
diff changeset
    44
\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
    45
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
    46
$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
    47
representative string, we might write
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    48
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
abracadabra
404
245d302791c7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 398
diff changeset
    51
\]
239
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    52
241
10f02605a46a polished
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 239
diff changeset
    53
\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
    54
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
    55
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
    56
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
    57
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
    58
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
    59
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
    60
241
10f02605a46a polished
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 239
diff changeset
    61
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
    62
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
    63
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
    64
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
    65
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
    66
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
    67
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
    68
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
    69
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
    70
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
    71
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    72
\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
    73
are many ways how we can write down strings. In programming
496
5c9de27a5b30 updated
Christian Urban <urbanc@in.tum.de>
parents: 476
diff changeset
    74
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
    75
double quotes indicate that we are dealing with a string. In
496
5c9de27a5b30 updated
Christian Urban <urbanc@in.tum.de>
parents: 476
diff changeset
    76
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
    77
type---namely \pcode{String} which is different from the type
502
bf1c472b244e updated
Christian Urban <urbanc@in.tum.de>
parents: 496
diff changeset
    78
for lists of characters. This is because strings can be
bf1c472b244e updated
Christian Urban <urbanc@in.tum.de>
parents: 496
diff changeset
    79
efficiently represented in memory, unlike lists. Since
bf1c472b244e updated
Christian Urban <urbanc@in.tum.de>
parents: 496
diff changeset
    80
\code{String} and the type of lists of characters
bf1c472b244e updated
Christian Urban <urbanc@in.tum.de>
parents: 496
diff changeset
    81
(\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
    82
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
    83
245d302791c7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 398
diff changeset
    84
\begin{lstlisting}[numbers=none]
245d302791c7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 398
diff changeset
    85
scala> "abc".toList
245d302791c7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 398
diff changeset
    86
res01: List[Char] = List(a, b, c)
245d302791c7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 398
diff changeset
    87
\end{lstlisting}
245d302791c7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 398
diff changeset
    88
502
bf1c472b244e updated
Christian Urban <urbanc@in.tum.de>
parents: 496
diff changeset
    89
\noindent
bf1c472b244e updated
Christian Urban <urbanc@in.tum.de>
parents: 496
diff changeset
    90
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
    91
pencil-and-paper, everyday arguments.  So in our (mathematical)
550
71fc4a7a7039 updated
Christian Urban <urbanc@in.tum.de>
parents: 505
diff changeset
    92
definitions we regard strings as lists of characters and we will also
71fc4a7a7039 updated
Christian Urban <urbanc@in.tum.de>
parents: 505
diff changeset
    93
write \dq{$hello$} as list
239
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    94
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    95
\[
404
245d302791c7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 398
diff changeset
    96
[\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
    97
\]
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    98
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    99
\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
   100
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
   101
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
   102
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
   103
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
   104
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
   105
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
   106
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
   107
represent the empty string.} 
10f02605a46a polished
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 239
diff changeset
   108
10f02605a46a polished
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 239
diff changeset
   109
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
   110
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
   111
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
   112
Suppose we are given two strings \dq{\textit{foo}} and
502
bf1c472b244e updated
Christian Urban <urbanc@in.tum.de>
parents: 496
diff changeset
   113
\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
   114
\dq{\textit{foo}} $@$ \dq{\textit{bar}}, gives
245d302791c7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 398
diff changeset
   115
\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
   116
simplify our life and just drop the double quotes whenever it
550
71fc4a7a7039 updated
Christian Urban <urbanc@in.tum.de>
parents: 505
diff changeset
   117
is clear we are talking about strings. So we will often just
404
245d302791c7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 398
diff changeset
   118
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
   119
\textit{foo $@$ bar}.
239
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   120
496
5c9de27a5b30 updated
Christian Urban <urbanc@in.tum.de>
parents: 476
diff changeset
   121
Occasionally we will use the notation $a^n$ for strings, which stands
5c9de27a5b30 updated
Christian Urban <urbanc@in.tum.de>
parents: 476
diff changeset
   122
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
   123
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
   124
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
   125
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   126
\[(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
   127
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   128
\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
   129
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
   130
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   131
\[s \,@\, [] = [] \,@\, s = s\]
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   132
241
10f02605a46a polished
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 239
diff changeset
   133
239
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   134
\subsubsection*{Sets and Languages}
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   135
241
10f02605a46a polished
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 239
diff changeset
   136
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
   137
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
   138
write $\varnothing$ or $\{\,\}$. The set containing the
10f02605a46a polished
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 239
diff changeset
   139
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
   140
with curly braces as
239
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   141
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
\{1, 2, 3\}
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   144
\]
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   145
496
5c9de27a5b30 updated
Christian Urban <urbanc@in.tum.de>
parents: 476
diff changeset
   146
\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
   147
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
   148
\emph{list} $[1, 2, 3]$ is something different from the \emph{set}
5c9de27a5b30 updated
Christian Urban <urbanc@in.tum.de>
parents: 476
diff changeset
   149
$\{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
   150
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
   151
Also sets can potentially have infinitely many elements, whereas lists
bf1c472b244e updated
Christian Urban <urbanc@in.tum.de>
parents: 496
diff changeset
   152
cannot. For example
496
5c9de27a5b30 updated
Christian Urban <urbanc@in.tum.de>
parents: 476
diff changeset
   153
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
   154
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
   155
550
71fc4a7a7039 updated
Christian Urban <urbanc@in.tum.de>
parents: 505
diff changeset
   156
We can define sets by giving all their elements, for example $\{0, 1\}$ for
71fc4a7a7039 updated
Christian Urban <urbanc@in.tum.de>
parents: 505
diff changeset
   157
the set containing just $0$ and $1$. But often we need to use \defn{set
71fc4a7a7039 updated
Christian Urban <urbanc@in.tum.de>
parents: 505
diff changeset
   158
  comprehensions} to define sets. For example the set of all \emph{even}
71fc4a7a7039 updated
Christian Urban <urbanc@in.tum.de>
parents: 505
diff changeset
   159
natural numbers can be defined as
239
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   160
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
\{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
   163
\]
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   164
  
550
71fc4a7a7039 updated
Christian Urban <urbanc@in.tum.de>
parents: 505
diff changeset
   165
\noindent Set comprehensions consist of a ``base set'' (in this case
71fc4a7a7039 updated
Christian Urban <urbanc@in.tum.de>
parents: 505
diff changeset
   166
all the natural numbers) and a predicate (here eveness).
71fc4a7a7039 updated
Christian Urban <urbanc@in.tum.de>
parents: 505
diff changeset
   167
71fc4a7a7039 updated
Christian Urban <urbanc@in.tum.de>
parents: 505
diff changeset
   168
Though silly, but the set $\{0, 1, 2\}$ could also be
239
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   169
defined by the following set comprehension
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   170
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   171
\[
550
71fc4a7a7039 updated
Christian Urban <urbanc@in.tum.de>
parents: 505
diff changeset
   172
\{n\;|\;  n \in \mathbb{N} \wedge n^2 < 9\}
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
496
5c9de27a5b30 updated
Christian Urban <urbanc@in.tum.de>
parents: 476
diff changeset
   175
\noindent Can you see why this defines the set $\{0, 1, 2\}$?  Notice
550
71fc4a7a7039 updated
Christian Urban <urbanc@in.tum.de>
parents: 505
diff changeset
   176
that set comprehensions are quite powerful constructions. For example they
71fc4a7a7039 updated
Christian Urban <urbanc@in.tum.de>
parents: 505
diff changeset
   177
could be used to define set union,
71fc4a7a7039 updated
Christian Urban <urbanc@in.tum.de>
parents: 505
diff changeset
   178
set intersection and set difference:
239
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   179
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   180
\begin{eqnarray*}
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   181
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
   182
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
   183
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
   184
\end{eqnarray*}
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   185
241
10f02605a46a polished
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 239
diff changeset
   186
\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
   187
$\{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
   188
(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
   189
 
10f02605a46a polished
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 239
diff changeset
   190
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
   191
``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
   192
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   193
\begin{equation}\label{bigunion}
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   194
\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
   195
\end{equation}
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
\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
   198
successors, so
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   199
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   200
\[
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   201
\{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
   202
\]
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   203
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   204
\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
   205
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
   206
\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
   207
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   208
\[
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   209
\{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
   210
\ldots
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   211
\]
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   212
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   213
\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
   214
550
71fc4a7a7039 updated
Christian Urban <urbanc@in.tum.de>
parents: 505
diff changeset
   215
As an aside: While this stuff about sets might all look trivial or
71fc4a7a7039 updated
Christian Urban <urbanc@in.tum.de>
parents: 505
diff changeset
   216
even needlessly pedantic, \emph{Nature} is never simple. If you want
71fc4a7a7039 updated
Christian Urban <urbanc@in.tum.de>
parents: 505
diff changeset
   217
to be amazed how complicated sets can get, watch out for the last
71fc4a7a7039 updated
Christian Urban <urbanc@in.tum.de>
parents: 505
diff changeset
   218
lecture just before Christmas where I want to convince you of the fact
71fc4a7a7039 updated
Christian Urban <urbanc@in.tum.de>
parents: 505
diff changeset
   219
that some sets are more infinite than other sets. Yes, you read
71fc4a7a7039 updated
Christian Urban <urbanc@in.tum.de>
parents: 505
diff changeset
   220
correctly, there can be sets that are ``more infinite'' than
71fc4a7a7039 updated
Christian Urban <urbanc@in.tum.de>
parents: 505
diff changeset
   221
others. If you think this is obvious: say you have the infinite set
71fc4a7a7039 updated
Christian Urban <urbanc@in.tum.de>
parents: 505
diff changeset
   222
$\mathbb{N}\backslash\{0\} = \{1, 2, 3, 4, \ldots\}$ which is all the
71fc4a7a7039 updated
Christian Urban <urbanc@in.tum.de>
parents: 505
diff changeset
   223
natural numbers except $0$, and then compare it to the set
71fc4a7a7039 updated
Christian Urban <urbanc@in.tum.de>
parents: 505
diff changeset
   224
$\{0, 1, 2, 3, 4, \ldots\}$ which contains the $0$ and all other
71fc4a7a7039 updated
Christian Urban <urbanc@in.tum.de>
parents: 505
diff changeset
   225
numbers. If you think, the second must be more infinite\ldots{} well,
71fc4a7a7039 updated
Christian Urban <urbanc@in.tum.de>
parents: 505
diff changeset
   226
then think again. Because the two infinite sets
496
5c9de27a5b30 updated
Christian Urban <urbanc@in.tum.de>
parents: 476
diff changeset
   227
5c9de27a5b30 updated
Christian Urban <urbanc@in.tum.de>
parents: 476
diff changeset
   228
\begin{center}
5c9de27a5b30 updated
Christian Urban <urbanc@in.tum.de>
parents: 476
diff changeset
   229
  $\{1, 2, 3, 4, \ldots\}$ and
5c9de27a5b30 updated
Christian Urban <urbanc@in.tum.de>
parents: 476
diff changeset
   230
  $\{0, 1, 2, 3, 4, \ldots\}$
5c9de27a5b30 updated
Christian Urban <urbanc@in.tum.de>
parents: 476
diff changeset
   231
\end{center}
5c9de27a5b30 updated
Christian Urban <urbanc@in.tum.de>
parents: 476
diff changeset
   232
5c9de27a5b30 updated
Christian Urban <urbanc@in.tum.de>
parents: 476
diff changeset
   233
\noindent
550
71fc4a7a7039 updated
Christian Urban <urbanc@in.tum.de>
parents: 505
diff changeset
   234
contain actually the same amount of elements. Does this make sense?
71fc4a7a7039 updated
Christian Urban <urbanc@in.tum.de>
parents: 505
diff changeset
   235
Though this might all look strange, infinite sets will be a
496
5c9de27a5b30 updated
Christian Urban <urbanc@in.tum.de>
parents: 476
diff changeset
   236
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
   237
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
   238
we cannot. But during the first 9 lectures we can go by without this
550
71fc4a7a7039 updated
Christian Urban <urbanc@in.tum.de>
parents: 505
diff changeset
   239
``weird'' stuff. End of aside.\smallskip
404
245d302791c7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 398
diff changeset
   240
245d302791c7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 398
diff changeset
   241
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
   242
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
   243
(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
   244
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
   245
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
   246
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
   247
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
   248
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
   249
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
   250
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
   251
element.
239
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
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
   254
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
   255
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   256
\begin{equation}\label{langconc}
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   257
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
   258
\end{equation}
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
\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
   261
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
   262
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
   263
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
   264
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
   265
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   266
\[
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   267
\{abzzz, abqq, abr, aczzz, acqq, acr\}
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   268
\] 
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   269
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   270
\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
   271
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
   272
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   273
\begin{center}
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   274
\begin{tabular}{ll}
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   275
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
   276
unit element:  & $A \,@\, \{[]\} = \{[]\} \,@\, A = A$\\
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   277
zero element:  & $A \,@\, \varnothing = \varnothing \,@\, A = 
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   278
\varnothing$
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   279
\end{tabular}
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   280
\end{center}
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   281
241
10f02605a46a polished
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 239
diff changeset
   282
\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
   283
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
   284
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
   285
502
bf1c472b244e updated
Christian Urban <urbanc@in.tum.de>
parents: 496
diff changeset
   286
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
   287
\defn{language power} operation as follows:
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   288
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   289
\begin{eqnarray*}
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   290
A^0     & \dn & \{[]\}\\
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   291
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
   292
\end{eqnarray*}
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   293
241
10f02605a46a polished
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 239
diff changeset
   294
\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
   295
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
   296
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
   297
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
   298
another hint about a connection between the $@$-operation and
502
bf1c472b244e updated
Christian Urban <urbanc@in.tum.de>
parents: 496
diff changeset
   299
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
   300
$x^0$?)
239
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   301
242
35104ee14f87 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 241
diff changeset
   302
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
   303
$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
   304
241
10f02605a46a polished
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 239
diff changeset
   305
\begin{equation}\label{star}
404
245d302791c7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 398
diff changeset
   306
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
   307
\end{equation}
239
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   308
241
10f02605a46a polished
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 239
diff changeset
   309
\noindent This star operation is often also called
550
71fc4a7a7039 updated
Christian Urban <urbanc@in.tum.de>
parents: 505
diff changeset
   310
\emph{Kleene-star}. Unfolding the definition in~\eqref{star}
241
10f02605a46a polished
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 239
diff changeset
   311
gives
239
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 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
   315
\]
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   316
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   317
\noindent
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   318
which is equal to 
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   319
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   320
\[
502
bf1c472b244e updated
Christian Urban <urbanc@in.tum.de>
parents: 496
diff changeset
   321
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
   322
\]
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   323
404
245d302791c7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 398
diff changeset
   324
\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
   325
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
   326
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
   327
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
   328
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   329
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
   330
$\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
   331
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
   332
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
   333
= \{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
   334
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   335
\[
246
baf41b05210f updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 242
diff changeset
   336
\{[], 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
   337
\]
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   338
246
baf41b05210f updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 242
diff changeset
   339
\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
   340
$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
   341
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   342
\end{document}
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   343
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   344
%%% Local Variables: 
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   345
%%% mode: latex
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   346
%%% TeX-master: t
68d98140b90b added notation handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   347
%%% End: