2 ||M|| This file is part of HELM, an Hypertextual, Electronic
3 ||A|| Library of Mathematics, developed at the Computer Science
4 ||T|| Department, University of Bologna, Italy.
6 ||T|| HELM is free software; you can redistribute it and/or
7 ||A|| modify it under the terms of the GNU General Public License
8 \ / version 2 or (at your option) any later version.
9 \ / This software is distributed as is, NO WARRANTY.
10 V_______________________________________________________________ *)
17 | Node of ('a foterm) list
19 type 'a substitution = (int * 'a foterm) list
21 type comparison = Lt | Eq | Gt | Incomparable
23 type rule = SuperpositionRight | SuperpositionLeft | Demodulation
24 type direction = Left2Right | Right2Left | Nodir
25 type position = int list
29 | Step of rule * int * int * direction * position * 'a substitution
30 (* rule, eq1, eq2, direction of eq2, position, substitution *)
33 | Equation of 'a foterm (* lhs *)
35 * 'a foterm (* type *)
36 * comparison (* orientation *)
37 | Predicate of 'a foterm
39 type varlist = int list
44 * varlist (* variable list *)
45 * 'a proof (* proof *)
47 type 'a passive_clause = int * 'a unit_clause (* weight * equation *)
53 let compare = Pervasives.compare
56 module M : Map.S with type key = int
59 type 'a bag = 'a unit_clause M.t
64 val eq : t -> t -> bool
65 val compare : t -> t -> int
69 module Utils (B : Blob) = struct
70 let rec eq_foterm x y =
73 | Leaf t1, Leaf t2 -> B.eq t1 t2
74 | Var i, Var j -> i = j
75 | Node l1, Node l2 -> List.for_all2 eq_foterm l1 l2
79 let rec lexicograph f l1 l2 =
84 if c <> 0 then c else lexicograph f xs ys
89 let rec compare_foterm x y =
91 | Leaf t1, Leaf t2 -> B.compare t1 t2
92 | Var i, Var j -> i - j
93 | Node l1, Node l2 -> lexicograph compare_foterm l1 l2
94 | Leaf _, ( Node _ | Var _ ) -> ~-1
96 | Node _, Var _ -> ~-1
100 let eq_literal l1 l2 =
102 | Predicate p1, Predicate p2 -> eq_foterm p1 p2
103 | Equation (l1,r1,ty1,o1), Equation (l2,r2,ty2,o2) ->
104 o1 = o2 && eq_foterm l1 l2 && eq_foterm r1 r2 && eq_foterm ty1 ty2
108 let compare_literal l1 l2 =
110 | Predicate p1, Predicate p2 -> compare_foterm p1 p2
111 | Equation (l1,r1,ty1,o1), Equation (l2,r2,ty2,o2) ->
112 let c = Pervasives.compare o1 o2 in
113 if c <> 0 then c else
114 let c = compare_foterm l1 l2 in
115 if c <> 0 then c else
116 let c = compare_foterm r1 r2 in
117 if c <> 0 then c else
118 compare_foterm ty1 ty2
119 | Predicate _, Equation _ -> ~-1
120 | Equation _, Predicate _ -> 1
123 let eq_unit_clause (id1,_,_,_) (id2,_,_,_) = id1 = id2
124 let compare_unit_clause (id1,_,_,_) (id2,_,_,_) = Pervasives.compare id1 id2