Lecture # 8

Post on 21-Mar-2016

25 views 1 download

Tags:

description

Lecture # 8. (Transition Graphs). Example. Consider the language L of strings, defined over Σ ={a, b}, having (containing) triple a or triple b. The language L may be expressed by RE ( a+b )* ( aaa + bbb ) ( a+b )* This language may be accepted by the following TG. - PowerPoint PPT Presentation

transcript

Lecture # 8Lecture # 8

(Transition Graphs)(Transition Graphs)

Example Example

Consider the language L of strings, defined Consider the language L of strings, defined over over ΣΣ={a, b}, ={a, b}, having (containing) having (containing) triple a or triple b. triple a or triple b.

The language L may be expressed by REThe language L may be expressed by RE(a+b)* (aaa + bbb) (a+b)*(a+b)* (aaa + bbb) (a+b)*

This language may be accepted by the This language may be accepted by the following TGfollowing TG

Example Continued … Example Continued …

OR OR

OR OR

Example Example Consider the language L of strings, defined Consider the language L of strings, defined

over over ΣΣ = {a, b}, = {a, b}, beginning and ending in beginning and ending in different lettersdifferent letters..

The language L may be expressed by RE The language L may be expressed by RE

a(a + b)*b + b(a + b)*a a(a + b)*b + b(a + b)*a

The language L may be accepted by the The language L may be accepted by the following TG following TG

Example continued … Example continued …

Example Example Consider the Language L of strings Consider the Language L of strings of of

length two or morelength two or more, defined over , defined over ΣΣ = {a, = {a, b}, b}, beginning with and ending in same beginning with and ending in same letters. letters.

The language L may be expressed by the The language L may be expressed by the following regular expression following regular expression

a(a + b)*a + b(a + b)*b a(a + b)*a + b(a + b)*b

This language may be accepted by the This language may be accepted by the following TG following TG

Example Continued … Example Continued …

Example Example Consider the Consider the EVEN-EVENEVEN-EVEN language, defined language, defined

over over ΣΣ={a, b}. ={a, b}.

As discussed earlier that As discussed earlier that EVEN-EVENEVEN-EVEN language can be expressed by a regular language can be expressed by a regular expression expression

(( aaaa + + bbbb + (ab+ba)(aa+bb)*(ab+ba) + (ab+ba)(aa+bb)*(ab+ba) )*)*

The language The language EVEN-EVENEVEN-EVEN may be accepted may be accepted by the following TG by the following TG

Example continued … Example continued …

Example Example Consider the language L, defined over Consider the language L, defined over

ΣΣ={a, b}, in which ={a, b}, in which a’s occur only in a’s occur only in even clumps (bundles) and that ends even clumps (bundles) and that ends in three or more b’sin three or more b’s. .

The language L can be expressed by its The language L can be expressed by its regular expression regular expression

(aa)*b (aa)*b (b*+((b*+(aa(aa)*baa(aa)*b)*))*) bb bb OROR

(aa)*b (aa)*b (b*+( (b*+( (aa)(aa)++bb)*))*) bb bb The language L may be accepted by the The language L may be accepted by the

following TGfollowing TG

Example Continued … Example Continued …

Example Example Consider the following TG Consider the following TG

Example Continued … Example Continued … Consider the string Consider the string abbbabbbabbaabbbabbbabba. It may . It may

be observed that the above string traces be observed that the above string traces the following three paths, (using the states)the following three paths, (using the states)

(a)(b) (b) (b) (ab) (bb) (a) (bb) (a) (a)(b) (b) (b) (ab) (bb) (a) (bb) (a) (-)(4)(4)(+)(+)(3)(2)(2)(1)(+)(-)(4)(4)(+)(+)(3)(2)(2)(1)(+)

(a)(b) ((b)(b)) (ab) (bb) (a) (bb) (a) (a)(b) ((b)(b)) (ab) (bb) (a) (bb) (a) (-)(4)(+)(+)(+)(3)(2)(2)(1)(+)(-)(4)(+)(+)(+)(3)(2)(2)(1)(+)

(a) ((b) (b)) (b) (ab) (bb) (a) (bb) (a) (a) ((b) (b)) (b) (ab) (bb) (a) (bb) (a) (-) (4)(4)(4)(+) (3)(2)(2)(1)(+)(-) (4)(4)(4)(+) (3)(2)(2)(1)(+)

Example Continued … Example Continued …

Which shows that all these paths are Which shows that all these paths are successful, (successful, (i.e. i.e. the path starting from an the path starting from an initial state and ending in a final state). initial state and ending in a final state).

Hence the string Hence the string abbbabbbabbaabbbabbbabba is is acceptedaccepted by the given TG. by the given TG.

