MELJUN CORTES - AUTOMATA with SOLUTION and ANSWER

August 13, 2018 | Author: MELJUN CORTES, MBA,MPA | Category: Syntax (Logic), Theory Of Computation, Formalism (Deductive), Models Of Computation, Formal Methods
Share Embed Donate


Short Description

MELJUN CORTES - AUTOMATA & THEORY OF FORMAL LANGAUGES with SOLUTION and ANSWER...

Description

MELJUN P. CORTES--------> Theory of Automata and Formal Language

2012

SET 

It is any well defined collection of objects.  It is a collection of distinct objects, without repetition and without ordering.  It is denoted by capital letter. Example:  A = {∇ , ,0} C = {1, 2, 3} B = {a, b, c, d} D = {Len, Joseph}

1.

– Roster / Tabular Form  Listing or enumerating all the elements of a given set. Example: A = {a, b, c}

– Set-Builder Form 2.  Elements have properties in common.  Elements must satisfy a given rule or condition. Example: le:

A = {x | x is a positive integer < 4}  A = {x | x < 5}



It is a member of a given set or an object in the collection.  It is denoted by small letter/s. Example:  A = {a, b, c} ; a ∈ A; b ∈ A; c ∈ A; d ∉ A 

1.

 – elements can be counted. Example:  A = {a, b, c}

2.

– elements cannot be counted. Example:  A = {x | x is a positive integer}

1. Order Order of of elem element entss is not import important ant 2. Repe Repeti titi tion on mus mustt be ign ignor ored ed

Prepared by: Marilyn M. Sanchez  2003

MELJUN P. CORTES--------> Theory of Automata and Formal Language

2012



If A is a subset of B, A is contained in B or every element of A is in B. Example:  A = {a, b} B = {a, b, c}



Every set is a subset of itself.   An empty set is a subset of every set.  If A ⊄ B then there is at least one element in A that is not in B. Example: Let A = {1, 2, 3}

= {{1}, {2}, {3}, {1, 2}, {1, 3}, {2, 3}, 3 }, {1, 2, 3}, {}} To check: |A| = 2n = 8

  A is a proper subset of B if A  ⊆ B and A ≠ B



It is the total number of elements in a given set Example: A = {1, 2, 3} |A| = 3



It is a set containing no element Example : A = { } or A = {ϕ }  A = {ϕ } is not an empty set



It is a set containing only one element. e.g. A = {1}

Prepared by: Marilyn M. Sanchez  2003

MELJUN P. CORTES--------> Theory of Automata and Formal Language

2012



 At least one set is a subset of another set. set.

Conditions so that A & B are comparable: 1.  A ⊆ B & B ⊆ A  Examp xample le:: A = {1, 2, 3, 3, 4} 4} B = {4, 3, 2, 1} 2.  A ⊆ B & B ⊄ A 

Example:

A = {1, 2} B = {1, 2, 3}

3.  A ⊄ B & B ⊆ A 

Example: le:

A = {a, b, b, c} c} B = {a, b}

 No set is a subset of the other set. (A  ⊄ B & B ⊄ A & A ≠ B) Example:

A = {l, e, e, n} n} B = {s, e, p, h}



Sets having exactly the same cardinality and kind of elements. Example: A = {l, e, e, n} n} B = {n, l, e}



Set having the same cardinality.

Example:



Every element of A is associated or paired to every element in B.

Example:



A = {1, 2, 2, 3} 3} B = {4, 5, 6}

A = {1, 2, 2, 3} 3} B= {l, e, n}

Sets having no common elements

Example

A = {1, 4, 5} B = {3, 2, 6}

MELJUN P. CORTES--------> Theory of Automata and Formal Language

2012

Prepared by: Marilyn M. Sanchez  2003



It is the biggest set under investigation wherein the other sets are subsets of this given set. Example: Let U = U = {1, 2, 3, 4, 5, 6} A = 1, 2, 3} B = {4, 5, 6} C = {5, 6}



It is a collection of set. sets.   All elements of the given set are sets. Example:

A = {A, B, B, C} C} A = {{1, 2, 3}, {4, 5, 6}, {5, 6}} B = {A, B, C, D, 0, 2} C = {A, B, C, D, z}

