File: edosSolver.mli

package info (click to toggle)
dose3 3.3~beta1-3
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 1,936 kB
  • ctags: 2,055
  • sloc: ml: 12,421; ansic: 433; makefile: 332; python: 164; perl: 139; sh: 43
file content (108 lines) | stat: -rw-r--r-- 4,211 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
(***************************************************************************************)
(*  Copyright (C) 2005-2009 Jerome Vouillon                                            *)
(*  Minor modifications and documentation :                                            *)
(*       Pietro Abate <pietro.abate@pps.jussieu.fr>                                    *)
(*                                                                                     *)
(*  This library is free software: you can redistribute it and/or modify               *)
(*  it under the terms of the GNU Lesser General Public License as                     *)
(*  published by the Free Software Foundation, either version 3 of the                 *)
(*  License, or (at your option) any later version.  A special linking                 *)
(*  exception to the GNU Lesser General Public License applies to this                 *)
(*  library, see the COPYING file for more information.                                *)
(***************************************************************************************)

(** Edos sat solver *)

(** generic failure reason *)
module type S = sig
  type reason
end

(** Sat solver functor type *)
module type T = sig

  (** generic failure reason *)
  module X : S

  (** state of the solver *)
  type state

  (** variables are integers numbered from 0 to (size - 1) *)
  type var = int

  (** The value of a literal *)
  type value = True | False | Unknown

  (** A literal. Literals can be positive or negative *)
  type lit

  (** [lit_of_var] given a variable create a positive or a negative literal.
      By default the {b assigment} of all variables (that is its value) is
      {b Unknown}. *)
  val lit_of_var : var -> bool -> lit

  (** initialize the solver [initialize_problem n]
     
      @param print_var a function to print a variable 
      @param buffer decide weather or not to store a human readable
      representaion of the sat problem.
      @param n the size of the sat problem. that is the max number of
      variables to consider
  *)
  val initialize_problem :
    ?pbo:int array ->
    ?print_var:(Format.formatter -> int -> unit) -> 
      ?buffer: bool -> int -> state

  (** provide a deep copy of the current state of the solver *)
  val copy : state -> state

  val propagate : state -> unit

  val protect : state -> unit

  (** [reset] reset the state of the solver to a state that would be obtained
      by re initializing the solver with an identical constraints set *)
  val reset : state -> unit

  (** [assignment st] return the array of values associated to every variable.*)
  val assignment : state -> value array

  (** [assignment_true st] return the list of variables that are true *)
  val assignment_true : state -> var list

  (** [add_rule st l] add a disjuction to the solver of type {% \Bigvee l %} *)
  val add_rule : state -> lit array -> X.reason list -> unit

  (** [associate_vars st lit vl] associate a variable to a list of variables. The solver
      will use this information to guide the search heuristic *)
  val associate_vars : state -> lit -> var list -> unit

  val solve_all : (state -> unit) -> state -> var -> bool
  val solve_pbo : (int array * state -> unit) -> state -> var -> bool
  (** [solve st v] finds a variable assignment that makes [v] [True] *)
  val solve : state -> var -> bool

  (** [solve st l] finds a variable assignment that makes [True] all variables in [l]*)
  val solve_lst : state -> var list -> bool

  (** in case of failure return the list of associated reasons *)
  val collect_reasons : state -> var -> X.reason list
  
  (** in case of failure return the list of associated reasons *)
  val collect_reasons_lst : state -> var list -> X.reason list

  (** if the solver was initialized with [buffer = true], 
      dump the state of the solver. Return an empty list otherwise *)
  val dump : state -> (int * bool) list list

  (** enable debug messages *)
  val debug : bool -> unit

  (* print detailed information about the internal status of the solver *)
  val stats : state -> unit
  val pboidx : state -> int -> int -> int
end

(** functor *)
module M : functor (X : S) -> T with module X = X