Puzzle solving using NuSMV model checking tools. This presentation includs the basic for modeling checking using NuSMV for a numbers puzzle like Number Paranoia Game.
1. Model Checking For Puzzle Solving
By Anit Thapaliya
Software Engineering Lab
Department of Computer Science
Kyonggi University
Suwon, South Korea
2. Problem Background
A number based puzzle game where we
a. Must start at lowest number (1)
b. Must follow the sequence of number
c. Must cover all the plates
d. Finish at the higher number
Game Outline
3. Problem Formulation
Using Model Checking Tool
NuSMV
Consideration
1. Start from the lowest number
2. Follow sequence in order
3. Cover each plates
4. Finish at the highest number
4. Problem Formulation
Using Model Checking Tool
NuSMV
NuSMV requires the program to look for any solution whose number of transitions
is up to 47. Given my encoding of the problem, if no solution is found within 47
steps then we can safely conclude that there exists no possible solution for the input
table.
From our earlier solution it is clear to us that this is due to a rather poor encoding of
the problem (Our LTL property is overly complicated).
5. Problem Formulation
Using Model Checking Tool
NuSMV
•Modeling phase:
•Model the transition system under consideration
•Requirement 1: Visit every plates for which I consider a index of 0-47 for
identifying every available plates.
•Requirement 2: Follow the provided sequences for which I consider the
the given sequences in association with their relative indexing i.e. initial
lowest no 1 is in the index of 19.
•Requirement 3 : Avoid plates visiting twice for which I consider an array
of index 0-47 in Boolean form to represent whether the plates is visited
or not {0 for not visited & 1 for visited}
•Requiremt 4: Must start at lowest no and finish at highest no for which
our start point is the index having the lowest number and the end point is
the deadlock stage having the highest number.
6. Problem Solution
Using Model Checking Tool
NuSMV
MODULE main
VAR
index : 0..47; -- current position
sequence : {19, 43, 24, 25, 34, 21, 22, 28, 17, 1, 9};
plates : array 0..47 of { 0, 1 };
-- 0: plate not visited, 1: plate visited
9. Problem Solution
-- possible moves from any given plate, ignoring
-- the restriction over visiting the same plate
-- more than once
next(index) := case
index = 0 : {1, 8};
index = 1 : {0, 2, 9};
..
index = 8 : {0, 9, 16};
-- end plate: omitted (index 9: end plate)
index = 16 : {8, 17, 24};
index = 17 : {9, 16, 18, 25};
..
index = 47 : {39, 46};
TRUE : index;
esac;
11. Problem Solution
-- mark each plate as visited as soon as we move on it
next(plates[0]) := case next(index) =0 : 1; TRUE : plates[0]; esac;
next(plates[1]) := case next(index) =1 : 1; TRUE : plates[1]; esac;
next(plates[2]) := case next(index) =2 : 1; TRUE : plates[2]; esac;
next(plates[3]) := case next(index) =3 : 1; TRUE : plates[3]; esac;
next(plates[4]) := case next(index) =4 : 1; TRUE : plates[4]; esac;
next(plates[5]) := case next(index) =5 : 1; TRUE : plates[5]; esac;
next(plates[6]) := case next(index) =6 : 1; TRUE : plates[6]; esac;
next(plates[7]) := case next(index) =7 : 1; TRUE : plates[7]; esac;
next(plates[8]) := case next(index) =8 : 1; TRUE : plates[8]; esac;
next(plates[9]) := case next(index) =9 : 1; TRUE : plates[9]; esac;
…
next(plates[47]) := case next(index) =10 : 1; TRUE : plates[47]; esac;
12. Problem Solution
-- forbid stepping over an already visited plate,
-- unless it is the end plate
TRANS
(index = 9) | (plates[next(index)] != 1)
-- There is no possible path that reaches the goal state
LTLSPEC !(F goal_state)