Login
Register
Dark Mode
Brightness
Profile
Edit Profile
Messages
My favorites
My Updates
Logout
Recent questions tagged context-free-grammar
0
votes
1
answer
61
TIFR CSE 2020 | Part B | Question: 6
Consider the context-free grammar below ($\epsilon$ denotes the empty string, alphabet is $\{a,b\}$): $S\rightarrow \epsilon \mid aSb \mid bSa \mid SS.$ What language does it generate? $(ab)^{\ast} + (ba)^{\ast}$ $(abba) {\ast} + (baab)^{\ast}$ ... of the form $a^{n}b^{n}$ or $b^{n}a^{n},n$ any positive integer Strings with equal numbers of $a$ and $b$
Consider the context-free grammar below ($\epsilon$ denotes the empty string, alphabet is $\{a,b\}$):$$S\rightarrow \epsilon \mid aSb \mid bSa \mid SS.$$What language doe...
admin
503
views
admin
asked
Feb 10, 2020
Theory of Computation
tifr2020
theory-of-computation
context-free-grammar
+
–
2
votes
4
answers
62
ISRO2020-39
The language which is generated by the grammar $S \rightarrow aSa \mid bSb \mid a \mid b$ over the alphabet of $\{a,b\}$ is the set of Strings that begin and end with the same symbol All odd and even length palindromes All odd length palindromes All even length palindromes
The language which is generated by the grammar $S \rightarrow aSa \mid bSb \mid a \mid b$ over the alphabet of $\{a,b\}$ is the set ofStrings that begin and end with the ...
Satbir
2.1k
views
Satbir
asked
Jan 13, 2020
Theory of Computation
isro-2020
theory-of-computation
context-free-grammar
normal
+
–
3
votes
0
answers
63
Michael Sipser Edition 3 Exercise 5 Question 36 (Page No. 242)
Say that a $CFG$ is minimal if none of its rules can be removed without changing the language generated. Let $MIN_{CFG} = \{\langle G \rangle \mid \text{G is a minimal CFG}\}$. Show that $MIN_{CFG}$ is $T-$recognizable. Show that $MIN_{CFG}$ is undecidable.
Say that a $CFG$ is minimal if none of its rules can be removed without changing the language generated. Let $MIN_{CFG} = \{\langle G \rangle \mid \text{G is a minimal CF...
admin
633
views
admin
asked
Oct 20, 2019
Theory of Computation
michael-sipser
theory-of-computation
context-free-grammar
recursive-and-recursively-enumerable-languages
decidability
proof
+
–
0
votes
0
answers
64
Michael Sipser Edition 3 Exercise 5 Question 32 (Page No. 241)
Prove that the following two languages are undecidable. $OVERLAP_{CFG} = \{\langle G, H\rangle \mid \text{G and H are CFGs where}\: L(G) \cap L(H) \neq \emptyset\}$. $PREFIX-FREE_{CFG} = \{\langle G \rangle \mid \text{G is a CFG where L(G) is prefix-free}\}$.
Prove that the following two languages are undecidable.$OVERLAP_{CFG} = \{\langle G, H\rangle \mid \text{G and H are CFGs where}\: L(G) \cap L(H) \neq \emptyset\}$.$PREF...
admin
455
views
admin
asked
Oct 20, 2019
Theory of Computation
michael-sipser
theory-of-computation
context-free-grammar
turing-machine
decidability
proof
+
–
0
votes
0
answers
65
Michael Sipser Edition 3 Exercise 5 Question 21 (Page No. 240)
Let $AMBIG_{CFG} = \{\langle G \rangle \mid \text{G is an ambiguous CFG}\}$. Show that $AMBIG_{CFG}$ is undecidable. (Hint: Use a reduction from $PCP$ ... $a_{1},\dots,a_{k}$ are new terminal symbols. Prove that this reduction works.)
Let $AMBIG_{CFG} = \{\langle G \rangle \mid \text{G is an ambiguous CFG}\}$. Show that $AMBIG_{CFG}$ is undecidable. (Hint: Use a reduction from $PCP$. Given an instance...
admin
395
views
admin
asked
Oct 19, 2019
Theory of Computation
michael-sipser
theory-of-computation
context-free-grammar
reduction
post-correspondence-problem
decidability
proof
+
–
0
votes
0
answers
66
Michael Sipser Edition 3 Exercise 5 Question 2 (Page No. 239)
Show that $EQ_{CFG}$ is co-Turing-recognizable.
Show that $EQ_{CFG}$ is co-Turing-recognizable.
admin
175
views
admin
asked
Oct 17, 2019
Theory of Computation
michael-sipser
theory-of-computation
context-free-grammar
recursive-and-recursively-enumerable-languages
proof
+
–
0
votes
0
answers
67
Michael Sipser Edition 3 Exercise 5 Question 1 (Page No. 239)
Show that $EQ_{CFG}$ is undecidable.
Show that $EQ_{CFG}$ is undecidable.
admin
164
views
admin
asked
Oct 17, 2019
Theory of Computation
michael-sipser
theory-of-computation
context-free-grammar
decidability
proof
+
–
1
votes
0
answers
68
Michael Sipser Edition 3 Exercise 4 Question 31 (Page No. 212)
Say that a variable $A$ in $CFL\: G$ is usable if it appears in some derivation of some string $w \in G$. Given a $CFG\: G$ and a variable $A$, consider the problem of testing whether $A$ is usable. Formulate this problem as a language and show that it is decidable.
Say that a variable $A$ in $CFL\: G$ is usable if it appears in some derivation of some string $w \in G$. Given a $CFG\: G$ and a variable $A$, consider the problem of te...
admin
457
views
admin
asked
Oct 17, 2019
Theory of Computation
michael-sipser
theory-of-computation
context-free-language
context-free-grammar
decidability
proof
+
–
0
votes
0
answers
69
Michael Sipser Edition 3 Exercise 4 Question 29 (Page No. 212)
Let $C_{CFG} = \{\langle G, k \rangle \mid \text{ G is a CFG and L(G) contains exactly $k$ strings where $k \geq 0$ or $k = \infty$}\}$. Show that $C_{CFG}$ is decidable.
Let $C_{CFG} = \{\langle G, k \rangle \mid \text{ G is a CFG and L(G) contains exactly $k$ strings where $k \geq 0$ or $k = \infty$}\}$. Show that $C_{CFG}$ is decidable...
admin
262
views
admin
asked
Oct 17, 2019
Theory of Computation
michael-sipser
theory-of-computation
context-free-grammar
decidability
proof
+
–
0
votes
0
answers
70
Michael Sipser Edition 3 Exercise 4 Question 28 (Page No. 212)
Let $C = \{ \langle G, x \rangle \mid \text{G is a CFG $x$ is a substring of some $y \in L(G)$}\}$. Show that $C$ is decidable. (Hint: An elegant solution to this problem uses the decider for $E_{CFG}$.)
Let $C = \{ \langle G, x \rangle \mid \text{G is a CFG $x$ is a substring of some $y \in L(G)$}\}$. Show that $C$ is decidable. (Hint: An elegant solution to this problem...
admin
182
views
admin
asked
Oct 17, 2019
Theory of Computation
michael-sipser
theory-of-computation
context-free-grammar
decidability
proof
+
–
0
votes
0
answers
71
Michael Sipser Edition 3 Exercise 4 Question 15 (Page No. 212)
Show that the problem of determining whether a CFG generates all strings in $1^{\ast}$ is decidable. In other words, show that $\{\langle { G \rangle} \mid \text{G is a CFG over {0,1} and } 1^{\ast} \subseteq L(G) \}$ is a decidable language.
Show that the problem of determining whether a CFG generates all strings in $1^{\ast}$ is decidable. In other words, show that $\{\langle { G \rangle} \mid \text{G is a C...
admin
561
views
admin
asked
Oct 17, 2019
Theory of Computation
michael-sipser
theory-of-computation
context-free-grammar
decidability
proof
+
–
0
votes
0
answers
72
Michael Sipser Edition 3 Exercise 4 Question 14 (Page No. 211)
Let $\Sigma = \{0,1\}$. Show that the problem of determining whether a $CFG$ generates some string in $1^{\ast}$ is decidable. In other words, show that $\{\langle {G \rangle}\mid \text{G is a CFG over {0,1} and } 1^{\ast} \cap L(G) \neq \phi \}$ is a decidable language.
Let $\Sigma = \{0,1\}$. Show that the problem of determining whether a $CFG$ generates some string in $1^{\ast}$ is decidable. In other words, show that $\{\langle {G \ra...
admin
192
views
admin
asked
Oct 17, 2019
Theory of Computation
michael-sipser
theory-of-computation
context-free-grammar
decidability
proof
+
–
0
votes
0
answers
73
Michael Sipser Edition 3 Exercise 4 Question 4 (Page No. 211)
Let $A\varepsilon_{CFG} = \{ \langle{ G }\rangle \mid G\: \text{is a CFG that generates}\: \epsilon \}.$Show that $A\varepsilon_{CFG}$ is decidable.
Let $A\varepsilon_{CFG} = \{ \langle{ G }\rangle \mid G\: \text{is a CFG that generates}\: \epsilon \}.$Show that $A\varepsilon_{CFG}$ is decidable.
admin
193
views
admin
asked
Oct 15, 2019
Theory of Computation
michael-sipser
theory-of-computation
turing-machine
context-free-grammar
decidability
proof
+
–
0
votes
0
answers
74
Michael Sipser Edition 3 Exercise 2 Question 59 (Page No. 160)
If we disallow $\epsilon$-rules in CFGs, we can simplify the DK-test. In the simplified test,we only need to check that each of DK’s accept states has a single rule. Prove that a CFG without $\epsilon$-rules passes the simplified DK-test iff it is a DCFG.
If we disallow $\epsilon$-rules in CFGs, we can simplify the DK-test. In the simplified test,we only need to check that each of DK’s accept states has a single rule. Pr...
admin
298
views
admin
asked
Oct 12, 2019
Theory of Computation
michael-sipser
theory-of-computation
context-free-grammar
descriptive
+
–
1
votes
0
answers
75
Michael Sipser Edition 3 Exercise 2 Question 55 (Page No. 159)
Let $G_{1}$ be the following grammar that we introduced in Example $2.45$. Use the DK-test to show that $G_{1}$ is not a DCFG. $R \rightarrow S \mid T$ $S \rightarrow aSb \mid ab$ $T \rightarrow aTbb \mid abb$
Let $G_{1}$ be the following grammar that we introduced in Example $2.45$. Use the DK-test to show that $G_{1}$ is not a DCFG.$R \rightarrow S \mid T$$S \rightarrow aSb \...
admin
242
views
admin
asked
Oct 12, 2019
Theory of Computation
michael-sipser
theory-of-computation
context-free-grammar
descriptive
+
–
0
votes
0
answers
76
Michael Sipser Edition 3 Exercise 2 Question 54 (Page No. 159)
Let G be the following grammar: $S \rightarrow T\dashv $ $T \rightarrow T aT b \mid T bT a | \epsilon$ Show that $L(G) = \{w\dashv \: \mid w\: \text{contains equal numbers of a’s and b’s} \}$. Use a proof by induction on the length of $w$. Use the DK-test to show that G is a DCFG. Describe a DPDA that recognizes L(G).
Let G be the following grammar:$S \rightarrow T\dashv $$T \rightarrow T aT b \mid T bT a | \epsilon$Show that $L(G) = \{w\dashv \: \mid w\: \text{contains equal numbers o...
admin
247
views
admin
asked
Oct 12, 2019
Theory of Computation
michael-sipser
theory-of-computation
context-free-grammar
descriptive
+
–
0
votes
0
answers
77
Michael Sipser Edition 3 Exercise 2 Question 52 (Page No. 159)
Show that every DCFG generates a prefix-free language.
Show that every DCFG generates a prefix-free language.
admin
243
views
admin
asked
Oct 12, 2019
Theory of Computation
michael-sipser
theory-of-computation
context-free-grammar
prefix-free-property
proof
+
–
0
votes
0
answers
78
Michael Sipser Edition 3 Exercise 2 Question 51 (Page No. 159)
Show that every DCFG is an unambiguous CFG.
Show that every DCFG is an unambiguous CFG.
admin
227
views
admin
asked
Oct 12, 2019
Theory of Computation
michael-sipser
theory-of-computation
context-free-grammar
ambiguous
proof
+
–
1
votes
0
answers
79
Michael Sipser Edition 3 Exercise 2 Question 47 (Page No. 159)
Let $\Sigma = \{0,1\}$ and let $B$ be the collection of strings that contain at least one $1$ in their second half. In other words, $B = \{uv \mid u \in \Sigma^{\ast}, v \in \Sigma^{\ast}1\Sigma^{\ast}\: \text{and} \mid u \mid \geq \mid v \mid \}$. Give a PDA that recognizes $B$. Give a CFG that generates $B$.
Let $\Sigma = \{0,1\}$ and let $B$ be the collection of strings that contain at least one $1$ in their second half. In other words, $B = \{uv \mid u \in \Sigma^{\ast}, v...
admin
780
views
admin
asked
Oct 12, 2019
Theory of Computation
michael-sipser
theory-of-computation
context-free-grammar
pushdown-automata
descriptive
+
–
0
votes
0
answers
80
Michael Sipser Edition 3 Exercise 2 Question 46 (Page No. 158)
Consider the following CFG $G:$ $S \rightarrow SS \mid T$ $T \rightarrow aT b \mid ab$ Describe $L(G)$ and show that $G$ is ambiguous. Give an unambiguous grammar $H$ where $L(H) = L(G)$ and sketch a proof that $H$ is unambiguous.
Consider the following CFG $G:$$S \rightarrow SS \mid T$$T \rightarrow aT b \mid ab$Describe $L(G)$ and show that $G$ is ambiguous. Give an unambiguous grammar $H$ where ...
admin
422
views
admin
asked
Oct 12, 2019
Theory of Computation
michael-sipser
theory-of-computation
context-free-grammar
ambiguous
proof
+
–
0
votes
0
answers
81
Ullman (Compiler Design) Edition 2 Exercise 4.4 Question 10 (Page No. 233)
Show how, having filled in the table as in Question $4.4.9$, we can in $O(n)$ time recover a parse tree for $a_{1}a_{2}\cdot\cdot\cdot a_{n}$. Hint: modify the table so it records, for each nonterminal $A$ in each table entry $T_{ij}$, some pair of nonterminals in other table entries that justified putting $A$ in $T_{ij}$.
Show how, having filled in the table as in Question $4.4.9$, we can in $O(n)$ time recover a parse tree for $a_{1}a_{2}\cdot\cdot\cdot a_{n}$. Hint: modify the table so i...
admin
203
views
admin
asked
Aug 20, 2019
Compiler Design
ullman
compiler-design
context-free-grammar
descriptive
+
–
0
votes
0
answers
82
Ullman (Compiler Design) Edition 2 Exercise 4.4 Question 9 (Page No. 232)
Every language that has a context-free grammar can be recognized in at most $O(n^{3})$ time for strings of length $n$. A simple way to do so,called the Cocke- Younger-Kasami (or CYK) algorithm is based on dynamic programming. ... in the table, how do you determine whether $a_{l}a_{2}\cdot\cdot\cdot a_{n}$ is in the language?
Every language that has a context-free grammar can be recognized in at most $O(n^{3})$ time for strings of length $n$. A simple way to do so,called the Cocke- Younger-Ka...
admin
282
views
admin
asked
Aug 20, 2019
Compiler Design
ullman
compiler-design
context-free-grammar
cyk-algorithm
descriptive
+
–
0
votes
0
answers
83
Ullman (Compiler Design) Edition 2 Exercise 4.2 Question 3 (Page No. 207)
Design grammars for the following languages: The set of all strings of $0's$ and $1's$ such that every $0$ is immediately followed by at least one $1$. The set of all strings of $0's$ and $1's$ that are palindromes; ... $1's$ of the form $xy$, where $x\neq y$ and $x$ and $y$ are of the same length.
Design grammars for the following languages:The set of all strings of $0's$ and $1's$ such that every $0$ is immediately followed by at least one $1$.The set of all strin...
admin
438
views
admin
asked
Aug 17, 2019
Compiler Design
ullman
compiler-design
context-free-grammar
descriptive
+
–
1
votes
0
answers
84
Ullman (Compiler Design) Edition 2 Exercise 4.2 Question 2 (Page No. 206 - 207)
Repeat Question $4.2.1$ for each of the following grammars and strings: $S\rightarrow 0S1\mid 01$ with string $000111$. $S\rightarrow +SS\mid \ast SS\mid a$ with string $+\ast aaa$ ... $bfactor\:\rightarrow\:not\:bfactor\mid (bexpr)\mid true\mid false$
Repeat Question $4.2.1$ for each of the following grammars and strings: $S\rightarrow 0S1\mid 01$ with string $000111$.$S\rightarrow +SS\mid \ast SS\mid a$ with string $+...
admin
749
views
admin
asked
Aug 17, 2019
Compiler Design
ullman
compiler-design
context-free-grammar
parsing
ambiguous
descriptive
+
–
4
votes
1
answer
85
Ullman (Compiler Design) Edition 2 Exercise 4.2 Question 1 (Page No. 206)
Consider the context-free grammar:$S\rightarrow SS + \mid SS {\ast} \mid a$and the string $aa + a{\ast}$. Give a leftmost derivation for the string. Give a rightmost derivation for the string. ... for the string. Is the grammar ambiguous or unambiguous? Justify your answer. Describe the language generated by this grammar.
Consider the context-free grammar:$$S\rightarrow SS + \mid SS {\ast} \mid a$$and the string $aa + a{\ast}$.Give a leftmost derivation for the string.Give a rightmost deri...
admin
10.9k
views
admin
asked
Aug 7, 2019
Compiler Design
ullman
compiler-design
context-free-grammar
parsing
ambiguous
descriptive
+
–
1
votes
0
answers
86
Ullman (Compiler Design) Edition 2 Exercise 2.2 Question 6 (Page No. 52)
Construct a context-free grammar for roman numerals.
Construct a context-free grammar for roman numerals.
admin
284
views
admin
asked
Jul 26, 2019
Compiler Design
ullman
compiler-design
context-free-grammar
+
–
0
votes
0
answers
87
Ullman (Compiler Design) Edition 2 Exercise 2.2 Question 4 (Page No. 51 - 52)
Construct unambiguous context-free grammars for each of the following languages. In each case show that your grammar is correct. Arithmetic expressions in postfix notation. Left-associative lists of identifiers separated by commas. Right- ... $(d)$.
Construct unambiguous context-free grammars for each of the following languages. In each case show that your grammar is correct. Arithmetic expressions in postfix notatio...
admin
659
views
admin
asked
Jul 26, 2019
Compiler Design
ullman
compiler-design
context-free-grammar
+
–
1
votes
2
answers
88
Ullman (Compiler Design) Edition 2 Exercise 2.2 Question 3 (Page No. 51)
Which of the grammars are ambiguous? $S\rightarrow 0S1 \mid 01$ $S\rightarrow +SS \mid -SS \mid a$ $S\rightarrow S(S)S \mid \epsilon$ $S\rightarrow aSbS \mid bSaS \mid \epsilon$ $S\rightarrow a \mid S+S \mid SS \mid S^{\ast} \mid (S)$
Which of the grammars are ambiguous? $S\rightarrow 0S1 \mid 01$$S\rightarrow +SS \mid -SS \mid a$$S\rightarrow S(S)S \mid \epsilon$$S\rightarrow aSbS \mid bSaS \mid \epsi...
admin
1.2k
views
admin
asked
Jul 26, 2019
Compiler Design
ullman
compiler-design
context-free-grammar
ambiguous
+
–
0
votes
0
answers
89
Ullman (Compiler Design) Edition 2 Exercise 2.2 Question 2 (Page No. 51)
What language is generated by the following grammars? In each case justify your answer. $S\rightarrow 0S1 \mid 01$ $S\rightarrow +SS \mid -SS \mid a$ $S\rightarrow S(S)S \mid \epsilon$ $S\rightarrow aSbS \mid bSaS \mid \epsilon$ $S\rightarrow a \mid S+S \mid SS \mid S^{\ast} \mid (S)$
What language is generated by the following grammars? In each case justify your answer. $S\rightarrow 0S1 \mid 01$$S\rightarrow +SS \mid -SS \mid a$$S\rightarrow S(S)S \m...
admin
333
views
admin
asked
Jul 26, 2019
Compiler Design
ullman
compiler-design
context-free-grammar
+
–
0
votes
0
answers
90
Ullman (Compiler Design) Edition 2 Exercise 2.2 Question 1 (Page No. 51)
Consider the context-free grammar $S\rightarrow SS+\mid SS^{\ast}\mid a$ Show how the string $aa+a^{\ast}$ can be generated by this grammar. Construct a parse tree for this string. What language does this grammar generate? Justify your answer.
Consider the context-free grammar$S\rightarrow SS+\mid SS^{\ast}\mid a$Show how the string $aa+a^{\ast}$ can be generated by this grammar.Construct a parse tree for this ...
admin
176
views
admin
asked
Jul 26, 2019
Compiler Design
ullman
compiler-design
context-free-grammar
+
–
Page:
« prev
1
2
3
4
5
6
7
8
...
12
next »
Email or Username
Show
Hide
Password
I forgot my password
Remember
Log in
Register