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

Finding two words of lengths that are relatively prime in a regular language?

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

Problem

Given a regular language $L$ over a unary alphabet $\Sigma = \{ a \}$.

How to decide whether there are two words $w,w' \in L$ such that
the length of $w$ is relatively prime to the length of $w'$ ?

Solution

Consider a minimal DFA for $L$. Each state in the DFA has one outgoing edge, so the DFA looks like a path entering a cycle. That means that $W = \{ n : a^n \in L \}$ is eventually periodic: for some $k,l$, for all $n \geq k$ it holds that $n \in W$ iff $n + l \in W$. We are now left with a problem in number theory, which I leave for you to ponder. (Try a few examples to see when an eventually periodic $W$ can fail to satisfy the property you're looking for.)

Context

StackExchange Computer Science Q#14106, answer score: 2

Revisions (0)

No revisions yet.