Regular and Context-free languages

  • Context:
  • Thread starter Thread starter evinda
  • Start date Start date
  • Tags Tags
    Regular
Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
2 replies · 3K views
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)
 
Physics 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)