new set of elements that belong to U but not in A (with respect to U) Example: Let U = U = {1, 2, 3, 4, 5, 6} A = {1, 2, 3} A’ = {4, 5, 6} new set of elements that belong to B but not in A (with respect to B) Example: Let B = {a, b, c, d, e} A = {a, b, c} A’ = {d, e}



It is a family of all subsets of a given set.  It is the set of all subsets. Example: Let A = {1, 2, 3} P (A) = {{1}, {2}, {3}, {1, 2}, {1, 3}, {}, {1, 2, 3}}

MELJUN P. CORTES--------> Theory of Automata and Formal Language

2012

Prepared by: Marilyn M. Sanchez  2003

1. 

It is a new set of elements that belong to A or to B or to both A and B.

Example: Let A = {1, 2, 3, 4} B = {2, 4, 6, 7} A ∪ B = {1, 2, 3, 4, 5, 6, 7} 2. 

It is a new sets of elements that belong to both A and B.

Example: Let A = {1, 2, 3, 4} B = {2, 4, 6, 7} A ∩ B = {2, 4} 3. 

It is a new set of elements that belong to A but not to B.

Example: Let A = {1, 2, 3, 4, 5} B = {1, 2, 4, 6, 7} A - B = {3, 5} B - A = {6, 7} 4. 

It is a new set of elements that belongs to U but not to A.

Example: Let U = {1, 2, 3, 4, 5, 6, 7, 8, 9} A = {1, 2, 3, 4} B = {2, 4, 6} A’ = {5, 6, 7, 8, 9} B’ = {1, 3, 5, 7, 8, 9} 5. 

It is a new set of elements that belong to A or B but not to A and B.

Example: Let Let A = {1, 2, 3, 4, 5} B = {0, 1, 2, 6, 7, 8} A ⊕ B = {0, 3, 4, 5, 6, 7, 8}

MELJUN P. CORTES--------> Theory of Automata and Formal Language

2012

Prepared by: Marilyn M. Sanchez  2003



It deals with idealized computer device.



It tells how to design and use special language.



It tells whether the problem is algorithmically solvable or not.

3.



It tells how to design and use special language.  It is a finite set of symbols.  It can be letters from a to z or digits from 0-9.  It is denoted by .

 It is a finite sequence of an alphabet.

It is a set of strings generated from some alphabets. Examples: Let Σ

{a,b} 

Write the strings generated from the given sets. 1.

L1 = A set of strings that begins and ends with

. 

 Answer: L1 ={aa, aba, abbbba, aaaaa, aaaaba, ……… }  2. L2 = A set set of stri strings ngs divi divisib sible le by 2.  Answer: L2 ={aa, bb, abba, bbaa, bababa, ……… }

MELJUN P. CORTES--------> Theory of Automata and Formal Language

2012

Prepared by: Marilyn M. Sanchez  2003



It is any number of leading symbols of a string. Example: W ={star} Prefix of a String = {e, s, st, sta, star}



It is any number of leading symbols other than the string itself. Example: W ={star} Proper Prefix of a String = {e, s, st, sta}



It is any number of trailing symbols of a string. Example: W ={star} Suffix of a String = {e, r, ar, tar, star }



It is any number of trailing symbols other than the string itself. Example: W ={star} Proper Suffix of a String = {e, r, ar, tar}



It is string formed by writing the first string followed by the second string with no intervening spaces.  It is denoted by ( ) concatenation operator. Example: automata theory = automatatheory * That is if w & x are strings, then wx is the concatenation of these two strings.

 It is denoted by W R .  It is a string that spelled backwards. Example: marilynR  = nyliram

MELJUN P. CORTES--------> Theory of Automata and Formal Language

2012

Prepared by: Marilyn M. Sanchez  2003



It is a mathematical model of a system with discrete inputs and outputs.  It consist of finite set of a sets and a set of transitions from state to state the occur on input symbol chosen from alphabet (Σ).

1.

