sr1 toc intro handout

29
CSE 211: Introduction to the Theory of Computation Md. Shaifur Rahman Dept. of CSE Bangladesh University of Engineering & Technology Week 1 Class 1 Shaifur (BUET)  CSE211: TOC-Intro  Week 1 Class 1 1 / 29

Upload: arannya-monzur

Post on 03-Jun-2018

246 views

Category:

Documents


0 download

TRANSCRIPT

8/12/2019 Sr1 Toc Intro Handout

http://slidepdf.com/reader/full/sr1-toc-intro-handout 1/29

CSE 211: Introduction to the Theory of Computation

Md. Shaifur Rahman

Dept. of CSEBangladesh University of Engineering & Technology

Week 1 Class 1

Shaifur (BUET)   CSE211: TOC-Intro   Week 1 Class 1 1 / 29

8/12/2019 Sr1 Toc Intro Handout

http://slidepdf.com/reader/full/sr1-toc-intro-handout 2/29

Outline

1   Necessity of CS Theory Courses

2   What is Theory of Computation?

3   Course Outline

Shaifur (BUET)   CSE211: TOC-Intro   Week 1 Class 1 2 / 29

8/12/2019 Sr1 Toc Intro Handout

http://slidepdf.com/reader/full/sr1-toc-intro-handout 3/29

Why Theory? (again!)

We don’t like theory, because:One has to memorize a lot of theorems, lemmas, proofs

It is inherently boring!

Where is the output?

How is it related to our career-path?We like non-theory courses,

We like programming in C, C++, JAVA, Python, Android etc.

The outcome is visible, projects done in these courses brighten our

resumeThe skills are necessary for the career-path of a developer

Achieving grades are comparatively easy :)

Shaifur (BUET)   CSE211: TOC-Intro   Week 1 Class 1 3 / 29

8/12/2019 Sr1 Toc Intro Handout

http://slidepdf.com/reader/full/sr1-toc-intro-handout 4/29

Theory vs. Non-theory

Difficult to separate theories from all courses!

Course Theory-bias

CSE 103 (Discrete Math) 90%

CSE 105 (Structured Programming Language) 30%

CSE 201 (Object Oriented Programming Language) 20%

CSE 203 (Data Structure) 80%CSE 205 (Digital Logic Design) 60%

In this semester:

Course Theory-bias

CSE 207 (Algorithms) 95%CSE 209 (Digital Electronics and Pulse Technique) 40%

CSE 211 (Theory of Computation)   100%

CSE207 is the fraternal brother of CSE211

Shaifur (BUET)   CSE211: TOC-Intro   Week 1 Class 1 4 / 29

8/12/2019 Sr1 Toc Intro Handout

http://slidepdf.com/reader/full/sr1-toc-intro-handout 5/29

The Power of Theory

Write a C program that finds all the factors of a 512-bit integer

For input  24, Output is:   1, 2, 3, 4, 6, 8, 12  and  24  , since  24 = 1× 23 × 3But wait! 512-bit number!So the input ranges from  1  to  2512 − 1 thats roughly  1.3× 10154

The highest input can be of  155-digits!

Input:   12345676449393993. . .

930049922 (155 digits)

3 hours gone, your C-program is not coming up with any answer?Your program worked perfectly for 1, 2, 10, 20 even 50 digit inputs!

So what’s wrong??

Is your program erroneous?

Is the computation power of the machine insufficient?

Is there a probem in the nature of the input?

Shaifur (BUET)   CSE211: TOC-Intro   Week 1 Class 1 5 / 29

8/12/2019 Sr1 Toc Intro Handout

http://slidepdf.com/reader/full/sr1-toc-intro-handout 6/29

The Power of Theory (Contd.)

Case: Your program is erroneousHow do you know? The program is not even stopping!It may indeed stop after 10 hours and show the correct output!

Case: Computation Power of the Machine is insufficientWe may use multi-core processors clocked at a very high speedlike: 10-core processor each core clocked at  3 GHzCan we afford that machine?What if the number is even bigger? Can the machine scale up to the

input?Caveat:  Even with today’s fastest computer, the computation for a500-digit input will take 5 billion years!

Shaifur (BUET)   CSE211: TOC-Intro   Week 1 Class 1 6 / 29

8/12/2019 Sr1 Toc Intro Handout

http://slidepdf.com/reader/full/sr1-toc-intro-handout 7/29

The Power of Theory (Contd.)

Case: Nature of Input

Some numbers are too big or too smallAre you crazy? 500-digit number? That’s pretty big!So is:

the number of stars in the universe

the number of electrons in your body

the energy in electron volt when two stars collide

the number of combinatorial choices of pairings of almost half-million

genes in our cellSo, data can be very large or too small? You never can tell

Shaifur (BUET)   CSE211: TOC-Intro   Week 1 Class 1 7 / 29

8/12/2019 Sr1 Toc Intro Handout

http://slidepdf.com/reader/full/sr1-toc-intro-handout 8/29

The Power of Theory (Contd.)

Case: Nature of Computation

Can we break down the processing into multiple blocks and distribute

