THEORY OF COMPUTATION

Similar documents
Complexity Theory. Compiled By : Hari Prasad Pokhrel Page 1 of 20. ioenotes.edu.np

CS402 - Theory of Automata Glossary By

Chapter 3. Set Theory. 3.1 What is a Set?

Proof Techniques Alphabets, Strings, and Languages. Foundations of Computer Science Theory

CSE 20 DISCRETE MATH. Winter

[Ch 6] Set Theory. 1. Basic Concepts and Definitions. 400 lecture note #4. 1) Basics

CSE 20 DISCRETE MATH. Fall

Decision Properties for Context-free Languages

CS6160 Theory of Computation Problem Set 2 Department of Computer Science, University of Virginia

1. Draw the state graphs for the finite automata which accept sets of strings composed of zeros and ones which:

Introduction to Sets and Logic (MATH 1190)

To illustrate what is intended the following are three write ups by students. Diagonalization

CS314: FORMAL LANGUAGES AND AUTOMATA THEORY L. NADA ALZABEN. Lecture 1: Introduction

Discrete Mathematics Lecture 4. Harper Langston New York University

Power Set of a set and Relations

Slides for Faculty Oxford University Press All rights reserved.

Introduction to Automata Theory. BİL405 - Automata Theory and Formal Languages 1

Learn Smart and Grow with world

MATH 139 W12 Review 1 Checklist 1. Exam Checklist. 1. Introduction to Predicates and Quantified Statements (chapters ).

Sets MAT231. Fall Transition to Higher Mathematics. MAT231 (Transition to Higher Math) Sets Fall / 31

Turing Machine Languages

CT32 COMPUTER NETWORKS DEC 2015

MATHEMATICS 191, FALL 2004 MATHEMATICAL PROBABILITY Outline #1 (Countability and Uncountability)

CSC Discrete Math I, Spring Sets

TOPIC PAGE NO. UNIT-I FINITE AUTOMATA

Summary of Course Coverage

2 Review of Set Theory

Theory of Programming Languages COMP360

A set with only one member is called a SINGLETON. A set with no members is called the EMPTY SET or 2 N

Finite Automata. Dr. Nadeem Akhtar. Assistant Professor Department of Computer Science & IT The Islamia University of Bahawalpur

Solutions to Homework 10

Theory of Computation

r=1 The Binomial Theorem. 4 MA095/98G Revision

THREE LECTURES ON BASIC TOPOLOGY. 1. Basic notions.

Formal languages and computation models

STABILITY AND PARADOX IN ALGORITHMIC LOGIC

CS402 Theory of Automata Solved Subjective From Midterm Papers. MIDTERM SPRING 2012 CS402 Theory of Automata

Chapter Summary. Mathematical Induction Recursive Definitions Structural Induction Recursive Algorithms

A Characterization of the Chomsky Hierarchy by String Turing Machines

Theory of Computation, Homework 3 Sample Solution

Trees. 3. (Minimally Connected) G is connected and deleting any of its edges gives rise to a disconnected graph.

MA651 Topology. Lecture 4. Topological spaces 2

Decidable Problems. We examine the problems for which there is an algorithm.

1. [5 points each] True or False. If the question is currently open, write O or Open.

ONE-STACK AUTOMATA AS ACCEPTORS OF CONTEXT-FREE LANGUAGES *

Functions. How is this definition written in symbolic logic notation?

Recursively Enumerable Languages, Turing Machines, and Decidability

Name: CS 341 Practice Final Exam. 1 a 20 b 20 c 20 d 20 e 20 f 20 g Total 207

Computation Engineering Applied Automata Theory and Logic. Ganesh Gopalakrishnan University of Utah. ^J Springer

Matching Algorithms. Proof. If a bipartite graph has a perfect matching, then it is easy to see that the right hand side is a necessary condition.

(a) R=01[((10)*+111)*+0]*1 (b) ((01+10)*00)*. [8+8] 4. (a) Find the left most and right most derivations for the word abba in the grammar

2.2 Set Operations. Introduction DEFINITION 1. EXAMPLE 1 The union of the sets {1, 3, 5} and {1, 2, 3} is the set {1, 2, 3, 5}; that is, EXAMPLE 2

Math 302 Introduction to Proofs via Number Theory. Robert Jewett (with small modifications by B. Ćurgus)

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

Limitations of Algorithmic Solvability In this Chapter we investigate the power of algorithms to solve problems Some can be solved algorithmically and

