计算理论导引4

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

CHAPTER 2 COMPUTATIONAL MODELS(3)
Precedence: *,°,∪ °∪ + R=RR* Rk L(R) Σ={0,1} A={w|w contains a single 1}= L(0*10*) A={w|w has at last one 1}= L(Σ*1Σ*) Σ Σ A={w|w contains the string 001 as substring 1}=L(Σ*001Σ*) Σ Σ A={w|every 0 in w is followed by at last one 1 }= L((01+)*) A={w|w is a string of even length}=L((ΣΣ ΣΣ)*) ΣΣ A={w|the length of w is a multiple of three}=L((ΣΣΣ ΣΣΣ)*) ΣΣΣ A={01,10}=L(01∪10) ∪ Σ ∪ Σ A={w|w starts and ends with the same symbol}= L(0Σ*0∪1Σ* 1∪0∪1) ∪ ∪ (0∪ε ∪ε)1*=01*∪1*,L((0∪ε ∪ε ∪ε)(1∪ε ∪ε ∪ ∪ε ∪ε))={ε,0,1,01},L(1*∅)= ∅, L(∅*)={ε} ε ∅ ∅ ε
CHAPTER 2 COMPUTATIONAL MODELS(3)
∅∪R=R ∅∪ R°ε °ε=R °ε R∪ε≠ ∪ε≠R ∪ε≠ R°∅ ∅ °∅=∅ °∅ THEOREM 2.7 A language is regular if and only if some regular expression describes it. LEMMA 2.1 If a language is described by a regular expression, then it is regular. PROOF IDEA a 1.R=a 2.R=ε ε 3.R=∅ ∅
ε qs ε q1 1 q2 0 0∪1 ∪ q3
CHAPTER 2 COMPUTATIONAL MODELS(3)
A GNFA accept a string w in Σ* if w=w1w2…wk, where each wi is in Σ* and a sequence of states q0,q1, … ,qk exists such that 1.q0=qstart is the start state, 2.qk=qaccept is the accept state,and 3.for each i, we have wi∈L(Ri), where Ri=δ(qi-1,qi). CONVERT(G): 1.Let k be the number of states of G. 2.If k=2, then Q must consist of a start state, an accept state, and a single arrow connecting them and labeled with a regular expression R. Return the expression. 3.If k>2,we select any state qdrip∈Q different from qstart and qaccept and let G’ be the GNFA (Q’, Σ, δ’ qstart,qaccept ) δ’(qi,qj)=(R1)(R2)*(R3)∪(R4),for R1= δ(qi,qdrip), R2= δ(qdrip,qdrip) ∪ R3=δ(qdrip,qj), R4= δ(qi,qj). 4.Compute CONVERT(G’) and return this value.
CHAPTER 2 COMPUTATIONAL MODELS(3)
LEMMA 2.2 If a language is regular, then it is described by a regular expression. Generalized nondeterministic finite automaton (GNFA):a generalized nondeterministic finite automaton is a 5tuple(Q, Σ, δ, qstart,qaccept), where 1.Q is the finite set of states, 2. Σ is the input alphabet, 3. δ :(Q-{qaccept})×(Q-{qstart})→R is the transition function, × → 4.qstart is the start state, and qs 5.qaccept is the accept state. 0 1
CHAPTER 2 COMPUTATIONAL MODELS(3)
•Regular Expressions FORMAL DEFINITION OF A REGULAR EXPRESSION Say that R is a regular expression if R is 1.a for some a in the alphabet Σ, 2.ε, 3. ∅, 4.(R1∪R2), where R1 and R2 are regular expressions, 5.(R1°R2), where R1 and R2 are regular expressions,or * 6.(R1), where R1 is a regular expression.
y i y
there is r1,…, rj,…,rk,…,rj,…,rk,…,rp+1,…,rn+1 . As j≠k and k≤p+1,so |y|>0, |xy| ≤p.
CHAPTER 2 COMPUTATIONAL MODELS(3)
Σ={0,1} B={0n1n|n≥0} ≥ p: the p pumping length p S= 0 1 =xyz 1.When y consists only of 0s, xyyz will have more 0s than 1s; 2.When y consists only of 1s, xyyz will have more 1s than 0s; 3. When y consists of both0s and 1s, xyyz will have the incorrect order of 1s and 0s; Σ={0,1} C={w|w has an equal number of 0s and 1s} p=? s=?
CHAPTER 2 COMPUTATIONAL MODELS(3)
0*1 1* ε 0 ∪ 0*11* ∪ 0*11*0 (0∪1) 1* ε qs 1 ε q2 1 0 0∪1 ∪ q3 (0∪1)1* ε ∪
qs
q1
ε0*1 0*11* 0
CHAPTER 2 COMPUTATIONAL MODELS(3)
a sequence of states q0,q1, … ,qk exists such that 1.q0=qstart is the start state, 2.qk=qaccept is the accept state,and 3.for each i, we have wi∈L(Ri), where Ri=δ(qi-1,qi). ∈
4. q1 is the start state, 5. F={q2}. how °{1}*°{0}∪ ∪ by ° ∪°∗ {0}*°{1}to describe A {1})°{1}*∪ {0}*°operations?(∪,°,∗) 0*11*0(0∪1)1*∪0*11* the regular°{1}°{1}* ∪ °({0}∪ ∪ °
•NONREGULAR LANGUAGES Σ={0,1} C={w|w has an equal number of 0s and 1s} D={w|w has an equal number of occurrences 01 and 10 as substrings} THEOREM 2.7 Pumping lemma If A is a regular language, then there is a number p (the pumping length) where, if s is any string in A of length at least p, then s may be divide into three pieces, s=xyz, satisfy the following conditions: 1.For each i ≥0, xy iz∈A ∈ 2.|y|>0, and 3.|xy|≤p. ≤
计算理论导引与算法复杂性
Introduction to the Theory of Computation and Algorithm Complexities
主讲: 主讲:刘国华 (学院楼①225室,ghliu@dhu.edu.cn) 学院楼①225室 ) 助教: 助教:辛婷婷 学院楼①153室 (学院楼①153室,xtt.moon@163.com) ) FTP:222.204.215.3
CHAPTER 2 COMPUTATIONAL MODELS(3)
CLAIM 2.1 For any GNFA G,CONVERT(G) is equivalent to G. PROOF IDEA 1. For any GNFA G(Q, Σ, δ, qstart,qaccept), if |Σ|=2, then CONVERT(G) is equivalent to G obviously ; 2. Assume that the claim is true for G with |Σ|=k-1; Let G’ is a GNFA converted from G by CONVERT(G) and |G’|=k 1, so for G’ the claim is true. If we can prove that G is equivalent to G’, then the claim is also true for G with |Σ|=k. So we should prove that any string w=w1w2…wk accepted by … G can also be accepted by G’, vice versa.
CHAPTER 2 COMPUTATIONAL MODELS(3)
A={w|w contains at least one 1 and even number of 0s follow the last 1}
0 1 0,1 q1 1 q2 0 q3
1.Q ={q1, q2, q3}, 2. Σ ={0,1}, 3. δ is desribed as 0 1 q1 q1 q2 q2 q3 q2 q3 q2 q2
Leabharlann Baidu
CHAPTER 2 COMPUTATIONAL MODELS(3)
PROOF IDEA M=(Q, Σ, δ, q1,F), A=L(M), p is the number of states of M, s=s1s2…sn is a string in A of length n ,where n≥p. r1,…,rn+1 is sequence of states that M enters while computing s. So, n+1>p. In r1,…,rp+1, there must be a special state which occurs twice. r1,…, rj ,…, rk ,…, rp+1,…,rn+1, where rj=rk, j≠k and k≤p+1. x=s1…sj-1, y=sj…sk-1, z=sk…sn. y z x r1→ rj, rj→rk, rk→rn+1. When i=0, for s1…sj-1sk…sn=xz there is r1,…,rk ,…, rp+1,…,rn+1. When i>0, for s1…sj-1sj…sk-1…sj…sk-1sk…sn=xy iz.
相关文档
最新文档