UNIT-1 Basic Foundations
UNIT-1 Basic Foundations
Automata Theory:
• Study of abstract machine and their properties, providing a mathematical notion of “computer”.
• Automata are abstract mathematical models of machines that perform computations on an input
by moving through a series of states or configurations. If the computation of an automaton reaches
an accepting configuration it accepts that input.
• Examples of Abstract models of computation: Finite automata, pushdown automata, and Turing
machines.
Computability Theory:
• Examining the limits of what can be computed algorithmically.
Complexity Theory:
• Analyzing the efficiency of algorithms and classifying problems by their computational complexity.
Abstract Model
• An abstract model is a model of computer system (considered either as
hardware or software) constructed to allow a detailed and precise analysis of
how the computer system works.
• Such a model usually consists of input, output and operations that can be
performed and so can be thought of as a processor.
• E.g. an abstract machine that models a banking system can have operations
like “deposit”, “withdraw”, “transfer”, etc.
Fig: Finite automaton modeling an on/off switch Fig: Finite automaton modeling of language accepting even
number of 1’s or 0’s
Applications of TOC
Web Form Validations Algorithms: TOC concepts are employed in validation of web forms.
Application: Allow regex rule to validate web form fields with complex rules.
Compiler Design: TOC principles are fundamental in lexical analysis and parsing stages of compiler design.
Application: Regular expressions and context-free grammars (CFGs) derived from TOC help define the syntax of
programming languages. Validates the rules and structure of programs.
Formal Language Specification: TOC provides the theoretical foundation for formal languages and their grammars.
Application: Finite-state machines are basis for programs for spell checking, indexing, grammar checking, searching large
bodies of text.
Algorithm Design and Analysis: TOC, particularly complexity theory, helps analyze and compare the efficiency of
algorithms.
Application: Engineers use TOC to choose the most suitable algorithm based on the problem's computational complexity.
Automated Verification and Model Checking: Automata theory and formal languages assist in formal methods for system
verification.
Application: Ensures correctness and reliability in critical systems, such as hardware designs or software protocols.
Artificial Intelligence (AI) and Machine Learning (ML): TOC contributes to the understanding of the computational limits
of AI and ML algorithms.
Application: Helps in assessing the feasibility and complexity of solving specific problems using AI and ML techniques.
BASIC TERMS::
Symbol (basic building block)
Alphabets (Σ) : some collection of symbol (we can form alphabet from symbol )
Strings (w): finite sequence of symbols selected from some alphabets
Languages (L): A set of strings all of which are chosen from Σ*, where Σ is particular
alphabet, is called a language
Mathematical Preliminaries
• Finite and Infinite Sets
• Cardinality of set:
• Subset
• Set operations (Union,Intersection,Differences)
• Sequences and Tuples
• Relations And Functions
• Closures
• Method of proofs:
Set: The term set is the collection of well-defined objects, which are called
the elements of the sets.
Sets are used throughout the theory of computation.
• Some examples of sets are given below:
• • The set of vowels in English alphabet
• • The set of natural numbers less than 12.
• • The set of odd numbers less than 20.
There are three methods to describe a set:
• a. Enumeration method: When the elements of a set are enumerated or
listed, we enclose them in braces.
e.g. A={1, 2, 3, ……, 100}
• b. Standard method or description method : Frequently used sets are
usually given symbols that are reserved for them only. e.g. N (Natural
Numbers)= {1, 2, 3, ……., n}
• c. Set builder method: Another way of representing set is to use set builder
method.
e.g. we could define the rational numbers as Q={x/y: x, yϵZ; y≠0}
Types of sets
• a. Empty set: A set, which has no element, is called as empty set or null set or
void set. It is denoted by Φ
• b. Singleton set: A set, which has single element, is called as singleton set.
• c. Disjoint sets: Two or more sets are said to be disjoints, if there are no common
elements among.
• d. Overlapping sets: Two or more sets are said to be disjoints, if there are at least
one common element among them.
• e. Finite sets: A set having specified number of elements is called as a finite set.
• f. Infinite sets: A set is called infinite set, if it is not finite set.
• g. Universal set: The set of all objects or things under consideration in discussion
is called the universal set.
Relation
• A relation is a correspondence between two sets (called the domain and the
range) such that to each element of the domain, there is assigned one or
more elements of the range.
Q. State the domain and range of the following relation. Is the relation a
function? {(2, –3), (4, 6), (3,–1), (6, 6), (2, 3)}
Solution:
• The above list of points, being a relationship between certain x's and certain
y's, is a relation. The domain is all the x-values, and the range is all the y-
values.
• To give the domain and the range, we just list the values without duplication:
• domain: {2, 3, 4, 6}
• range: {–3, –1, 3, 6}
Types of relation
• a. Identity relation:
Consider a set A={1,2,3} Then, its identity relation is: R={(1,1), (2,2),(3,3)}
• b. Reflexive relation:
Consider a set A={1,2,3} Then, one of the possible reflexive relations can be:
R={(1,1), (2,2), (3,3), (1,2), (1,3)}
• c. Symmetric relation:
Consider some of the examples of the symmetric relation,
R1={(1,2),(2,1),(1,3),(3,1)}
R2={(1,2),(1,3),(2,1),(3,1),(3,3)}
• d. Transitive relation:
Iff(x,y)∈R and (y,z)∈R⇒(x,z)∈R for all a,b,c∈A
• e. Equivalence relation: A relation is equivalence relation if it is reflexive,
symmetric and transitive at the same time
a. Identity relation:
• In an identity relation "R", every element of the set “A” is related to itself
only. Note the conditions conveyed through words “every” and “only”.
The word “every” conveys that identity relation consists of ordered pairs
of element with itself - all of them. The word “only” conveys that this
relation does not consist of any other combination.
• Consider a set A={1,2,3} Then, its identity relation is: R={(1,1), (2,2),(3,3)}
b. Reflexive relation
• In reflexive relation, "R", every element of the set “A” is related to itself.
The definition of reflexive relation is exactly same as that of identity
relation except that it misses the word “only” in the end of the sentence.
The implication is that this relation includes identity relation and permits
other combination of paired elements as well.
• Consider a set A={1,2,3} Then, one of the possible reflexive relations can
be:
R={(1,1), (2,2), (3,3), (1,2), (1,3)}
• However, following is not a reflexive relation: R1={(1,1), (2,2), (1,2), (1,3)}
c. Symmetric relation
• In symmetric relation, the instance of relation has a mirror image. It means that if
(1,3) is an instance, then (3,1) is also an instance in the relation. Clearly, an ordered
pair of element with itself like (1,1) or (2,2) is themselves their mirror images.
Consider some of the examples of the symmetric relation,
• R1={(1,2),(2,1),(1,3),(3,1)}
• R2={(1,2),(1,3),(2,1),(3,1),(3,3)}
• We have purposely jumbled up ordered pairs to emphasize that order of elements
in relation is not important. In order to decide symmetry of a relation, we need to
identify mirror pairs. We state the condition of symmetric relation as:
Iff(x,y)∈R⇒(y,x)∈R for all x,y∈A
• The symbol “Iff” means “If and only if”. Here one directional arrow means
“implies”.
• Alternatively, the condition of symmetric relation can be stated as: xRy⇒yRx for all
x,y∈A
d. Transitive relation
• If “R” be the relation on set A, then we state the condition of transitive
relation as:
• Iff(x,y)∈R and (y,z)∈R⇒(x,z)∈R for all a,b,c∈A
• Alternatively, xRy and yRz⇒xRz for all x,y,z∈A
e. Equivalence relation
• A relation is equivalence relation if it is reflexive, symmetric and
transitive at the same time.
• In order to check whether a relation is equivalent or not, we need to
check all three characterizations.
Function
• A function is a correspondence between two sets (called the domain and the
range) such that to each element of the domain, there is assigned exactly one
element of the range.
• The domain is all values that x can take on. The only problem I have with this
function is that I cannot have a negative inside the square root. So we'll set the
insides greater than or equal to zero, and solve. The result will be domain are:
• –2x + 3 > 0 =>–2x > –3 =>2x < 3 =>x < 3/2
• Then the domain is "all x < 3/2".
• Alphabet, Powers of Alphabet
• Closure of an alphabet
• String, Empty String, Length of string
• Concatenating of string
Alphabets (Represented by ‘Σ’)
• Alphabet is a finite non-empty set of symbols.
• The symbols can be the letters such as {a, b, c}, bits {0, 1}, digits {0, 1, 2, 3…
9}.
• It is denoted by ‘Σ’ symbol.
• E.g.: An alphabet of set of decimal numbers is given by Σ= {0, 1,…….., 9).
• The alphabet for binary number is Σ={0, 1}.
Power of alphabet
The set of all strings of certain length k from an alphabet is the kth power
of that alphabet.
i.e. Σk = {w / |w| = k}
If Σ = {0, 1} then,
Σ0 = {ε}
Σ1 = {0, 1}
Σ2 = {00, 01, 10, 11}
Σ3 = {000, 001, 010, 011, 100, 101, 110, 111}
Strings (Strings are denoted by lower case letters)
• A string or word is a finite sequence of symbols selected from
some alphabets.
• E.g. if Σ={a, b} then ‘abab’ is a string over Σ.
Concatenating of string
• Let w1 and w2 be two strings, then w1w2 denotes the concatenation of w1
and w2.
• e.g.
if w1 = abc, w2 = xyz, then
w1w2 = abcxyz
Empty String: -
• It is a string with zero occurrences of symbols. It is denoted by ‘ε’ (epsilon).
Length of String
• The length of a string w, denoted by | w |, is the number of positions for symbols in
w. we have for every string s, length (s) ≥ 0.
• | ε | = 0 as empty string have no symbols.
• | 0110 | = 4
Substring
• A string s is called substring of a string w if it is obtained by removing 0 or more
leading or trailing symbols in w. It is proper substring of w if s ≠ w.
• If s is a string then Substr (s, i, j) is substring of s beginning at ith position & ending at
jth position both inclusive.
Suffix of a string
• A string s is called a suffix of a string w if it is obtained by removing 0 or
more leading symbols in w. For example;
• w = abcd
• s = bcd is suffix of w.
• here s is proper suffix if s ≠ w.
Prefix of a string
• A string s is called a prefix of a string w if it is obtained by removing 0 or
more trailing symbols of w. For example;
• w = abcd
• s = abc is prefix of w,
• Here, s is proper suffix i.e. s is proper suffix if s ≠ w.
Kleen Closure/ Closure of an alphabet
• Kleen Closure (Closure of an alphabet ) is set of all all strings over
alphabet Σ with length 0 or more.
• ∴Σ* = Σ0 ∪ Σ1 ∪ Σ2 ∪ Σ3 ∪ ……………
• E.g. If albhabet , A = {X} ; Then Kleen Closure of A is:
• A* = {Xn | n = 0, 1, 2, …}
Positive Closure: -
• The set of all the strings over an alphabet Σ, except the empty
string is called positive closure and is denoted by Σ+.
• ∴Σ+ = Σ1 ∪ Σ2 ∪ Σ3 ∪……………
• E.g. If albhabet , A = {X} ; Then Positive Closure of A is:
• A+ = {Xn | n = 1, 2, …}
NOTE:
Σ* = Σ + U {ε}
• Let Σ = {0, 1} then
• Σ* = {ε, 0, 1, 00, 10, 01, 11,….}
• Σ1 = {0, 1}
• Σ2 = {00, 01, 10, 11}
• Σ3 = {000, 001, 010, 011, 100, 101, 110, 111}
• Σ+ = Σ1 U Σ2 U Σ3 U….
• Therefore, Σ* = Σ + U {ε}
Languages
• A set of strings all of which are chosen from Σ*, where Σ is particular
alphabet, is called a language.
• Theorem
• A theorem is a mathematical proposition that is true.
• Many theorems are conditional propositions.
• For example, if f(x) and g(x) are continuous then f(x)± g(x)
are also continuous.
NOTE: a→B
• Direct Proofs
• To prove p→q, we start assuming hypothesis p is true and
we use information already available to prove q is true, and
if q is true then the argument is valid. This is called direct
proof.
• Eg:
• Theorem: If n is a positive integer then n7 - n is divisible by 7.
• Proof:
• First we factor n7 - n = n(n6 - 1) = n(n3 - 1)(n3 + 1)
• = n(n-1)(n2 + n + 1)(n+1)(n2 - n + 1).
• Now there are 7 cases to consider, depending on n = 7 q + r
where r = 0, 1, 2, 3, 4, 5, 6, 7.
• Case 1: n = 7q. Then n7 - n has the factor n, which is divisible by
7.
• Case 2: n = 7q + 1. Then n7 - n has the factor n-1 = 7q which is
divisible by 7.
• Case 3: n = 7q + 2. Then the factor n2 + n + 1 = (7q + 2)2 + (7q+2)
+ 1 = 49 q2 + 35 q + 7 is clearly divisible by 7.
• Case 4: n = 7q + 3. Then the factor n2 - n + 1 = (7q + 3)2 - (7q+3)
+ 1 = 49 q2 + 35 q + 7 is clearly divisible by 7.
• Case 5: n = 7q + 4. Then the factor n2 + n + 1 = (7q + 4)2 + (7q+4)
+ 1 = 49 q2 + 63 q + 21 is clearly divisible by 7.
• Case 6: n = 7q + 5. Then the factor n2 - n + 1 = (7q + 5)2 - (7q+5)
+ 1 = 49 q2 + 63 q + 21 is clearly divisible by 7.
• Case 7: n = 7q + 6. Then the factor n + 1 = 7q +7 is clearly
divisible by 7.
• Poof by mathematical induction
• Mathematical induction is a powerful, yet straightforward method of
proving statements whose "domain" is a subset of the set of integers.
• Usually, a statement that is proven by induction is based on the set of
natural numbers.
• This statement can often be thought of as a function of a number n,
• where n = 1,2,3...
• Proving the base of induction involves showing that the claim holds true for
some base value (usually 0, 1, or 2). There are sometimes many ways to do
this, and it can require some ingenuity.
• We will outline this with a simple example.
• Proof. (By Mathematical Induction.)
• 1. Initial Step.
• When n = 0, the formula gives us
• (1 - 1/22n)/2 = (1 - 1/2)/2 = 1/4 = a0.
• So the closed form formula gives us the correct answer when n =
0.
• Inductive Step.
• 2. Our inductive assumption is: Assume there is a k, greater than
or equal to zero, such that ak = (1 - 1/22k)/2. We must prove the
formula is true for n = k+1.
• First we appeal to the recurrsive definition of
• ak+1 = 2 ak(1-ak).
• 3. Next, we invoke the inductive assumption, for this k, to get
• ak+1 = 2 (1 - 1/22k)/2 (1 - (1 - 1/22k)/2)
• = (1 - 1/22k)(1 + 1/22k)/2
• = (1 - 1/22k+1)/2.
• Proof by Counterexample
• Consider a statement of the form ∀x∈ M, if P(x) then Q(x).
• Suppose that we wish to prove that this statement is false. In
order to disprove this statement, we have to find a value of x in
M for which P(x) is true and Q(x) is false. Such an x is called a
counterexample.