theory of computation...1.3 regular expressions and languages, equivalence of regular expressions...

Post on 09-Jul-2020

20 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Theory of Computation

St. Xavier’s College Maitighar Kathmandu Nepal

Mr. Ganesh Dhami

1

Course Title: Theory of Computation

Course no: CSC-251 Full Marks: 80+20

Credit hours: 3 Pass Marks: 32+8

Nature of course: Theory (3 Hrs.)

Course Synopsis: Deterministic and non-deterministic finite state machines, regular expressions, languages and their properties. Context free grammars, push down automata, Turing machines and computability, undecidableand intractable problems, and Computational complexity.

Goal: To gain understanding of the abstract models of computation and formal language approach to computation

2

Unit 1: 14 Hrs.

1.1 Review of Mathematical Preliminaries: Sets, Logic, Functions, Relations, Languages, Proofs.

1.2 Finite Automata: Deterministic and Non-deterministic Finite Automata, Equivalence of Deterministic and Non-deterministic Finite Automata, Finite Automata with Epsilon-Transition.

1.3 Regular Expressions and Languages, Equivalence of Regular Expressions and Finite Automata, Algebraic Laws for Regular Expressions, Properties of Regular Ranguages, Pumping Lemma for Regular Languages, Minimization of Finite State Machine.

Unit 2: 11 Hrs.

2.1 Context-Free Grammar, Parse Trees, Derivation and Ambiguity, Normal Forms(CNF and GNF) of Context-Free Grammar, Regular Grammars, Closure Properties of Context-Free Languages, Proving a Language to be Non-Context-Free.

2.2 Push Down Automata (PDA), Language of PDA, Deterministic and Non-deterministic PDA, Equivalence of PDA's and CFG,s.

3

Unit 3: 10 Hrs.

3.1 Introduction to Turing Machines, Computation by Turing Machines, Variants of Turing Machines, Non-deterministic Turing Machines, Turing Enumerable Languages.

3.2 Church's Thesis and Algorithm, Universal Turing Machines, Halting Problems, Turing Machines and Computers.

Unit 4: 10 Hrs.

4.1 Undecidability: Recursive and Recursively Enumerable Languages, Encoding of Turing Machine, Universal Language, Unrestricted Grammars and Chomsky Hierarchy, Unsolvable Problems by Turing Machines, Undecidable Problems, Post's Correspondence Problem.

Computational Complexity and Intractable Problems, Measuring Complexity, Class P, Class NP, NP-Completeness and Problem Reduction , NP-Complete Problems.

4

Text Book:

John E. Hopcroft, Rajeev Motwani, Jeffrey D. Ullman, Introduction to Automata Theory, Languages, and Computation, Second Edition, Addison-Wesley, 2001. ISBN: 81-7808-347-7

References:

1. Efim Kinber, Carl Smith, Theory of Computing: A Gentle introduction, Prentice- Hall, 2001. ISBN: 0-13-027961-7.

2. John Martin, Introduction to Languages and the theory of computation, 3rd Edition, Tata McGraw Hill, 2003, ISBN:0-07-049939-X

3. Harry R. Lewis and Christos H. Papadimitriou, Elements of the Theory of Computation, 2nd Edition, Prentice Hall, 1998.

5

6

1.1 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:

7

Computation:

Automata Theory

Computability Theory

Complexity Theory

Why to Study of Automata ?

Abstract Model

Brief History

The basic concepts of Languages ( Alphabets,Strings,Empty String, Length

of String, Power of alphabet, Empty String ,Length of String )

Power of alphabet

Language

Concatenation of Strings

Suffix of a string

Prefix of a string

Substring

Problem

8

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.

9

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

10

1.2 Finite Automata

A finite automaton is a mathematical (model) abstract machine that has a set of “states”

and its “control” moves from state to state in response to external “inputs”. The control

may be either “deterministic” meaning that the automation can’t be in more than one

state at any one time, or “non deterministic”, meaning that it may be in several states at

once. This distinguishes the class of automata as DFA or NFA.

11

• The DFA, i.e. Deterministic Finite Automata can’t be in more than one state at any time.

• The NFA, i.e. Non-Deterministic Finite Automata can be in more than one state at a time.

12

Fig: - Finite automaton modeling an on/off switch

A language is a subset of the set of strings over an alphabet. A language can be generated by grammar. A language can also be recognized by a machine. Such machine is called recognition device. The simplest machine is the finite state automaton.

13

Applications:

The finite state machines are used in applications in computer science and data networking. For example, finite-state machines are basis for programs for spell checking, indexing, grammar checking, searching large bodies of text, recognizing speech, transforming text using markup languages such as XML & HTML, and network protocols that specify how computers communicate.

14

DFA

A deterministic finite automaton is defined by a quintuple (5-tuple) as (Q, Σ, δ, q0, F).

Where,Q = Finite set of states,Σ = Finite set of input symbols,δ = A transition function that maps Q × Σ -> Qq0 = A start state; q0 ∈ QF = Set of final states; F ⊆ QA transition function δ that takes as arguments a state and an

input symbol and returns a state. In our diagram, δ is represented by arcs between states and the labels on the arcs

15

For example

If s is a state and a is an input symbol then δ(p,a)

is that state q such that there are arcs labled „a‟

from p to q

16

General Notations of DFA

• Transition Table

• Transition Diagram

17

Transition Table: -Transition table is a conventional, tabular

representation of the transition function δ that takes the arguments from Q × Σ & returns a value which is one of the states of the automation. The row of the table corresponds to the states while column corresponds to the input symbol. The starting state in the table is represented by -> followed by the state i.e. ->q, for q being start state, whereas final state as *q, for q being final state.

The entry for a row corresponding to state q and the column corresponding to input a, is the state δ (q, a).

18

For example:

Consider a DFA;

Q = {q0, q1, q2, q3}

Σ = {0, 1}

q0 = q0

F = {q0}

δ = Q × Σ -> Q

Then the transition table for above DFA is as follows:

19

This DFA accepts strings having both an even number of 0’s & even number of 1’s.

20

Transition Diagram:

A transition diagram of a DFA is a graphical representation where; (or is a graph)

• For each state in Q, there is a node represented by circle,

• For each state q in Q and each input a in Σ, if δ (q, a) = p then there is an arc

from node q to p labeled a in the transition diagram. If more than one input

symbol cause the transition from state q to p then arc from q to p is labeled by

a list of those symbols.

• The start state is labeled by an arrow written with “start” on the node.

• The final or accepting state is marked by double circle.

21

For the previous example , the corresponding

transition diagram is:

22

How a DFA process strings?

The first thing we need to understand about a DFA is how DFAdecides whether or not to “accept” a sequence of inputsymbols. The “language” of the DFA is the set of allsymbols that the DFA accepts. Suppose a1, a2, …… an is asequence of input symbols. We start out with the DFA in itsstart state, q0. We consult the transition function δ also forthis purpose. Say δ (q0, a1) = q1 to find the state that theDFA enters after processing the first input symbol a1. Wethen process the next input symbol a2, by evaluating δ (q1,a2); suppose this state be q2. We continue in this manner,finding states q3, q4, …, qn. such that δ (qi-1, ai) = qi foreach i. if qn is a member of F, then input a1, a2, --- an isaccepted & if not then it is rejected.

23

24

For Example

25

That is; the language of a DFA is the set of all strings w that take DFA starting from start state to one of the accepting states. The language of DFA is called regular language.

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

top related