Understanding Context-Free Languages and Their Closure Properties

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

Discussion Overview

The discussion revolves around the properties of context-free languages (CFLs) and the specific language defined as $\{w \in \{a,b\}^{*}: a^{r}b^{k}, r \neq k\}$. Participants explore whether this language can be shown to be context-free using known closure properties and examples of context-free languages.

Discussion Character

  • Exploratory
  • Technical explanation
  • Debate/contested
  • Mathematical reasoning

Main Points Raised

  • Some participants inquire about which languages are known to be context-free, suggesting that they could use examples from textbooks or class materials.
  • Others propose that it is possible to demonstrate the context-freeness of the language by understanding the proofs independently, despite potential drawbacks in presentation.
  • It is noted that $\{a^nb^n \mid n \ge 0\}$ is context-free and that context-free languages are closed under union and concatenation with regular languages.
  • Concerns are raised about the inclusion of the empty word in $\{a\}^{*}$ and its implications for the union of context-free languages.
  • Some participants suggest using $\{a\}^{+}$ and $\{b\}^{+}$ instead of $\{a\}^{*}$ and $\{b\}^{*}$ to avoid issues with the empty word.
  • There is a discussion about the correctness of set-builder notation used to define the language, with suggestions for clarification.
  • Participants explore the relationship between the sets $\{w = a^{r}b^{k}: r \neq k\}$ and $\{w \neq a^{r}b^{r}: r \geq 0\}$, noting differences in their definitions and contents.
  • Some participants affirm that the original approach to using closure properties is valid, while others express uncertainty about whether the proposed sets are the only options available.

Areas of Agreement / Disagreement

Participants express differing views on the correct approach to demonstrating the context-freeness of the language in question. There is no consensus on the best method or the implications of using certain sets, indicating ongoing debate and exploration of the topic.

Contextual Notes

Participants highlight limitations in the definitions used, such as the inclusion of the empty word and the need for precise set-builder notation. There are also unresolved questions regarding the completeness of the proposed sets for demonstrating closure properties.

evinda
Gold Member
MHB
Messages
3,741
Reaction score
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
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.
 
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??
 
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.
 
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.
 
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 :)
 
evinda said:
So,could we use $\{a\}^{+} \text{and} \{b\}^{+} $ instead of $\{a\}^{*} \text{and} \{b\}^{*}$
Yes.
 
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:
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! :o 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! :o 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:

Similar threads

  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 13 ·
Replies
13
Views
3K
  • · Replies 15 ·
Replies
15
Views
4K
  • · Replies 14 ·
Replies
14
Views
4K
  • · Replies 10 ·
Replies
10
Views
2K
  • · Replies 9 ·
Replies
9
Views
8K
  • · Replies 1 ·
Replies
1
Views
5K
  • · Replies 53 ·
2
Replies
53
Views
9K
  • · Replies 6 ·
Replies
6
Views
5K