kleen theorem

21
Presentation Kleene theorem Automata theory Presented by Junaid Khan University of Peshawar Pakistan [email protected]

Transcript of kleen theorem

Page 1: kleen theorem

PresentationKleene theorem

Automata theory

Presented by

Junaid KhanUniversity of Peshawar Pakistan

[email protected]

Page 2: kleen theorem

Kleene theorem

• A language can be defined by there separate ways .

• 1 Regular expression or

• 2 Finite automaton or

• 3 Transition Garaph.

• An 1956 kleene proved a theorem called kleene theorem.

Page 3: kleen theorem

Vision of kleene theorem

• The vision of kleene theorem is that if a language can be defined one of the above ways then at can also be defined by the other two.

• Means these are three deferent ways that equally define a language.

Page 4: kleen theorem

Proof

• The proof of this theorem contain three parts.• Part1: every language that can be defined

by a finite automaton can also be

defined by a transition Graph.

part2: every language that can be defined

by a transition graph can also be

defined by a regular expressions.

Page 5: kleen theorem

Proof (cont…..)

• Part3: every language that can be defined

by a regular expression can also

be defined by a finite automaton.

Page 6: kleen theorem

Proof of part1

• The proof of this part is very easy. That is every finite automaton is itself already a transition graph. Therefore any language that has been defined by a finite automation has already been defined by a transition graph.

Page 7: kleen theorem

Proof of part2

• The proof of this part will be by constructive algorithm. This mean that we present a procedure that starts out with a transition graph and ends up with a regular expression that define the same language.

Page 8: kleen theorem

Algorithm

Step1: create a unique, unenterable minus state and a unique

unleavealble plus state.

Step2: one by one, in any order, bypass and eliminate all the non - or +

states in the TG. A state is bypassed by connecting each incoming

edge With each outgoing edge. The label of each resultant edge is

the concatenation of the label on the incoming edge with the label on

the loop edge if there is one and the label on the outgoing edge.

Step3: when two states are joined by more than one edge going in the same

direction unify them by adding their edge.

Step4: finally, the only one edge from – to + the label on that edge is regular

expression.

Page 9: kleen theorem

Example

+

+aa

a,b

bb

aa,bb

– +

(aa+bb)(a+b)*(aa+bb)

Page 10: kleen theorem

Part 3.

Part 3: Every language that can be defined by a regular expression can also be defined by a finite automaton.

Proof: By constructive algorithm starting from the recursive definition of regular expressions 1. There is an FA that accepts only the empty word (Λ) and an FA that accepts

only a single letter.

2. If there is an FA that accepts the language defined by r1 and an FA that accepts the language defined by r2, then there is an FA that accepts the language r1+r2.

3. If there is an FA that accepts the language defined by r1 and an FA that accepts the language defined by r2, then there is an FA that accepts the language defined by their concatenation r1r2.

4. If there is an FA that accepts the language defined by r then there is an FA that accepts the language defined by r*.

Thus for every regular expression, we can construct a FA.

Page 11: kleen theorem

Part 3(cont….)Build a finite automaton that accepts the language: (a+b)*(aa+bb)(a+b)*

Rule:

1. The letter a 1

2. The letter b 1

3. The word aa (using 1) 3

4. The word bb (using 2) 3

5. The expression aa+bb (using 3 and 4) 2

6. The expression a+b (using 1 and 2) 2

7. The expression (a+b)* (using 6) 4

8. The expression (a+b)*(aa+bb) (using 7 and 5) 3

9. The expression (a+b)*(aa+bb)(a+b)* (using 8 and 7) 3

Page 12: kleen theorem

Part 3(Rule 1)

+all

all

+

all

– xall except x

all

The language Λ

Only the letter x

Rule 1

Page 13: kleen theorem

Part 3(Rule 2)

All word containing

aa–x1

+x

3

a

b

a,bb

x2a

+y1 y2

b

b

a

y3 y4

b

b

a a a

a b

–x1 x2 x1

x2 x3 x1

+x3 x3 x3

a b

+y1 y3 y2

y2 y4 y1

y3 y1 y4

y4 y2 y3

EVEN-EVEN

Rule 2: r1+r2, Example 1

Page 14: kleen theorem

Combine two tables into one

x1 or y1 - + z1 z2= x2 or y3 z3= x1 or y2

x2 or y3 z2 z4 z5

x1 or y2 z3 z6 z1

x3 or y1 + z4 z7 z8

x1 or y4 z5 z9 z10

x2 or y4 z6 z8 z10

x3 or y3 + z7 z4 z11

x3 or y2 + z8 z11 z4

x2 or y2 z9 z11 z1

x1 or y3 z10 z12 z5

x3 or y4 + z11 z8 z7

x2 or y1 + z12 z7 z3

New state name a b

Page 15: kleen theorem

The New FA are as.

1+9 6bb

3a

b

1012+ 2

ba

5 b

b

11+

7+ 4+

8+

bb bb

a

a

a

a

a a

aa

a

a

b

b

Result: r1+r2

Page 16: kleen theorem

Algorithm Rule 2Algorithm 1: r1+r2

Input:FA 1: alphabet: states: x1, x2, x3,… start state: x1

FA 2: alphabet: states: y1, y2, y3,… start state: y1

plus final states and transitionsThe new FA: alphabet: states: z1, z2, z3,… start state: x1 or y1

transitions: if zi= xj or yk and xj xnew and yk ynew

(for input p) then znew= (xnew or ynew) for input p. If xnew or ynew is a final state, then znew is a final state.

Page 17: kleen theorem

Part3 Rule 3

r1: all with aax1

–x3

+

a

b

a,bb

x2a

y1

–y2+

b

a

ba

r2: words ending in b

Example 2

z1–a

b

b

z2a z3 z4+

b

a

ba

r1r2

Page 18: kleen theorem

Part 3 Rul3

We start by creating the states z1=x1and z2=x2

(z2, a)= x3 “we continue on FA1” ORy1 ”we move to FA2, since x3 is a final state in AF1”

z1–a

b

b

z2a z3 z4+

b

a

ba

(z3, a) = x3 or y1= z3(z3, b) = x3 or y1 or y2 = z4 +

(z4, a)= x3 or y1=z3(z4, b)= x3 or y1 or y2 = z4 +

(z2, a) = x3 or y1= z3 -running FA1

-beginning FA2

(y1 added to x3)

-running FA2

Page 19: kleen theorem

Part3 Rule 4

r: a* + aa*b

r*: words without double b, and that do not start with b.

x4a,b

x3+x2

+b

x1+a

a,bb

aRule 4: r*, Example 1

Page 20: kleen theorem

Part 3 Rule 3

z2+

a

z1

+b

a

z4

a,b z3+ z5+

aa

bb

br*

z1=x1 ± (z1, a) = x1 or x2= z2 + (z1,b) = x4= z4(z2,a)= x1 or x2 =z2 (z2, b)= x1 or x3 or x4= z3 +(z3, a)=z4 (z3,b) = z4(z3,a)= x1 or x2 or x4= z5 + (z3, b)= x4 = z4(z5,a)= x1 or x2 or x4= z5 (z5, b)= x1 or x3 or x4= z3

Page 21: kleen theorem

Any Questions?

Massage

if the path is Beautiful first confirm where

does it lead?

But ,if the destination is Beautiful, Don’t

check How the path is, keep walking.