2.1 Sets 2.2 Set Operations

Discrete mathematics , Fall Instructor: prof. János Pach

Midterm Exam II CIS 341: Foundations of Computer Science II Spring 2006, day section Prof. Marvin K. Nakayama

2. Sets. 2.1&2.2: Sets and Subsets. Combining Sets. c Dr Oksana Shatalov, Fall

DISCRETE MATHEMATICS

Reflection in the Chomsky Hierarchy

Fundamental mathematical techniques reviewed: Mathematical induction Recursion. Typically taught in courses such as Calculus and Discrete Mathematics.

University of Nevada, Las Vegas Computer Science 456/656 Fall 2016

TAFL 1 (ECS-403) Unit- V. 5.1 Turing Machine. 5.2 TM as computer of Integer Function

Figure 1.1: This is an illustration of a generic set and its elements.

Material from Recitation 1

Name: Finite Automata

The Language of Sets and Functions

Point-Set Topology 1. TOPOLOGICAL SPACES AND CONTINUOUS FUNCTIONS

CIT3130: Theory of Computation. Regular languages

Review of Sets. Review. Philippe B. Laval. Current Semester. Kennesaw State University. Philippe B. Laval (KSU) Sets Current Semester 1 / 16

CS3102 Theory of Computation Problem Set 2, Spring 2011 Department of Computer Science, University of Virginia

Semantics via Syntax. f (4) = if define f (x) =2 x + 55.

ECS 120 Lesson 16 Turing Machines, Pt. 2

Functions 2/1/2017. Exercises. Exercises. Exercises. and the following mathematical appetizer is about. Functions. Functions

We show that the composite function h, h(x) = g(f(x)) is a reduction h: A m C.

Discrete Mathematics. Kruskal, order, sorting, induction

Variants of Turing Machines

Theory Bridge Exam Example Questions Version of June 6, 2008

EDAA40 At home exercises 1

Theory of Languages and Automata

Taibah University College of Computer Science & Engineering Course Title: Discrete Mathematics Code: CS 103. Chapter 2. Sets

LOGIC AND DISCRETE MATHEMATICS

LECTURE NOTES THEORY OF COMPUTATION

1. (10 points) Draw the state diagram of the DFA that recognizes the language over Σ = {0, 1}

A GRAPH FROM THE VIEWPOINT OF ALGEBRAIC TOPOLOGY

Lamé s Theorem. Strings. Recursively Defined Sets and Structures. Recursively Defined Sets and Structures

Recursively Defined Functions

Ambiguous Grammars and Compactification

CS525 Winter 2012 \ Class Assignment #2 Preparation

Integers and Mathematical Induction

AXIOMS FOR THE INTEGERS

Recursive Definitions Structural Induction Recursive Algorithms

Turing Machines. A transducer is a finite state machine (FST) whose output is a string and not just accept or reject.

A Reduction of Conway s Thrackle Conjecture

Theory of Computations Spring 2016 Practice Final Exam Solutions

Formal Languages and Automata

Multiple Choice Questions

UNIT I PART A PART B

Definition For vertices u, v V (G), the distance from u to v, denoted d(u, v), in G is the length of a shortest u, v-path. 1

Transcription:

THEORY OF COMPUTATION UNIT-1 INTRODUCTION Overview This chapter begins with an overview of those areas in the theory of computation that are basic foundation of learning TOC. This unit covers the introduction of TOC with the below topics Sets Functions Relations Languages Principle of Mathematical Induction Recursive definition Objective SETS Definition: To understand the basic concepts of Sets, Functions, Relations To know about what is a Language To learn about Mathematical induction and solving problems To know about Recursive definitions A set is a collection of objects. For example, the collection of four letters a, b, c and d is a set, which is written as L = { a, b, c, d } The objects comprising a set are called its elements or members. A set having only one element is called a singleton. A set with no element at all is called the empty set, which is denoted by ф.it is essential to have a criterion for determining, for any given thing, whether it is or is not a member of the given set. This criterion is called the Membership criterion of the set. There are two common ways to indicate the members of a set: (i) List all the elements, e.g, {a, e, i, o, u}. (ii) Provide some kind of an algorithm or a rule, such as a grammar. Let us now take a look at the notation that is being used to denote sets. (a) To indicate that x is a member of the set S, we write x S. (b) If every element of set A is also an element of set B, we say that A is a subset of B, and write A B.

