Questions tagged [context-free-language]

In formal language theory, a context-free language (CFL) is a language generated by some context-free grammar (CFG). The set of regular languages is a subset of the set of context-free languages.

183 questions
1
vote
1 answer

How can I define ε when I'm writing the grammar rules in parsing code?

I'm trying to write a compiler program for a specific grammar I defined. There are a few ε in the grammar because of some iterative and recursive rules. I tried to define ε by creating an empty token: tokens = ( 'EMPTY' ) t_EMPTY = r'\ '…
user18470316
1
vote
1 answer

In Context Free Grammer, do we replace all variable during a substitution? or can we apply substitution rule to only of the variable of same type?

Imagine we have a Context Free Grammer, CFG, as follows: S -> a ...(1) S -> SS ...(2) And i derive a string in the specified language as follows: S ..start state SS ..using (2) aS ...using (1) <- is this valid, like only applying the…
1
vote
2 answers

CFG for a^n b^3m c d^m e f^2n with m, n > 0

I want to find the CFG for this a^n b^3m c d^m e f^2n with m, n > 0 What I have so far S -> A B C A -> a A ff B -> bbb B d C -> c e Does this make any sense?
sarkle
  • 23
  • 3
1
vote
0 answers

Decidability of if (A⋂B)⋃(B⋂C) is empty

I've been trying to wrap my head around decidability problems for CFGs, and I just wanted to ask if my approach to solving this problem (the title) was accurate. From my understanding: If A, B, C are CFLs, then A⋂B and B⋂C are not closed under…
1
vote
0 answers

bounded PDA and context-free languages

How can we prove that: Class of linear bounded PDA languages ∼ Class of CFLs I know that for a linear bounded PDA there is a constant k such that the stack size for w is at most k|w|. I also read about PDA's and CFL's and know that pushdown…
1
vote
1 answer

Implementation of a context-free grammar for logical operators with parentheses

I'm trying to implement a context-free grammar for the language of logical operators with parentheses including operator precedence. For example, the follows: {1} or {2} {1} and {2} or {3} ({1} or {2}) and {3} not {1} and ({2} or {3}) ... I've…
1
vote
1 answer

Is the given language a valid CFG?

Language, L = { a^n b^n a^n ; n=1,2,3,.. } I want to check whether the given language L is context free or not. CFG make use of PDA which uses stacks. So, first store each 'a' to the stack. Then pop twice for each occurrence of 'b'. Is this logic…
1
vote
1 answer

Is this a not context-free Language? Can I describe it with an Automata?

I'm struggling to know if this Language is context free or not. The Language is: "L={a^n*a^z*b^n*b^z*c^n*c^k|n≥0, z≥0, k≥0}". In my opinion this language is not context/free, because I can't describe with an Automata the case where z=k=0, in this…
1
vote
1 answer

can i push two symbols to the stack of a pushdown automata?

I would like to know if for a given pushdown automata, where the initial symbol or Z0 is y, can i stack two Xs when i read 'a' from chain of strings during a transition? Say that i have a transition function as it follows: (s1, a, y) -> (s2, e,…
1
vote
1 answer

What is the result of this CFG?

I have this example of free context grammar a(x^i) a(y^i). I wonder, if my accepted chains of letters would be something like axxx ayyy or would it be something like axaxayay. Also for this grammar: a(x^i)(y^i)(z^i), what kind of grammar would it…
1
vote
1 answer

Context-Free Grammar of language {a^i b^j c^i}

During exercise, I am supposed to write a Context-Free Grammar for the following language: I am not sure I fully understand the approach, but here is what I got. Since we need at least 1 c surrounded by any equal numbers of a's and b's (could be…
1
vote
1 answer

Automata and Computability

How long will it take for a program to print a truth table for n propositional symbols? (Symbols: P1, P2, ..., Pn) Can't seem to crack this question, not quite sure how to calculate this instance.
jimmyb
  • 21
  • 3
1
vote
1 answer

What is the language described by this CFG?

What is the language described by this CFG?
1
vote
1 answer

Multiple Push / pop in PDA

While designing Push Down Automata consider my inputs are {a,b} Now can I push multiple a's or multiple b's while scanning them...and then while popping can I pop multiple number of a's or multiple number of b's... OR is it the case that I can…
1
vote
1 answer

Is it possible for an ambiguous CFG convert into CNF and becomes unambiguous?

Is it possible for an ambiguous context-free grammar(CFG) to convert into Chomsky Normal Form(CNF) and becomes unambiguous?
1 2
3
12 13