Add functions to normalize an automaton:
[tatoo.git] / src / auto / 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 (*
17   Time-stamp: <Last modified on 2013-02-08 18:36:33 CET by Kim Nguyen>
18 *)
19
20 module type PREDICATE =
21 sig
22   type t
23   type ctx
24   val eval : ctx -> t -> bool
25   val neg : t -> t
26   include Utils.Hcons.Abstract with type t := t
27   include Utils.Sigs.AUX.Printable with type t := t
28 end
29
30 type ('formula,'pred) expr =
31   | False
32   | True
33   | Or of 'formula * 'formula
34   | And of 'formula * 'formula
35   | Atom of 'pred
36
37 (** View of the internal representation of a formula,
38     used for pattern matching *)
39
40 module Make(P : PREDICATE) :
41 sig
42   type t
43
44   (** Abstract type representing hashconsed formulae *)
45
46   val hash : t -> int
47   (** Hash function for formulae *)
48
49   val uid : t -> Utils.Uid.t
50   (** Returns a unique ID for formulae *)
51
52   val equal : t -> t -> bool
53   (** Equality over formulae *)
54
55   val expr : t -> (t,P.t) expr
56   (** Return a view of the formulae *)
57
58   val compare : t -> t -> int
59   (** Comparison of formulae *)
60
61   val print : Format.formatter -> t -> unit
62   (** Pretty printer *)
63
64   val is_true : t -> bool
65   (** [is_true f] tests whether the formula is the atom True *)
66
67   val is_false : t -> bool
68   (** [is_false f] tests whether the formula is the atom False *)
69
70   val true_ : t
71   (** Atom True *)
72
73   val false_ : t
74   (** Atom False *)
75
76   val atom_ : P.t -> t
77   (** [atom_ dir b q] creates a down_left or down_right atom for state
78       [q]. The atom is positive if [b == true].
79   *)
80
81   val not_ : t -> t
82   val or_ : t -> t -> t
83   val and_ : t -> t -> t
84   (** Boolean connective *)
85
86   val of_bool : bool -> t
87   (** Convert an ocaml Boolean value to a formula *)
88
89   val eval : P.ctx -> t -> bool
90     (** Evaluate a formula given a context for atomic predicates *)
91 end