How to define context-free grammar which includes words without the last letter from another grammar?
$begingroup$
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
$endgroup$
add a comment |
$begingroup$
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
$endgroup$
add a comment |
$begingroup$
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
$endgroup$
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 '18 at 13:36
YosYos
1,127723
1,127723
add a comment |
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
return StackExchange.using("mathjaxEditing", function () {
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
});
});
}, "mathjax-editing");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "69"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
noCode: true, onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
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
0
active
oldest
votes
0
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.
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