Regular and Context-free languages

  • MHB
  • Thread starter evinda
  • Start date
  • Tags
    Regular
In summary, we have shown that the language $L_1$ is regular and the language $L_2$ is context-free, using the closure properties of regular and context-free languages. Additionally, we have determined that the given languages $L_1$ and $L_2$ are not over the alphabet $\Sigma= \{ 0,1,2\}$, but instead over the alphabet $\Sigma= \{ 0,1\}$. Finally, we have clarified the conditions for the language $L_2$, where inside every pair of parentheses, there can't be more than two pairs of parentheses.
  • #1
evinda
Gold Member
MHB
3,836
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
  • #2
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!
 
  • #3
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)
 

Related to Regular and Context-free languages

1. What are Regular and Context-free languages?

Regular languages are a type of formal language used to describe regular expressions, which are patterns used to match strings of characters. Context-free languages are a type of formal language that are more powerful than regular languages, and allow for more complicated patterns and structures.

2. What are some examples of Regular languages?

Examples of Regular languages include strings with only a certain number of a certain character, or strings that follow a certain pattern such as a date or phone number format. Regular expressions are commonly used in programming languages for tasks such as data validation and search algorithms.

3. How are Context-free languages different from Regular languages?

Context-free languages are more powerful than Regular languages because they allow for more complicated patterns and structures. They are able to handle nested structures and can recognize patterns that have an arbitrary number of occurrences. Regular languages, on the other hand, are limited in their ability to handle complex patterns and structures.

4. What are some examples of Context-free languages?

Examples of Context-free languages include programming languages, such as C++, Java, and Python, which have complex grammar rules and allow for nested structures. HTML and XML are also examples of Context-free languages, as they have strict rules for structuring and organizing content.

5. How are Regular and Context-free languages used in the real world?

Regular and Context-free languages are used in various applications, such as data validation, search algorithms, and programming languages. They are also used in natural language processing, which involves analyzing and interpreting human language. Additionally, they are used in the development of software tools and compilers for programming languages.

Similar threads

  • Set Theory, Logic, Probability, Statistics
Replies
6
Views
2K
  • Programming and Computer Science
Replies
9
Views
7K
  • Programming and Computer Science
Replies
6
Views
4K
  • Set Theory, Logic, Probability, Statistics
Replies
4
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
3K
  • Math Proof Training and Practice
3
Replies
100
Views
7K
  • STEM Academic Advising
Replies
13
Views
2K
  • Math Proof Training and Practice
4
Replies
105
Views
12K
  • Math Proof Training and Practice
3
Replies
77
Views
10K
Back
Top