FL 1
FL 1
Preliminary Mathematical
Theories
1
Sets
• Sets are collections of well defined objects in which order of elements
and duplication of elements do not matter.
• The individual objects in a set are called the elements or the members.
• To indicate that x is an element of the set S, we write x ∈ S.
• The statement that x is not in S is written x ∉ S.
• A set can be specified by enclosing some description of its
elements in curly braces;
• for example, the set of integers 0, 1, 2 is shown as
S = {0, 1, 2}.
• order of elements and duplication of elements do not matter.
– {1,a,1,1} = {a,a,a,1} = {a,1}
Operations on Sets
3
Finite Set, Infinite Set, Subsets and Power set
Definition
i A set S is called finite, if it contains n elements
where n is some non-negative integer.
a S = { xÎℝ½x2=–1}, so n (S) = 0
b S = {xÎℕ½x is a multiple of 2 less than 12}, n (S) = 5
ii A set S is called infinite, if it is not finite.
a Let E = {2, 4, 6,…}. E is infinite
b Let T = {x½x is a real number and 0<x < 1}. T is infinite.
4
Finite Set, Infinite Set, Subsets and
Powerset
• A is a subset of B if all elements of A are elements of B as well.
Notation: A B.
Note: If A is not a subset of B, then we denote this by A⊈B.
• For any set A
• iÆÍA ii A Í A
• The powerset P(A) is the set whose elements are all subsets of
A: P(A) = {X | X A }.
• Let M = {–1, 1}. Then subsets of M are Æ, {–1}, {1} and M.
• Therefore P(M) = {Æ, {–1}, {1}, M}
6
•Disjoint Sets. If A and B have no common
element, that is, A B = , then the sets A and B
are said to be disjoint.
•Cardinality. The “Cardinality” of a set A, written |A|,
is the number of elements in set A.
To prove that two sets A and B are not equal, you need to
produce a counterexample : an element x that belongs to
one of the two sets, but does not belong to the other.
• Example. Prove that P(A B) P(A) P(B).
• Counterexample: A={1}, B={2}, X={1,2}. The set X belongs to
P(A∪ B), but it does not belong to P(A) ∪
P(B).
8
Various Ways of Describing a Set
•By listing its elements. For example, the set of all positive
integers divisible by 15 and less than 100 can be written as
{15, 30, 45, 60, 75, 90}.
•By describing the properties of the elements of the set.
For example. The set {15, 30, 45, 60, 75, 90} can be
described as: {n│n is a positive integer divisible by 15 and
less than 100}. (The description of the property is called
predicate.
•By recursion. example the set of all natural numbers
leaving a remainder 1 when divided by 3 can be described
as {an l ao = 1, an+1 = an + 3} The previous set can be written
as {1. 4, 7, 10, ...}.The four elements given suggest that the
computational rule is: an+1 = an + 3. 9
Relation
Definition: A relation R in a set S is a collection of
ordered pairs of elements in S (i.e. a subset of S x S).
When (x, y) is in R, we write xRy. When (x, y) is not in
R. we write xR’y.
• An input output relationship where a single input
can have more than 1 output is called a relation.
• Less(4) = {3,2,1,0} i.e. a set of results
11
Relations
Let A = {0,1,2}, B = {1,2,3}. A x B = {(0,1), (0,2), (0,3),
(1,1), (1,2), (1,3), (2,1), (2,2), (2,3)}
Let say an element x in A is related to an element y in B
iff x is less than y. x R y: x is related to y
0 R 1, 0 R 2, 0 R 3, 1 R 2, 1 R 3, 2 R 3
The set of all ordered pair in A x B where elements
are related {(0,1), (0,2), (0,3), (1,2), (1,3), (2,3)}
12
Properties of Relations
Definition Let R be a binary relation on S2.
• R is reflexive iff R(x, x) for all x ∈ S.
• R is symmetric iff R(x , x ) implies R(x , x ).
1 2 2 1
R(x , x ).
1 3
13
Functions
Definition
-A function is a relation such that no two ordered pairs
have the same first-coordinates and different second-
coordinates.
-For nonempty sets A and B,
A function, or mapping, f from A to B, denoted
f: A B, is a relation from A to B in which every
element of A appears exactly once as the first
component of an ordered pair in the relation
Sample functions:
f : R R, f(x) = x2
f : Z Z, f(x) = x + 1
f : Q Z, f(x) = 2
14
Example (1)
Let A = {1,2,3}, B = {7,8,9}
Proper suffix: For a string, any suffix of the string other than the string
itself is called as the proper suffix of the string. Example: For the string w
= 0110, the proper suffixes are λ, 0, 10, and 110.
eg. S={0,1}
L1=set of all strings of length 2, ={00,01,10,11}
L2=set of all strings of length 3, ={000,001,010,011,100, 101, 111}
L3=set of all strings that begin with 0, ={0,00,01,011,000, 0101, …}
L1and L2 are finite and L3 is infinite
Power of S : S={0,1}
S0= set of all strings of length 0: S0={Î}
S1= set of all strings of length 1: S1={0,1}
S2= set of all strings of length 2: S2={00,01,10,11}
S3= set of all strings of length 3: S3={000,001,010,011,101,110,111}
….
Sn= set of all strings of length n
Cardinality: number of elements in a set, Sn =2n . Cardinality(S0)=1
S*={Î} u {0,1} u {00,01,10,11} u...
= set of all possible strings of all lengths over {0,1}
it is infinite
Concatenation of Languages:
If L and L are languages over S, their
1 2
concatenation is L = L L , or simply L = L L ,
1· 2 1 2
where
L= {wÎS* :w = x y for some x ÎL , and yÎ L }
· 1 2
Formal Language
• A formal language is a set of words, i.e. finite strings of letters, or
symbols.
• The inventory/list from which these letters are taken is called the
alphabet over which the language is defined.
• A formal language is often defined by means of a formal grammar.
Formal languages are a purely syntactical notion, so there is not
necessarily any meaning associated with them.
• To distinguish the words that belong to a language from arbitrary
words over its alphabet, the former are sometimes called well-formed
words (or, in their application in logic, well-formed formulas).
Formal Definition
A formal language L over an alphabet Σ is just a subset of Σ*, that
is, a set of words over that alphabet. For example, three sample
languages over the same alphabet Σ = { a, b }:
L1 = {a a, a a a }
L2 = {a ba, a a b}
L3 = {a b, b a, a a bb, a ba b, . . . , a a a bbb, . . . }
In computer science and mathematics, which do not deal with
natural languages, the adjective "formal" is usually omitted as
redundant.
Example1
The following rules define a formal language L over the alphabet Σ=
{0,1,2,3,4,5,6,7,8,9,+,=}:
• Every non empty string that does not contain + or = and does not
start with 0 is in L.
• The string 0 is in L.
• A string containing=is in L if and only if there is exactly one =, and
it separates two strings in L.
• A string containing + is in L if and only if every + in the string
separates two valid strings in L.
• No string is in L other than those implied by the previous rules.
Automata
• An automaton is an abstract model of a digital
computer and the computational problems that
can be solved using these machines.
• abstract 'mathematical' machines or systems
• It has a mechanism for reading input
• the input is a string over a given alphabet, written
on an input file, which the automaton can read but
not change
• The input file is divided into cells, each of which can
hold one symbol.
27
Figure 1.1 schematic representation of a general automaton.
• The input mechanism can read the input file from left
to right, one symbol at a time
• The automaton can produce output of some form.
• It may have a temporary storage device,
• consisting of an unlimited number of cells,
• each capable of holding a single symbol from an alphabet
(not necessarily the same one as the input alphabet).
• The automaton can read and change the contents of
the storage cells.
• the automaton has a control unit, which can be in
any one of a finite number of internal states, and
which can change state in some defined manner.
• Automata theory is closely related to formal language theory,
• automata are often classified by the class of formal languages they
are able to recognize.
• An automaton can be a finite representation of a formal language
that may be an infinite set.
In other words, automata theory is a subject matter which studies
properties of various types of automata.
For example, following questions are studied about a given type of
automata.
• Which class of formal languages is recognizable by some type of
automata? (Recognizable languages)
• Is certain automata closed under union, intersection, or
complementation of formal languages? (Closure properties)
• How much is a type of automata expressive in terms of recognizing
class of formal languages? And, their relative expressive power?
(Language Hierarchy)
Automata theory also studies if there exist any effective algorithm
or not to solve problems similar to the following list:
• Does an automaton accept any input word? (emptiness checking)
• Is it possible to transform a given non-deterministic automaton
into deterministic automaton without changing the recognizing
language? (Determinization)
• For a given formal language, what is the smallest automaton that
recognizes it? (Minimization).
Automata play a major role in compiler design and parsing.