Exercise

Distinguishable or Not

Repeated practice: the tool draws a language and two words, and you decide whether they are in the same class or write a distinguishing word that the tool checks.

Last updated:


On this page we practise deciding whether two words are indistinguishable with respect to a language, and finding a distinguishing word when they are distinguishable.

Two words, one language

The tool draws a language from the languages of the lesson and of the tools page, and two short words.
If you think the words are in the same class, click “Same class”.
Otherwise, write a distinguishing word, that is, a continuation that puts exactly one of them in the language, and check it.
After each answer you can move on to another question.

The tool needs JavaScript. Use the questions on paper below.

Questions on paper

For each pair, decide whether the words are distinguishable with respect to the language, and if so write a distinguishing word.

Question 1. Laba={u aba v∣u,v∈{a,b}∗}L_{aba}=\{u\,aba\,v \mid u,v\in\{a,b\}^*\}⁠: the pair abab and aabaab⁠; the pair bb and baba⁠.

Answer

ab≡Labaaabab\equiv_{L_{aba}}aab⁠: a DFA that follows progress in the pattern abaaba (as in Designing a Deterministic Finite Automaton) is in the state “read abab” after both, so they are indistinguishable.
bb and baba are distinguishable: z=baz=ba⁠, because baba∈Labababa\in L_{aba} and bba∉Lababba\notin L_{aba}⁠.

Question 2. L2={u a v∣u,v∈{a,b}∗, ∣v∣=1}L_2=\{u\,a\,v \mid u,v\in\{a,b\}^*,\ |v|=1\}⁠: the pair aabaab and babbab⁠; the pair baba and bbbb⁠.

Answer

aab≡L2babaab\equiv_{L_2}bab⁠: both have the same last two letters, abab⁠. For every continuation zz⁠, the second letter from the end of the resulting word is a letter of zz or one of the last two letters of the original word, so it is the same for both words.
baba and bbbb are distinguishable: z=az=a⁠, because baa∈L2baa\in L_2 and bba∉L2bba\notin L_2⁠.

Question 3. L={u aa v∣u,v∈{a,b}∗}∪{u bb v∣u,v∈{a,b}∗}L=\{u\,aa\,v \mid u,v\in\{a,b\}^*\}\cup\{u\,bb\,v \mid u,v\in\{a,b\}^*\}⁠: the pair abababab and babbab⁠; the pair abaaba and bb⁠.

Answer

abab≡Lbababab\equiv_L bab⁠: neither has two equal letters next to each other, and both end with bb (both are in the class [b][b]⁠).
abaaba and bb are distinguishable: z=az=a⁠, because abaa∈Labaa\in L and ba∉Lba\notin L⁠.

Back to Myhill–Nerode: What a State Remembers, or see the glossary.