78edcfcb0b7e8350dcf4967eb88e78c1a5870fa2
[tatoo.git] / src / formula.mli
1 (***********************************************************************)
2 (*                                                                     *)
3 (*                               TAToo                                 *)
4 (*                                                                     *)
5 (*                     Kim Nguyen, LRI UMR8623                         *)
6 (*                   Université Paris-Sud & CNRS                       *)
7 (*                                                                     *)
8 (*  Copyright 2010-2012 Université Paris-Sud and Centre National de la *)
9 (*  Recherche Scientifique. All rights reserved.  This file is         *)
10 (*  distributed under the terms of the GNU Lesser General Public       *)
11 (*  License, with the special exception on linking described in file   *)
12 (*  ../LICENSE.                                                        *)
13 (*                                                                     *)
14 (***********************************************************************)
15
16 (** Implementation of hashconsed Boolean formulae *)
17
18 type move = [ `Left | `Right | `Epsilon | `Up1 | `Up2 ]
19
20 (** Direction for automata predicates *)
21
22 type 'formula expr =
23   | False
24   | True
25   | Or of 'formula * 'formula
26   | And of 'formula * 'formula
27   | Move of (move * bool * State.t)
28   | Label of QNameSet.t
29
30 (** View of the internal representation of a formula,
31     used for pattern matching *)
32
33 type t
34
35 (** Abstract type representing hashconsed formulae *)
36
37 val hash : t -> int
38 (** Hash function for formulae *)
39
40 val uid : t -> Uid.t
41 (** Returns a unique ID for formulae *)
42
43 val equal : t -> t -> bool
44 (** Equality over formulae *)
45
46 val expr : t -> t expr
47 (** Equality over formulae *)
48
49 (*val st : t -> StateSet.t * StateSet.t
50 (** states occuring left and right, positively or negatively *)
51 *)
52
53 val compare : t -> t -> int
54 (** Comparison of formulae *)
55
56 val print : Format.formatter -> t -> unit
57 (** Pretty printer *)
58
59 val is_true : t -> bool
60 (** [is_true f] tests whether the formula is the atom True *)
61
62 val is_false : t -> bool
63 (** [is_false f] tests whether the formula is the atom False *)
64
65 val true_ : t
66 (** Atom True *)
67
68 val false_ : t
69 (** Atom False *)
70
71 val atom_ : move -> bool -> StateSet.elt -> t
72 (** [atom_ dir b q] creates a down_left or down_right atom for state
73     [q]. The atom is positive if [b == true].
74 *)
75
76 val not_ : t -> t
77 val or_ : t -> t -> t
78 val and_ : t -> t -> t
79 (** Boolean connective *)
80
81 val of_bool : bool -> t
82 (** Convert an ocaml Boolean value to a formula *)
83
84 module Infix : sig
85   val ( +| ) : t -> t -> t
86   val ( *& ) : t -> t -> t
87   val ( *+ ) : move -> StateSet.elt -> t
88   val ( *- ) : move -> StateSet.elt -> t
89 end
90 (** Module to facilitate infix notations of formulae.
91     Just [open Formla.Infix] and write:
92     [let f = `Left *+ q1 +| `Right *+ q2 in ...]
93 *)