Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Simulate the behavior of a nondeterministic finite automaton
ResourceFunction["NFASimulation"][rules,alphabet,start,accept,input] simulates the finite automaton described by rules, alphabet, start and accept over input. |
A simple NFA that rejects the given input:
In[1]:= |
Out[1]= |
If the last state is in the list of accept states, the input is accepted:
In[2]:= |
Out[2]= |
If one of the letters in the input is not in the alphabet, the simulation will throw an error:
In[3]:= |
Out[3]= |
The resource function NFAPlot can illustrate the NFA before simulation:
In[4]:= |
Out[4]= |
In[5]:= |
Out[5]= |
This work is licensed under a Creative Commons Attribution 4.0 International License