Presentation is loading. Please wait.

Presentation is loading. Please wait.

Complexity and Computability Theory I Lecture #13 Instructor: Rina Zviel-Girshin Lea Epstein Yael Moses.

Similar presentations


Presentation on theme: "Complexity and Computability Theory I Lecture #13 Instructor: Rina Zviel-Girshin Lea Epstein Yael Moses."— Presentation transcript:

1 Complexity and Computability Theory I Lecture #13 Instructor: Rina Zviel-Girshin Lea Epstein Yael Moses

2 Rina Zviel-Girshin @ASC2 Overview Usage of pumping lemma for CFL Review of the course Decidability Decision problems in FA Turing machine

3 Rina Zviel-Girshin @ASC3 L={a i b i c 2i |i>0} We will use the pumping lemma to prove that L={a i b i c 2i |i>0} is not CFL. Proof: We assume that L is CFL and obtain a contradiction. Let p be the pumping length for L. We select a string w= a p b p c 2p. w  L and |w|>p, so it can be pumped.

4 Rina Zviel-Girshin @ASC4 Lets divide w into five parts uvxyz such that |vy|>0 and |vxy|  p. We have two major partition cases: 1.vxy contains a single alphabet symbol ( 3 types of partition: or a’-s or b’-s or c’-s) 2.vxy contains two symbols of the alphabet ( 2 types of partition: or a’-s and b’-s or b’-s and c’-s) L={a i b i c 2i |i>0}

5 Rina Zviel-Girshin @ASC5 If vxy contains only one type of alphabet symbol then i=2 will give us a word w 2 =uv 2 xy 2 z and w 2  L. WHY? Because w 2 does not contain the same number of a's, b's and twice c's. L={a i b i c 2i |i>0}