(c) If every element of set A is also an element of set B, but B also has some elements not contained in A, we say that A is a proper subset of B and write A B. (d) We denote the empty set as { } or ф Operations on sets: (a) Union The union of two sets is the set that has objects that are elements of at least one of the two given sets, and possibly both. That is, the union of sets A and B, written A B, is a set that contains everything in A, or in B, or in both. A B = {x :x A or x B} Example: A = {1, 3, 9} B = {3, 5} Therefore, A B = {1, 3, 5, 9} (b) Intersection The intersection of sets A and B, written A B, is a set that contains exactly those elements that are in both A and B. A B = {x : x A and x B} Example: Given A = {1, 3, 9}, B = {3, 5}, C = {a, b, c} A B = {3} A C = { } (c) Set Difference The set difference of set A and set B, written as A B, is the set that contains everything that is in A but not in B. A B = {x : x A and x B} Given A = {1,3,9}, B = {3,5} A B = {1, 9} (d) Complement The complement of set A, written as A is the set containing everything that is not in A. Additional Terminology (a) 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. (b) Cardinality. The Cardinality of a set A, written A, is the number of elements in set A.

(c) Powerset. The powerset of a set A, written 2A, is the set of all subsets of A; i.e., a set containing n elements has a powerset containing 2n elements. (d) Cartesian Product. Let A and B be two sets. Then the set of all ordered pairs (x, y) where x A and y B is called the Cartesian Product of the sets A and B and is denoted by A B, i.e. A B = {(x, y) : x A and y B} Relations Definition of Relation: A relation on sets S and T is a set of ordered pairs (s, t), where (a) s S (s is a member of S ) (b) t T (c) S and T need not be different (d) The set of all first elements in the domain of the relation, and (e) The set of all second elements is the range of the relation. Example Suppose S is the set {a, b, c, d, e} and set T is {w, x, y, z}. Then a relation on S and T is R = {(a, y), (c, w), (c, z), (d, y)} The four ordered pairs in the relation is represented as shown in Fig. 2.

Equivalence Relation: A subset R of A A is called an equivalence relation on A if R satisfies the following conditions: (i) (a, a) R for all a A (R is reflexive) (ii) If (a, b) R, then (b, a) R, then (a, b) R (R is symmetric) (iii) If (a, b) R and (b, c) R, then (a, c) R (R is transitive) Partial Ordering Relations A relation R on a set S is called a Partial ordering or a Partial order, if R is reflexive, antisymmetric and transitive. A set S together with a partial ordering R is called a Partially ordered set or Poset. Example: The relation on the set R of real numbers is reflexive, antisymmetric and transitive. Therefore is a Partial ordering. Partition A Partition P of S is a collection {Ai} of nonempty subsets of S with the properties: (i) Each a S belongs to some Ai, (ii) If Ai Aj Aj, then Ai Aj =. Thus a partition P of S is a subdivision of S into disjoint nonempty sets. If R is an equivalence relation on a set S, for each a in S, let [a] denote the set of elements of S to which a is related under R, i.e. [a] = {x : (a, x) R} Here [a] is the Equivalence class of a in S. Example Given a relation R is circular if (a, b) R and (b, c) R (c, a) R. Show that a relation is reflexive and circular if and only if it is reflexive, symmetric, and transitive. Solution:

Functions: Suppose every element of S occurs exactly once as the first element of an ordered pair. In Fig shown, every element of S has exactly one arrow arising from it. This kind of relation is called a function. A function is otherwise known as Mapping. A function is said to map an element in its domain to an element in its range. Every element in S in the domain, i.e., every element of S is mapped to some element in the range. No element in the domain maps to more than one element in the range. Functions as relations A function f :A B is a relation from A to B i.e., a subset of A B, such that each a A belongs to a unique ordered pair (a, b) in f.

Kinds of Functions (a) One-to-One Function (Injection): A function f : A B is said to be one-to-one if different elements in the domain A have distinct images in the range. A function f is one-to-one if f (a) = f (a ) implies a = a. (b) Onto function (Surjection): A function f : A B is said to be an onto function if each element of B is the image of some element of A. i.e., f :A B is onto if the image of f is the entire co domain, i.e. if f (A) = B. i.e., f maps A onto B. (c) One-to-one onto Function (Bijection): A function that is both one-to-one and onto is called a Bijection. Such a function maps each and every element of A to exactly one element of B, with no elements left over. Fig. below shows bijection.