Generalized Transition Generalized Transition Graphs Graphs

A generalized transition graph (GTG) is a A generalized transition graph (GTG) is a collection of three things: collection of three things:

1.1. Finite number of states, at least one of which is Finite number of states, at least one of which is start state and some (maybe none) final states. start state and some (maybe none) final states.

2.2. Finite set of input letters (Finite set of input letters (ΣΣ) from which input ) from which input strings are formed. strings are formed.

3.3. Directed edges connecting some pair of states Directed edges connecting some pair of states labeled with labeled with regular expressionregular expression

It may be noted that in GTG, the labels of transition It may be noted that in GTG, the labels of transition edges are corresponding regular expressions edges are corresponding regular expressions

Example Example Consider the language L of strings, defined Consider the language L of strings, defined

over over ΣΣ={a,b}, containing ={a,b}, containing double a or double a or double bdouble b. .

The language L can be expressed by the The language L can be expressed by the following regular expression following regular expression (a+b)* (aa + bb) (a+b)*(a+b)* (aa + bb) (a+b)*

The language L may be accepted by the The language L may be accepted by the following GTG.following GTG.

Example continued … Example continued …

OrOr

Example Example Consider the Language L of strings, defined Consider the Language L of strings, defined

over over ΣΣ = {a, b}, = {a, b}, beginning with and beginning with and ending in same letters excluding ending in same letters excluding ΛΛ . .

The language L may be expressed by the The language L may be expressed by the following regular expression following regular expression

(a + b) + a(a + b)*a + b(a + b)*b (a + b) + a(a + b)*a + b(a + b)*b

This language may be accepted by the This language may be accepted by the following GTG following GTG

Example Example

Example Example Consider the language L of strings of, Consider the language L of strings of,

defined over defined over ΣΣ = {a, b}, = {a, b}, beginning and beginning and ending in different lettersending in different letters..

The language L may be expressed by RE The language L may be expressed by RE a(a + b)*b + b(a + b)*aa(a + b)*b + b(a + b)*a

The language L may be accepted by the The language L may be accepted by the following GTG following GTG

Example Continued … Example Continued …

Another option of GTG for above language LAnother option of GTG for above language L

Example Continued … Example Continued …

Example Example Consider the language L of strings, defined Consider the language L of strings, defined

over over ΣΣ={a, b}, ={a, b}, having triple a or triple having triple a or triple b. b.

The language L may be expressed by RE The language L may be expressed by RE (a+b)* (aaa + bbb) (a+b)*(a+b)* (aaa + bbb) (a+b)*

This language may be accepted by the This language may be accepted by the following GTGfollowing GTG

Example Continued … Example Continued …

OR OR

NonDeterminism NonDeterminism TGs and GTGs provide certain relaxations TGs and GTGs provide certain relaxations

i.e. i.e. there may exist more than one path for there may exist more than one path for a certain string or there may not be any a certain string or there may not be any path for a certain string, this property path for a certain string, this property creates creates nondeterminismnondeterminism and it can also and it can also help in differentiating TGs or GTGs from help in differentiating TGs or GTGs from FAs. FAs.

Hence an Hence an FAFA is also called a is also called a Deterministic Deterministic Finite Automaton (DFA).Finite Automaton (DFA).

Kleene’sKleene’s Theorem Theorem If a language can be If a language can be expressedexpressed by by 1.1. FA or FA or 2.2. TG or TG or 3.3. RE RE then it can also be then it can also be expressedexpressed by by other twoother two

as well. as well.

It may be noted that the theorem is It may be noted that the theorem is proved, proving the following three partsproved, proving the following three parts

Kleene’sKleene’s Theorem continued Theorem continued … …

Kleene’s Theorem Part IKleene’s Theorem Part IIf a language can be accepted by an FA If a language can be accepted by an FA then it can be accepted by a TG as well. then it can be accepted by a TG as well.

Kleene’s Theorem Part IIKleene’s Theorem Part IIIf a language can be accepted by a TG If a language can be accepted by a TG then it can be expressed by an RE as well. then it can be expressed by an RE as well.

Kleene’s Theorem Part IIIKleene’s Theorem Part IIIIf a language can be expressed by a RE If a language can be expressed by a RE then it can be accepted by an FA as wellthen it can be accepted by an FA as well

Kleene’sKleene’s Theorem continued Theorem continued … …

Proof(Kleene’s Theorem Part I)Proof(Kleene’s Theorem Part I)

Since every Since every FAFA can be considered to be a can be considered to be a TGTG as well, as well, therefore there is nothing to therefore there is nothing to proveprove. .

Thank You…Thank You…