I'm trying to create a Deterministic Finite Automaton(DFA) with Prolog but I'm stuck. I didn't have this problem with Haskell, so I would highly appreciate any help. So far, here is what I've done:
start(q1). final(q4). transition(q1, '.', q3). transition(q1, '0', q2). transition(q1, '1', q2). transition(q2, '.', q4). transition(q2, '0', q2). transition(q2, '1', q2). transition(q3, '.', q5). transition(q3, '0', q4). transition(q3, '1', q4). transition(q4, '.', q5). transition(q4, '0', q4). transition(q4, '1', q4). transition(q5, '0', q5). transition(q5, '1', q5). accept(symbols, startState). dfaAccept(symbols) :- start(startstate). dfaAccept([], State) :- final(State). dfaAccept([Symbol|Symbols], State) :- transition(State, Symbol, NextState), accept(Symbols, NextState). When I run
dfaAccept(df1, "1.01"). I should get true, but I'm getting false ....