- 96 Views
- Uploaded on
- Presentation posted in: General

Complexity and Computability Theory I

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

Complexity and Computability Theory I

Lecture #3

Rina Zviel-Girshin

Leah Epstein

Winter 2002-2003

- Finite automata
- Deterministic automata
- Regular languages
- Regular operations
- Nondeterminism

Rina Zviel-Girshin @ASC

- 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

- 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

- 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

u

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

Rina Zviel-Girshin @ASC

- Let A=(Q,,,q0,F) be a finite automaton and w=12...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

- 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

is regular.

Rina Zviel-Girshin @ASC

* is regular.

Rina Zviel-Girshin @ASC

L={} is regular.

Rina Zviel-Girshin @ASC

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

Rina Zviel-Girshin @ASC

- Union
- Intersection
- Complement
- Minus
- Concatenation

Rina Zviel-Girshin @ASC

Theorem:

The class of regular languages is closed under the union operation.

If L1 and L2 are regular, so is L1L2.

- 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

- 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

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

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 = AB
- is defined as follows: for each (rA,rB) in Q and in , let ((rA,rB),)=(A(rA,),B(rB,)).

Rina Zviel-Girshin @ASC

- 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 = (FAQB)(QAFB).

This concludes the construction of the finite automaton M that recognizes the union of L1 and L2.

Rina Zviel-Girshin @ASC

- 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

- If x L1 L2then x L1orx L2
- That means:
’A(q0A,x)=rAFa or’B(q0B,x))= rBFB

- So ’(q0,x)= ’((q0A,q0B),x)= (’A(q0A,x), ’B(q0B,x)) = (rA,rB)
where (rA,rB) (FAQB) or (rA,rB) (QAFB).

- By definition of F:
’(q0,x)=(rA,rB) (FAQB)(QAFB)=F

- That means x L(M).

Rina Zviel-Girshin @ASC

- If xL(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

Theorem:

The class of regular languages is closed under the intersection operation.

If L1 and L2 are regular, so is L1L2.

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

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

- 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 = FAFB.

That concludes the construction of the finite automaton M that recognizes intersection of L1 and L2.

Rina Zviel-Girshin @ASC

- 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

- Let w* and wL(M) ’(q0,w)=’((q0A,q0B),w)=(’A(q0A,w),’B(q0B,w))
if wL(M) then ’(q0,w)=’((q0A,q0B),w)F

(’A(q0A,w),’B(q0B,w))F=(FAFB)

’A(q0A,w)FA and ’B(q0B,w)FB

means wL(A) and wL(B) wL(A)L(B)

L(M)L(A) L(B).

Q.E.D.

Rina Zviel-Girshin @ASC

- Let w* and w L(A) L(B)
wL(A) and wL(B)

’A(q0A,w)FA and ’B(q0B,w)FB

’(q0,w)=’((q0A,q0B),w)=(’A(q0A,w),’B(q0B,w))(FAFB)=F

means wL(M) L(A) L(B)L(M).

Q.E.D.

Rina Zviel-Girshin @ASC

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

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

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

Theorem:

The class of regular languages is closed under the concatenation operation.

If L1 and L2 are regular, so is L1L2.

Rina Zviel-Girshin @ASC

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

- In a nondeterministic machine several "next states" are possible.
- The automaton may choose any of these legal next states.

Rina Zviel-Girshin @ASC

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

This situation called an - transition

Rina Zviel-Girshin @ASC

- Every deterministic finite automaton DFA is immediately a nondeterministic finite automaton NFA.
- The opposite is not true.

Rina Zviel-Girshin @ASC

- Construct a nondeterministic finite automaton for the following language:
L = { w1 | w over *={0,1}*}

Rina Zviel-Girshin @ASC

- More about non-determinism on next lecture.

Rina Zviel-Girshin @ASC