(d) Invertible function: A function f : A B is invertible if its inverse relation f 1 is a function from B to A.A function f : A B is invertible if and only it is both one-to-one and onto. Example:1 Find whether the function f (x) = x 2 from the set of integers to the set of integers is one-to-one. Solution The function f (x) = x 2 is not one-to-one as, for example f (1) = f ( 1) = 1, but 1 1. Example:2 Given f is a function f : A B where A = {a, b, c, d} and B = {1, 2, 3} with f (a) = 3, f (b) = 2, f (c) =1, and f(d) = 3. Is the function f an onto function? Solution As all three elements of the co domain are images of elements in the domain, we have f as an onto function. Languages: The general definition of a language will be "the body of words and methods of combining words used and understood by a considerable community." However, this definition is not sufficiently precise for building a mathematical theory of languages; hence we form the definition as A language is any set of sentences over an alphabet. Most languages of interest will contain an infinite number of sentences. Alphabet: An alphabet or vocabulary is any finite set of symbols. Although a unaccountably infinite number of symbols exists, we shall consider only a countable infinite subset from which all finite sets will be drawn. This subset will include digits, the Latin and Greek

letters both upper and lower case (possibly with combinations of subscripts, superscripts, underscores, etc.),and special symbols such as #,, and so on. Example: Roman alphabet {a, b,... z}. Binary Alphabet {0, 1} is pertinent to the theory of computation. String/sentence: A string over an alphabet is a finite sequence of symbols from that alphabet, which is usually written next to one another and not separated by commas. (i) If Σa = {0,1} then 001001 is a string over Σa. (ii) If Σb = {a, b,, z) then axyrpqstcd is a string over Σb. A sentence over an alphabet is any string of finite length composed of symbols from the alphabet. Synonyms for sentence are string and word. The empty sentence,, is the sentence consisting of no symbols. If V is an alphabet, then V* denotes the set of all sentences composed of symbols of V, including the empty sentence. We use V + to denote the set V* - { }. Thus, if V = {0, 1}, then V* = {e, 0, 1, 00, 01, 10, 11,000,...} and V + = {0, 1, 00,...}. Length of String: The length of a string is its length as a sequence. The length of a string w is written as w. Example: 10011 = 5 Empty String: The string of zero length is called the empty string. This is denoted by.the empty string plays the role of 0 in a number system. Substring: z is a substring of w if z appears consecutively within w.as an example, deck is a substring of abcdeckabcjkl. Formal Proofs Structure of proof it is just a series of statements, each one being either An assumption or A conclusion, clearly following from an assumption or previously proved result. Direct Proofs Example: Divisibility is Transitive

Conclusion If a and b are two natural numbers, we say that a divides b if there is another natural number k such that b = a k. If a divides b and b divides c then a divides c By our assumptions, and the definition of divisibility, there are natural numbers k1 and k2 such that b = a k1 and c = b k2.consequently, c = b k2 = a k1 k2. Let k = k1 k2. Now k is a natural number and c = a k, so by the definition of divisibility, a divides c. If P, Then Q Most proofs are (and should be) direct proofs. Always try direct proof first, unless you have a good reason not to. If you find a simple proof, and you are convinced of its correctness, then don't be shy about. Many times proofs are simple and short. Proof by Contradiction In a proof by contradiction we assume, along with the hypotheses, the logical negation of the result we wish to prove, and then reach some kind of contradiction. That is, if we want to prove "If P, Then Q", we assume P and Not Q. The contradiction we arrive at could be some conclusion contradicting one of our assumptions, or something obviously untrue like 1 = 0. Converse of a Theorem The Converse of "If P, Then Q" is the assertion "If Q, Then P". For example, the converse of "If it is my car, it's red" is "If the car is red, then its mine." It should be clear from this example that there is no guarantee that the converse of a true statement is true. Proof by Contradiction is often the most natural way to prove the converse of an already proved theorem. Proof by Contra positive Proof by contra positive takes advantage of the logical equivalence between "P implies Q" and "Not Q implies Not P". For example, the assertion "If it is my car, then it is red" is equivalent to "If that car is not red, then it is not mine". So, to prove "If P, Then Q" by the method of contra positive means to prove "If Not Q, Then Not P". Example: An integer x is called even (respectively odd) if there is another integer k for which x = 2k (respectively 2k+1). Two integers are said to have the same parity if they are both odd or both even.

