Understanding Context-Free Languages and Their Closure Properties

  • MHB
  • Thread starter evinda
  • Start date
In summary: There is a difference between the 2 sets. $\{w=a^{r}b^k: r \neq k\}$ is not equal to $\{weq a^{r}b^r:r \geq 0\}$.
  • #1
evinda
Gold Member
MHB
3,836
0
Hello! :cool:
I have to use the closure properties and languages that are known to be contextfree,to show that the language $\{w\in\{a,b\}^{*}:a^{r}b^{k},r\neq k \}$ is contextfree.
But...which languages are known to be contextfree?
Or aren't there languages that are known to be contextfree and it is meant,that I can use no matter which languages I want and I just have to show that they are contextfree? :confused:
 
Technology news on Phys.org
  • #2
But...which languages are known to be contextfree?
This refers to languages that are shown to be CF in the textbook, in class or in homeworks.

Or aren't there languages that are known to be contextfree and it is meant,that I can use no matter which languages I want and I just have to show that they are contextfree?
This strategy is also possible. It has the benefit that you will understand those proofs for yourself, which is ultimately what matters, but it also has the drawback of presenting you as not following what has been covered in the course.

In this problem, you can use the fact that $\{a^nb^n\mid n\ge0\}$ is CF and that CF languages are closed under union and concatenation with regular (in fact, all CF) languages.
 
  • #3
Evgeny.Makarov said:
This refers to languages that are shown to be CF in the textbook, in class or in homeworks.

This strategy is also possible. It has the benefit that you will understand those proofs for yourself, which is ultimately what matters, but it also has the drawback of presenting you as not following what has been covered in the course.

In this problem, you can use the fact that $\{a^nb^n\mid n\ge0\}$ is CF and that CF languages are closed under union and concatenation with regular (in fact, all CF) languages.

Since $\{a\}^{*}$ is regular ,the concatenation of this and $\{a^nb^n\mid n\ge0\}$ is context-free.Also,since $\{b\}^{*}$ is regular,the concatenation of this and $\{a^nb^n\mid n\ge0\}$ is context-free.So,the language $\{w \epsilon \{a,b\}^{*}:a^{r}b^k,r \neq k\}$ is the union of these two context-free languages,so it is also context-free.Or am I wrong??
 
  • #4
evinda said:
Since $\{a\}^{*}$ is regular ,the concatenation of this and $\{a^nb^n\mid n\ge0\}$ is context-free.
This is true, but $\{a\}^{*}$ includes the empty word.

evinda said:
So,the language $\{w \epsilon \{a,b\}^{*}:a^{r}b^k,r \neq k\}$ is the union of these two context-free languages
It would be if empty words are removed from the two regular languages.

By the way, $\{w\in \{a,b\}^{*}:a^{r}b^k,r \neq k\}$ is an incorrect set-builder notation since $a^{r}b^k$ is not true or false. Perhaps the following set is meant: $\{a^rb^k: r\ne k\}$.

Hint: Use \in instead of \epsilon for set membership.
 
  • #5
evinda said:
Since $\{a\}^{*}$ is regular ,the concatenation of this and $\{a^nb^n\mid n\ge0\}$ is context-free.Also,since $\{b\}^{*}$ is regular,the concatenation of this and $\{a^nb^n\mid n\ge0\}$ is context-free.So,the language $\{w \epsilon \{a,b\}^{*}:a^{r}b^k,r \neq k\}$ is the union of these two context-free languages,so it is also context-free.Or am I wrong??

Hmm, isn't $ab$ an element of $\{a^nb^n\mid n\ge0\}$, but not an element of $\{a^{r}b^k :r \neq k\}$? Seems to me the latter cannot be a union involving the first set.
 
  • #6
Evgeny.Makarov said:
This is true, but $\{a\}^{*}$ includes the empty word.

It would be if empty words are removed from the two regular languages.

So,could we use $\{a\}^{+} \text{and} \{b\}^{+} $ instead of $\{a\}^{*} \text{and} \{b\}^{*}$

Evgeny.Makarov said:
By the way, $\{w\in \{a,b\}^{*}:a^{r}b^k,r \neq k\}$ is an incorrect set-builder notation since $a^{r}b^k$ is not true or false. Perhaps the following set is meant: $\{a^rb^k: r\ne k\}$.
Yes,I mean this one!

Evgeny.Makarov said:
Hint: Use \in instead of \epsilon for set membership.
Ok :)
 
  • #7
evinda said:
So,could we use $\{a\}^{+} \text{and} \{b\}^{+} $ instead of $\{a\}^{*} \text{and} \{b\}^{*}$
Yes.
 
  • #8
Evgeny.Makarov said:
Yes.

Nice,thank you very much! :)

- - - Updated - - -

I like Serena said:
Hmm, isn't $ab$ an element of $\{a^nb^n\mid n\ge0\}$, but not an element of $\{a^{r}b^k :r \neq k\}$? Seems to me the latter cannot be a union involving the first set.