those among multiple computers?Can we predict the time required by analyzing the nature of input(input-domain) and the method of computation (algorithm)?

Can we identify certain problems as really hard problems?

Shaifur (BUET)   CSE211: TOC-Intro   Week 1 Class 1 8 / 29

8/12/2019 Sr1 Toc Intro Handout

http://slidepdf.com/reader/full/sr1-toc-intro-handout 9/29

Really Hard Problems

General Tile Fitting Problem

Given a finite set of tiles and an area on a plane, is it possible to cover thecomplete area using each type of tiles at least once?

Shaifur (BUET)   CSE211: TOC-Intro   Week 1 Class 1 9 / 29

8/12/2019 Sr1 Toc Intro Handout

http://slidepdf.com/reader/full/sr1-toc-intro-handout 10/29

8/12/2019 Sr1 Toc Intro Handout

http://slidepdf.com/reader/full/sr1-toc-intro-handout 11/29

Really Hard Problems (Contd.)

There are many problems that cannot be guaranteed to be solved by any

computer! These are called undecidable problems

David Hilbert

Entscheidungsproblem

Give an algorithm A that takes as input

a hypothesis   H and answers True orFalse based on a finite set of axioms  S A.In other word, Algorithm A decideswhether  H   logically follows from  S A.

Hypothesis:  A machine works withoutconsuming any energy.Decision:  False (according to the set of axioms of Physics)

Shaifur (BUET)   CSE211: TOC-Intro   Week 1 Class 1 11 / 29

8/12/2019 Sr1 Toc Intro Handout

http://slidepdf.com/reader/full/sr1-toc-intro-handout 12/29

Really Hard Problems (Contd.)

Alonzo Church & Alan Turing

Alonzo Church and Alan Turing independently proved respectively in 1936and in 1937 that

Hilbert’s Entscheidungsproblem is undecidable

This is known as Church-Turing Thesis.

Shaifur (BUET)   CSE211: TOC-Intro   Week 1 Class 1 12 / 29

8/12/2019 Sr1 Toc Intro Handout

http://slidepdf.com/reader/full/sr1-toc-intro-handout 13/29

Really Hard Problems (Contd.)

More undecided problems:

Mortal Matrix Problem

Given a finite set of  n× n  matrices with integer entries, determinewhether they can be multiplied in some order, possibly with repetition, toyield the zero matrix.

Conjugacy problem

Given two words  x and  y  of a Group  G, whether there exists a  z  such that:y = zxz−1

*A group is an algebraic structure consisting of a set with one or moreoperators such that the result of applying the operators on one or moreelements of the is also an element in the set. For example, the set of integer  I   is a group.

Shaifur (BUET)   CSE211: TOC-Intro   Week 1 Class 1 13 / 29

8/12/2019 Sr1 Toc Intro Handout

http://slidepdf.com/reader/full/sr1-toc-intro-handout 14/29

Really Hard Problems (Contd.)

Some problems are hard but still solvable i.e. NOT undecidable

(Euclidian) Travelling Salesman ProblemGiven a set of vertices and their coordinates, find a tour or cycle whichvisits each vertex exactly once and is of the minimum length.

Shaifur (BUET)   CSE211: TOC-Intro   Week 1 Class 1 14 / 29

8/12/2019 Sr1 Toc Intro Handout

http://slidepdf.com/reader/full/sr1-toc-intro-handout 15/29

Really Hard Problems (Contd.)

Some problems are hard but still solvable i.e. NOT undecidable

Chromatic Number or Graph Coloring ProblemGiven a graph  G = (V,E ), find the minimum number of different colorsneeded for this graph such that two adjacent vertices are not given thesame color.

Total three different colors are needed

Shaifur (BUET)   CSE211: TOC-Intro   Week 1 Class 1 15 / 29

8/12/2019 Sr1 Toc Intro Handout

http://slidepdf.com/reader/full/sr1-toc-intro-handout 16/29

R ll H d P bl (C d )

8/12/2019 Sr1 Toc Intro Handout

http://slidepdf.com/reader/full/sr1-toc-intro-handout 17/29

Really Hard Problems (Contd.)

There is relationships among the hard solvable problems, we can comparetheir hardness!

Circuit satisfiability problem(Circuit-SAT) can be reducedto Travelling Salesman

Problem (TSP)If there is a good solution toCircuit-SAT, there is also agood solution to TSP

Shaifur (BUET)   CSE211: TOC-Intro   Week 1 Class 1 17 / 29

R ll H d P bl (C d )

8/12/2019 Sr1 Toc Intro Handout

http://slidepdf.com/reader/full/sr1-toc-intro-handout 18/29

Really Hard Problems (Contd.)

Moral of the story

If the given problem is proved to be  undecidable or unsolvable, don’tinvest your valuable effort to write program to solve it.

If the given problem is solvable but still  hard, it is not your program’sfault that the computation is taking too much time.

If the given problem is solvable and not hard, and your program failsto solve it in the reasonable amount of time,  only then invest effort

for improvement of your program!

Shaifur (BUET)   CSE211: TOC-Intro   Week 1 Class 1 18 / 29

