سوال ۵۳ کنکور ارشد مهندسی کامپیوتر ۱۴۰۰
گرامر زیر چه زبانی را تولید میکند؟ ( بیانگر رشتهٔ تهی است.)
پاسخ صحیح: گزینهٔ A —
Despite the wording, is an unrestricted (type-0) grammar — the productions and rewrite strings, not single nonterminals. Handle the two factors separately: lays down the 's and the first block of 's, while pumps extra 's.
Step 1 — the factor. From , applying exactly times gives The only way to remove is the context-sensitive rule , which needs the surrounding pattern , so . Replacing the innermost by : With the sentential form is . So the number of 's is fixed at (hence at least ).
Step 2 — the factor (pumping 's). Now is preceded by . The rule fires only when a sits immediately left of , and each firing adds two 's. Applying it times () and finishing with :
Step 3 — collect the counts. With the -count is Writing it as , the surplus runs over — odd values starting at , advancing in steps of . Therefore which is option 1.
Why the others fail.
- Option 4 (, independent counts) over-generates: the - and -counts here are tightly coupled.
- Option 3 () has the right base coupling but a step of ; the grammar shifts the -count only in steps of , so e.g. is never derivable — the parity is wrong.
- Option 2 () forces , yet (with 's) is generated, so can be well below ; it also has the wrong leading -offset.
Exam trick: When the options differ only in the step of the surplus exponent ( vs. vs. ), just count how many terminals one application of the pumping rule adds. Here appends two 's, forcing a step of in the exponent — which instantly kills every "step-of-one" () option.