[PDF] [PDF] 1 Equivalence of Finite Automata and Regular Expressions 2

1 Equivalence of Finite Automata and Regular Expressions Given regular expression R, will construct NFA N such that L(N) = L(R) • Given DFA M, will 



Previous PDF Next PDF





[PDF] Equivalence of Regular Expressions and Regular Languages

12 sept 2018 · In this lecture we will formalize the equivalence between regular expressions and reg- ular languages To do so, we first need to formalize the 



[PDF] 1 Equivalence of Finite Automata and Regular Expressions 2

1 Equivalence of Finite Automata and Regular Expressions Given regular expression R, will construct NFA N such that L(N) = L(R) • Given DFA M, will 



[PDF] Equivalence of DFA and Regular Expressions - CUHK CSE

If R asd S are regular expressions, so are R + S, RS and R∗ Page 8 8/19 General method regular expression =⇒ NFA ∅ q0 ε q0 a ∈ Σ q0 q1 a Page 9 9/19



[PDF] Regular Expressions and the Equivalence of Programs - CORE

simple fashion For example, consider the following regular expression representation of the elemental program in Fig 1: f (~-~(p ~ r) g(~-/pg)* ,~ ~p)*(p ~ r) g,



[PDF] Proof Pearl: Regular Expression Equivalence and Relation Algebra

He informally describes a neat algorithm for deciding equivalence of regular expressions r and s: incrementally construct the relation of all (Dw(r), Dw(s)) between



[PDF] Equivalence of Regular Languages and FSMs

Do Homework 8 Theorem: The set of languages expressible using regular expressions (the regular languages) equals the class of languages recognizable by 



[PDF] Lecture 2: Regular Expression

8 jan 2015 · thus equivalent to DFA, NFA) Proof (Regular expression ⇒ NFA with ϵ-moves) We will prove, if L is accepted by a regular expression, then 

[PDF] eragon full book

[PDF] erasmus 2020/21

[PDF] erasmus application example

[PDF] erasmus darwin

[PDF] erasmus definition

[PDF] erasmus exchange program

[PDF] erasmus huis training centre

[PDF] erasmus motivation letter sample

[PDF] erasmus mundus interview

[PDF] erasmus mundus mechanical engineering

[PDF] erasmus mundus scholarship how to apply

[PDF] erasmus of rotterdam

[PDF] erasmus plus apply

[PDF] erasmus plus courses

[PDF] erasmus programme post 2020

1 Equivalence of Finite Automata and Regular Expressions

Finite Automata Recognize Regular Languages

Theorem 1.Lis a regular language i there is a regular expressionRsuch thatL(R) =Li there is a DFAMsuch thatL(M) =Li there is a NFANsuch thatL(N) =L. i.e., regular expressions, DFAs and NFAs have the same computational power. Proof.Given regular expressionR, will constructNFANsuch thatL(N) =L(R) GivenDFAM, will construct regular expressionRsuch thatL(M) =L(R)2 Regular Expressions to NFA

Regular Expressions to Finite Automata

:::to Non-determinstic Finite Automata Lemma 2.For any regexR, there is an NFANRs.t.L(NR) =L(R).

Proof Idea

We will build the NFANRforR, inductively, based on the number of operators inR, #(R). Base Case:#(R) = 0 means thatRis;;, ora(from somea2). We will build NFAs for these cases. Induction Hypothesis:Assume that for regular expressionsR, with #(R)< n, there is an

NFANRs.t.L(NR) =L(R).

Induction Step:ConsiderRwith #(R) =n. Based on the form ofR, the NFANRwill be built using the induction hypothesis.Regular Expression to NFA

Base Cases

IfRis an elementary regular expression, NFANRis constructed as follows. R=;q 0R=q 0R=aq 0q 1a 1

Induction Step: Union

