1 / 37

Complexity and Computability Theory I

Complexity and Computability Theory I. Lecture #3 Rina Zviel-Girshin Leah Epstein Winter 2002-2003. Overview. Finite automata Deterministic automata Regular languages Regular operations Nondeterminism. FA vs. computer.

testher
Download Presentation

Complexity and Computability Theory I

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Complexity and Computability Theory I Lecture #3 Rina Zviel-Girshin Leah Epstein Winter 2002-2003

  2. Overview • Finite automata • Deterministic automata • Regular languages • Regular operations • Nondeterminism Rina Zviel-Girshin @ASC

  3. FA vs. computer • Both a finite automaton (or a finite-state machine) and a real computer have a "central processing unit" of a fixed, finite capacity. • This is a common property of them both. • A FA delivers no output at all. • A FA is a language recognition device. • A FA is a restricted model of real computers with no memory apart from the fixed central processor. Rina Zviel-Girshin @ASC

  4. Deterministic finite automata • A finite automaton is called deterministic if for each  in  and each qj in Q there exist a unique (qj,)=qk. Example: Rina Zviel-Girshin @ASC

  5. Extended transition function • Notation: ’ • ’: Q*Q • The extended transition function ’ defines the computation of an automaton on word w= u. • Formal definition ’(q,u)=  (’(q,u), )=m Rina Zviel-Girshin @ASC

  6. q k m Example u  where ’(q,u)=  (’(q,u), )=  (k, )= m Rina Zviel-Girshin @ASC

  7. Language recognition • Let A=(Q,,,q0,F) be a finite automaton and w=12...n a string over *. A accepts w if there exists a sequence of states r0,r1,..rn in Q with the following properties: • r0 = q0 • (ri, i+1) = ri+1 for i=0,1,..n • rn F • We say A recognizes language L if L = {w| A accepts w}. Rina Zviel-Girshin @ASC

  8. Regular language • A language is called “a regular language” if some finite automaton recognizes it. • Notation: R • The class of languages accepted by finite automata is identical to the class of regular languages. Rina Zviel-Girshin @ASC

  9. Example  is regular. Rina Zviel-Girshin @ASC

  10. Example * is regular. Rina Zviel-Girshin @ASC

  11. Example L={} is regular. Rina Zviel-Girshin @ASC

  12. Example For each α in  the language Lα = {α} is regular. Rina Zviel-Girshin @ASC

  13. Regular operations • Union • Intersection • Complement • Minus • Concatenation Rina Zviel-Girshin @ASC

  14. Union Theorem: The class of regular languages is closed under the union operation. If L1 and L2 are regular, so is L1L2. • Basic idea: • proof by construction: construct an automaton M that uses the automaton A of L1 and the automaton B of L2 and works by simulating both A and B. Rina Zviel-Girshin @ASC

  15. How can M simulate A and B? • M could run w on A and if A accepts then M accepts. • Or it could run w on B and if B accepts then M accepts.  But • if w not accepted by A? • We can't rewind the input tape. • Once the letter is used the is no way back. Rina Zviel-Girshin @ASC

  16. Simulator Another approach: • We simulate A and B simultaneously. • To do so we need to remember the current states of both machines. • M will have states in QA QB. Rina Zviel-Girshin @ASC

  17. Formal proof Let A recognize L1 where A = (QA, , A, q0A, FA) and B recognize L2 where B = (QB, , B, q0B, FB) . Construct M to recognize L1 L2, where M = ( Q, , , q0, F). • Q={ (rA,rB) | rA in QA and rB in QB}. •  is the same for both A and B. Otherwise let construct  = AB •  is defined as follows: for each (rA,rB) in Q and  in , let ((rA,rB),)=(A(rA,),B(rB,)). Rina Zviel-Girshin @ASC

  18. Formal proof • q0 is a pair (q0A,q0B) • F is the set of pairs in which at least one member is an accept state of A or B. F = { (rA,rB) | rA in FA or rB in FB} or F = (FAQB)(QAFB). This concludes the construction of the finite automaton M that recognizes the union of L1 and L2. Rina Zviel-Girshin @ASC

  19. Formal proof • Now we have to prove that L(M)= L1 L2. To prove the equality we have to prove that: • L1 L2 L(M). and • L(M) L1 L2. Rina Zviel-Girshin @ASC

  20. L1 L2 L(M). • If x L1 L2then x L1orx L2 • That means: ’A(q0A,x)=rAFa or’B(q0B,x))= rBFB • So ’(q0,x)= ’((q0A,q0B),x)= (’A(q0A,x), ’B(q0B,x)) = (rA,rB) where (rA,rB) (FAQB) or (rA,rB) (QAFB). • By definition of F: ’(q0,x)=(rA,rB)  (FAQB)(QAFB)=F • That means x L(M). Rina Zviel-Girshin @ASC

  21. L(M) L1 L2 • If xL(M) then ’(q0,x)= ’((q0A,q0B),x)= (’A(q0A,x), ’B(q0B,x)) F • By definition of F: (’A(q0A,x), ’B(q0B,x))F means ’A(q0A,x) FA or ’B(q0B,x)) FB • So x belongs to L1or to L2. • By definition of union: x L1 L2 • That means L(M) L1 L2. Rina Zviel-Girshin @ASC

  22. Intersection Theorem: The class of regular languages is closed under the intersection operation. If L1 and L2 are regular, so is L1L2. Basic idea: • proof by construction: construct an automaton M that uses the automaton A of L1 and the automaton B of L2 and works by simulating both A and B. Rina Zviel-Girshin @ASC

  23. Formal proof Let A recognize L1 where A = (QA, , A, q0A, FA) and B recognize L2 where B = (QB, , B, q0B, FB) . Construct M to recognize L1 L2, where M = ( Q, , , q0, F). • Q={ (rA,rB) | rA in QA and rB in QB}. •  is the same for both A and B. Otherwise let construct  = A  B •  is defined as follows: for each (rA,rB) in Q and  in , let ((rA,rB),)=(A(rA,),B(rB,)). Rina Zviel-Girshin @ASC

  24. Formal proof • q0 is a pair (q0A,q0B) • F is the set of pairs in which each member is an accept state of A or B (respectively). F = { (rA,rB) | rA in FAand rB in FB} or F = FAFB. That concludes the construction of the finite automaton M that recognizes intersection of L1 and L2. Rina Zviel-Girshin @ASC

  25. Correctness • To prove the correctness of the construction algorithm in a formal way we need to prove that • L(M)L(A)  L(B) and • L(A)  L(B)L(M). Rina Zviel-Girshin @ASC

  26. L(M)L(A) L(B) • Let w* and wL(M) ’(q0,w)=’((q0A,q0B),w)=(’A(q0A,w),’B(q0B,w))  if wL(M) then ’(q0,w)=’((q0A,q0B),w)F  (’A(q0A,w),’B(q0B,w))F=(FAFB)  ’A(q0A,w)FA and ’B(q0B,w)FB means wL(A) and wL(B)  wL(A)L(B) L(M)L(A)  L(B). Q.E.D. Rina Zviel-Girshin @ASC

  27. L(A) L(B)L(M) • Let w* and w L(A)  L(B)  wL(A) and wL(B) ’A(q0A,w)FA and ’B(q0B,w)FB ’(q0,w)=’((q0A,q0B),w)=(’A(q0A,w),’B(q0B,w))(FAFB)=F  means wL(M) L(A)  L(B)L(M). Q.E.D. Rina Zviel-Girshin @ASC

  28. Complement Theorem: The class of regular languages is closed under the complement operation. If L is regular, so is “not L” (the complement language of L). Basic idea: • proof by construction: construct an automaton M that uses the automaton A of L and rejects all words A accepts and vice versa. Rina Zviel-Girshin @ASC

  29. Formal proof Let A recognize L where A = (QA, , A, q0A, FA) . Construct M to recognize L, where M = ( Q, , , q0, F). • Q= QA •  = A •  is defined as follows: for each rA in Q and  in , let (rA, )=A(rA,) • q0 =q0A • F = { rA | rA not in FA } or F = QA - FA. Rina Zviel-Girshin @ASC

  30. The set minus operation Theorem: The class of regular languages is closed under the minus operation. If L1 and L2 are regular, so is L1-L2. Formal proof: L1-L2 = L1(notL2) Rina Zviel-Girshin @ASC

  31. Concatenation Theorem: The class of regular languages is closed under the concatenation operation. If L1 and L2 are regular, so is L1L2. Rina Zviel-Girshin @ASC

  32. Concatenation Basic idea: • To construct M we need to break a word w into two pieces u and v and check if u is in L1 and v is in L2. • But how to break an input into the pieces? • To solve this problem we need to use a new approach called nondeterminism. Rina Zviel-Girshin @ASC

  33. Nondeterminism • In a nondeterministic machine several "next states" are possible. • The automaton may choose any of these legal next states. Rina Zviel-Girshin @ASC

  34. Nondeterminism • It also allows to change a current state without reading an input. This situation called an  - transition Rina Zviel-Girshin @ASC

  35. DFA vs. NFA • Every deterministic finite automaton DFA is immediately a nondeterministic finite automaton NFA. • The opposite is not true. Rina Zviel-Girshin @ASC

  36. Example • Construct a nondeterministic finite automaton for the following language: L = { w1 | w over *={0,1}*} Rina Zviel-Girshin @ASC

  37. Any Questions? • More about non-determinism on next lecture. Rina Zviel-Girshin @ASC

More Related