Refactor the code to have a unique place for signature definition.
[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 ]
19 (** Direction for automata predicates *)
20
21 type 'formula expr =
22   | False
23   | True
24   | Or of 'formula * 'formula
25   | And of 'formula * 'formula
26   | Move of (move * bool * State.t)
27   | Label of QNameSet.t
28
29 (** View of the internal representation of a formula,
30     used for pattern matching *)
31
32 type t
33
34 (** Abstract type representing hashconsed formulae *)
35
36 val hash : t -> int
37 (** Hash function for formulae *)
38
39 val uid : t -> Uid.t
40 (** Returns a unique ID for formulae *)
41
42 val equal : t -> t -> bool
43 (** Equality over formulae *)
44
45 val expr : t -> t expr
46 (** Equality over formulae *)
47
48 (*val st : t -> StateSet.t * StateSet.t
49 (** states occuring left and right, positively or negatively *)
50 *)
51
52 val compare : t -> t -> int
53 (** Comparison of formulae *)
54
55 val size : t -> int
56 (** Syntactic size of the formula *)
57
58 val print : Format.formatter -> t -> unit
59 (** Pretty printer *)
60
61 val is_true : t -> bool
62 (** [is_true f] tests whether the formula is the atom True *)
63
64 val is_false : t -> bool
65 (** [is_false f] tests whether the formula is the atom False *)
66
67 val true_ : t
68 (** Atom True *)
69
70 val false_ : t
71 (** Atom False *)
72
73 val atom_ : move -> bool -> StateSet.elt -> t
74 (** [atom_ dir b q] creates a down_left or down_right atom for state
75     [q]. The atom is positive if [b == true].
76 *)
77
78 val not_ : t -> t
79 val or_ : t -> t -> t
80 val and_ : t -> t -> t
81 (** Boolean connective *)
82
83 val of_bool : bool -> t
84 (** Convert an ocaml Boolean value to a formula *)
85
86 module Infix : sig
87   val ( +| ) : t -> t -> t
88   val ( *& ) : t -> t -> t
89   val ( *+ ) : move -> StateSet.elt -> t
90   val ( *- ) : move -> StateSet.elt -> t
91 end
92 (** Module to facilitate infix notations of formulae.
93     Just [open Formla.Infix] and write:
94     [let f = `Left *+ q1 +| `Right *+ q2 in ...]
95 *)