Check that for dfa all transitions must have all the alphabets
Opened this issue · 0 comments
Devorein commented
const { DeterministicFiniteAutomaton } = require('fauton');
const startsWithBC = new DeterministicFiniteAutomaton(
(inputString) => inputString.startsWith('bc'),
{
alphabets: ['a', 'b'],
transitions: {
A: ['A'],
B: [null, 'B'],
},
}
);
The DFA accepts 2 alphabets a
and b
but in the transition map for state A
, it only indicates where to go when we encounter the symbol a
but not for b
. This should not be the case for dfa. Even in the 2nd state B
, it's gonna transition to null state for symbol a
, which is also a violation for DFA. Every state must have an array of state strings that have an equal length as that of the alphabets to ensure we cover all cases. An error should be thrown in this regard