Lets say I have a language like this: L_k:={w∈Σ∗: (w)10=i·k, i∈N}. now using k as a parameter
I now want to define a DFA, that accepts L_{k}- and proof then that this DFA is valid. Important: k is a parameter, so the conditions and transition function is dependent on k.
I'd greatly appreciate any help!
A simple solution is to store, in each state, the current and next remainder after division by k;
the next remainder is after the one you would have after reading a 0.
So you would use states
S={(i,j) : 0≤i,j<k\}
, where (0,0) is the initial state.After reading a digit q, you would move from
(i,j)
to(j+q mod k, 10(j+q) mod k)
.Every state
(0,j)
is final, as the current remainder is 0 there.To prove that this is correct, let
x
denote some decimal number with the next remainderj
. Sox0
has remainderj
. If we read a digit other than 0, sayq
, then we would havexq
, which has remainderj+q mod k
(follows immediately from modulo arithmetic, as xq-x0 = q), and the next remainder is the remainder ofxq0 = xq * 10
, so simply(j+q)*10 mod k
.So i is indeed the current remainder, and j the next remainder.