Guide: Creating a Finite Automaton - automatarium/automatarium GitHub Wiki

Hi there! In this short guide we'll go through the steps of creating a basic finite automaton using Automatarium. Follow along to create your own!

Step 1: Create a File

Let's first load up Automatarium and create a new file by clicking on "Finite State Automaton" under the "New Project" section.

image

You should now see a screen similar to the following with your new empty file:

image

Step 2: Place Some States

In this guide we're going to create a finite state automaton that accepts the string abc repeated 0 or more times. For this, we'll need 3 states. Click on the state tool in the sidebar (or press S).

image

With the state tool selected, click on the canvas to create 3 states like the following:

image

You can switch back to the cursor tool by clicking on the toolbar or pressing V on your keyboard. Use the cursor tool to move your states around by clicking and dragging, then when you're ready, move to step 3.

Step 3: Connect With Transitions

Switch to the transition tool by clicking on it in the toolbar or pressing T on your keyboard.

image

With the transition tool selected, click and drag between two states (q0 and q1) to create a transition. An input dialog will appear where you can type in a string to be accepted by this transition.

image

After entering the input you want (in this case we want a transition that accepts a from q0 to q1), press enter on your keyboard, or click the return symbol to create the transition.

Create two more transitions, one for b going from q1 to q2, and a third for c from q2 back to q0. Your screen should now look similar to this:

image

Step 4: Set Initial and Final States

Currently we have all our states and transitions set up, however we haven't specified where to start and stop on our automaton. To do this, right click on state q0 and click "Set as initial". This will place a large arrow to the left of the state indicating that this is where the automaton begins.

image

Because we want our automaton to accept zero or more instances of abc, we also need to set q0 to a final state. This can also be done using the right click menu, this time to "Toggle is final".

image

The state q0 should now have both an initial arrow, and a double border to indicate that it is both the entrypoint and a final state of the automaton. Your screen should now look similar to the following completed graph:

image

Step 5: Testing Inputs

Let's test some inputs on our automaton to check that it follows our requirements. Open the testing lab by clicking the flask icon on the top right of the screen, or using the keyboard shortcut Shift 1.

When first opened, the testing lab will look like this:

image

Trace

Let's use the trace functionality first. Enter abc into the trace input and try clicking through the input using the left and right buttons. As we can see, this input was accepted, and the trace panel shows the path the input took through the automaton.

image

If we instead enter an input like abcd, the trace will let you know that there is no transition that can consume d from q0, and therefore the input will be rejected.

Pro tip: Try enabling the "trace tape" feature to see your inputs being consumed as they run through the automaton.

image

Multi-Run

The multi-run section as the name suggests lets you test many inputs quickly to see if they are accepted or rejected. The multi-run section supports pasting many inputs at once, try it out by copying the text below and pasting into a multi-run cell:

abc
abcabc
abcd
ab
bca

Pro tip: Add an extra input in the multiline section, but leave it blank. This will test our automaton on an empty input!

Run the multi-run section by clicking the "run" button or pressing Ctrl Enter from any cell.

image

We can easily see which inputs were accepted and rejected by the colour and symbol shown.

🎉 Congratulations on completing this guide!

⚠️ **GitHub.com Fallback** ⚠️