For the purpose of this example we will assume as proved that each integer is either even or odd. Theorem. If x and y are two integers for which x+y is even, then x and y have the same parity. Proof. The contra positive version of this theorem is "If x and y are two integers with opposite parity, then their sum must be odd." So we assume x and y have opposite parity. Since one of these integers is even and the other odd, there is no loss of generality to suppose x is even and y is odd. Thus, there are integers k and m for which x = 2k and y = 2m+1. Now then, we compute the sum x+y = 2k + 2m + 1 = 2(k+m) + 1, which is an odd integer by definition. Difference The difference between the Contra positive method and the Contradiction method is subtle. Let's examine how the two methods work when trying to prove "If P, Then Q". Method of Contradiction: Assume P and Not Q and prove some sort of contradiction. Method of Contra positive: Assume Not Q and prove Not P. The method of Contra positive has the advantage that your goal is clear: Prove Not P. In the method of Contradiction, your goal is to prove a contradiction, but it is not always clear what the contradiction is going to be at the start. If and Only If Many theorems are stated in the form "P, if, and only if, Q". Another way to say the same things is: "Q is necessary and sufficient for P". This means two things: "If P, Then Q" and "If Q, Then P". So to prove an "If, and Only If" theorem, you must prove two implications. 1. Prove the if-part: Assume P and prove Q. 2. Prove the only-if-part: Assume Q, prove P. Example Theorem If a is an integer, then a is not evenly divisible by 3 if, and only if, a2-1 is evenly divisible by 3. Proof: Since this is an "If, and Only If" theorem, we must prove two implications. ("If") We must prove "a is not evenly divisible by 3 if a2-1 is evenly divisible by 3". So we assume that 3 evenly divides a2-1 = (a-1)(a+1). Since 3 is a prime number, 3 must evenly divide either a-1 or a+1. In either case, it should be apparent that 3 cannot evenly divide a.

("Only If"). We must prove "a is not evenly divisible by 3 only if a2-1 is evenly divisible by 3." This means "If a is not evenly divisible by 3, then a2-1 is evenly divisible by 3". This is where we use the division algorithm stated above. We can write a = 3q + r, where r = 0, 1 or 2. Our assumption that a is not divisible by 3 implies r cannot be 0. If r =1, then a-1 = 3q and so 3 evenly divides a2-1 = (a- 1)(a+1). A similar argument works if r = 2. Note: The if and only-if parts are converses of each other. One part, say if X then Y," says nothing about whether Y is true when X is false. An equivalent form to if X then Y is if not Y then not X"; the latter is the contra positive of the former. Sometimes you can prove an "If, and Only If" assertion without explicitly dividing the proof into two parts. The next example illustrates how this might be done. Counter Examples Counter examples play an important role in mathematics. Whereas a complicated proof may be the only way to demonstrate the validity of a particular theorem, a single counter example is all that is need to refute the validity of a proposed theorem. For example, numbers in the form 22n + 1, where n is a positive integer, were once thought to be prime. These numbers are prime for n = 1, 2, 3 and 4. But when n = 5, we get 225 + 1 = 4294967297 = (641)(6700417) a composite number. A natural place for counter examples to occur is when the converse of a known theorem comes into question. The converse of an assertion in the form "If P, Then Q" is the assertion "If Q, Then P". Principle of Mathematical Induction Strategy Mathematical Induction works like this: Suppose you want to prove a theorem in the form "For all integers n greater than equal to a, P(n) is true". P(n) must be an assertion that we wish to be true for all n = a, a+1,...; like a formula. You first verify the initial step. That is, you must verify that P(a) is true. Next comes the inductive step. Here you must prove "If there is a k, greater than or equal to a, for which P(k) is true, then for this same k, P(k+1) is true." Since you have verified P(a), it follows from the inductive step that P(a+1) is true, and hence, P(a+2) is true, and hence P(a+3) is true, and so on. In this way the theorem has been proved. Proof of induction is used to show that all elements of an infinite set have a specified property. The proof by induction has two parts, (i) Induction step (ii) Basis Step

