]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/software/components/ng_paramodulation/terms.ml
Branched paramodulation for CNF (Horn clauses)
[helm.git] / helm / software / components / ng_paramodulation / terms.ml
index 91ca56271404a9e9ccb2cd9df6ee37fa99e8a81b..db4c8cad6bce2680f9b98f538373cb8a9c274d5d 100644 (file)
@@ -18,14 +18,14 @@ type 'a foterm =
 
 type 'a substitution = (int * 'a foterm) list
 
-type comparison = Lt | Le | Eq | Ge | Gt | Incomparable
+type comparison = Lt | Eq | Gt | Incomparable
 
-type rule = SuperpositionRight | SuperpositionLeft | Demodulation
+type rule = Superposition | Demodulation
 type direction = Left2Right | Right2Left | Nodir
 type position = int list
 
 type 'a proof =
-  | Exact of 'a
+  | Exact of 'a foterm
   | Step of rule * int * int * direction * position * 'a substitution
          (* rule, eq1, eq2, direction of eq2, position, substitution *)
 
@@ -44,8 +44,23 @@ type 'a unit_clause =
  * varlist       (* variable list *)
  * 'a proof      (* proof *)
 
-type 'a passive_clause = int * 'a unit_clause (* weight * equation *)
+type 'a clause =
+    int
+    * 'a literal list (* left hand side of the arrow *)
+    * 'a literal list (* right hand side of the arrow *)
+    * varlist
+    * 'a proof
 
+type 'a passive_clause = int * 'a clause (* weight * equation *)
+
+
+let vars_of_term ?(start_acc=[]) t =
+  let rec aux acc = function
+    | Leaf _ -> acc
+    | Var i -> if (List.mem i acc) then acc else i::acc
+    | Node l -> List.fold_left aux acc l
+  in aux start_acc t
+;;
 
 module OT =
  struct
@@ -56,4 +71,36 @@ module OT =
 module M : Map.S with type key = int 
   = Map.Make(OT) 
 
-type 'a bag = 'a unit_clause M.t
+type 'a bag = int
+              * (('a unit_clause * bool * int) M.t)
+
+  let add_to_bag (_,lit,vl,proof) (id,bag) =
+    let id = id+1 in
+    let clause = (id, lit, vl, proof) in
+    let bag = M.add id (clause,false,0) bag in
+    (id,bag), clause 
+   ;;
+
+  let replace_in_bag ((id,_,_,_),_,_ as cl) (max_id,bag) =
+    let bag = M.add id cl bag in
+      (max_id,bag)
+  ;;
+
+  let get_from_bag id (_,bag) =
+    M.find id bag
+  ;;
+    
+  let empty_bag = (0,M.empty);;
+
+module type Blob =
+  sig
+    type t
+    val eq : t -> t -> bool
+    val compare : t -> t -> int
+    val eqP : t
+    val pp : t -> string
+    type input
+    val embed : input -> t foterm
+    val saturate : input -> input -> t foterm * t foterm
+  end
+