ztellman / automat

better automata through combinators

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

infinite loop with "or"

huahaiy opened this issue · comments

The or function in core may run into infinite loop at the minimization step. In particular, when it happens, the infinite loop will appear in the root function in the merge-pairs function. The occurrence of the infinite loop seems to be random, however, it will always appear if one runs or enough times.

To reproduce, run the following code:

(dotimes [i 100]
   (println (str "No." i))
   (a/or 1 2 3 4))

It may take a couple of runs of the above to generate an infinite loop. The process will have to be killed to stop it.

If we only or two states together, this bug doesn't appear.

Apparently, calling (fsm/reset-generation) between calls solve the problem.

There are still infinite loop issues with certain construction. For example, the following still leads to infinite loop:

(dotimes [i 10]
  (println i)
  (apply a/or [[1 2 4 (a/or 5 6 7 8)] [1 (a/or 5 6 7 8) 10]])
  (fsm/reset-generations))

Namely, if we or together automatons containing identical nested or of more than 3 items, an infinite loop appears.

This is now fixed. Thanks.