Convert the NDFA to DFA Computational TheoryUniversity of

  • Slides: 10
Download presentation
Convert the NDFA to DFA Computational Theory/University of Salahaddin/College of Eng. /Software Dep. /Mr.

Convert the NDFA to DFA Computational Theory/University of Salahaddin/College of Eng. /Software Dep. /Mr. Salar Atroshi 1

The Equivalence of NDFA’s and DFA’s: for every NDFA can construct an equivalence DFA,

The Equivalence of NDFA’s and DFA’s: for every NDFA can construct an equivalence DFA, one which accept the same language. Def. : let L be a set accepted by NDFA, then their exist a DFA that accept this L. If NDFA= (K, ∑, q 0, δ, F) be accepted language, then we defined DFA= (K, ∑, q 0, δ, F) where the state (K) of DFA are all the subset of the set of states of NDFA and K =2 K and F= is the set of all states in K containing a set of F. Computational Theory/University of Salahaddin/College of Eng. /Software Dep. /Mr. Salar Atroshi 2

Ex 1: Let M = ({q 0, q 1}, {0, 1}, q 0, δ,

Ex 1: Let M = ({q 0, q 1}, {0, 1}, q 0, δ, {q 1}) be a NDFA where δ is: - δ(q 0, 0) = {q 0, q 1} 0 - δ(q 0, 1) = {q 1} 1 0, 1 q 0 - δ(q 1, 0) = Φ q 1 1 - δ(q 1, 1) = {q 0, q 1} convert it to DFA that accepts the same language. Computational Theory/University of Salahaddin/College of Eng. /Software Dep. /Mr. Salar Atroshi 3

Solution: -δ(q 0, 0) = q 0 q 1 = [q 0 q 1]

Solution: -δ(q 0, 0) = q 0 q 1 = [q 0 q 1] 0, 1 -δ(q 0, 1) = [q 1] -δ(q 1, 0) = Φ -δ(q 1, 1) = q 1 0 q 0 = [q 0 q 1] -δ(q 0 q 1, 0) = q 0 q 1 Φ =[q 0 q 1] -δ(q 0 q 1, 1) = q 0 q 1 = [q 0 q 1] 1 1 Computational Theory/University of Salahaddin/College of Eng. /Software Dep. /Mr. Salar Atroshi q 0 q 1 0 [] 4

Ex 2: Let NDFA= ({q 0, q 1, q 2}, {0, 1}, q 0,

Ex 2: Let NDFA= ({q 0, q 1, q 2}, {0, 1}, q 0, δ, {q 1}) where δ is: - δ(q 0, 0) = {q 1} - δ(q 0, 1) = {q 0, q 1} - δ(q 1, 0) = {q 0, q 2} 0 1 q 0 0, 1 q 1 0 q 2 convert it to DFA that accepts the same language. Computational Theory/University of Salahaddin/College of Eng. /Software Dep. /Mr. Salar Atroshi 5

Solution: -δ(q 0, 0) = [q 1] -δ(q 0, 1) = q 0 q

Solution: -δ(q 0, 0) = [q 1] -δ(q 0, 1) = q 0 q 1 = [q 0 q 1] -δ(q 1, 0) = q 0 q 2 = [q 0 q 2] -δ(q 0 q 1, 0) = q 1 -δ(q 0 q 1, 1) = q 0 q 1 -δ(q 0 q 2, 0) = q 1 -δ(q 0 q 2, 1) = q 0 q 1 q 0 q 2 = [q 0 q 1 q 2] Φ = [q 0 q 1] Computational Theory/University of Salahaddin/College of Eng. /Software Dep. /Mr. Salar Atroshi 6

-δ(q 0 q 1 q 2, 0) = q 1 -δ(q 0 q 1

-δ(q 0 q 1 q 2, 0) = q 1 -δ(q 0 q 1 q 2, 1) = q 0 q 1 q 0 q 2 Φ Φ = [q 0 q 1 q 2] Φ = [q 0 q 1] 0, 1 Φ 0 1 0 q 0 1 q 1 1 q 0 q 2 0 1 q 0 q 1 0 1 Computational Theory/University of Salahaddin/College of Eng. /Software Dep. /Mr. Salar Atroshi q 0 q 1 q 2 0 7

Ex 3: Let NDFA= ({q, r, s, t}, {a, b}, q, δ, {t}) where

Ex 3: Let NDFA= ({q, r, s, t}, {a, b}, q, δ, {t}) where δ is: - δ(q, a) = {q, r} - δ(r, a) = {s} - δ(s, b) = {t} - δ(t, a) = {t} - δ(t, b) = {t} - δ(q, b) = {q} a, b q a, b a r a s b t convert it to DFA that accepts the same language. Computational Theory/University of Salahaddin/College of Eng. /Software Dep. /Mr. Salar Atroshi 8

Solution: -δ(q, a) = q r = [qr] -δ(q, b) = [q] -δ(qr, a)

Solution: -δ(q, a) = q r = [qr] -δ(q, b) = [q] -δ(qr, a) = qr s = [qrs] -δ(qr, b) = q Φ = [q] Φ = [qrs] -δ(qrs, a) = qr s -δ(qrs, b) = q t = [qt] -δ(qt, a) = qr t = [qrt] Computational Theory/University of Salahaddin/College of Eng. /Software Dep. /Mr. Salar Atroshi 9

-δ(qt, b) = q t = [qt] -δ(qrt, a) = qr s -δ(qrt, b)

-δ(qt, b) = q t = [qt] -δ(qrt, a) = qr s -δ(qrt, b) = q t = [qrst] t = [qt] -δ(qrst, a) = qr s -δ(qrst, b) = q Φ t = [qrst] Φ b t = [qt] a qrs b b a qt b b b Computational Theory/University of Salahaddin/College of Eng. /Software Dep. /Mr. Salar Atroshi qrt a a qrst 10