2017-12-05 11 views
0

나는이 숙제를 가지고있다.오토 마토라 정규 표현

Which pair of regular expressions are equivalent? 
a) (ab)* and a*b* 
b) r(rr)* and (rr)*r 
c) r+ and r*r 
d) (b) and (c) 

답변은 (d)입니다. 나는 (b)(c)도 해답이되어야한다고 생각한다. 누군가 나를 위해 이것을 분명히 할 수 있습니까?

+0

대답'(d)'는 (b)와 (c)가 동일하다는 것입니다. 가장 정확한 답을 하나만 선택해야한다면'(b)'와'(c) '가 같은 쌍이되기 때문에 답은'(d)'입니다. '(b)'는 홀수 개의 'r'문자열입니다. '(c)'는 적어도 하나의'r' 문자열입니다. – Welbog

답변

1

먼저 각 언어로 간단한 문자열을 작성해야합니다. 한 RE의 언어로되어 있지만 다른 언어의 언어가 아닌 RE를 찾으면 확인하고, 그렇다면 완료했는지 확인할 수 있습니다. 다음은 이러한 모양입니다.

(a) 
- (ab)*: e, ab, abab, ababab, ... 
- a*b* : e, a, b, aa, ab, bb, ... 
guess: a is in L(a*b*) but not (ab)*. 
check: (ab)* only generates strings with the same number of a's as b's. 
L((ab)*) != L(a*b*) 

(b) 
- r(rr)*: r, rrr, rrrrr, rrrrrrr, ... 
- (rr)*r: r, rrr, rrrrr, rrrrrrr, ... 
guess: these look the same. 
proof: the first generates all and only strings of r's of odd length. 
     the second generates all and only strings of r's of odd length. 
     these languages are the same. 
     alternatives: 
     - derive DFAs L and R and show DFAs for L \ R and R \ L accept 
      the empty language. 

(c) 
- r+ : r, rr, rrr, rrrr, ... 
- r*r: r, rr, rrr, rrrr, ... 
guess: these look the same. 
proof: the first generates all and only non-empty strings of r's. 
     the second generates all and only non-empty strings of r's. 
     these languages are the same. 
     alternatives: 
     - derive DFAs L and R and show DFAs for L \ R and R \ L accept 
      the empty language 

위의 내용을 바탕으로 가장 정확한 대답은 (d) 인 것으로 보입니다.

+0

동일하고 동등한 것은 차이가 있습니까? –

+0

@Riyakathil * 정규 표현식 *은 동일한 * 언어를 나타 내기 때문에 동일합니다. 분명히,'r (rr) *'는'(rr) * r'과 같은 * 것은 아니지만, 동등합니다. 동일한 기본 개념이 오토마타 및 문법에 적용됩니다. 동등하지 않아도 동등 할 수 있습니다. – Patrick87