loop phi
- let eval_trans_aux auto cache2 cache4 tag fcs nss ps old_status =
+ let eval_trans_aux auto cache2 tag fcs nss ps old_status =
let { sat = old_sat;
todo = old_todo;
summary = old_summary } as os_node = old_status.NodeStatus.node
let eval_trans auto cache2 cache5 tag fcs nss ps ss =
+ let rec loop old_status =
+ let new_status =
+ eval_trans_aux auto cache2 tag fcs nss ps old_status
+ in
+ if new_status == old_status then old_status else loop new_status
+ in
let fcsid = (fcs.NodeStatus.id :> int) in
let nssid = (nss.NodeStatus.id :> int) in
let psid = (ps.NodeStatus.id :> int) in
+ let ssid = (ss.NodeStatus.id :> int) in
let tagid = (tag.QName.id :> int) in
- let rec loop old_status =
- let oid = (old_status.NodeStatus.id :> int) in
- let res =
- let res = Cache.N5.find cache5 tagid oid fcsid nssid psid in
- if res != dummy_status then res
- else
- let new_status =
- eval_trans_aux auto cache2 cache5 tag fcs nss ps old_status
- in
- Cache.N5.add cache5 tagid oid fcsid nssid psid new_status;
- new_status
- in
- if res == old_status then res else loop res
- in
- loop ss
-
+ let res = Cache.N5.find cache5 tagid ssid fcsid nssid psid in
+ if res != dummy_status then res
+ else let new_status = loop ss in
+ Cache.N5.add cache5 tagid ssid fcsid nssid psid new_status;
+ new_status
let cache2 = run.cache2 in
let cache5 = run.cache5 in
let unstable = run.unstable in
+ let init_todo = StateSet.diff (Ata.get_states auto) (Ata.get_starting_states auto) in
let rec loop node =
let node_id = T.preorder tree node in
if node == T.nil || not (Bitvector.get unstable node_id) then false else begin
(* first time we visit the node *)
NodeStatus.make
{ sat = StateSet.empty;
- todo = StateSet.diff
- (Ata.get_states auto)
- (Ata.get_starting_states auto);
+ todo = init_todo;
summary = NodeSummary.make
(node == T.first_child tree parent) (* is_left *)
(node == T.next_sibling tree parent) (* is_right *)
(fun q -> Hashtbl.add res_mapper q [])
(Ata.get_selecting_states auto)
in
+ let dummy = [ T.nil ] in
+ let res_mapper = Cache.N1.create dummy in
+ let () =
+ StateSet.iter
+ (fun q -> Cache.N1.add res_mapper (q :> int) [])
+ (Ata.get_selecting_states auto)
+ in
let rec loop node =
if node != T.nil then
let () = loop (T.next_sibling tree node) in
let () = loop (T.first_child tree node) in
StateSet.iter
(fun q ->
- try
- let acc = Hashtbl.find res_mapper q in
- Hashtbl.replace res_mapper q (node::acc)
- with
- Not_found -> ())
+ let res = Cache.N1.find res_mapper (q :> int) in
+ if res != dummy then
+ Cache.N1.add res_mapper (q :> int) (node::res)
+ )
cache.(T.preorder tree node).NodeStatus.node.sat
in
loop (T.root tree);
- StateSet.fold
- (fun q acc -> (q, Hashtbl.find res_mapper q)::acc)
- (Ata.get_selecting_states auto) []
+ List.rev (StateSet.fold
+ (fun q acc -> (q, Cache.N1.find res_mapper (q :> int))::acc)
+ (Ata.get_selecting_states auto) [])
let prepare_run run list =
let tree = run.tree in
if full then `Full (get_full_results run)
else `Normal (get_results run)
-
let full_eval auto tree nodes =
match eval true auto tree nodes with
`Full l -> l