We are currently working on new rules for what content should and shouldn't be allowed on this website, and are looking for feedback! See Esolang:2026 topicality proposal to view and give feedback on the current draft.

FFFF

From Esolang
Jump to navigation Jump to search

FFFF or 4F. Is a finite state machine programming language using fractions created by user RainbowDash in 2025.

Overview

In this language, you only have one register, which encodes the state. It can start as an integer or a fraction. After that, the user will be prompted for a number. That number will be divided by the current register, and the resulting value will then be checked against the program. If a match is found, the register will be divided by the preprogrammed number associated with that specific match, and the result will be stored back in the register. After that, control will be given back to the user to divide any number by the current register, and the process repeats forever. If no match is found, control is also given back to the user.

Syntax

A sample file looks like this

1
1/2 :: 3/2
2/1 :: 3/2

The lone number 1 can be set to a fraction or an integer. This determines what value the register starts at.
1/2 :: 3/2 means if the register is 1/2 then divide it by 3/2.

Example FSM encoding.

Say we want to make the FSM

The resulting program would be

1
1 : 1/2
2/3 : 2/3

Where state A is encoded by the output fraction 1/1 while state B is encoded by the output fraction 2/1.

How to convert to any FSM

To convert to any FSM. We must use only prime numbers. Prime numbers for the states and prime numbers for the input symbols. Nothing can share a prime number, states can not use the same prime numbers as input symbols.

Now given a list of primes

2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97

To recreate the example FSM from the Example FSM encoding section. We can designate

State Designation
A 2
B 3
Symbol Designation
1 5
2 7
3 11

Then we can apply this rule.


Where current_state_prime is the current state input_prime is the transition symbol and target_state_prime is the state you are transitioning to. Make sure to convert it into a fraction and simplify it.
The end format for a state transition looks like

STATE/SYMBOL :: ARRAY_VALUE

Since A is our starting state we will set the register to 2 at the start.
The converted FSM looks like this.

2
2/5 :: 2/15
3/7 :: 1/7
3/11 :: 3/22

So to explain the program above.

State Symbol Target State Calculation Output Line Code
A (2) 1 (5) B (3) 2 / (5 × 3) = 2/15 2/5 :: 2/15
B (3) 2 (7) B (3) 3 / (7 × 3) = 3/21 = 1/7 3/7 :: 1/7
B (3) 3 (11) A (2) 3 / (11 × 2) = 3/22 3/11 :: 3/22

Implementation

FFFF/Implementation