let propagate_epsilon_transitions (states, _ as auto) =
let rec transitive_closure start (conds,actions) known_states curr =
let known_states = curr :: known_states in
let trans = Path_analysis.get_transitions_of_state curr auto in
List.fold_left
(fun acc tr ->
match tr.cross with
| Epsilon (cond,my_actions) ->
Aorai_option.debug "Treating epsilon trans %s -> %s"
curr.name tr.stop.name;
if List.exists (fun st -> st.nums = tr.stop.nums) known_states
then acc
else
transitive_closure
start (tand cond conds, my_actions @ actions)
known_states tr.stop @ acc
| Normal (cond, action) ->
Aorai_option.debug "Adding transition %s -> %s from epsilon trans"
start.name tr.stop.name;
new_trans start tr.stop (tand cond conds,action @ actions) ::acc)
[] trans
in
let treat_one_state acc st =
acc @ transitive_closure st (TTrue,[]) [] st
in
let trans = List.fold_left treat_one_state [] states in
(states, trans)