states  q’s and p’s 2. q0  initial state 3. 0, 1, a, b  input symbols 4. w, x, y, z  strings of input symbols. Finite Automata are limite limited d in stren strengt gth h but they they are a thoro thoroug ughly hly unders understo tood od subcla subclass ss of more more powe powerfu rfull  are computational models.  a further reason for studying FA is their applicability to the design of several common types of  computer algorithms and programs.

Example: Lexical analysis phase of Compilers is often based on the simulation of a automatation.

 Vertices  denotes the store Edges  transition function Initial State

δ ( set of states, set of input alphabet )

Final State

MELJUN P. CORTES--------> Theory of Automata and Formal Language

2012

Prepared by: Marilyn M. Sanchez  2003

Example: State Diagram

qo

q1

State Table

q0 q1

x q1 q0

y q1 q0

Transition Function δ (q0,x) = q0 δ (q0,y) = q0 δ (q1,x) = q1 δ (q1,y) = q1

1.

 For each input symbol in Σ, there is exactly one transition of each state (possibly back to the state itself).  It do not accept empty strings.  It is a quintuple where M = (Q, Σ, q0, δ , F) where: Q = finite set of all sets

MELJUN P. CORTES--------> Theory of Automata and Formal Language

2012

Σ = finite set of input symbols q0 = initial state δ = transition function F = set of final state

Prepared by: Marilyn M. Sanchez  2003

Examples: 1. Diagrams that ends with 10. 0

1

1

qo

q1

0

q2

1 0

Transition Table

q0 q1 q2 

x q1 q2 q3

y q1 q1 q1

Strings that can be derived:  10  010  0110  01010

Transition Function δ (q0,0) = q0 δ (q0,1) = q1 δ (q1,0) = q2 δ (q1,1) = q1 δ (q2,0) = q0 δ (q2,1) = q1 2. Draw a transition transition diagram that will end with 001. 001.

MELJUN P. CORTES--------> Theory of Automata and Formal Language

2012

1

qo

0

0

q1

0

1

q2

1

q3

0 1

Prepared by: Marilyn M. Sanchez  2003

*

In FA or DFA, for each input there is exactly one transition output of each state. Let’s try to modify the finite automaton by alowing zero, one or more transitions from a state on the same input symbol. The modified model is called Non-Deterministic Finite  Automaton. If for some of  ∈Q, a∈Σ, δ (q,a) does either to a unique state or several states or not states at all, then the FA is a NFA. Automaton is a quintuple M=(Q,Σ,q0,ε,F)   A Non-Deterministic Finite Automaton where: Q = set of states Σ = set of input alphabets δ = transition function δ ---> QXΣ to 2Q q0 = initial state F = set of final state  It allows zero, one or more transitions for every inputs symbol.  Empty string accepted   A sequence of symbols, say a1, a2, ...an is accepted by NFA if there exists a sequence of  transition corresponding to the input sequence that leads from the initial states to the final state. Example: Construct a NFA that accepts string ending with 011.

MELJUN P. CORTES--------> Theory of Automata and Formal Language

2012

1

qo

0

1

q1

q2

1

q3

0

δ (q0,011)--> q3 To check if 1011 is a valid string

q0q0q1q2q2 q0q0q0

Prepared by: Marilyn M. Sanchez  2003

The reason for the word “nondeterministic” is that we are in a state where there are multiple outgoing edges all having the same input symbol – we have a choice of next state. The only difference between a NFA & DFA is that in DFA the next state function takes us to a uniquely defined state whereas in NFA the next state takes us to a set of states. Example : 1

0

q0 qo

0 0

q3

0

q4 1

1

q1 1

q2

q0 q1 q2 q3 q4

1,0

0 {q0,q3} 0 {q2} {q4} {q4}

1 {q0,q1} {q2} {q2} 0 {q4}

MELJUN P. CORTES--------> Theory of Automata and Formal Language

2012

