HiveBrain v1.2.0
Get Started
← Back to all entries
gotchaMinor

Difference between regular language and context free language

Submitted by: @import:stackexchange-cs··
0
Viewed 0 times
freeregularlanguagedifferencebetweencontextand

Problem

What is nature of difference of regular language and context free language?

My guess is

RL - CFL = RL
CFL - RL = CFL


Am I correct with this?

Solution

No, those are not quite correct.

For any alphabet $\Sigma$, the language $\Sigma^*$ is regular. The set difference between that and any CFG with the same alphabet is the complement of the CFG, and CFGs are not closed with respect to complement. So your first claim is incorrect.

However, CFGs are closed with repect to intersection with a regular language and regular languages are closed with respect to complement. Thus, your second claim is correct.

Context

StackExchange Computer Science Q#93999, answer score: 3

Revisions (0)

No revisions yet.