inherent limitations of computer programs
DESCRIPTION
CSci 4011. INHERENT LIMITATIONS OF COMPUTER PROGRAMS. THE REGULAR OPERATIONS. Negation: A = { w | w A }. Union: A B = { w | w A or w B }. Intersection: A B = { w | w A and w B }. Reverse: A R = { w 1 …w k | w k …w 1 A }. - PowerPoint PPT PresentationTRANSCRIPT
INHERENT LIMITATIONS OF COMPUTER PROGRAMS
CSci 4011
THE REGULAR OPERATIONS
Union: A B = { w | w A or w B }
Intersection: A B = { w | w A and w B }
Negation: A = { w | w A }
Reverse: AR = { w1 …wk | wk …w1 A }
Concatenation: A B = { vw | v A and w B }
Star: A* = { w1 …wk | k ≥ 0 and each wi A }
1 0
1
0 1
0,1
0
NON-DETERMINISM1 0
1
0 1
0,1
0
An NFA accepts if there is a series of choices that take it to an accept state
DeterministicComputation
Non-DeterministicComputation
accept or reject accept
reject
Theorem: Every NFA has an equivalent DFA
Corollary: A language is regular iff it is recognized by an NFA
FROM NFA TO DFAInput: N = (Q, Σ, , Q0, F)
Output: M = (Q, Σ, , q0, F)
accept
reject
To learn if NFA accepts, we could do the computation in parallel, maintaining the
set of states where all threads are
Q = 𝒫(Q)
Idea:
(R,) = ε( (r,) )
Q = 𝒫(Q)
: Q Σ → Q
(R,) = ε( (r,) )rR
q0 = ε(Q0)
F = { R Q | f R for some f F }
FROM NFA TO DFAInput: N = (Q, Σ, , Q0, F)
Output: M = (Q, Σ, , q0, F)
(R,) = ε( (r,) )
EXAMPLES: NFA TO DFA
1
0,1
ε 02 31
a b
1
REGULAR LANGUAGES CLOSED UNDER CONCATENATION
Given DFAs M1 and M2, construct NFA by
connecting all accept states in M1 to start
states in M2
ε
ε
L(M1)=A L(M2)=B
REGULAR LANGUAGES ARE CLOSED UNDER REGULAR OPERATIONS
Union: A B = { w | w A or w B }
Intersection: A B = { w | w A and w B }
Negation: A = { w | w A }
Reverse: AR = { w1 …wk | wk …w1 A }
Concatenation: A B = { vw | v A and w B }
Star: A* = { w1 …wk | k ≥ 0 and each wi A }
REGULAR LANGUAGES CLOSED UNDER STAR
Let L be a regular language and M be a DFA for L
We construct an NFA N that recognizes L*
00,1
00
1
1
1
ε
ε
ε
Formally:
Input: M = (Q, Σ, , q1, F)
Output: N = (Q, Σ, , {q0}, F)
Q = Q {q0}
F = F {q0}
(q,a) =
{(q,a)}
{q1}
{q1}
if q Q and a ≠ ε
if q F and a = ε
if q = q0 and a = ε
if q = q0 and a ≠ ε
else
L(N) = L*Assume w = w1…wk is in L*, where w1,…,wk L
We show N accepts w by induction on k
Base Cases:
k = 0
k = 1
Inductive Step:
Assume N accepts all strings v = v1…vk L*, and let u = u1…ukuk+1 L*
Since N accepts u1…uk and M accepts uk+1, N must accept u
Assume w is accepted by N, we show w L*
If w = ε, then w L*
If w ≠ ε
accept
ε
ε
REGULAR LANGUAGES ARE CLOSED UNDER REGULAR OPERATIONS
Union: A B = { w | w A or w B }
Intersection: A B = { w | w A and w B }
Negation: A = { w | w A }
Reverse: AR = { w1 …wk | wk …w1 A }
Concatenation: A B = { vw | v A and w B }
Star: A* = { w1 …wk | k ≥ 0 and each wi A }
REGULAR EXPRESSIONS
REGULAR EXPRESSIONS
s is a regular expression representing {}
ε is a regular expression representing {ε}
is a regular expression representing
If R1 and R2 are regular expressions representing L1 and L2 then:
(R1R2) represents L1L2
(R1 R2) represents L1 L2
(R1)* represents L1*
PRECEDENCE
*
R2R1*(
EXAMPLE
R1*R2 R3 = ( ) ) R3
{ w | w has exactly a single 1 }
0*10*
{ w | w has length ≥ 3 and its 3rd symbol is 0 }
000(01)* 010(01)* 100(01)* 110(01)*
{ w | every odd position of w is a 1 }