0

I have a question regarding this question:

L= empty where the alphabet is {a,b}

how to create a grammar for this ? how can be the production rule ? thanks in advance

  • I don't think this is a question of software development but in any case it seems unclear what you're asking. – biziclop May 04 '17 at 12:48
  • What are you having trouble with, specifically? Stack Overflow works best when you can ask very specific questions about your problem, rather than questions whose nature is "solve this problem for me". Are you having trouble defining an epsilon production rule? – Welbog May 04 '17 at 13:40
  • I'm voting to close this question as off-topic because it is not a programming question. – rici May 04 '17 at 15:37

1 Answers1

1

A grammar G is an ordered 4-tuple {S, N, E, e, P} where:

  1. N is a set of non-terminal symbols
  2. E is a set of terminal symbols
  3. N and E are disjoint
  4. E is a superset of the alphabet of L(G)
  5. e is the empty string
  6. P is a set of ordered pairs of elements of (N U E U e); that is, P is a subset of (N U E U e) X (N U E U e)*.
  7. S, the start symbol, is in N

A derivation in G is a sequence of elements of (N U E U e)* such that:

  1. The first element is S
  2. Adjacent elements w[i] and w[i+1] can be written as w[i] = uxv and w[i+1] = uyv such that (x, y) is in P

If there is a derivation in G whose last element is a string w[n] over (E U e)*, we say G generates w[n]; that is, w[n] is in L(G).

Now, we want to define a grammar G such that L(G) is the empty set. We fix the alphabet E = {a, b}. We must still define:

  1. N, the set of nonterminals
  2. S, the start symbol
  3. P, the productions

We might as well take S as our start symbol. So N contains at least S; N is a superset of {S}. We will only add more nonterminals if we determine we need them. Let us turn our attention to the condition that L(G) is empty.

If L(G) is empty, that means there is no derivation in G that leads to a string of only terminal symbols. We can accomplish this easily be ensuring all our productions produce at least one nonterminal with any terminal. Or produce no terminals at all. So the following grammars would all work:

S := S

or

S := aSb

or

S := aXb | XXSSX
X := aabbXbbaaS

etc. All of these grammars have L(G) empty since none of them can derive a string of nonterminals.

Patrick87
  • 27,682
  • 3
  • 38
  • 73