Example:1 The induction step proves that for each i 1, if P(i) is true, then so is P(i +1). The basis proves that P(1) is true. When both these parts are proved, then for each i, P(i) is proved. Let us illustrate the method of writing a proof by induction. Basis: To prove that P(1) is true. Induction Step: For each i 1, assume that P(i) is true and use this assumption to show that P(i + 1) is true. A binary tree with n leaves has 2n - 1 nodes. Formally, S (T): if T is a binary tree with n leaves, then T has 2n - 1 nodes. Induction is on the size = number of nodes of T. Basis: If T has 1 leaf, it is a one-node tree. 1 =2 1-1 so OK. Induction: Assume S (U) for trees with fewer nodes than T. In particular, assume for the sub trees of T. T must be a root plus two suttees U and V. If U and V have u and v leaves, respectively, and T has t leaves, then u + v = t. By the inductive hypothesis, U and V have 2u - 1 and 2v - 1 node, respectively. Then T has 1 + (2u - 1) + (2v -A 1) nodes. o = 2(u + v) A 1. o = 2t - 1, proving the inductive step. Example:2 Theorem: For any positive integer n, 1 + 2 +... + n = n(n+1)/2. Proof: (Proof by Mathematical Induction) Let's let P(n) be the statement "1 + 2 +... + n = (n (n+1)/2." (The idea is that P(n) should be an assertion that for any n is verifiably either true or false.) The proof will now proceed in two steps: the initial step and the inductive step Initial Step: We must verify that P(1) is True. P(1) asserts "1 = 1(2)/2", which is clearly true. So we are done with the initial step.

Inductive Step: Here we must prove the following assertion: "If there is a k such that P(k) is true, then (for this same k) P(k+1) is true." Thus, we assume there is a k such that 1 + 2 +... + k = k (k+1)/2. (We call this the inductive assumption.) We must prove, for this same k, the formula 1 + 2 +... + k + (k+1) = (k+1)(k+2)/2. 1 + 2 +... + k + (k+1) = k(k+1)/2 + (k+1) = (k(k+1) + 2 (k+1))/2 = (k+1)(k+2)/2. The first equality is a consequence of the inductive assumption. Note: Math induction is of no use for deriving formulas. But it is a good way to prove the validity of a formula that you might think is true. Recurrence formulas are notoriously difficult to derive, but easy to prove valid once you have them. Recursive Definitions A recursive definition (or inductive definition) is used to define an object in terms of itself. A recursive definition of a function defines values of the functions for some inputs in terms of the values of the same function for other inputs. For example, the factorial functions n! is defined by the rules 0! = 1. (n+1)! = (n+1) n!. This definition is valid because, for all n, the recursion eventually reaches the base case of 0. Thus the definition is well-founded. The definition may also be thought of as giving a procedure describing how to construct the function n!, starting from n = 0 and proceeding onwards with n = 1, n = 2, n = 3 etc.. An inductive definition of a set describes the elements in a set in terms of other elements in the set. For example, one definition of the set N of natural numbers is: 1. 0 is in N. 2. If an element n is in N then n+1 is in N. 3. N is the smallest set satisfying (1) and (2). There are many sets that satisfy (1) and (2); clause (3) makes the definition precise by choosing the smallest such set as N. Properties of recursively defined functions and sets can often be proved by an induction principle that follows the recursive definition. For example, the definition of the natural numbers presented here directly implies the principle of mathematical induction for natural numbers: if a property holds of the natural

number 0, and the property holds of n+1 whenever it holds of n, then the property holds of all natural numbers Form of recursive definitions Most recursive definition has three foundations: a base case (basis), an inductive clause, and an extremal clause. The difference between a circular definition and a recursive definition is that a recursive definition must always have base cases, cases that satisfy the definition without being defined in terms of the definition itself, and all other cases comprising the definition must be "smaller" (closer to those base cases that terminate the recursion) in some sense. In contrast, a circular definition may have no base case, and define the value of a function in terms of that value itself, rather than on other values of the function. Such a situation would lead to an infinite regress Examples Prime numbers The prime numbers can be defined as consisting of: 2, the smallest prime; Each positive integer which is not evenly divisible by any of the primes smaller than itself. The integer 2 is our base case; checking the primality of any larger integer X requires us to know the primality of every integer between X and 2, but each such integer is closer to our base case of 2 than X is. Non-negative even numbers The even numbers can be defined as consisting of 0 is in the set E of non-negative evens (basis clause) For any element x in the set E, x+2 is in E (inductive clause) Nothing is in E unless it is obtained from the basis and inductive clauses (extremal clause).

