1

I am attempting to run "random" or non-deterministic simulations of a NuSMV model I have created. However between subsequent runs the trace that is produced is exactly the same.

Here is the model:

MODULE main
VAR x : 0..4;
VAR clk : 0..10;

DEFINE next_x :=
    case
        x = 0 : {0,1};
        x = 1 : {1,2};
        x = 2 : {1,0};
        TRUE : {0};
    esac;

DEFINE next_clk :=
    case
        (clk < 10) : (clk+1);
        TRUE : clk;
    esac;

INIT (x = 0);
INIT (clk = 0);

TRANS (next(x) in next_x);
TRANS next(clk) = next_clk;

CTLSPEC AG(clk < 10);

I am running this using the following commands in the interactive shell:

go
pick_state -r
simulate -k -r 30
show_traces 1
quit

Perhaps I have a mistake in my model? Or I am not running the correct commands in the shell.

Thanks in advance!

Simon Diemert
  • 330
  • 3
  • 9
  • Maybe there is only one path and no room for non-deterministic values. What does it say if you try and view the number of possible states for your model? – Niklas Rosencrantz Jul 30 '17 at 15:04
  • 1
    @DjDac it suffices to perform an *interactive simulation* to see that the model has some non-deterministic choices available, since more than one option is presented to the user for making it progress. – Patrick Trentin Jul 30 '17 at 16:08

1 Answers1

2

As far as I can tell after playing around with the tool, I would say that what you experience is a common behaviour due to using pseudo-random generators in a certain way.

Basically, I posit that each time one starts NuSMV void srand(unsigned int seed) is initialised with the same seed value. The obvious result is that NuSMV performs the exact same non-deterministic choices among independent runs, provided that you load the exact same model and perform exactly the same sequence of commands.

This kind of design is common among model checkers because it allows to reproduce potential bug traces reported by users more easily.


After looking at NuSMV -help and NuSMV documentation, it appears to me that the program has no option to manually set an arbitrary seed for the pseudo-random generator. (Note: you might want to contact NuSMV mailing list about this, it may be possible that there exists some internal variable to configure the random seed with the aid of the set command)

Therefore, I would like to propose the following work-around to help you achieving your goal of collecting different, non-deterministic execution traces from the same model. Try:

go
pick_state -r
simulate -r RANDOM_SEED
pick_state -r
simulate -r 30
show_traces 2
quit

Basically, the idea is to exploit the first simulation in order to move forward the pseudo-random generator to an arbitrary point in the pseudo-random chain. Each time you execute this script, you change the value of RANDOM_SEED, so that any two executions of NuSMV have a different starting-point in the pseudo-random generator for the second trace. In this way, NuSMV no longer repeats the same choices it has done in other executions for the second trace, unless that happens by pure chance.

Alternatively, you may obtain all the non-deterministic execution traces you want from a single run of the NuSMV solver:

go
pick_state -r
simulate -r 30
show_traces 1
pick_sate -r
simulate -r 30
show_traces 2
...
pick_state -r
simulate -r 30
show_traces N
quit

Note 1: your model has only one initial state, so pick_state -r always chooses the same initial state.

Note 2: your model reports the following error on my system:

TYPE ERROR file test.smv: line 23 :
    illegal operand types of "=" : integer-set and integer

when I type pick_state -i.

Note 3: since NuSMV source code is available, another possible solution is to patch it so as to accept a novel option for setting an arbitrary seed to initialise the pseudo-random generator.

Patrick Trentin
  • 7,126
  • 3
  • 23
  • 40
  • 1
    Thank you for the detailed answer. RE Note 2: I receive this error as well, as far as I can tell and according to the manual this is a valid expression, I am curious to know what you think? – Simon Diemert Jul 31 '17 at 02:10
  • 2
    @SimonDiemert after commenting one line of code after another, it looks like the problem truly is on a different line, and for some reason NuSMV reports the incorrect one. The incorrect part seems to be the definition of `next_x`, which somehow is assigned to be a `set` of integer values. I suggest you to drop a mail in *NusMV's mailing list* about this error message, perhaps they can provide an explanation. – Patrick Trentin Jul 31 '17 at 05:15
  • 1
    I just heard back from the NuSMV developers. This is apparently a known error with the syntax checking routines. it will be addressed in the next release. – Simon Diemert Jul 31 '17 at 18:28