Counterexample Hunter
Claims about languages and their operations: decide whether each is true for all languages, refute the false ones with a counterexample that the tool checks exactly, and order the proof of the true ones.
Last updated:
True for all languages, or false for some?
A claim about languages says that two expressions always describe the same language, whatever languages we put in the variables .
For example, ” for all languages”. Two kinds of work belong to such a claim:
- To show that it is false, one counterexample is enough: particular languages, and one word that belongs to one side and not to the other.
- To show that it is true, no number of examples is enough, because there are infinitely many languages. We need a proof for an arbitrary word, usually a chain of “if and only if” steps, each justified by a definition or a law of logic.
The tool below draws a claim about languages over the alphabet , and you decide whether it is true.
How to use the tool
Choose whether the claim is true or false. For a false claim, build small finite languages and a word that is in only one of the sides, and the tool evaluates both sides exactly.
For a true claim, put the lines of its proof in order and pick the reason for each line.
The languages that you type are finite lists of words.
The Counterexample Hunter needs JavaScript. Use the questions below on paper instead.
Questions on paper
Question 1. Decide whether holds for all languages. If not, give languages and a word that separates the two sides.
Hint 1
What happens on the left-hand side when and have no word in common?
Hint 2
A word can be split into a part from or and a part from in more than one way.
Take and with no word in common.
Answer
The claim is false. Take , and . The languages and have no word in common, so the left side is .
On the right, and , so their intersection is .
The word is in the right side only.
Question 2. Prove that for all languages.
Hint
Take an arbitrary word and follow it through the definitions.
The reverse of a product of two words is the product of the reverses in the opposite order:
.
Answer
Let be an arbitrary word. Then if and only if (definition of reverse), if and only if for some and (definition of concatenation), if and only if for some such and (by the lemma , Question 13 in Languages: Practice and Check of Understanding, and by the reverse of ), if and only if (definitions of reverse and concatenation).
The two languages have the same words, so they are equal.
Question 3. A student tests a claim on a thousand random small languages and finds no counterexample.
Does this prove the claim? What would you do next?
Answer
No. A claim “for all languages” can fail only on rare languages that the random choice did not produce, and there are infinitely many languages, so a finite test is evidence and not a proof.
The next step is a proof for an arbitrary word, or a search that is aimed at the places where such claims usually fail:
empty languages, languages that contain , and languages with no word in common.