Let the input be 01001 δ (q0, ∈) = δ (q0, ∈0) = δ (δ (q0, ∈)0) = δ (q0,0)= δ (q1, ∈01) = δ (δ (q0,0)1) =δ (q0,1) U δ (q3,1)={q0,q1}U{ }= δ (q1, ∈010) = δ (δ (q0,01)0)=δ (q0, (q0,0) 0) U δ (q1,0)={q0 (q1,0)={q0,q3}U ,q3}U{{ } = δ (q2, ∈0100) = δ (δ (q0,010)0)=δ (q0,1) U δ (q3,1) U δ (q3,0)={q0,q3} U δ {q4}= δ (q2, ∈01001) = δ (δ (q0,1) U δ (q3,1) U δ (q4,1) = {q0,q1} U {} U {q4} =

Prepared by: Marilyn M. Sanchez  2003

Theorem: For every NFA model, there exist one and only one equivalent DFA  Let M’ be the equivalent DFA of a NFA M. M’=(Q’, Σ,δ ’,q0’,F’) Example: Transform the given NFA to DFA  0, 1

0 1

qo

q1

0

0

q2

={{},q0,q1,q2,{q0,q1},{q0,q1},{q0,q2},{q1,q2},{q0,q1,q2}} =q2 ={q2,{q0,q2},{q1,q2},{q0,q1,q2}}

q0 q1 q2

0 {q0} {q1,q2} {q2}

1 {q0,q1} {} {}

MELJUN P. CORTES--------> Theory of Automata and Formal Language

2012

δ’ δ’ δ’ δ’ δ’ δ’ δ’ δ’ δ’

({},0) = {} ({},1) = {} (q0,0) = q0 (q0,1) = {q0,q1} (q1,0) = {q1,q2} (q1,1) = {} (q2,0) = q2 (q2,1) = {} ((q0,q1),0) = δ {q0,0} U δ( q1,0) = q0 U {q1,q2} = {q0,q1,q2} δ ’ ((q0,q1),1) = δ {q0,1) U δ (q1,1) = {q0,q1} U {} = { q0,q1} δ ’ ((q0,q2),0) = δ {q0,0) U δ (q2,0) = {q0} U {q2} = {q0,q2}

Prepared by: Marilyn M. Sanchez  2003

δ ’ ((q0,q2),1) = δ {q0,1) U δ (q2,1) = {q0,q1} U {q2} = {q0,q1,q2} δ ’ ((q1,q2),0) = δ {q1,0) U δ (q2,0) = {q1,q2} U {q2} = {q1,q2} δ ’ ((q0,q1,q2),0) = δ {q0,0) U δ (q1,0) U δ (q2,0) = {q0} U {q1,q2} U {q2} = {q0,q1,q2} δ ’ ((q0,q1,q2),1) = δ {q0,1) U δ (q1,1) U δ (q2,1) = {q0,q1} U {} U {} = {q0,q1}

q0 q1 q2 q0,q1 q0,q2 q1,q2 q0,q1,q2 {}

0 {q0} {q1,q2} {q2} {q0,q1,q2} {q0,q2} {q1,q2} {q0,q1,q2} {}

1 {q0,q1} {} {} {q0,q1} {q0,q1} {} {q0,q1} {}

MELJUN P. CORTES--------> Theory of Automata and Formal Language

2012

0

1

0

q1

q1q2

1

{}

1

q2 0,1

0

q0, q1

q0

q0,q 1,q2

q0, q2

Prepared by: Marilyn M. Sanchez  2003

 It is quintuple M = {Q,Σ,δ,q0,F} where the transition functions δ maps. δ :Q x (Σ U {Є}) 2Q δ (q,a)={p | δ (q,a) p and a=Є or aЄΣ ∗will consist of all states p such that there is a transition labeled a from q to p where a is either Є or a symbol in the Σ. Є-closure(q)= { p | , a path from q to p marked Є } Є-closure(p)= UqЄp Є-closure where p is a set of states

→2Q δ (q,w) →{ p | δ( q,w) contains p including edges labeled Є δ : Q x Σ∗

δ (q,Є) = Є-closure (q) *δ (q,w) will be all states p such that one can go from q to p doing a path labeled w, perhaps including edges labeled Є.

Example:

MELJUN P. CORTES--------> Theory of Automata and Formal Language

2012

a

qo

Є

q1

Є

a

q2

q3

transition: δ (q0,a) → q0 δ (q0,Є) → q1

→ q2 δ (q2,a) → q3 δ (q1,Є)

Є-closure (q0) = {q0,q1,q2} Є-closure (q1) = {q1,q2} Є-closure(p) = Є-closure of {q0,q1} = Є-closure {q0} U Є-closure {q1} = {q0,q1,q2} U {q1,q2} = {q0,q1,q2}

Є-closure: q0 q0 q0

Є Є

q1 q1

Є

q2

Prepared by: Marilyn M. Sanchez  2003

Є

For each NFA’s NFA’s there is one and and only one equivalent NFA. NFA. NFA or NFA’s: M = {Q, Σ, δ, q0, F} Let Equivalent NFA be M’  = {Q, Σ, δ1, q0, F1} where: F’ = {F U Є –closure (qo)1 l Є−closure (qo) contains state of F } Example: 1. Convert the given NFA ε to NFA.

0

qo

Є

1

Є

q1

Є

2

q3 q2

MELJUN P. CORTES--------> Theory of Automata and Formal Language

2012

0

1

2

ε

q0 q1 q2

{q0} {} {}

{} q1 {}

{} {} q2

q1 q2 {}

q0 q1 q2

0 {q0,q1,q2} 0 {}

1 {q1,q2} {q1,q2} {}

2 {q2} {q2} {q2}

= {F U Є –closure (q0)} = {q0,q1,q2}

0

1 0,1

qo

1,2

q1 0,1,2

Prepared by: Marilyn M. Sanchez  2003

Є

2. Convert the given NFA ε to NFA. a,b a

q1

a, b a

q2

qq32

Є q0

Є

F = {q3,q5} q0 = {q0} Σ = {a,b}

b b

q4

qq55

Є-closure (q0) = {q0,q1,q4}

Є

a

b

E

2

q3 q2

MELJUN P. CORTES--------> Theory of Automata and Formal Language

2012

q0 q1 q2 q3 q4 q5

{} {q1,q2} {q3} {q3} {} {}

q0 q1 q2 q3 q4 q5

{} q1 {} {q3} {q4} {q5}

{q1,q4} {} {} {} {} {}

a {q1,q2} {q1,q2} {q3} {q3} {} {}

b {q1,q5} {q1} 0 {q3} {q5} {q5}

Prepared by: Marilyn M. Sanchez  2003

Є

F’ = {q3,q5} a,b

q1

a,b

a a,b

q0

a

q2 q4

b b b

q5 q5

a

qq32

MELJUN P. CORTES--------> Theory of Automata and Formal Language

2012

Prepared by: Marilyn M. Sanchez  2003

DEFINITION: Σ is an alphabet  A regular expression over Σ is recursively defined as: 1.

0 is a regular expression denoting the set of {}. 2. Є is a regular expression denoting the set of { Є}. 3. For any aЄΣ , a is a regular expression denoting the set {a}. 4. If r,s,t r,s,t are are reg. reg. exp. exp. Denoting Denoting sets sets R,S,T R,S,T respecti respectively, vely, then (r t s) denotes R u S rs denotes RS r* denotes R*

Σ finite set of symbols L1,L2,L: set of strings from Σ

MELJUN P. CORTES--------> Theory of Automata and Formal Language

2012 Examples: a. L1L2 = { xyl xЄL1 ^ Y ЄL2} is the concatenation of L1 & L2 Σ = {a,b} e.g L1 = {a,b} {Є}={} Є ={} L2 = {ba,a} L1L2 = {a} {ba} {b} {a } = {aba,aa,bba,ba} b. L0 = {Є} Li = LL i–1 e.g.

L = {0,1} L0 = {Є}

Find L3 L1 = LL0 = {0,1},{Є} = {0,1} 2 1 L = LL ={0,1}{0,1} = {00,01,10,11} L3 = LL2 = {0,1}{00,01,10,11} = {000,001,010,011,100,101,110,111}

Prepared by: Marilyn M. Sanchez  2003



of L is defined as α i

L* = U L i=0



of L is defined as L+ = U L α i

i=0

Example: L = {0,1} L* = {e,0,1,00,11,101,01,10,111,000,101,…..} L+ = {0,1,00,11,101,01,10,111,000,101,…….} L = {1} L* = {e,1,11,111,1111,…..} Examples: Let Σ = {0,1}

MELJUN P. CORTES--------> Theory of Automata and Formal Language

2012

1. 0 = {0} 2. 01 = {01} 3. 0 + 1 = {0,1} 4. 1* = {e, {e,1, 1,11 11,11 ,111, 1,11 1111, 11,…… ………} …} 5. 0* + 1 = {e, {e,0, 0,1, 1,00 00,00 ,000,… 0,…….. …..}} 6. 1*00 1*00 = {00, {00,100 100,11 ,1100 00,11 ,11100 100,… ,….} .} 7. (0+1)* (0+1)* = {e,0,1, {e,0,1,00, 00,11,0 11,000,1 00,111,1 11,10,0 0,01,10 1,101,00 1,0001… 01………. …….}} 8. (00+1* (00+1*)* )* = {e,00 {e,00,1,1 ,1,11,11 1,1111,0 11,00001 0001,100 ,100……. …….}} 9. (010+10 (010+101) 1) = {e,010,101 {e,010,101,101 ,1011,10 1,10111, 111,1011 101111…… 11……….. …..}} 10. (0+1)*101 (0+1)*101 = set of strings strings ending ending with 101. 101. 11. (0+1)*11(0+1)* = set of strings with 11 as a substring.

REGULAR EXRESSION

NFA   qo

0 or {}

q1

q0 qo

Є = {Є}* w/o input

a

qo

a = {a}

q1

Prepared by: Marilyn M. Sanchez  2003

 If r & s are regular expression, assume that there is a NFAe corresponding to r &  s. q0

L (r)

qf

 

q0

L (s)

qf

 

a. r + s ( r or s) Є

q0

L (r)

qf

 

Є

q0

Є

qqf  2

q0

L (s)

qf

 

Є

MELJUN P. CORTES--------> Theory of Automata and Formal Language

2012

b. rs (r conc concate atenat nates es s or conc concate atenat nation ion of rs) rs) Є q0

c.

L (r)

qf

 

q0

L (s)

qf

 

r* (r (r clos closur ure e or r kle kleen ene e closu closure re)) Є

Є

q0

Є q0

L (r)

qf

 

qqf  2

Є

Examples: Construct the equivalent NFAe of the ff, reg. expression: 1.

W/ ANSWER na ni…..

0 0

qo

q1

Prepared by: Marilyn M. Sanchez  2003

2. 01 0

qo

3. 0+1

q1

Є q2

1

q3

MELJUN P. CORTES--------> Theory of Automata and Formal Language

2012

0

q1

Є

q2

Є

qo

q5

Є

1

q3

Є

q4

4. 1* Є Є

qo

q1

Є

1

q2

q3

Є

5. 11+0 11

0

1

qo

0

q1

Є

q1

q2

1

q3

q2

q1

1

Є q2

q3

1

q4

Є Є

q0

Є

q6

0

q7

Є

Prepared by: Marilyn M. Sanchez  2003



Context-free Grammars describe context-free languages. Regular set is an example of Context Free language.  Context-Free grammar (CFG) is a quadruple  G = (V,T,P,S) where V – set of variables {S,B} 

q5 q2

MELJUN P. CORTES--------> Theory of Automata and Formal Language

2012 T – set of terminals (a,b,c) P – Production or rule (How to form the string) S – the starting symbol Examples : Construct CFG for the following: 1. ab*c ab*c = {ac,ab {ac,abc,a c,abbc bbc,ab ,abbbc bbc,…. ,….}} given: S aBc B bB B Є

S aBc a Є c ac

S aBc abBc abЄc abc

S aBc abbBc abbbBc abbbbBc abbbbbBc abbbbbЄc abbbbbc

2. Construct a CFG for anbn; n>0 

= {ab,aabb,aaabbb..}

 V=S S=S T={a,b} P: S aSb S Є

S aSb aЄb ab

S aSb aaSbb aaЄbb aabb

Prepared by: Marilyn M. Sanchez  2003

3. Construct a CFG for the following: a. 0*1 = {1,01,001,..} V=S,B T={0,1} S=S

W/ ANSWER na ni…..

MELJUN P. CORTES--------> Theory of Automata and Formal Language

2012

P:

S B1 B 0B B Є

S B1 Є1 1

S B1 0B1 00B1 000B1 000Є1 0001

b. (0+1)* S 1s|0s S Є 01

S 0s 01s 01Є 01

111001

S 1s 11s 111s 1110s 11100s 111001s 111001Є 111001

c. ambn | m>= n S aMb M aMb | aM | Є aabb

aaabb

S aMb aaMbb aaЄbb aabb

S aMb aaMbb aaaMbb aaaЄbb aaabb

Prepared by: Marilyn M. Sanchez  2003

d. S Є | 0 | 1 S 1s1 | 0s0

MELJUN P. CORTES--------> Theory of Automata and Formal Language

2012

S 0s0 0Є0 00

S 1s1 101

e. zanzbnz | n>=0

S aSb aЄb ab

S aSb aaSbb aaЄbb aabb

f. set of integers (+ or -) S +N| -N S 0N | … | 9N | 0 | … | 9

S +N +1N +10

S -N -9N -98N -987

g. {anbncmdm | n,m > 0} S abcd| aMbcNd M aMb | Є N aNb | Є aabbcd

aabbccdd

S aMbcNd aaMbbc Єd aaЄbbcd aabbcd

S aMbcNd aaMbbccNdd aaЄbbccЄdd aabbccdd

Prepared by: Marilyn M. Sanchez  2003

S MN M aMb |ab

S 0s0 00s00 00100

MELJUN P. CORTES--------> Theory of Automata and Formal Language

2012 N cNd | cd aabbcd

S MN aMbcd aabbcd h. {xmyxm| m >= 0} S xSx |y

S xSx xyx

Prepared by: Marilyn M. Sanchez  2003

S xSx xxSxx xxxSxxx xxxyxxx

MELJUN P. CORTES--------> Theory of Automata and Formal Language

2012

Context Free Grammar’s Grammar’s machine machine counterpa counterpart. rt.(J (Jus ustt as the the RE have have an equi equiva vale lent  nt   Context autometon-FA).  Non deterministic device.(Deterministic device.(Deterministic version is only a subset of all CFL’s).  Have input tape, finite control and a stack   Essentially a FA with control of both input and stack “FILO” list.  – is a string of symbols from some alphabet. The leftmost symbol of the stack is considered to be the “tape” of the stack.

1. An inpu inputt sym symbo boll is is use used. d. ⇒ Depending on the input symbol, the top symbol on the stack, and state of the finite control, a number of choices are possible. Each choice consist of next state for the finite control and a (possibly empty) string of symbols to replace the top stack symbol. After selecting a choice, the input head is advanced one symbol. 2. Input symbol is not used ( Є-move). ⇒ Similar to the first except that the input symbol is not used and the input head is not advanced after the move. ⇒  Allows the PDA to manipulate the stack without without reading input symbols.



no final state – empty both input

tape & stack 

1. Set of all all inputs inputs for which which some sequenc sequence e of moves moves causes causes the PDA to empty empty a stack. stack. 2. Designate Designate some some states states as final final sates defin define e the accepted accepted language language as the the set of all all inputs inputs for which some choice of moves causes the PDA to enter final state. 

with final state – empty input tape

M = (Q, Σ, Г, δ , qo, Zo, F) where: Q = finite set of all sets Σ = finite set of input symbols Г = stack alphabet q0 = in Q, initial state Zo = in Г, start symbol F = ⊆ Q, set of final states δ = mapping Q x (Σ U {Є}) x Г to Q x Г*

δ (q, a, Z) = {(P1, y1)…(P m, ym)} initial state 

 Pop  Push Input Destination State

Prepared by: Marilyn M. Sanchez  2003

MELJUN P. CORTES--------> Theory of Automata and Formal Language

2012 Example: M = ( {q1,q2}, {0,1}, {R, B, G}, δ , q1, R, q2 ) 1. 2. 3. 4. 5. 6. 7. 8. 9. 10.

δ( δ( δ( δ( δ( δ( δ( δ( δ( δ(

q1, 0, R ) = {( q1, BR )} q1, 1, R ) = {( q1, GR )} q1, 0, B ) = {( q1, BB )}, {( q 2, Є )} q1, 0, G ) = {( q1, BG )} q1, 1, B ) = {( q1, GB )} q1, 1, G ) = {( q1, GG )}, {( q2, Є )} q2, 0, B ) = {( q2, Є )} q2, 1, G ) = {( q2, Є )} q1, Є, R ) = {( q2, Є )} q2, Є, R ) = {( q2, Є )}

Determine if the input 001100 is valid for PUSHDOWN AUTOMATA. (q1,001100,R)

(q1,01100,BR)

(q2,001100,Є)

(q1,1100,BBR) (q2,1100,R)

(q2,1100,Є)

(q1,100,GBBR) (q1,0,BGGBBR)

(q1,00,GGBBR) (q2,00,BBR)

(q1,0,BGGBBR)

( q2, 0, BR )

(q1,Є,BBGGBB R)

(q2,Є,GGBBR)

?

?

Prepared by: Marilyn M. Sanchez  2003

( q2, Є, R )

( q2, Є, Є )

MELJUN P. CORTES--------> Theory of Automata and Formal Language

2012

M = (Q, Σ, Г, δ , qo, B, F) where: Q = finite set of all sets Г = finite set of allowable tape symbols B = in Г, is blank  Σ = ⊆ Г not including B, set of input symbols q0 = in Q, start state Zo = in Г, start symbol F = ⊆ Q, set of final states δ = “next “next move function” Q x Г to Q x Г {L,R}

 initial state

 

destination state

head movement

(basic model) has finite control, input tape that is divided into cells, a tape head that scans one cell of the tape at a time. Introduced by Allan Turing in 1936 • Tape has a leftmost cell but infinite to the right • Each cell may hold exactly one of a finite number of tape symbols • Initially, the n leftmost cell (n>0) hold the input, which is a string of symbols chosen from a subset of the tape symbols called input symbols. • The remaining infinity of cells each hold blank, which is a special tape symbol that is not input symbol.

a1

a2



a1



an

B

B



Finite Control

In one move, the TM (depending (depending upon the symbol scanned by th tape head & the state of finite  control)  1. chan change gess state tate 2. prints prints symbol symbol on the tape tape cell scanned scanned,, replacing replacing what what was written written there there 3. moves moves its its head head left left or right right one one cell cell

Prepared by: Marilyn M. Sanchez  2003

MELJUN P. CORTES--------> Theory of Automata and Formal Language

2012



Recurs Recursive ively ly enumer enumerable able string stringss can be enumer enumerate ated d or listed listed by a Turing Turing Machine.

Example: M = ({qo, q1… q4}, {0,1}, {0,1,x,y,B}, δ , q0, B, q4)

qo

(q1,x,R)

q1

(q1,0,R)

q2

(q2,0,L)

(q3,y,R) (q2,y,L)

(q1,y,R) (q0,x,R)

q3

(q2,y,L) (q3,y,R)

q4 Determine if the given inputs are accepted by TM 1. 0011 State

Head Position

qo q1 q1 q2 q2 qo q1 q1 q2 q2 qo q3 q3 q4

0011 x011 x011 x0y1 x0y1 x0y1 xxy1 xxy1 xxyy xxyy xxyy xxyy xxyyB xxyyBB Therefore, accepted

Prepared by: Marilyn M. Sanchez  2003

(q4,B,R)

MELJUN P. CORTES--------> Theory of Automata and Formal Language

2012

2. 0011 State

Head Position

qo q1 q1 q2 q2 qo q1 q1 q2 q2 qo q3 q3

0011 01 x01101 x01101 x0y101 x0y101 x0y101 xxy101 xxy101 xxyy01 xxyy01 xxyy01 xxyy01 xxyy01 ? Therefore, not accepted

Prepared by: Marilyn M. Sanchez  2003

MELJUN P. CORTES--------> Theory of Automata and Formal Language

2012

AMA COMPUTER UNIVERSITY Project 8, Quezon City COLLEGE OF COMPUTER STUDIES

MANUAL IN  AUTOMATA THEORY 

Prepared by :

MELJUN P. CORTES MSCS STUDENT

View more...

Comments

Copyright ©2017 KUPDF Inc.
SUPPORT KUPDF