minor in run + fix infinite loop, must think about an algo here + fix print of solve
[tatoo.git] / src / run.ml
index 2e0cf95..fed18f0 100644 (file)
@@ -43,8 +43,8 @@ let rec bu_oracle asta run tree tnode =
     then ()
     else NodeHash.add run node (map_leaf asta)
   else
-    let tfnode = Tree.first_child tree tnode (* first child *)
-    and tnnode = Tree.next_sibling tree tnode in (* next-sibling *)
+    let tfnode = Tree.first_child tree tnode
+    and tnnode = Tree.next_sibling tree tnode in
     let fnode,nnode =                            (* their preorders *)
       (Tree.preorder tree tfnode, Tree.preorder tree tnnode) in
     begin
@@ -137,15 +137,28 @@ let rec tp_max asta run tree tnode =
       let qf,qn = q_rec fnode,q_rec nnode in
       let lab = Tree.tag tree tnode in
       let list_tr,_ = Asta.transitions_lab asta lab in (* only take query. *)
-      let set_node,_ = try NodeHash.find run node
-        with _ -> raise Max_fail in
-      let self = try NodeHash.find run node
+      let (set_node,set_nr) as self = try NodeHash.find run node
         with Not_found -> raise Max_fail in
+      (* We must compute again accepting states from self transitions since
+         previous calls of tp_max may remove them *)
+      let rec comp_acc_self set flag =
+       () (* given a current set of states we add
+             states from self transitions which satisfy the two conditions *)
+      (* With result (below) we have all valid transitions at step 0
+      we compute the self states which occur in it and which are not in cthe current state.
+      For each of these states we compute the transitions with the correct label and state
+      we infer each of these transitions: true -> add self states occuring in it
+         to the acc and to the current set + add left and right states as result do *)
+      (* ----> With a FIFO *)
+      and fix_point selfq_i =
+        () in
+      NodeHash.replace run node (set_node, set_nr);
+      
       let rec result = function
         | [] -> []
         | (q,form) :: tl ->
-          if (Formula.infer_form self qf qn form) &&
-            (StateSet.mem q set_node)   (* infers & trans. can start here *)
+          if (StateSet.mem q set_node) &&  (* infers & trans. can start here *)
+            (Formula.infer_form self qf qn form)
           then form :: (result tl)
           else result tl in
       let list_form = result list_tr in (* tran. candidates *)
@@ -168,6 +181,7 @@ let rec tp_max asta run tree tnode =
         if tnnode == Tree.nil
         then ()
         else NodeHash.replace run nnode (StateSet.inter qnq qr,qnr);
+        (* indeed we delete all states from self transitions!  *)
         tp_max asta run tree tfnode;
         tp_max asta run tree tnnode;
       end;