Finite Automata

Answer & solution
Official answer: 6
Step through it (2 parts)
No input symbol is divisible by 7, so a product can never have residue 0. A DFA can keep one of the six nonzero residues 1,…,6 as its state. Start in state 1, use transition δ(r,a)=ra mod 7 for a∈{1,2,3,4}, and accept only state 2. This proves that six states suffice.
To prove minimality, first show all six residues are reachable. Repeated input 3 gives the cycle 1→3→2→6→4→5→1, so every state is reached by some power of the string symbol 3.
Next distinguish two different residues r and s. Nonzero residues modulo the prime 7 have multiplicative inverses. Choose a suffix whose product is t=2r−1 mod 7. Such a suffix exists because powers of 3 realize every nonzero residue. Appending it to a prefix with product r yields rt=2 and is accepted. Appending it to a prefix with product s cannot yield 2: st=rt would imply s=r after cancellation. Thus every pair of reachable states has different residual languages.
By the DFA distinguishability criterion, none of these states can be merged. Exactly six are necessary and sufficient; no seventh zero-residue state is reachable or needed for this alphabet. Answer: 6.
