Last active
June 24, 2022 22:35
-
-
Save Average-user/4241ca84777ae6ed38326710d8b47da4 to your computer and use it in GitHub Desktop.
Search to prove the nonexistence of a 4-states minimal time solution to the Firing Squad Synchronization Problem.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Computer search to prove the nonexistence of minimal time solutions | |
-- to the FSSP with 4-(non-boundary)states. | |
-- States *,g,s,f,h... are represented by 0,1,2,3,4... respectively. | |
-- Hosted at: https://gist.github.com/Average-user/4241ca84777ae6ed38326710d8b47da4 | |
function initial_squad(n) | |
local squad = {} | |
squad[1],squad[2],squad[n+2] = "0","1","0" | |
for i = 3,n+1 do squad[i] = "2" end | |
return squad | |
end | |
function run(n,rule) | |
local xs, ys = initial_squad(n), initial_squad(n) | |
for j = 1,2*n-2 do | |
local fired,nfired = false,false | |
for i = 2,n+1 do | |
local st = xs[i-1]..xs[i]..xs[i+1] | |
local nv = rule[st] | |
if not nv then return false,st | |
elseif nv == "3" then fired = true | |
elseif nv ~= "3" then nfired = true | |
end | |
ys[i] = nv | |
end | |
if fired and nfired then return false,nil | |
elseif fired and j == 2*n-2 then return true,nil | |
elseif fired then return false,nil | |
end | |
for i = 2,n+1 do xs[i] = ys[i] end | |
end | |
return false,nil | |
end | |
function try_to_k(rule,k,start) | |
for n = start,k do | |
local solves,undef = run(n,rule) | |
if not solves then | |
return solves,undef,n | |
end | |
end | |
return true, nil, nil | |
end | |
TOT,POS = 0,0 | |
function find(N,rule,k,start) | |
local solves, undef, n = try_to_k(rule,k,start) | |
TOT = TOT+1 | |
if undef then | |
for i=1,N do | |
rule[undef] = tostring(i) | |
find(N,rule,k,n) | |
rule[undef] = nil | |
end | |
elseif solves then | |
POS = POS+1 | |
end | |
end | |
find(arg[1],{["022"]="2", ["222"]="2", ["220"]="2"},arg[2],2) | |
print(TOT,POS) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The FSSP is a well known problem in combinatorics/automata theory.
A first search to prove the nonexistence of minimal time solutions with four states was done first by R.Balzer in his paper An 8-state minimal time solution to the firing squad synchronization problem in 1967. Later, in 1994, P. Sanders reported that the search done by Balzer was incomplete and gave a description of another search in his paper Massively parallel search for transition-tables of polyautomata. I was unable to find the source code, so I made my own search. It reaffirms the result, and also the fact reported by Sanders that there are minimal time solutions that work for n up to 8, but not 9.
To run use
Which will output two numbers. The first indicates the amount of partial transition rules analyzed. The second the amount of ones that actually solve the problem in minimal time for squads of length no more than
k
.So, to obtain the result wanted is enough to check squads up to 9:
Which means that of the
241176313
nodes tried in the search0
solve the FSSP in minimal time for alln
in{2..9}
. With 8 westill have solutions (as reported by Sanders):
(runs were executed with LuaJIT
2.0.5
).States of
boundary
,general
,soldier
,firing
,(and possible more)
are represented by0,1,2,3, ...
respectively. Should be notedthat with four-state solution, we mean a solution with four-states not counting the
boundary
state0
.