Implement the ranked automata evaluation to guarantee a O(|D|x|Q|)
[tatoo.git] / src / ata.mli
index 8b7851b..2aa27b3 100644 (file)
@@ -21,6 +21,21 @@ type move = [ `First_child
             | `Parent
             | `Previous_sibling
             | `Stay ]
+
+module Move :
+  sig
+    type t = move
+    type 'a table
+    val create_table : 'a -> 'a table
+    val get : 'a table -> t -> 'a
+    val set : 'a table -> t -> 'a -> unit
+    val iter : (t -> 'a -> unit) -> 'a table -> unit
+    val fold : (t -> 'a -> 'b -> 'b) -> 'a table -> 'b -> 'b
+    val for_all : (t -> 'a -> bool) -> 'a table -> bool
+    val for_all2 : (t -> 'a -> 'b -> bool) -> 'a table -> 'b table -> bool
+    val exists : (t -> 'a -> bool) -> 'a table -> bool
+  end
+
 (** Type of moves an automaton can perform *)
 
 type predicate =
@@ -34,7 +49,7 @@ type predicate =
 
 module Atom : sig
   include Hcons.S with type data = predicate
-  include Common_sig.Printable with type t:= t
+  include Common_sig.Printable with type t := t
 end
 (** Module representing atoms of Boolean formulae, which are simply hashconsed [predicate]s *)
 
@@ -65,10 +80,14 @@ module Formula :
           particular kind *)
     val get_states : t -> StateSet.t
       (** [get_state f] retrieves all the states occuring in [move] predicates in [f] *)
+    val get_states_by_move : t -> StateSet.t Move.table
   end
 (** Modules representing the Boolean formulae used in transitions *)
 
-module Transition : Hcons.S with type data = State.t * QNameSet.t * Formula.t
+module Transition : sig
+  include Hcons.S with type data = State.t * QNameSet.t * Formula.t
+  val print : Format.formatter -> t -> unit
+end
 (** A [Transition.t] is a hashconsed triple of the state, the set of labels and the formula *)
 
 
@@ -82,21 +101,75 @@ end
 type t
 (** 2-way Selecting Alternating Tree Automata *)
 
+val uid : t -> Uid.t
+(** return the internal unique ID of the automaton *)
+
 val get_states : t -> StateSet.t
 (** return the set of states of the automaton *)
 
+val get_starting_states : t -> StateSet.t
+(** return the set of starting states of the automaton *)
+
 val get_selecting_states : t -> StateSet.t
 (** return the set of selecting states of the automaton *)
 
+val get_states_by_rank : t -> StateSet.t array
+(** return an array of states ordered by ranks.
+*)
+
+val get_max_rank : t -> int
+(** return the maximal rank of a state in the automaton, that is the
+    maximum number of runs needed to fuly evaluate the automaton.
+*)
+
 val get_trans : t -> QNameSet.elt -> StateSet.t -> TransList.t
-(** [get_trans auto l q] return the list of transitions taken by [auto]
+(** [get_trans auto l q] returns the list of transitions taken by [auto]
     for label [l] in state [q]. Takes time proportional to the number of
     transitions in the automaton.
  *)
 
+val get_form : t -> QNameSet.elt -> State.t -> Formula.t
+(** [get_form auto l q] returns a single formula for label [l] in state [q].
+    Takes time proportional to the number of transitions in the automaton.
+ *)
+
 val print : Format.formatter -> t -> unit
 (** Pretty printing of the automaton *)
 
+val copy : t -> t
+(** [copy a] creates a copy of automaton [a], that is a new automaton with
+    the same transitions but with fresh states, such that [get_states a] and
+    [get_states (copy a)] are distinct
+*)
+val concat : t -> t -> t
+(** [concat a a'] creates a new automaton [a''] such that, given a set of tree
+    nodes [N], [a'' N = a' (a N)].
+*)
+
+val merge : t -> t -> t
+(** [merge a a'] creates a new automaton [a''] that evaluates both [a] and [a'']
+    in parallel
+*)
+
+val union : t -> t -> t
+(** [union a a'] creates a new automaton [a''] that selects node
+    selected by either [a] or [a']
+*)
+
+val inter : t -> t -> t
+(** [inter a a'] creates a new automaton [a''] that selects node
+    selected by both [a] and [a']
+*)
+
+val neg : t -> t
+(** [neg a] creates a new automaton [a'] that selects the nodes not
+    selected by [a]
+*)
+
+val diff : t -> t -> t
+(** [diff a a'] creates a new automaton [a''] that select nodes selected
+    by [a] but not selected by [a']
+*)
 
 module Builder :
 sig
@@ -109,10 +182,11 @@ sig
   val make : unit -> t
     (** Create a fresh builder *)
 
-  val add_state : t -> ?selecting:bool -> State.t -> unit
-    (** Add a state to the set of states of the automaton. The optional argument
-        [?selecting] (defaulting to [false]) allows to specify whether the state is
-        selecting. *)
+  val add_state : t -> ?starting:bool -> ?selecting:bool -> State.t -> unit
+  (** Add a state to the set of states of the automaton. The
+      optional arguments [?starting] and [?selecting] (defaulting
+      to [false]) allow one to specify whether the state is
+      starting/selecting. *)
 
   val add_trans : t -> State.t -> QNameSet.t -> Formula.t -> unit
     (** Add a transition to the automaton *)