Th f C i

8/12/2019 Sr1 Toc Intro Handout

http://slidepdf.com/reader/full/sr1-toc-intro-handout 19/29

Theory of Computation

Theory of computation

The branch that deals with whether and how efficiently problems can besolved on a model of computation, using an algorithm

The field is divided into three major branches:

Automata TheoryComputability Theory and

Computational Complexity Theory

There are many models of computation:

Turing MachineCombinatory logic

Markov Algorithm etc.

In our CS couses, we use Turing Machine model.

Shaifur (BUET)   CSE211: TOC-Intro   Week 1 Class 1 19 / 29

B h f Th f C t ti

8/12/2019 Sr1 Toc Intro Handout

http://slidepdf.com/reader/full/sr1-toc-intro-handout 20/29

Branches of Theory of Computation

Automata Theory

the study of  abstract machines ( in our case,  Turing Machine) andthe problems that can be solved using these machines

If the abstract machine cannot solve the problem, no computer onearth, no matter how powerful it is, can ever solve the problem

Topics include: Finite Automaton (FA), Push-down Automaton(PDA), Turing Machine (TM) etc.

studied in the theory of computation, compiler design, verificationsystems, robotics etc.

Shaifur (BUET)   CSE211: TOC-Intro   Week 1 Class 1 20 / 29

8/12/2019 Sr1 Toc Intro Handout

http://slidepdf.com/reader/full/sr1-toc-intro-handout 21/29

Branches of Theory of Computation (Contd )

8/12/2019 Sr1 Toc Intro Handout

http://slidepdf.com/reader/full/sr1-toc-intro-handout 22/29

Branches of Theory of Computation (Contd.)

Computational Complexity Theory

deals with classifying computational problems according to theirinherent difficulty

Two major aspects are considered: time complexity (how many stepsthe algorithm takes) and space complexity (how much memory isrequired by the program)

studies complexity classes:   P ,  NP ,  NPC  and relationships among

these classes

Shaifur (BUET)   CSE211: TOC-Intro   Week 1 Class 1 22 / 29

Course Outline

8/12/2019 Sr1 Toc Intro Handout

http://slidepdf.com/reader/full/sr1-toc-intro-handout 23/29

Course Outline

Course Name:  CSE 211 (Theory of Computation)Credit Hour:   2.0Number of Class Tests:   3

Course Teachers:

Md. Shaifur Rahman (first seven weeks before mid-term)and

Sukarna Barua (after mid-term)

Shaifur (BUET)   CSE211: TOC-Intro   Week 1 Class 1 23 / 29

Class Outline

8/12/2019 Sr1 Toc Intro Handout

http://slidepdf.com/reader/full/sr1-toc-intro-handout 24/29

Class Outline

Week Day Topics

1  1 Introduction to TOC

2 Deterministic Finite Automaton (DFA)

2  1 DFA (Contd.)

2 Operators of Finite Automaton

3  1 Non-deterministic Finite Automaton (NFA)

2 Equivalence of DFA and NFA4

  1 Regular Expressions2   Class Test-1

5  1 Regular Expressions (Contd.)

2 Pumping Lemma

6   1 Context-free Grammar (CFG)2 CFG (Contd.)

7  1 Overall Discussion

2   Class Test-2

Shaifur (BUET)   CSE211: TOC-Intro   Week 1 Class 1 24 / 29

Textbooks

8/12/2019 Sr1 Toc Intro Handout

http://slidepdf.com/reader/full/sr1-toc-intro-handout 25/29

Textbooks

Main textbook

Introduction to the Theory of Computation (3rd Edition)

byMichael Sipser

Shaifur (BUET)   CSE211: TOC-Intro   Week 1 Class 1 25 / 29

Textbooks (Contd )

8/12/2019 Sr1 Toc Intro Handout

http://slidepdf.com/reader/full/sr1-toc-intro-handout 26/29

Textbooks (Contd.)

Supporting textbooks

Introduction to Automata Theory,Languages & Computation

(3rd Edition)by

Hopcroft et. al.

Shaifur (BUET)   CSE211: TOC-Intro   Week 1 Class 1 26 / 29

Textbooks (Contd )

8/12/2019 Sr1 Toc Intro Handout

http://slidepdf.com/reader/full/sr1-toc-intro-handout 27/29

Textbooks (Contd.)

Supporting textbooks

Elements of the Theory of Computation(2nd Edition)

by

Lewis et. al.

Shaifur (BUET)   CSE211: TOC-Intro   Week 1 Class 1 27 / 29

Course Website

8/12/2019 Sr1 Toc Intro Handout

http://slidepdf.com/reader/full/sr1-toc-intro-handout 28/29

Course Website

http://sites.google.com/site/cse211february2013

Shaifur (BUET)   CSE211: TOC-Intro   Week 1 Class 1 28 / 29

8/12/2019 Sr1 Toc Intro Handout

http://slidepdf.com/reader/full/sr1-toc-intro-handout 29/29

Question?

Shaifur (BUET)   CSE211: TOC-Intro   Week 1 Class 1 29 / 29