Introduction to TOC Objectives of TOC Understand the inherent capabilities of computing/machines Understand the essence of computing through abstract models Apply these models in practice to solve problems Understand the limitations of computing Identifying the resources needed to solve a computational problem such as time, space, communication, and number of processors What is TOC? Theory of Computation is the study of the inherent capabilities and limitations of computers Theory of Computation aims at studying How and how much efficiently decided whether a given string belongs to a language or not? Abstract Model is a theoretical model of a computer hardware or software system Often used in identifying computability of a problem, analyzing complexity of algorithms. Automata theory is the study of abstract machines and problems they are able to solve Formal Languages A formal language is a set of words, i.e. finite strings of letters, symbols, or tokens The set from which these letters are taken is called the alphabet over which the language is defined A formal language L over an alphabet Σ is just a subset of Σ*, that is, a set of words over that alphabet Examples Set of all strings from { 0, 1 } Set of all strings from { a, b,... z }

Fig Differences among FA, PDA and Turing Machine Chomsky s Hierarchy of formal languages The Chomsky Hierarchy, as originally defined by Noam Chomsky, comprises four types of languages and their associated grammars and machines.

Context-Sensitive Language A context-sensitive Language is a language generated by a context sensitive grammar. Definition 1: A context-sensitive grammar is one whose productions are all of the form xay xvy where A v and x, v, y (V T )*. Context-sensitive implies the fact that the actual string modification is given by A v, while the x and y provide the context in which the rule may be applied. Definition 2: A context-sensitive grammar is one whose productions are all of the form x y where x, y (V T )+, and x y. This type of grammar is called Non-contracting as the derivation steps never decrease the length of the sentential form. This definition given above is mostly used. The two kinds of grammar are almost equivalent generating the same languages with only the exception: One kind of grammar permits languages to contain the empty

string, while the other doesn t. A language L is context-sensitive if there exists a context sensitive grammar G such that either L = L(G) or L = L(G) {λ}. Example Show that the language L = {a n b n c n n 1} is a context-sensitive language Solution Let us prove this by showing a context-sensitive grammar for the language. Regular Languages Most restricted, and the simplest in the Noam Chomsky Hierarchy Described using regular expressions Recognized by Finite Automata in deterministic or non deterministic form Generated by regular grammar Every finite language is regular Advantages of Regular languages Scan for virus signatures Search for information using Google Access information in digital libraries Reading text enclosed by markup language tags Search-and-replace in a word processors Validate data-entry fields like dates, email, URL, credit card, IP addresses Recognizing identifiers, integers, decimal, keywords, operators in programming languages

Reading comments in programming languages Describing Regular languages Linear Bounded Automata A Turing machine has an infinite supply of blank tape. A linear-bounded automaton is a Turing machine whose tape is only an squares long, where n is the length of the input string and a is a constant associated with the particular linear-bounded automaton. Theorem: For every context-sensitive language L there exists a linear-bounded automaton M such that L = L(M), i.e., M accept exactly the strings of L. Theorem : For every language L accepted by a linear-bounded automaton that produces exactly L or L {λ}, depending on the definition of context sensitive grammar. Relationship among the Grammars Theorem: Every context-free language is context-sensitive.

Proof: The productions of a context-free language have the form A v. The productions of a context-sensitive language have the form xay xvy, where x and y are permitted to be λ. Hence the result. Theorem: There exists a context-sensitive language that is not context-free. Proof: The language {a n b n c n n 0} is not context-free (which could be proved using a pumping lemma). It can be shown that it is context-sensitive by providing an appropriate grammar. The productions of one such grammar is given here. Theorem Every context-sensitive language is recursive. Proof: A context-sensitive grammar is no contracting. Moreover, for any integer n there are only a finite number of sentential forms of length n. Therefore, for any string w we could set a bound on the number of derivation steps required to generate w, hence a bound on the number of possible derivations. The string w is in the language if and only if one of these derivations produces w. Extending Chomsky Hierarchy So far we have discussed about other types of languages besides those in the classical Chomsky hierarchy. For example, we noted that deterministic pushdown automaton were less powerful than nondeterministic pushdown automata. The table below shows a table of some of the language classes we have covered that fit readily into the hierarchy.

It should be noted that not all language classes fit into a hierarchy. When linear languages are considered, they fit neatly between the regular languages and the contextfree languages. However there are languages that are linear but not deterministic contextfree, and there are languages that are deterministic context-free but not linear. Language recognizers The language recognizers are the automaton which can work on a particular language. The following table describes different automaton for the formal languages