CaseR=R1[R2

By induction hypothesis, there areN1;N2s.t.L(N1) =L(R1) andL(N2) =L(R2). Build NFAN s.t.L(N) =L(N1)[L(N2)q 0q 1q 11q 12q 2q 21

Figure 1: NFA forL(N1)[L(N2)Induction Step: Union

Formal Denition

CaseR=R1[R2

LetN1= (Q1;;1;q1;F1) andN2= (Q2;;2;q2;F2) (withQ1\Q2=;) be such thatL(N1) = L(R1) andL(N2) =L(R2). The NFAN= (Q;;;q0;F) is given by

Q=Q1[Q2[ fq0g, whereq062Q1[Q2

F=F1[F2

is dened as follows (q;a) =8

1(q;a) ifq2Q1

2(q;a) ifq2Q2

fq1;q2gifq=q0anda= ;otherwiseInduction Step: Union

Correctness Proof

Need to show thatw2L(N) iw2L(N1)[L(N2).

)w2L(N) impliesq0w!Nqfor someq2F. Based on the transitions out ofq0,q0!N q

1w!Nqorq0!Nq2w!Nq. Considerq0!Nq1w!Nq. (Other case is similar) This

meansq1w!N1q(asNhas the same transition asN1on the states inQ1) andq2F1. This meansw2L(N1). 2 (w2L(N1)[L(N2). Considerw2L(N1); case ofw2L(N2) is similar. Then,q1w!N1qfor someq2F1. Thus,q0!Nq1w!Nq, andq2F. This means thatw2L(N).Induction Step: Concatenation

CaseR=R1R2

By induction hypothesis, there areN1;N2s.t.L(N1) =L(R1) andL(N2) =L(R2)

Build NFANs.t.L(N) =L(N1)L(N2)q

1q 11q 12q 2q 21
Figure 2: NFA forL(N1)L(N2)Induction Step: Concatenation

Formal Denition

CaseR=R1R2

LetN1= (Q1;;1;q1;F1) andN2= (Q2;;2;q2;F2) (withQ1\Q2=;) be such thatL(N1) = L(R1) andL(N2) =L(R2). The NFAN= (Q;;;q0;F) is given by

Q=Q1[Q2

q0=q1 F=F2 is dened as follows (q;a) =8

1(q;a) ifq2(Q1nF1) ora6=

1(q;a)[ fq2gifq2F1anda=

2(q;a) ifq2Q2

;otherwiseInduction Step: Concatenation

Correctness Proof

Need to show thatw2L(N) iw2L(N1)L(N2).

3 w2L(N) iq0w!Nqfor someq2F=F2. The computation ofNonwstarts in a state of N

1(namely,q0=q1) and ends in a state ofN2(namely,q2F2). The only transitions from a state

ofN1to a state ofN2is from a state inF1which have-transitions toq2, the initial state ofN2.

Thus, we have

q

0=q1w!Nqwithq2F=F2

i

9q02F1:9u;v2: w=uvandq0=q1u!Nq0!Nq2v!Nq

This means thatq1u!N1q0(withq02F1) andq2v!N2q(withq2F2). Hence,u2L(N1) and v2L(N2), and sow=uv2L(N1)L(N2). Conversely, ifu2L(N1) andv2L(N2) then for some q

02F1andq2F2, we haveq1u!N1q0andq2v!N2q. Then,

q

0=q1u!Nq0!Nq2v!Nq

Thus,q0w=uv!Nqand souv2L(N).Induction Step: Kleene Closure

First Attempt

CaseR=R1

By induction hypothesis, there isN1s.t.L(N1) =L(R1)

Build NFANs.t.L(N) = (L(N1))q

0q 1q 2

Figure 3: NFA accepts (L(N1))+

Problem:May not accept! One can show thatL(N) = (L(N1))+.Induction Step: Kleene Closure

Second Attempt

CaseR=R1

By induction hypothesis, there isN1s.t.L(N1) =L(R1)

Build NFANs.t.L(N) = (L(N1))

4 q 0q 1q 2

Figure 4: NFA accepts(L(N1))

Problem:May accept strings that are not in (L(N1))!Example demonstrating the problem q 0q

10;110;1Figure 5: Example NFANq

0q

10;110;1Figure 6: Incorrect Kleene Closure ofN

L(N) = (0[1)1(0[1). Thus, (L(N))=[(0[1)1(0[1). The previous construction, gives an NFA that accepts 062(L(N))!Induction Step: Kleene Closure

Correct Construction

CaseR=R1

First buildN1s.t.L(N1) =L(R1)

GivenN1build NFANs.t.L(N) =L(N1)

5 qq 0q 1q 2 Figure 7: NFA forL(N1)Induction Step: Kleene Closure

Formal Denition

CaseR=R1LetN1= (Q1;;1;q1;F1) be such thatL(N1) =L(R1). The NFAN= (Q;;;q0;F) is given by

Q=Q1[ fq0gwithq062Q1

F=F1[ fq0g

is dened as follows (q;a) =8

1(q;a) ifq2(Q1nF1) ora6=

1(q;a)[ fq1gifq2F1anda=

fq1gifq=q0anda= ;otherwiseInduction Step: Kleene Closure

Correctness Proof

Let us begin by stating what our goal is. We would like to showw2L(N) iw2L. If we choose to prove this statement by induction, most induction proofs will fail because this statement is too weak to be established by induction. How we choose to strengthen it depends on what parameter we will choose to induct over. One possibility isjwj. If we do induction on the length ofw, then we need to strengthen the statement by saying which strings are accepted from any stateq2Q, and not just the initial stateq0as in the above statement. We can carry such a proof out, but it is long. We instead present a proof that does induction over a parameter dierent than length ofw, but before presenting this proof we need to introduce some notation and terminology that we will nd convenient. Observe that we constructNfromN1by adding some-transitions: one fromq0toq1, and others fromq2F1toq1. We will call these \new" transitions. Recall that an accepting computation is a sequence of steps starting from the initial stateq0and ending in some accept state, such that every step conforms to the transition relation. Let us call a computationas havingnnew steps, if exactlynsteps inare according to the new-transitions. For anyn, let us dene A n=fw2jwhas an accepting computation where exactlynnew transitions are usedg 6 Observe that ifwhas an accepting computation thenw2Anfor somen0. We will prove by induction onn, the following statement

8n2N: w2Aniw2Ln

Before proving the above stronger statement by induction, let us see how proving the above state- ment establishes the correctness of the construction. Supposew2Lthen (by denition of Kleene closure)w2Lifor somei2N. By the above statement, it would mean thatw2Ai. In other words,whas an accepting computation that uses exactlyinew transitions, which just implies that Nacceptsw. On the other hand, supposeNacceptsw. SinceNhas an accepting computation onw, it must have an accepting computation that uses exactlyinew transitions, for some value ofi. In other words,w2Ai. By the above statement that means thatw2Liwhich implies that w2L. Thus we can establish both sides of the correctness claim.

Let us now prove by induction onn

8n2N: w2Aniw2Ln

Base CaseFor this statement we need to establish two base cases: one whenn= 0 and the other whenn= 1. Case 1:Letn= 0. Since the only transition out of the initial stateq0is a new transition, w2A0means that the computation takes no steps and stays inq0. If the computation on whas no transition steps, it means thatw=and clearlyw2L0. On the other hand, if w2L0thenw=andNacceptswby taking no steps asq02F. Thus, we have established the base case forn= 0. Case 2:Letn= 1. Supposew2L, thenN1has an accepting computation. Thus, there isq2F1such thatq1w!N1q. Observe that since every transition ofN1is a transition of N(which is not new), andF1Fwe have the following accepting computation ofNwith exactly one new transition q

0!Nq1w!N1q

Thusw2A1. Conversely, supposew2A1. Again, the only transition out ofq0is a new transition. Thus the accepting computation ofNonwmust be of the form q

0!Nq1w!N1q

for someq2F1; the reason thatqmust be inF1is becauseq0(the only other accept state) has no incoming transitions. Thus,q1w!N1qforq2F1, which means thatwis accepted byN1, and from the fact thatL(N1) =L, we can conclude thatw2L=L1. We have, therefore, established the base case forn= 1. Ind. Hyp.Assume that for alli < n,w2Aiiw2Li, wheren >1. Ind. StepSupposew2Ln. Then there areu;vsuch thatw=uv,u2Ln1andv2L. By induction hypothesis, we haveu2An1. Now, sincen >1, the accepting computation onu must end in a stateq2F1(because once you leaveq0you can never get back to it). Moreover sincev2L, from the correctness ofN1, we haveq1v!N1q0for someq02F1. Putting all of this together we have the following accepting computation q

0u!Nq!Nq1v!N1q0

7 which has exactlynnew transitions. Thus,w2An. To prove the converse, supposew2An. Sincen >1, the accepting computation onwmust be of the form qquotesdbs_dbs4.pdfusesText_7