How to define context-free grammar which includes words without the last letter from another grammar?
up vote
0
down vote
favorite
Let $G=(V,T,P,S)$ be a context-free grammar without a production rule for $epsilon$. Define a new context-free grammar $G'$ which produces every word in $L(G)$ such that the word is without its last letter:
$$
L(G')=bigg{win T^*bigg|exists tin T: wtin L(G) bigg}
$$
The solution to the problem is as follows:
let $G'=(Vcup hat V, T,P', hat S)$, where $hat V$ is the set of variables in $V$ but with the hat sign. For, all $Ain V$:
$$
ifquad (Ato alpha)in P implies (Ato alpha)in P'\
ifquad(Ato alpha t)implies (hat Ato alpha)in P'quad (*)\
ifquad(Ato alpha X)in P, Xin Vimplies (hat Ato alpha hat X)in P'quad (**)
$$
I think I understand the solution: if some production rule leads to a letter which is not the last, we add the rule as is to $P'$. If the rule leads to a string whose last letter is $t$ then we add the string without $t$ to $P'$. Lastly, if a rule leads to a variable and a letter we add them to $P'$.
I don't understand why we needed to define $hat V$. I guess I could understand its use in the $2$nd case (*) because if $Ato alpha t$ then $Ato alpha$ didn't really exist in $V$. But then I don't understand why we need to "hat-ify" the last case (**). $Atoalpha X$ was in $V$ so it continues to exist in $V$ why do we need to add it as $hat Ato alpha hat X$?
proof-explanation context-free-grammar
add a comment |
up vote
0
down vote
favorite
Let $G=(V,T,P,S)$ be a context-free grammar without a production rule for $epsilon$. Define a new context-free grammar $G'$ which produces every word in $L(G)$ such that the word is without its last letter:
$$
L(G')=bigg{win T^*bigg|exists tin T: wtin L(G) bigg}
$$
The solution to the problem is as follows:
let $G'=(Vcup hat V, T,P', hat S)$, where $hat V$ is the set of variables in $V$ but with the hat sign. For, all $Ain V$:
$$
ifquad (Ato alpha)in P implies (Ato alpha)in P'\
ifquad(Ato alpha t)implies (hat Ato alpha)in P'quad (*)\
ifquad(Ato alpha X)in P, Xin Vimplies (hat Ato alpha hat X)in P'quad (**)
$$
I think I understand the solution: if some production rule leads to a letter which is not the last, we add the rule as is to $P'$. If the rule leads to a string whose last letter is $t$ then we add the string without $t$ to $P'$. Lastly, if a rule leads to a variable and a letter we add them to $P'$.
I don't understand why we needed to define $hat V$. I guess I could understand its use in the $2$nd case (*) because if $Ato alpha t$ then $Ato alpha$ didn't really exist in $V$. But then I don't understand why we need to "hat-ify" the last case (**). $Atoalpha X$ was in $V$ so it continues to exist in $V$ why do we need to add it as $hat Ato alpha hat X$?
proof-explanation context-free-grammar
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
Let $G=(V,T,P,S)$ be a context-free grammar without a production rule for $epsilon$. Define a new context-free grammar $G'$ which produces every word in $L(G)$ such that the word is without its last letter:
$$
L(G')=bigg{win T^*bigg|exists tin T: wtin L(G) bigg}
$$
The solution to the problem is as follows:
let $G'=(Vcup hat V, T,P', hat S)$, where $hat V$ is the set of variables in $V$ but with the hat sign. For, all $Ain V$:
$$
ifquad (Ato alpha)in P implies (Ato alpha)in P'\
ifquad(Ato alpha t)implies (hat Ato alpha)in P'quad (*)\
ifquad(Ato alpha X)in P, Xin Vimplies (hat Ato alpha hat X)in P'quad (**)
$$
I think I understand the solution: if some production rule leads to a letter which is not the last, we add the rule as is to $P'$. If the rule leads to a string whose last letter is $t$ then we add the string without $t$ to $P'$. Lastly, if a rule leads to a variable and a letter we add them to $P'$.
I don't understand why we needed to define $hat V$. I guess I could understand its use in the $2$nd case (*) because if $Ato alpha t$ then $Ato alpha$ didn't really exist in $V$. But then I don't understand why we need to "hat-ify" the last case (**). $Atoalpha X$ was in $V$ so it continues to exist in $V$ why do we need to add it as $hat Ato alpha hat X$?
proof-explanation context-free-grammar
Let $G=(V,T,P,S)$ be a context-free grammar without a production rule for $epsilon$. Define a new context-free grammar $G'$ which produces every word in $L(G)$ such that the word is without its last letter:
$$
L(G')=bigg{win T^*bigg|exists tin T: wtin L(G) bigg}
$$
The solution to the problem is as follows:
let $G'=(Vcup hat V, T,P', hat S)$, where $hat V$ is the set of variables in $V$ but with the hat sign. For, all $Ain V$:
$$
ifquad (Ato alpha)in P implies (Ato alpha)in P'\
ifquad(Ato alpha t)implies (hat Ato alpha)in P'quad (*)\
ifquad(Ato alpha X)in P, Xin Vimplies (hat Ato alpha hat X)in P'quad (**)
$$
I think I understand the solution: if some production rule leads to a letter which is not the last, we add the rule as is to $P'$. If the rule leads to a string whose last letter is $t$ then we add the string without $t$ to $P'$. Lastly, if a rule leads to a variable and a letter we add them to $P'$.
I don't understand why we needed to define $hat V$. I guess I could understand its use in the $2$nd case (*) because if $Ato alpha t$ then $Ato alpha$ didn't really exist in $V$. But then I don't understand why we need to "hat-ify" the last case (**). $Atoalpha X$ was in $V$ so it continues to exist in $V$ why do we need to add it as $hat Ato alpha hat X$?
proof-explanation context-free-grammar
proof-explanation context-free-grammar
asked Dec 2 at 13:36
Yos
1,227623
1,227623
add a comment |
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Mathematics Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
Use MathJax to format equations. MathJax reference.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3022651%2fhow-to-define-context-free-grammar-which-includes-words-without-the-last-letter%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown