Regular and Context-free languages

  • Context: MHB 
  • Thread starter Thread starter evinda
  • Start date Start date
  • Tags Tags
    Regular
Click For Summary
SUMMARY

The discussion focuses on the classification of two languages, L1 and L2, over the alphabet Σ = {0, 1, 2}. L1 is defined as the set of strings that contain at least one "000" and also at least one "111", proving it to be a regular language through closure properties. L2, which consists of sequences of balanced parentheses with the restriction of no more than two pairs within any single parenthesis, is established as a context-free language due to its intersection with a regular language. The participants clarify the correct symbols and conditions for both languages, ensuring accurate definitions.

PREREQUISITES
  • Understanding of regular languages and context-free languages
  • Familiarity with closure properties of formal languages
  • Knowledge of balanced parentheses and their representations
  • Basic concepts of formal language theory
NEXT STEPS
  • Study the closure properties of regular languages in detail
  • Learn about context-free grammars and their applications
  • Explore the Pumping Lemma for regular and context-free languages
  • Investigate the implications of language restrictions on automata theory
USEFUL FOR

This discussion is beneficial for computer science students, language theorists, and software developers interested in formal language classification and automata theory.

evinda
Gold Member
MHB
Messages
3,741
Reaction score
0
Hello! (Wave)

Show,using the closure properties,that from the following languages over $\Sigma= \{ 0,1,2\}$,the first one is regular and the second one is context-free.

  • $ \displaystyle{ L_1=\text{ the strings,that,when they contain at least one "000", } \\ \text{they contain also at least one "bbb" }}$
  • $\displaystyle{ L_2=\text{ the sequences of balanced parenthesis, } \\ \text{ at which in one parenthesis,there can't be more than two pairs of parenthesis} \\ \text{(for example the language does not contain this string: "()(()()())()") }}$

That's what I have tried:

  • $$M_1=(\Sigma^* \{ 000 \} \Sigma^*), M_2=(\Sigma^* \{ 111\} \Sigma^*) \\ L_1=(\Sigma^*-M_1) \cup M_2$$
    We conclude that $L_1$ is regular,from the closure under the complement and the union.
    $$$$
  • We know that the language $P$ of balanced parenthesis is context-free and the language $B=\Sigma^* - (\Sigma^* ()()() \Sigma^*)$ is regular,as a complement of a regular language.

    Since $L_2=P \cap B$ is the intersection of a context-free language with a regular one, $L_2$ is context-free.
Could you tell me if it is right or if I have done something wrong? (Thinking)
 
Technology news on Phys.org
Hint: In typed text, every comma and period must be followed by a space.

evinda said:
Show,using the closure properties,that from the following languages over $\Sigma= \{ 0,1,2\}$,the first one is regular and the second one is context-free.

  • $ \displaystyle{ L_1=\text{ the strings,that,when they contain at least one "000", } \\ \text{they contain also at least one "bbb" }}$
Since you are talking about "bbb", the language does not seem to be over $\Sigma= \{ 0,1,2\}$.

evinda said:
  • $\displaystyle{ L_2=\text{ the sequences of balanced parenthesis, } \\ \text{ at which in one parenthesis,there can't be more than two pairs of parenthesis} \\ \text{(for example the language does not contain this string: "()(()()())()") }}$
This language is not over $\Sigma$ either. More importantly, I am not sure I understand the condition "inside every pair of parentheses, there can't be more than two pairs of parentheses". Are the following strings allowed: "( ((())) )", "( (()) () )"?

evinda said:
  • $$M_1=(\Sigma^* \{ 000 \} \Sigma^*), M_2=(\Sigma^* \{ 111\} \Sigma^*) \\ L_1=(\Sigma^*-M_1) \cup M_2$$
    We conclude that $L_1$ is regular,from the closure under the complement and the union.
This is correct. Well done!
 
Evgeny.Makarov said:
Hint: In typed text, every comma and period must be followed by a space.
I will take it into consideration..

Evgeny.Makarov said:
Since you are talking about "bbb", the language does not seem to be over $\Sigma= \{ 0,1,2\}$.

Oh,sorry! I meant "111", instead of "bbb" .. (Tmi)

Evgeny.Makarov said:
This language is not over $\Sigma$ either. More importantly, I am not sure I understand the condition "inside every pair of parentheses, there can't be more than two pairs of parentheses". Are the following strings allowed: "( ((())) )", "( (()) () )"?

I don't know.. (Sweating) It is only given that the substrings of the form $() \dots ()$ consist always of at most two pairs of parentheses.

Evgeny.Makarov said:
This is correct. Well done!

(Happy)
 

Similar threads

  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 9 ·
Replies
9
Views
8K
  • · Replies 6 ·
Replies
6
Views
5K
  • · Replies 4 ·
Replies
4
Views
2K
Replies
1
Views
4K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 100 ·
4
Replies
100
Views
12K
  • · Replies 13 ·
Replies
13
Views
3K
Replies
6
Views
5K
  • · Replies 1 ·
Replies
1
Views
3K