MERZAK-X / DFA-Analyser

Deterministic Finite-State Automaton Analyser is a program that determins whether a string is accepted by a given DFSA.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Automaton accepts word not defined by its language

MERZAK-X opened this issue · comments

If word starts with alphabet that's accepted by the automaton, the word would be accepted as well, ex b is accepted would mean that bx^+ would also be accepted.

Automaton [Test Automaton] : E = {0, 1, 2, 3, 4, 5, 6, 7} ; A = {a, b, c, d, e} ; Transitions: { [ σ(0, a) = 1 ]  [ σ(0, b) = 2 ]  [ σ(1, a) = 2 ]  [ σ(1, b) = 3 ]  [ σ(2, e) = 4 ]  [ σ(3, a) = 4 ]  [ σ(3, c) = 3 ]  [ σ(4, b) = 5 ]  [ σ(5, d) = 6 ]  [ σ(5, e) = 7 ] } ; q₀ = 0 ; F = {5, 6, 7}

Enter a word (-1 to exit) : 
aaeb[AnyRandomTextHere]

✓ The word `aaeb[AnyRandomTextHere]` is accepted by the automaton's described language !

The problem is that the accept(word) function keeps looping over the word even though there are no valid transitions for a state.