(*
This file is part of the dpll(t) engine sammy
Copyright (C) 2004  The University of Iowa
Cesare Tinelli
George Hagen

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
*)

(* cstore.mli *)

exception Assert_error
exception Retract_error

(** Constraint store object.  Interface with the theory. *)
class cstore : Pred_db.pred_db ->
object
(*
  method conflict_set : Pred.clause -> (Global.pred_id list)
*)
  (** Returns the conflict set for a clause.  The exact method used
   is determined through a [global.ml] parameter. *)

  (** t_status pred path
  Returns the status of a predicate & when it was set.
  @param pred
  @param path
  @return the current status of the pred
  *)
  method t_status : Pred.pred -> Global.status
  (** Returns the actual (theory-defined) status of the predicate. *) 

  method assert_lit : Pred.lit -> 
                       Global.pred_id list
  (** Asserts a predicate as having the indicated status.
  Side effect: keeps an assertion stack for backtracking purposes and sets
  the implicants of the asserted predicate.
  Returns a list of triples consisting of predicate ids of predicates that
  have been detected as determined due to this assertion (including the
  asserted predicate), their new status, and a boolean indicating whether
  their reasons need to be set. The just-asserted predicate will be
  first in this list. *) 

(*
  method decide_lit : Pred.lit -> Global.pred_id list
  (** As [assert_lit], above, but for decision literals *)
*)

(*
  method assert_unit : Pred.lit -> Pred.clause -> 
                       (Global.pred_id * Global.status * bool) list
*)
  (** Asserts a predicate through BCP.  Given the literal and clause it
  occurs as unit in. 
  Side effect: keeps an assertion stack for backtracking purposes and sets
  the implicants of the asserted predicate.
  Returns a list of triples consisting of predicate ids of predicates that
  have been detected as determined due to this assertion (including the
  asserted predicate), their new status, and a boolean indicating whether
  their reasons need to be set. The just-asserted predicate will be
  first in this list. *) 


  method backtrack : State.state -> unit
  (** Backtracks the cstore to the given state *)

  method theory : Theory.theory
  (** accessor for the actual theory *)

  method print_stats : unit
  (** prints out various statistics for this cstore *)
(*
  method set_theory_implicants : Pred.pred -> Global.status -> unit
*)
  (** Sets theory-derived implicants for a pred (if any). *)
(*
  method augment_theory_implicants : Pred.pred -> Global.status -> 
    Pred.clause -> unit
*)
  (** [augment_theory_implicants p s c] 
   augments the theory implements of [p] ([p] must be theory-interpreted) 
   with elememts from the clause [c] *)

  method implicants : Global.pred_id -> Global.pred_id list

  method increment_activity : Global.pred_id -> unit
  (** Increments a literal's activity score (used during initial parsing) *)

(*
  method reduce_assert : Pred.lit -> unit
*)
  (** Asserts a literal as an axiom.  This method does not allow backtracking.
  It should only be called in a preprocessing step, before and of the
  above assertions.
  Side effect: sets the implicants of the asserted predicate (to null).
  Raises [Theory.Incons] if it detects a conflict.
  *) 

  method unregister_pred : Pred.pred -> unit
  (** Clears the predicate from the theory (if possible) *)
(*
  method get_state : Global.pred_id -> State.state
  (** Returns the state of a predicate, based on its id. *)
*)
  method next_id : Global.pred_id
  (** Returns a fresh identifier. *)

end
