nusmv.pl 14 KB
Newer Older
Thierry Martinez's avatar
NuSMV  
Thierry Martinez committed
1 2 3
:- module(
  nusmv,
  [
4 5 6
    % options
    nusmv_initial_states/1,
    nusmv_counter_example/1,
7
    boolean_semantics/1,
8
    % commands
9
    export_nusmv/1,
10 11
    check_ctl/1,
    % API
SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
12 13
    check_ctl_impl/5,
    enumerate_all_molecules/1
Thierry Martinez's avatar
NuSMV  
Thierry Martinez committed
14 15 16
  ]
).

SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
17 18
:- use_module(ctl).

19 20 21
% Only for separate compilation/linting
:- use_module(reaction_rules).

22

Thierry Martinez's avatar
NuSMV  
Thierry Martinez committed
23 24 25 26
export_nusmv(OutputFile) :-
  biocham_command,
  type(OutputFile, output_file),
  doc('
David Rosenblueth's avatar
David Rosenblueth committed
27
    exports the current Biocham set of reactions and initial state in an SMV
Thierry Martinez's avatar
NuSMV  
Thierry Martinez committed
28 29
    \\texttt{.smv} file.
  '),
30 31 32 33 34 35
  option(boolean_semantics, boolean_semantics, BoolSem,
    'Use positive or negative boolean semantics for inhibitors.'),
  export_nusmv_file(OutputFile, BoolSem).


export_nusmv_file(OutputFile, BoolSem) :-
Thierry Martinez's avatar
NuSMV  
Thierry Martinez committed
36 37 38
  automatic_suffix(OutputFile, '.smv', write, FilenameSmv),
  setup_call_cleanup(
    open(FilenameSmv, write, Stream),
39
    export_nusmv_stream(Stream, BoolSem),
Thierry Martinez's avatar
NuSMV  
Thierry Martinez committed
40 41 42 43
    close(Stream)
  ).


44
export_nusmv_stream(Stream, BoolSem) :-
David Rosenblueth's avatar
David Rosenblueth committed
45 46 47 48 49 50 51
  (
    is_reaction_model
  ->
    export_nusmv_stream_reactions(Stream)
  ;
    is_influence_model
  ->
52
    export_nusmv_stream_influences(Stream, BoolSem)
David Rosenblueth's avatar
David Rosenblueth committed
53 54 55 56
  ).


export_nusmv_stream_reactions(Stream) :-
57
  write(Stream, 'MODULE main\n\n'),
Thierry Martinez's avatar
NuSMV  
Thierry Martinez committed
58
  findall(
59
    (Reactants, [], Products, []),
Thierry Martinez's avatar
NuSMV  
Thierry Martinez committed
60
    (
David Rosenblueth's avatar
David Rosenblueth committed
61 62
      item([kind: reaction, item: Item]),
      reaction(Item, _, Reactants, Products)
Thierry Martinez's avatar
NuSMV  
Thierry Martinez committed
63
    ),
David Rosenblueth's avatar
David Rosenblueth committed
64
    Reactions
Thierry Martinez's avatar
NuSMV  
Thierry Martinez committed
65
  ),
66
  enumerate_all_molecules(Molecules),
SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
67
  Molecules \= [],
68 69
  export_initial_state(Stream, Molecules),
  export_transitions(Stream, Molecules, Reactions).
Thierry Martinez's avatar
NuSMV  
Thierry Martinez committed
70 71


72
enumerate_all_molecules(Molecules) :-
Thierry Martinez's avatar
NuSMV  
Thierry Martinez committed
73
  (
74
    enumerate_molecules(ReactionMolecules)
Thierry Martinez's avatar
NuSMV  
Thierry Martinez committed
75
  ->
76
    true
Thierry Martinez's avatar
NuSMV  
Thierry Martinez committed
77
  ;
78
    ReactionMolecules = []
Thierry Martinez's avatar
NuSMV  
Thierry Martinez committed
79
  ),
80 81 82 83 84 85
  (
    enumerate_molecules_influences(InfluenceMolecules)
  ->
    true
  ;
    InfluenceMolecules = []
Thierry Martinez's avatar
NuSMV  
Thierry Martinez committed
86
  ),
87 88 89 90 91 92 93 94 95
  union(ReactionMolecules, InfluenceMolecules, ModelMolecules),
  (
    query_mols(QueryMolecules)
  ->
    true
  ;
    QueryMolecules = []
  ),
  union(ModelMolecules, QueryMolecules, Molecules).
Thierry Martinez's avatar
NuSMV  
Thierry Martinez committed
96 97


98 99
export_initial_state(Stream, Molecules) :-
  forall(
Thierry Martinez's avatar
NuSMV  
Thierry Martinez committed
100
    member(Molecule, Molecules),
101 102 103 104 105 106
    (
      make_nusmv_name(Molecule, Name),
      format(Stream, 'VAR ~a: boolean;\n', [Name]),
      get_initial_state(Molecule, InitialState),
      nusmv_initial_state(InitialState, NusmvInitialState),
      format(Stream, 'INIT ~a in ~a;~n', [Name, NusmvInitialState])
Thierry Martinez's avatar
NuSMV  
Thierry Martinez committed
107 108
    )
  ),
109
  nl(Stream).
Thierry Martinez's avatar
NuSMV  
Thierry Martinez committed
110 111


112
export_nusmv_stream_influences(Stream, BoolSem) :-
113
  write(Stream, 'MODULE main\n\n'),
114
  findall(
115
    (PositiveInputs, NegativeInputs, [Output | PositiveInputs], NegativeInputs),
116
    (
117
      item([kind: influence, item: Item]),
118
      influence(Item, _Force, PositiveInputs, NegInputs, '+', Output),
119 120 121 122 123 124 125
      (
        BoolSem == positive
      ->
        NegativeInputs = []
      ;
        subtract(NegInputs, [Output], NegativeInputs)
      )
126
    ),
127
    PInfluences
128 129
  ),
  findall(
130
    (PositiveInputs, NegativeInputs, PositiveInputs, [Output | NegativeInputs]),
131
    (
132
      item([kind: influence, item: Item]),
133 134 135 136 137 138 139 140
      influence(Item, __Force, PosInputs, NegInputs, '-', Output),
      (
        BoolSem == positive
      ->
        NegativeInputs = []
      ;
        NegativeInputs = NegInputs
      ),
141
      subtract(PosInputs, [Output], PositiveInputs)
142
    ),
143
    NInfluences
144
  ),
145 146 147 148
  append(PInfluences, NInfluences, Influences),
  enumerate_all_molecules(Molecules),
  export_initial_state(Stream, Molecules),
  export_transitions(Stream, Molecules, Influences).
149

150
:- dynamic(allmolecules/1).
151

152

153 154 155 156 157
export_transitions(Stream, Molecules, Reactions) :-
  retractall(allmolecules(_)),
  assertz(allmolecules(Molecules)),
  write(Stream, 'TRANS '),
  maplist(reaction_to_trans, Reactions, Trans),
Sylvain Soliman's avatar
Sylvain Soliman committed
158 159 160 161
  maplist(reaction_to_nofire, Reactions, Loops),
  all_nochange(NoChange),
  atomic_list_concat([NoChange | Loops], ' & ', Loop),
  atomic_list_concat([Loop | Trans], ' | ', TransOred),
162 163 164
  write(Stream, TransOred),
  nl(Stream).

David Rosenblueth's avatar
David Rosenblueth committed
165

166
reaction_to_trans((PositiveInputs, NegativeInputs, Products, Degraded), Trans) :-
David Rosenblueth's avatar
David Rosenblueth committed
167
  (
168
    PositiveInputs == []
David Rosenblueth's avatar
David Rosenblueth committed
169
  ->
170 171
    PositiveNames = [],
    NusmvPositive = 'TRUE'
David Rosenblueth's avatar
David Rosenblueth committed
172
  ;
173 174 175 176 177 178 179
    maplist(reactant_to_name, PositiveInputs, PositiveNames),
    apply_and_join(
      [make_nusmv_name],
      PositiveNames,
      ' & ',
      NusmvPositive
    )
David Rosenblueth's avatar
David Rosenblueth committed
180
  ),
181 182 183 184 185 186 187 188 189 190 191 192
  (
    NegativeInputs == []
  ->
    NegativeNames = [],
    NusmvNegative = 'TRUE'
  ;
    maplist(reactant_to_name, NegativeInputs, NegativeNames),
    apply_and_join(
      [make_nusmv_name, prepend_not],
      NegativeNames,
      ' & ',
      NusmvNegative
193 194
    )
  ),
195 196 197 198 199 200 201 202 203 204 205 206
  (
    Products == []
  ->
    ProductNames = [],
    NusmvProducts = 'TRUE'
  ;
    maplist(reactant_to_name, Products, ProductNames),
    apply_and_join(
      [make_nusmv_name, surround_next],
      ProductNames,
      ' & ',
      NusmvProducts
David Rosenblueth's avatar
David Rosenblueth committed
207
    )
208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243
  ),
  (
    Degraded == []
  ->
    DegradedNames = [],
    NusmvDegraded = 'TRUE'
  ;
    maplist(reactant_to_name, Degraded, DegradedNames),
    apply_and_join(
      [make_nusmv_name, surround_next, prepend_not],
      DegradedNames,
      ' & ',
      NusmvDegraded
    )
  ),
  allmolecules(Molecules),
  subtract(Molecules, PositiveNames, NoPositive),
  subtract(NoPositive, NegativeNames, NoNegative),
  subtract(NoNegative, ProductNames, NoProducts),
  subtract(NoProducts, DegradedNames, OtherMolecules),
  (
    OtherMolecules == []
  ->
    NusmvOthers = 'TRUE'
  ;
    apply_and_join(
      [make_nusmv_name, equiv_next],
      OtherMolecules,
      ' & ',
      NusmvOthers
    )
  ),
  atomic_list_concat(
    [NusmvPositive, NusmvNegative, NusmvProducts, NusmvDegraded, NusmvOthers],
    ' & ',
    Trans
David Rosenblueth's avatar
David Rosenblueth committed
244 245 246
  ).


Sylvain Soliman's avatar
Sylvain Soliman committed
247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287
reaction_to_nofire((PosInputs, NegInputs, _, _), ParenLoop) :-
  (
    PosInputs == []
  ->
    NusmvPos = 'FALSE'
  ;
    maplist(reactant_to_name, PosInputs, PosNames),
    apply_and_join(
      [make_nusmv_name, prepend_not],
      PosNames,
      ' | ',
      NusmvPos
    )
  ),
  (
    NegInputs == []
  ->
    NusmvNeg = 'FALSE'
  ;
    maplist(reactant_to_name, NegInputs, NegNames),
    apply_and_join(
      [make_nusmv_name],
      NegNames,
      ' | ',
      NusmvNeg
    )
  ),
  atomic_list_concat([NusmvPos, NusmvNeg], ' | ', Loop),
  format(atom(ParenLoop), '(~a)', [Loop]).


all_nochange(Result) :-
  allmolecules(Molecules),
  apply_and_join(
    [make_nusmv_name, equiv_next],
    Molecules,
    ' & ',
    Result
  ).


288 289 290 291 292 293
apply_and_join([], List, Join, Result) :-
  atomic_list_concat(List, Join, Result).

apply_and_join([Function | Functions], List, Join, Result) :-
  maplist(Function, List, NewList),
  apply_and_join(Functions, NewList, Join, Result).
David Rosenblueth's avatar
David Rosenblueth committed
294 295


296 297
surround_next(Atom, Next) :-
  format(atom(Next), 'next(~a)', [Atom]).
David Rosenblueth's avatar
David Rosenblueth committed
298 299


300 301
prepend_not(Atom, Not) :-
  format(atom(Not), '!~a', [Atom]).
David Rosenblueth's avatar
David Rosenblueth committed
302 303


304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320
equiv_next(Atom, Equiv) :-
  format(atom(Equiv), '(~a <-> next(~a))', [Atom, Atom]).


reactants_to_condition(Reactants, Condition) :-
  apply_and_join([reactant_to_name, make_nusmv_name], Reactants, ' & ', Condition).


reactant_to_name(_ * Name, Name) :-
  !.

reactant_to_name(Name, Name).


objects_to_condition(Objects, Condition) :-
  apply_and_join(make_nusmv_name, Objects, ' & ', Condition).

David Rosenblueth's avatar
David Rosenblueth committed
321

Thierry Martinez's avatar
NuSMV  
Thierry Martinez committed
322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341
nusmv_initial_state(present(_), 'TRUE').

nusmv_initial_state(absent, 'FALSE').

nusmv_initial_state(undefined, '{FALSE, TRUE}').


make_nusmv_name(Molecule, Name) :-
  reserved(Molecule),
  !,
  atom_concat('_', Molecule, Name).


make_nusmv_name(Molecule, Name) :-
  atom_chars(Molecule, MoleculeChars),
  findall(
    TranslatedChar,
    (
      member(Char, MoleculeChars),
      (
SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
342 343 344
        translate_char(Char, TranslatedChar)
      ->
        true
Thierry Martinez's avatar
NuSMV  
Thierry Martinez committed
345 346 347 348 349 350 351 352 353 354 355 356 357
      ;
        TranslatedChar = Char
      )
    ),
    TranslatedList
  ),
  atomic_list_concat(TranslatedList, Name).


translate_char('_', '__').

translate_char(',', '_c').

SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
358
translate_char('~', '').
Thierry Martinez's avatar
NuSMV  
Thierry Martinez committed
359 360 361 362 363

translate_char('{', '_l').

translate_char('}', '_r').

SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
364 365 366 367
translate_char('(', '_L').

translate_char(')', '_R').

Thierry Martinez's avatar
NuSMV  
Thierry Martinez committed
368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398

reserved('B').

reserved('F').

reserved('G').

reserved('H').

reserved('O').

reserved('S').

reserved('T').

reserved('V').

reserved('W').

reserved('X').

reserved('Y').

reserved('Z').

reserved('A').

reserved('E').

reserved('U').

399
reserved('xor').
Thierry Martinez's avatar
NuSMV  
Thierry Martinez committed
400

401
reserved('R').
Thierry Martinez's avatar
NuSMV  
Thierry Martinez committed
402

403 404
reserved(Atom) :-
  ctl_unary_op(Atom).
Thierry Martinez's avatar
NuSMV  
Thierry Martinez committed
405 406


407 408
ctl_unary_op(Op) :-
  memberchk(Op, ['AF', 'EF', 'AG', 'EG', 'AX', 'EX']).
409 410


411 412 413 414 415 416 417
:- grammar(boolean_semantics).

boolean_semantics(positive).

% Default. Set in library/initial.bc
boolean_semantics(negative).

418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434
:- grammar(nusmv_counter_example).

nusmv_counter_example(yes).

% Default. Set in library/initial.bc
nusmv_counter_example(no).

:- grammar(nusmv_initial_states).

nusmv_initial_states(some).

% Default. Set in library/initial.bc
nusmv_initial_states(all).


check_ctl(Query) :-
  biocham_command,
435 436
  doc('
    evaluates the \\argument{Query} on the current model by calling the
SOLIMAN Sylvain's avatar
typos  
SOLIMAN Sylvain committed
437 438 439
    NuSMV model-checker.

    As is usual in Model-Checking, the query is evaluated for all possible
440
    initial states (\\texttt{Ai} in Biocham v3). This can be changed via
441
    the \\texttt{nusmv_initial_states} option.
SOLIMAN Sylvain's avatar
typos  
SOLIMAN Sylvain committed
442
  '),
443
  type(Query, ctl),
444 445 446 447
  option(nusmv_initial_states, nusmv_initial_states, NusmvInitialState,
    'Consider that a query is true if verified for all/some initial states.'),
  option(nusmv_counter_example, nusmv_counter_example, NusmvCX,
    'Compute a counter-example for a query when possible.'),
448 449 450
  option(boolean_semantics, boolean_semantics, BoolSem,
    'Use positive or negative boolean semantics for inhibitors.'),
  check_ctl_impl(Query, NusmvInitialState, NusmvCX, BoolSem, Result),
451 452
  format('~w is ~w\n', [Query, Result]).

453

SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
454 455 456 457 458 459
:- doc('\\begin{example}\n').
:- biocham_silent(clear_model).
:- biocham(present(a)).
:- biocham(absent(b)).
:- biocham(a => b).
:- biocham(a + b => a).
460 461
:- biocham(check_ctl('EX'(not(a) \/ 'EG'(not(b))), nusmv_counter_example:yes)).
:- biocham(check_ctl('EG'(not(b)), nusmv_counter_example:yes)).
SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
462
:- biocham(check_ctl(reachable(b), nusmv_counter_example:yes)).
SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
463
:- doc('\\end{example}').
464

465

466 467
check_ctl_impl(Query, some, NusmvCX, BoolSem, Result) :-
  check_ctl_impl(not(Query), all, NusmvCX, BoolSem, NotResult),
468 469 470 471 472 473 474 475 476 477 478
  (
    NotResult == 'true'
  ->
    Result = 'false'
  ;
    NotResult == 'false'
  ->
    Result = 'true'
  ;
    Result = 'error'
  ).
479 480


481 482 483 484 485
% stores the counter-example trace from NuSMV
% argument is a list, with R, then molecules in enumerate_all_molecules order
:- dynamic(trace/1).


486 487 488 489
% stores unknown molecules coming from the query
:- dynamic(query_mols/1).


490 491
% care that if Result is instantiated, the predicate might fail before parsing
% the full output/trace
492
check_ctl_impl(Query, all, NusmvCX, BoolSem, Result) :-
493
  retractall(trace(_)),
494 495 496
  retractall(query_mols(_)),
  normalize_query(Query, NQuery, Mols),
  assertz(query_mols(Mols)),
SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
497
  translate_ctl_for_nusmv(NQuery, NusmvQuery),
498
  % FIXME better template, in $TMP, check if not existing, etc.
499
  export_nusmv_file(nusmv, BoolSem),
500
  open('nusmv.cmd', write, Stream),
501
  write(Stream, 'set input_file nusmv.smv\ngo\n'),
502
  (
503
    NusmvCX == 'no'
504 505
  ->
    write(Stream, 'set counter_examples 0\n')
506 507
  ;
    write(Stream, 'set default_trace_plugin 2\nset counter_examples 1\n')
508
  ),
509
  format(Stream, 'check_ctlspec -p "~a"\nquit\n', [NusmvQuery]),
510
  close(Stream),
511
  call_subprocess(
512
    path('NuSMV'),
513
    ['-df', '-source', 'nusmv.cmd'],
514
    [stdin(null), stdout(pipe(NusmvOut))]
515
  ),
516
  call_cleanup(parse_nusmv_out(NusmvOut, NusmvCX, Result), close(NusmvOut)),
517
  (
518
    NusmvCX == 'yes',
519 520 521
    trace(_)
  ->
    write('Trace:\n'),
522
    enumerate_all_molecules(Molecules),
523 524
    findall(T, trace(T), Trace),
    forall(
Sylvain Soliman's avatar
Sylvain Soliman committed
525
      member(Line, [Molecules | Trace]),
526 527 528 529 530 531 532 533 534 535
      (
        atomic_list_concat(Line, '\t', Atom),
        write(Atom),
        nl
      )
    ),
    nl
  ;
    true
  ).
536 537


538 539 540 541
translate_ctl_for_nusmv(A -> B, Atom) :-
  !,
  translate_ctl_for_nusmv(A, AA),
  translate_ctl_for_nusmv(B, BB),
SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
542
  atomic_list_concat(['(', AA, ' -> ', BB, ')'], Atom).
SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
543

544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560
translate_ctl_for_nusmv(A \/ B, Atom) :-
  !,
  translate_ctl_for_nusmv(A, AA),
  translate_ctl_for_nusmv(B, BB),
  atomic_list_concat(['(', AA, ' | ', BB, ')'], Atom).

translate_ctl_for_nusmv(A /\ B, Atom) :-
  !,
  translate_ctl_for_nusmv(A, AA),
  translate_ctl_for_nusmv(B, BB),
  atomic_list_concat(['(', AA, ' & ', BB, ')'], Atom).

translate_ctl_for_nusmv(not(A), Atom) :-
  !,
  translate_ctl_for_nusmv(A, AA),
  atomic_list_concat(['!', AA], Atom).

SOLIMAN Sylvain's avatar
typos  
SOLIMAN Sylvain committed
561
translate_ctl_for_nusmv('EU'(A, B), Atom) :-
562 563 564 565 566
  !,
  translate_ctl_for_nusmv(A, AA),
  translate_ctl_for_nusmv(B, BB),
  atomic_list_concat(['E [', AA, ' U ', BB, ']'], Atom).

SOLIMAN Sylvain's avatar
typos  
SOLIMAN Sylvain committed
567
translate_ctl_for_nusmv('AU'(A, B), Atom) :-
568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583
  !,
  translate_ctl_for_nusmv(A, AA),
  translate_ctl_for_nusmv(B, BB),
  atomic_list_concat(['A [', AA, ' U ', BB, ']'], Atom).

translate_ctl_for_nusmv(CTL, Atom) :-
  CTL =.. [Operator, A],
  ctl_unary_op(Operator),
  !,
  translate_ctl_for_nusmv(A, AA),
  atomic_list_concat([Operator, AA], ' ', Atom).

translate_ctl_for_nusmv(Object, Atom) :-
  make_nusmv_name(Object, Atom).


584
parse_nusmv_out(Out, NusmvCX, Result) :-
585 586 587 588
  read_line_to_codes(Out, Codes),
  (
    Codes = end_of_file
  ->
589
    Result = 'error'
590
  ;
591
    % "-- "
592
    Codes = [0'-, 0'-, 0'  | _]
593
  ->
594
    (
595
      append(_, [0'i, 0's, 0' , 0't, 0'r, 0'u, 0'e], Codes)
596 597 598
    ->
      Result = 'true'
    ;
599
      append(_, [0'i, 0's, 0' , 0'f, 0'a, 0'l, 0's, 0'e], Codes)
600 601 602 603
    ->
      Result = 'false'
    ;
      Result = 'error'
604 605
    ),
    (
606
      NusmvCX == 'no'
607 608
    ->
      true
609 610
    ;
      parse_nusmv_out_trace(Out)
611
    )
612
  ;
613
    parse_nusmv_out(Out, NusmvCX, Result)
614
  ).
615 616 617 618

parse_nusmv_out_trace(Out) :-
  % -- as demonstrated by the following execution sequence
  read_line_to_codes(Out, [0'-, 0'-, 0'  | _]),
619
  !,
620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637
  read_line_to_codes(Out, [0'N, 0'a, 0'm, 0'e, 0'\t | _]),
  read_string(Out, "\n", "\r", _End, InitialString),
  state_string_to_trace(InitialString, InitialTrace),
  assertz(trace(InitialTrace)),
  repeat,
  read_line_to_codes(Out, _Constants),
  read_line_to_codes(Out, _Inputs),
  read_string(Out, "\n", "\r", End, StateString),
  (
    End = -1
  ->
    !
  ;
    state_string_to_trace(StateString, StateTrace),
    assertz(trace(StateTrace)),
    fail
  ).

638 639 640
parse_nusmv_out_trace(Out) :-
  read_line_to_codes(Out, end_of_file).

641 642 643

state_string_to_trace(String, Trace) :-
  split_string(String, "\t", "\t", [_ | Trace]).
644 645 646 647


prolog:message(error(unknown_molecule)) -->
  ['Unknown molecule in query.'].