Complexity and Computability Theory I

1 / 37

# Complexity and Computability Theory I - PowerPoint PPT Presentation

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.

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.

## PowerPoint Slideshow about ' Complexity and Computability Theory I' - lindsey

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

Lecture #3

Rina Zviel-Girshin

Leah Epstein

Winter 2002-2003

Overview
• Finite automata
• Deterministic automata
• Regular languages
• Regular operations
• Nondeterminism

Rina Zviel-Girshin @ASC

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
• 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
• 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

q

k

m

Example

u

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

Rina Zviel-Girshin @ASC

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
• 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

Example

 is regular.

Rina Zviel-Girshin @ASC

Example

* is regular.

Rina Zviel-Girshin @ASC

Example

L={} is regular.

Rina Zviel-Girshin @ASC

Example

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

Rina Zviel-Girshin @ASC

Regular operations
• Union
• Intersection
• Complement
• Minus
• Concatenation

Rina Zviel-Girshin @ASC

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?
• 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

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

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

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) 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

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 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 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
• 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)
• 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)
• 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

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

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

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

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
• In a nondeterministic machine several "next states" are possible.
• The automaton may choose any of these legal next states.

Rina Zviel-Girshin @ASC

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
• Every deterministic finite automaton DFA is immediately a nondeterministic finite automaton NFA.
• The opposite is not true.

Rina Zviel-Girshin @ASC

Example
• Construct a nondeterministic finite automaton for the following language:

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

Rina Zviel-Girshin @ASC

Any Questions?
• More about non-determinism on next lecture.

Rina Zviel-Girshin @ASC