What would you suggest?? :)
 
Last edited:
  • #9
I have also an other question.Is this set: $\{w=a^{r}b^k: r \neq k\}$ equal to this one: $\{w \neq a^{r}b^r:r \geq 0\}$ ?
 
  • #10
evinda said:
I have also an other question.Is this set: $\{w=a^{r}b^k: r \neq k\}$ equal to this one: $\{w \neq a^{r}b^r:r \geq 0\}$ ?

Or is there a difference between the 2 sets? :confused:
 
  • #11
evinda said:
What would you suggest?? :)

Well $\{ a^nb^m : n \ne m\} = \{ a^nb^m : n > m\} \cup \{ a^nb^m : n < m\} $.
So it suffices to verify the 2 right hand sets.

evinda said:
I have also an other question.Is this set: $\{w=a^{r}b^k: r \neq k\}$ equal to this one: $\{w \neq a^{r}b^r:r \geq 0\}$ ?

evinda said:
Or is there a difference between the 2 sets? :confused:

There are a couple of differences.
The second set would contain for instance $c$, since you did not specify that $a$ and $b$ are the only allowed terminals.
More importantly, the second set contains for instance $ba$, which is not in the first set.
 
  • #12
I like Serena said:
Well $\{ a^nb^m : n \ne m\} = \{ a^nb^m : n > m\} \cup \{ a^nb^m : n < m\} $.
So it suffices to verify the 2 right hand sets.
I understand.And are these two languages the only ones I could take to use the closure properties?

I like Serena said:
There are a couple of differences.
The second set would contain for instance $c$, since you did not specify that $a$ and $b$ are the only allowed terminals.
More importantly, the second set contains for instance $ba$, which is not in the first set.

Oh,I am sorry! :eek: I forgot to write that $w\in\{a,b\}^{*}$ . I meant the set:
$\{w \in \{a,b\}^{*}:w \neq a^{r}b^r:r \geq 0\}$ .
 
  • #13
evinda said:
I understand.And are these two languages the only ones I could take to use the closure properties?

After rereading your and Evgeny's post, I see that your original idea does work (with his modification).

Oh,I am sorry! :eek: I forgot to write that $w\in\{a,b\}^{*}$ . I meant the set:
$\{w \in \{a,b\}^{*}:w \neq a^{r}b^r:r \geq 0\}$ .

Good!
Let's make it $\{w \in \{a,b\}^{*}:w \neq a^{r}b^r, r \geq 0\}$ though.
Still, this set would contain for instance $ba$, which does not belong to the other set.
 
  • #14
I like Serena said:
After rereading your and Evgeny's post, I see that your original idea does work (with his modification).

Great! ;)

I like Serena said:
Good!
Let's make it $\{w \in \{a,b\}^{*}:w \neq a^{r}b^r, r \geq 0\}$ though.
Still, this set would contain for instance $ba$, which does not belong to the other set.

Oh,I understand.. (Wait)

Thank you very much! :)
 
Last edited:

Related to Understanding Context-Free Languages and Their Closure Properties

1. What programming languages can I use for scientific research?

There are many programming languages that can be used for scientific research, including Python, R, Java, C++, and MATLAB. The choice of programming language often depends on the specific research field and the type of data being analyzed.

2. Can I use multiple programming languages for my research project?

Yes, it is common to use multiple programming languages in a research project. For example, you may use Python for data analysis and R for statistical modeling. It is important to ensure that the different languages are compatible and can communicate with each other.

3. Are there any restrictions on which programming languages I can use for scientific publications?

There are typically no restrictions on which programming languages can be used for scientific publications. However, it is important to ensure that the language is well-known and widely used in the scientific community to increase the credibility of your research.

4. Can I use a programming language that I am not familiar with for my research?

It is generally recommended to use a programming language that you are familiar with for research projects. However, if there is a specific language that is well-suited for your research and you are willing to invest the time to learn it, then it is possible to use it for your project.

5. How do I choose the right programming language for my research project?

The best programming language for your research project will depend on the specific requirements and goals of your project. It is important to consider factors such as the type of data, the complexity of the analysis, and the availability of libraries and resources for the language. It may also be helpful to consult with other researchers in your field for their recommendations.

Similar threads

  • Programming and Computer Science
Replies
6
Views
2K
  • Programming and Computer Science
Replies
2
Views
2K
  • Programming and Computer Science
Replies
13
Views
3K
  • Programming and Computer Science
Replies
1
Views
1K
  • Programming and Computer Science
Replies
10
Views
2K
  • Programming and Computer Science
Replies
10
Views
4K
  • Programming and Computer Science
Replies
17
Views
2K
  • Sticky
  • General Discussion
Replies
0
Views
753
  • Programming and Computer Science
Replies
14
Views
3K
Back
Top