Example 1: The set "Candy"Lets take the set "Candy." So members of the set are individual pieces of candy. If you take a piece of candy, and drop it on the ground, is it still candy? I say, according to the 5-second rule, I would still eat it, so it's still candy. That means that our set Candy is closed under the operation "drop."
What if I take two pieces of candy, x and y, and stick them together--stick(x,y)--to make a new piece of candy. Since what comes out of stick(x.y) is a piece of candy, Candy is closed under stick. Note: it only works if both operands are candy.
Now let's say that I take a piece of candy, x, and feed it to a bird. Then later, after digesting the candy, the bird leaves some droppings on my car (assume the droppings came from the candy, and we'll call this bird(x)). Is bird(x) candy? No way. So Candy is not closed under bird.
An important part of closure is that when we say that the set is "closed under" an operation, it has to be true for everything in the set. So even if all kinds of candies--except for one--were still candy after the bird() operation, Candy would still not be closed under bird(). Next is an example of closure that is more formal.
Example 2: The set of Integers
Can you think of some operations that the integers are closed under? One is addition. But the integers are not closed under division. It works sometimes--for example 12/3 = 4 (all integers)--but remember that it has to work all the time.
Closure Properties (memorize these) | ||
|---|---|---|
| The set of [set] | is [closed under/not closed under] | the operation [operation]. |
| Regular Languages | closed under | union, intersection, complement, concatenation, "*" operator |
| Context-Free Languages | closed under | union, concatenation, "*" operator |
| Context-Free Languages | not closed under | intersection, complement |