Complexity and computability theory i
This presentation is the property of its rightful owner.
Sponsored Links
1 / 37

Complexity and Computability Theory I PowerPoint PPT Presentation


  • 82 Views
  • Uploaded on
  • Presentation posted in: General

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.

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.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript


Complexity and computability theory i

Complexity and Computability Theory I

Lecture #3

Rina Zviel-Girshin

Leah Epstein

Winter 2002-2003


Overview

Overview

  • Finite automata

  • Deterministic automata

  • Regular languages

  • Regular operations

  • Nondeterminism

Rina Zviel-Girshin @ASC


Fa vs computer

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


Deterministic finite automata

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


Extended transition function

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


Example

q

k

m

Example

u

where ’(q,u)=  (’(q,u), )=  (k, )= m

Rina Zviel-Girshin @ASC


Language recognition

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


Regular language

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


Example1

Example

 is regular.

Rina Zviel-Girshin @ASC


Example2

Example

* is regular.

Rina Zviel-Girshin @ASC


Example3

Example

L={} is regular.

Rina Zviel-Girshin @ASC


Example4

Example

For each α in  the language Lα = {α} is regular.

Rina Zviel-Girshin @ASC


Regular operations

Regular operations

  • Union

  • Intersection

  • Complement

  • Minus

  • Concatenation

Rina Zviel-Girshin @ASC


Union

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


How can m simulate a and b

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


Simulator

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


Formal proof

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


Formal proof1

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


Formal proof2

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


L 1 l 2 l m

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


L m l 1 l 2

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) FAor ’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


Intersection

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


Formal proof3

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


Formal proof4

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


Correctness

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


L m l a l b

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


L a l b l m

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


Complement

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


Formal proof5

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


The set minus operation

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


Concatenation

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


Concatenation1

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


Nondeterminism

Nondeterminism

  • In a nondeterministic machine several "next states" are possible.

  • The automaton may choose any of these legal next states.

Rina Zviel-Girshin @ASC


Nondeterminism1

Nondeterminism

  • It also allows to change a current state without reading an input.

This situation called an  - transition

Rina Zviel-Girshin @ASC


Dfa vs nfa

DFA vs. NFA

  • Every deterministic finite automaton DFA is immediately a nondeterministic finite automaton NFA.

  • The opposite is not true.

Rina Zviel-Girshin @ASC


Example5

Example

  • Construct a nondeterministic finite automaton for the following language:

    L = { w1 | w over *={0,1}*}

Rina Zviel-Girshin @ASC


Any questions

Any Questions?

  • More about non-determinism on next lecture.

Rina Zviel-Girshin @ASC


  • Login