Summary This chapter covers the basic concepts of Sets, Relations and Functions and the operations performed with them. Various formal proofs including Deductive, If-then, If and only if, Proof by contradiction, Proof by contra positive, Proof by counter example and Mathematical induction have been discussed. The basics of TOC and Chomsky hierarchy of languages are discussed. Key Terms Set: Collection of objects Singleton: Set having only one element. Empty set: Set with no element Complement: Set containing everything not contained in the base set. Cardinality: Number of elements in a set. Power set: Set having n elements have a power set having 2n elements. Relation: A relation on two sets is a set of ordered pair. Poset: Partially ordered set. Mapping: A function is otherwise called Mapping. Injection (one-to-one function): Function is one-to-one if different elements in domain of one set have distinct images in the range. Surjection (onto function): A function is onto function if each element of a set is the image of some element of the other set. Bijection (one-to-one onto function): Function that is both one-to-one and onto Invertible function: Function is invertible if and only if it is both one-to-one and onto. Alphabet: Finite set of symbols. String: Finite sequence of symbols from an alphabet. Lexicographic ordering: Dictionary ordering, except that shorter strings precede longer strings. Language: Any set of strings over an alphabet. Kleene star: Set of all strings obtained by concatenating zero or more strings from a language. Boolean logic: System built with two values True and False. Negation: Means NOT operation Conjunction: Means AND operation Disjunction: Means OR operation. Exclusive-OR: 1 if either but not both of its operands are 1. Mathematical Induction: Has two parts (a) Induction step (b) Basis. Pigeon-hole principle: If an attempt is made to pair off the elements of A ( the pigeons ) with elements of B (the pigeon holes ), sooner or later we will have to put more than one pigeon in a pigeon hole. Context sensitive language: Language generated by a context-sensitive grammar. Context-sensitive grammar: It is one whose productions are of the form xay xvy where A V and x, v, y (V T )*. Linear Bounded automata (LBA): It is a TM whose tape is only αn squares long, where n is the length of input string and α is a constant associated with the LBA.

Chomsky hierarchy: Has 4 types of languages, (a) Regular language (b) Context-free language (c) Context-sensitive language (d) Recursively enumerable language. Unrestricted grammar: Production of the form α β where α,β are arbitrary strings of grammar symbols, with α λ forms unrestricted grammar. Review Questions 1. Define the following terms: (a) Set (b) Union (c) Intersection 2. Define the following terms: (a) set difference (b) Complement Explain with examples. 3. What have you understood by the following: (a) Idem potency (b) Commutatively (c) Associatively in respect of sets. 4. Define the following w.r.t. sets: (a) Distributivity (b) Absorption (c) DeMorgan s laws 5. Stand prove DeMorgan s Laws. 6. Define the following terms w.r.t. sets: (a) Disjoint sets (b) Cardinality (c) Power set (d) Cartesian product. 7. Define a relation. Explain with an example. 8. What is an equivalence relation? Give an example. 9. Explain the terms: (a) Partial ordered set/poset (b) Partition of a relation 10. What do you mean by equivalence class? 11. Define function as a relation. 12. What are the kinds of functions? 13. Explain the following with an example for each: (a) One-to-one function (b) Onto function (c) One-to-one onto function (d) Invertible function. 14. Differentiate between Injection, Surjection and bijection with examples. 15. How will you define the following: (a) string (b) alphabet in languages. 16. How do you define the length of a string? 17. Define the following in respect of languages. (a) Empty string (b) Reverse string (c) Substring (d) Concatenation 18. What do you mean by lexicographic ordering of strings? 19. What do you mean by prefix and suffix of a string?

20. Define a language with an example. 21. Define concatenation of strings with an example. 22. Define kleene star, with an example. 23. What are the kinds of fundamental proof techniques? 24. Explain the following with an example (in Boolean logic) (a) Negation (b) Conjunction (c) Disjunction (d) Exclusive-OR (e) Equality (f) Implication 25. State and explain the principle of Mathematical Induction with an example. 26. What do you mean by a context-sensitive grammar? 27. What do you mean Linear bounded automata? 28. Prove: Every context-free language is context-sensitive. 29. Prove: There exists a context-sensitive language that is not context-free. 30. Prove: Every context-sensitive language is recursive. 31. Given an example for (a) Context-sensitive language (b) Recursively enumerable language. 32. What are the machines corresponding to each of the following? (a) Recursively enumerable language (b) Context sensitive language (c) Context-free language (d) Regular language. 33. What do you mean by unrestricted grammar? 34. What do you mean by a random access machine?

Exercises