- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

# Explain formal definition of language with examples in TOC?

The set of all strings (over terminal symbols) which can be derived from the start symbol is the language generated by the grammar G.

**Example 1**

Let grammar G be defined by the set of terminals T = {a, b}, the only non-terminal start symbol S and the set of production rules. Hence, the grammar G would be as follows −

S → ∧, S → aSb

Or in shorthand, it is as mentioned below −

S → ∧ | aSb

L(G) = {∧, ab, aabb, aaabbb, . . . }

**Definition**

If G is called as a grammar with start symbol S and set of terminals T, then the language generated by G is the following set −

S → ∧ | aSb

L(G) = {s | s ∈ T* and S ⇒+ s}.

That is, it’s the set of all strings containing only terminal symbols which can be derived from the start symbol using one or more steps.

**Example 2**

Let ∑ = {a, b, c} be the set of terminal symbols and {A, S} be the set of non-terminal symbols with the start symbol S. A language L over ∑ is defined by the following productions −

S → b | aA, A → c | bS

Examples of strings which belong to the language L are as follows −

Clearly, we can generate b. All longer strings begin with a. All strings will either end with b or ac.

We can make the strings − b, ac, abb, abac, ababb, ababac, abababb, . . .

Is the following characterisation correct?

‘Any string from L contains a, b (in any order) and ends with either b or ac’

. . . NO!,

For example, ba, abaabac ∈/ L

**Example 3**

Let ∑ = {a, b, c} be the set of terminal symbols, S be the only non-terminal symbol. Which language is described by the following four productions?

S → ∧

S → aS

S → bS

S → cS

Or in shorthand − S → ∧ | aS | bS | cS.

Try to realize that all strings from ∑* can be generated by these rules and verify it for the string aacb.

S ⇒ aS ⇒ aaS ⇒ aacS ⇒ aacbS ⇒ aacb∧ = aacb

Hence, S ⇒*aacb.

- Related Questions & Answers
- Explain the different operations on Regular language in TOC.
- Explain the relationship between grammar and language in TOC
- Explain about link and definition section in C language
- Explain the operation of DFA with block diagram in TOC
- Microsoft Interface Definition Language
- Explain the concept of derivation in TOC
- Explain the concept of grammar in TOC
- Explain the concept of set in TOC?
- Explain the concept of strings in TOC?
- Explain Python Matrix with examples
- Explain Stack in Python with examples
- Explain 5NF with examples in DBMS
- Explain Chomsky hierarchy in TOC
- Parallel Circuit: Definition and Examples
- Endurance Testing (Definition, Types, Examples)