(*
This file is part of the dpll(t) engine sammy
Copyright (C) 2004  The University of Iowa
George Hagen
Michael Decoster
                                                                                
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.
*)
                                                                                

(** the parser_helper module contains all the helper functions for the [smt_parser.mly]*)

(** should be raised if in a benchset no formula is declared*)
exception No_formula_declared

(** should be raised if a sort is used that wasn't declared*)
exception Sort_symbol_not_declared

(** should be raised if a predicate or function is used with a different number of arguments than declared*)
exception Rank_mismatch

(** should be raised if a predicate or function is used with different sorts for any of its arguments or return type *)
exception Type_mismatch

(** should be raised if a predicate is used that wasn't declared*)
exception Pred_not_declared

(** should be raised if a function is used that wasn't declared*)
exception Function_not_declared

val time_finished_parsing: float ref

(** stores an attribute for a benchmark*)
type bench_attribute =
    ASSUMPTION of Formula.exprtype (** stores a formula that is assumed to be true *)
  | FORMULA of Formula.exprtype (** stores the formula to be checked *)
  | STATUS of string (** Stores the validity if known of the benchmark *)
  | LOGIC of string
  | EXTRASORTS
  | EXTRAFUNS
  | EXTRAPREDS
  | NOTES
  | BENCH_ANNOTATION

(** groups the two types of variables allowed*)
type var_type = 
    BOUND of Global.var_id*Theory_db.sort  (** Stores a bound variable as its id and its sort *)
  | LET of Expressions.ite_wrapper*Theory_db.sort (** stores a term let variable as its equivalent expression and its sort *)

(** provides the interface to the cvcl theory *)
val theory : Theory.theory

(** provides the mechanisms to deal with quantification and cnf conversion*)
val skolemizer : Skolemizer.skolemizer

(** takes a sort id and creates a fresh constant of that sort *)
(** returns new Formula.expression ID *)
(** typeid : id of type of expression to be replaced *)
val define_fresh_unnamed_constant : Global.type_id -> Formula.exprtype

(** compares 2 type ids, allowing ints and reals to be considered of the same type *)
val compare_sorts : Theory_db.sort -> Theory_db.sort -> bool 

(*val bound_var_counter : Counter.set_counter*)

(*val var_table : (string,var_type)Hashtbl.t*)

(** returns the variable corresponding to the specified string.  
If it was added by add_let_var it will be of the LET constructor, 
otherwise if it was added by add_bound_var it will be of the BOUND constructor*)
val get_var : string -> var_type

(** takes in a variable name and its sort, adds it to the variable table and returns the name again*)
val add_bound_var : string -> Theory_db.sort -> string

(** takes in a variable name, its equivalent expression, the sort of that expression, and adds it to the variable table.*)
val add_let_var : string -> Expressions.ite_wrapper -> Theory_db.sort -> unit 

(** removes the specified variable name from the variable table*)
val del_var : string -> unit

(*val flet_table : (string,Formula.exprtype)Hashtbl.t*)

(** takes in a variable name and its equivalent formula expression and adds it to the formula variable table*)
val add_flet_formula : string -> Formula.exprtype -> unit

(** returns the expression associated with the specified varable name from the formula variable table *)
val get_flet_formula : string -> Formula.exprtype

(** removes the specified variable from the formula variable table*)
val remove_flet_formula : string -> unit

val partially_clear_parser_tables : int list -> unit
val clear_parser_tables : unit -> unit
(** Clears the local variable renaming tables. *)

(** quantify_expression binder generate_ids expr
Quantifies expr with binder, and will generate an id for the quantifier if expr has an id or if generate_ids is true.
*)
val quantify_expression : Formula.binder -> bool -> Formula.exprtype -> Formula.exprtype

(** if the expression has a quantifier as its top symbol, that quantifier will be pushed down as far as possible,
otherwise it will return the expression unchanged.*)
val push_down : Formula.exprtype -> Formula.exprtype

val term_db: Term_db.term_db