6 Rina Zviel-Girshin @ASC6 If vxy contains only two type of alphabet symbols (can't have three because |vxy|<=p) then i=2 will give us a word w 2 =uv 2 xy 2 z and w 2  L. WHY? Because w 2 does not contain the same number of a's, b's and twice c's. We pumped only two alphabet symbols. L={a i b i c 2i |i>0}

7 Rina Zviel-Girshin @ASC7 L={a i b i c 2i |i>0} One of these cases must occur. In both cases we have a contradiction to lemma. So the assumption that L is CFL must be false. L is not CFL.

8 Rina Zviel-Girshin @ASC8 Review Among the aims: practical techniques - useful in compilation, translation, data compression etc. formalization of the concept of language - useful in formal linguistics etc. computational models - useful in answering basic questions about computations.

9 Rina Zviel-Girshin @ASC9 Computational Model A simplistic and minimal model for computation. Computation - not only arithmetic but also solving a problem, anything a computer can or is expected to perform.

10 Rina Zviel-Girshin @ASC10 Computational Model Usage To answer basic questions about our ability to solve problems and better understand the formal (algorithmic/logical/mathematical) computation. Understanding of the computer abilities and its limits.

11 Rina Zviel-Girshin @ASC11 Formal Languages One, very important, formalization of computation, in addition to its usefulness in other aspects. The computation determines if a word is in a language. Any problem can be reduced to this problem of a word belonging to a language.

12 Rina Zviel-Girshin @ASC12 Example An arithmetical problem of finding the answer to: 3*7=X This problem can be formulated as a question: –which of the following words belong to the language of correct arithmetic: 3*7=0 3*7=1 3*7=2... 3*7=21 3*7=22 3*7=23...

13 Rina Zviel-Girshin @ASC13 Computational Models Families Two families of Computational Models were studied: –machines/automata –rewriting systems

14 Rina Zviel-Girshin @ASC14 Machine model The machines/automata use or built on basic machine model: –states –transition between states –control and memory

15 Rina Zviel-Girshin @ASC15 Rewriting systems The rewriting systems compute by rewriting a string: –from input to output string –from empty string to output

16 Rina Zviel-Girshin @ASC16 Automata We studied two least powerful models in the hierarchy: –finite automata FA –pushdown automata PDA We have seen that the first is less powerful than the second.

17 Rina Zviel-Girshin @ASC17 Automata The type of problems the FA can solve (regular languages) is therefore a proper subset of the type of problems the PDA can solve (CFL – context-free languages).

18 Rina Zviel-Girshin @ASC18 The Turing-Church thesis We did not study the most powerful machine –Turing Machine. TM has less restrictions on the availability of memory than PDA. The Turing-Church thesis is that TM can do what any computer can do, and there isn’t a more powerful computational model than TM.

19 Rina Zviel-Girshin @ASC19 Determinism versus Non- determinism We have seen one very important attribute of a computational model: –its being deterministic/nondeterministic. Do we have only one possibility on each input or more? We saw that in different automata the attribute does not add power (FA) or it does (PDA). We will see that in TM it again does not.

20 Rina Zviel-Girshin @ASC20 Rewriting Systems We studied one such system – grammars. It has by itself great practical usage in compilation, languages etc. It is also one of the major Computational Models. We saw here again two parallel hierarchies of: –grammars and –parallel language families

21 Rina Zviel-Girshin @ASC21 Rewriting Systems(cont.) We did not study the most powerful grammar – the one with no restrictions, and especially no forbidding of deleting terminals. This grammar is a full-power Computational Model, not less powerful than any other, not less powerful than TM.

22 Rina Zviel-Girshin @ASC22 Decision Problems Problems for which the answer is “yes/no”. Any problem can be reduced to decision problem.

23 Rina Zviel-Girshin @ASC23 Example An arithmetical problem of finding the answer to : 3*7=X This problem can be formulated as a decision problem: –for each of the following answer “yes/no”: 3*7=03*7=13*7=2... 3*7=213*7=223*7=23...

24 Rina Zviel-Girshin @ASC24 Decidability One of the major usages of computational models. Informally: Decidability of problem X – whether the problem has an algorithm which solves it (decides it). Decidability of a problem – whether the problem is decidable, i.e. whether there is a correct algorithm which: Always halts With the correct answer

25 Rina Zviel-Girshin @ASC25 Decidability A decidable problem has such an algorithm/TM/grammar. An undecidable problem does not have such an algorithm/TM/grammar.

26 Rina Zviel-Girshin @ASC26 Undecidable problems There are problems which are undecidable. Examples: The barber The Cretan

27 Rina Zviel-Girshin @ASC27 The barber problem All and only citizens of a town that do not cut their own hair themselves, have their hair cut by the only barber in the town. Who cuts the hair of the barber? Does the barber cut its own hair?

28 Rina Zviel-Girshin @ASC28 The Cretan problem All Cretans always lie. All non-Cretans never lie. A man says: “I am a Cretan.” Is he?

29 Rina Zviel-Girshin @ASC29 Decidability of Decision Problems in FA The following are the most basic Decision Problems in FA: –membership –Emptiness –Finiteness/Infiniteness

30 Rina Zviel-Girshin @ASC30 membership Informally: whether a word is in a language of given DFA? Input: DFA A and a string w Output:“yes” if w  L(A); “no” otherwise.

31 Rina Zviel-Girshin @ASC31 Proof of decidability The algorithm to decide the problem is: –start A on w from q 0 –if  ’(q 0,w)  F  return “yes” –otherwise return “no” The algorithm will always halt after |w| steps.

32 Rina Zviel-Girshin @ASC32 Emptiness Informally: whether the language of an FA is empty? Input: FA A Output:“yes” if L(A)=  ; “no” otherwise.

33 Rina Zviel-Girshin @ASC33 Proof of decidability The algorithm to decide the problem is: –find all states of A reachable from q 0 and enter them into a set called Reachable –if F  Reachable=  return “yes” –otherwise return “no”

34 Rina Zviel-Girshin @ASC34 Correctness (or halting) Determining the reachable states can be done in BFS, DFS or any other graph traversing algorithm in O(E) steps, i.e. the algorithm will always halt after |arcs in A| steps. This number is bounded from above by the square of the number of states of A, which is finite. Determining for each state in Reachable whether it is accepting or not, is O(1).

35 Rina Zviel-Girshin @ASC35 Finiteness Informally: whether the number of words in a language of an FA is finite? Input: FA A Output:“yes” if L(A) is finite; “no” otherwise.

36 Rina Zviel-Girshin @ASC36 Proof of decidability The algorithm to decide the problem is: –find all the reachable states: set R –find among them all the states that have path from them to an accepting state: set RF –find if the graph of A has cycles with one of the states in RF in it –if it does not return “yes” –otherwise return “no”

37 Rina Zviel-Girshin @ASC37 Correctness (or halting) Determining the existence of cycles can be done using BFS, DFS or any other graph traversing algorithm in O(E) steps, i.e. the algorithm will always halt after |arcs in A| steps. This number is bounded from above by the square of the number of states of A, which is finite.

38 Rina Zviel-Girshin @ASC38 Infiniteness Informally: whether the number of words in a language of an FA is infinite? Input: FA A Output:“yes” if L(A) is infinite; “no” otherwise.

39 Rina Zviel-Girshin @ASC39 Proof The same algorithm as in finiteness but in the last stage gives reverse answers: –if it contains circle that leads to an accepting state return “yes” –otherwise return “no” Correctness or halting – as before

40 Rina Zviel-Girshin @ASC40 Turing Machines First proposed by Alan Turing 1936. Unlimited and unrestricted memory. A model of a general purpose computer. Can do anything that a real computer can do. Cannot solve all problems!!

41 Rina Zviel-Girshin @ASC41 Turing Machine An infinite tape - unlimited memory. A tape head - can move left and right, can read and write. bbacb head bdac__

42 Rina Zviel-Girshin @ASC42 Input/Output 00111 ___ q accept 010 _____... q0q0 _ Initial Configuration Final Configuration InputOutput

43 Rina Zviel-Girshin @ASC43 Initialization Input: appears on the leftmost n squares of the tape. The rest of the tape is blank. Head starts on the left-most square. State: q 0 bba _____... head

44 Rina Zviel-Girshin @ASC44 Output State: accept or reject. Can also return a value: the symbols to the left of the head. Does a program always has an output? Can also run forever - loop.

45 Rina Zviel-Girshin @ASC45 Final Configuration q  {q accept, q reject } The tape contains uw. – Example: u = 00 w=101, The rest of the tape is blank. The output is u. –Example: u = 00... 00101 ___ q accept

46 Rina Zviel-Girshin @ASC46 Example: B={w#w|w  {0,1} * } 010 0 # 01... 00 _ x 10 0 # 0100 _ x10 0 #x 100 _ xxx x # xxxx _ accept

47 Rina Zviel-Girshin @ASC47 Example: B={w#w|w  {0,1} * } M 1 =“On input string w: 1.Scan and check that the input contains a single #. If not reject. 2.Zig-zag to check whether corresponding positions on either sides of # contain the same symbol. If not, reject. Cross off the checked symbols. 3.When all symbols to the left of # are crossed, check for remaining symbols to the right of #. If any symbol, reject. Otherwise, accept. ”

48 Rina Zviel-Girshin @ASC48 Differences Between Finite Automata and TM A TM can both read and write. The head can move left and right. The tape is infinite. The special cases of reject and accept take an immediate action.

49 Rina Zviel-Girshin @ASC49 Formally: (Q, , , , q 0, q accept, q reject ) Q is the set of states.  is the input alphabet _  .  is the tape alphabet, _  and .  :Qx   Qx  x{R,L} the transition function. q 0, q accept, q reject the start, accept and reject states. q accept  q reject

50 Rina Zviel-Girshin @ASC50 Example: B={w#w|w  {0,1} * } Q={q 0, q accept, q reject,q 1,q 2,…}  ={0,1,#}  =   {_,x}  :Qx   Qx  x{R,L} q 0, q accept, q reject  =?... 010 0 # 0100 _ x 10 0 # 0100 _ x10 0 #x 100 _ xxx x # xxxx _ q accept... q0q0

51 Rina Zviel-Girshin @ASC51 Any Questions?


Download ppt "Complexity and Computability Theory I Lecture #13 Instructor: Rina Zviel-Girshin Lea Epstein Yael Moses."

Similar presentations


Ads by Google