INHERENT LIMITATIONS OF COMPUTER PROGRAMS - PowerPoint PPT Presentation

1 / 28
About This Presentation
Title:

INHERENT LIMITATIONS OF COMPUTER PROGRAMS

Description:

Q S Q transition function* q0 Q is start state. F = {q1, q2} Q ... (brett [ favre)* CONVERT TO NFAs. L can be represented by a regexp. L is a regular language ... – PowerPoint PPT presentation

Number of Views:115
Avg rating:3.0/5.0
Slides: 29
Provided by: nickh4
Category:

less

Transcript and Presenter's Notes

Title: INHERENT LIMITATIONS OF COMPUTER PROGRAMS


1
CSci 4011
INHERENT LIMITATIONS OF COMPUTER PROGRAMS
2
M (Q, S, ?, q0, F) where
Q q0, q1, q2, q3
S 0,1
? Q ? S ? Q transition function
q0 ? Q is start state
F q1, q2 ? Q accept states

3
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 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
4
REGULAR EXPRESSIONS
5
REGULAR EXPRESSIONS
  • is a regular expression representing ?

e is a regular expression representing e
? is a regular expression representing ?
If R1 and R2 are regular expressions representing
L1 and L2 then
(R1R2) represents L1?L2
(R1 ? R2) represents L1 ? L2
(R1) represents L1
6
REGULAR EXPRESSIONS
( - ?) 09 (. ?) 09
? NICK STINKS ?
CSCI 1...40...90...909
? NICK RULES ?
7
PRECEDENCE
? ?
EXAMPLE
R1R2 ? R3
(R1 (R2)) R3
8
w w has exactly a single 1
010
w w 3 and its 3rd symbol is 0
SS0S
w every odd position of w is a 1
(1S)(1e)
9
EQUIVALENCE
L can be represented by a regexp ? L is a regular
language
10
EQUIVALENCE
Given regular expression R, we show there exists
NFA N such that R represents L(N)
L can be represented by a regexp ? L is a regular
language
Induction on the length of R
11
L can be represented by a regexp ? L is a regular
language
Base Cases (R has length 1)
R ?
R e
R ?
12
Inductive Step
Assume R has length k gt 1 and that any regular
expression of length lt k represents a language
that can be recognized by an NFA
Three possibilities for R
R R1 ? R2
R R1R2
R (R1)
13
L can be represented by a regexp ? L is a regular
language
14
Transform (1(0 ? 1)) to an NFA
1
e
1,0
e
15
CONVERT TO NFAs
a(be)a
(1?)1(?1)
(brett favre)
16
Proof idea Transform an NFA for L into a regular
expression by removing states and re-labeling the
arrows with regular expressions
L can be represented by a regexp ? L is a regular
language
?
17
GENERALIZED NFAs
ab
qs
qa
G accepts w if it finds q0q1qk, w1wk wi 2
R(qi,qi1) w w1w2wk q0qs, qkqa
R(qs,q2) ab
R(qa,q) Ø
R(q,qs) Ø
18
NFA TO GNFA
NFA
Add unique and distinct start and accept states
19
GNFA TO REGEXP
NFA
While machine has more than 2 states
Pick an internal state, rip it out and re-label
the arrows with regular expressions to account
for the missing state
20
q3
q0
R(q0,q3) (ab)(a?b)
21
b
bb
a
q2
q1
a
e
b
e
b
a
e
q3
22
b
bb
a
q2
q1
a ? ba
a
e
b
e
b
a
e
23
b
R(q1,q1)
bb ? (a ? ba)ba
bb
a
q2
q1
a ? ba
e
e
b ? (a ? ba)b
b
24
Convert the NFA to a regular expression
a, b
(a ? b)bb(bbb)
b
q2
q1
(a ? b)bb
e
b
(a ? b)bb(bbb)a
bbb
a
b
e
q3
e
25
((a ? b)bb(bbb)a) ? ((a ? b)bb(bbb)a)(a
? b)bb(bbb)
26
Formally
Add qstart and qaccept to create G
Run CONVERT(G)
If states 2
return the expression on the arrow going from
qstart to qaccept
If states gt 2
27
Formally
Add qstart and qaccept to create G
Run CONVERT(G)
If states gt 2
select qrip?Q different from qstart and qaccept
define Q? Q qrip
define R? as
R?(qi,qj) R(qi,qrip)R(qrip,qrip)R(qrip,qj) ?
R(qi,qj)
return CONVERT(G?)
28
NFA
DFA
DEF
Regular Language
Regular Expression
Write a Comment
User Comments (0)
About PowerShow.com