Skip to content

Commit 2e55758

Browse files
committed
A patch renaming equal into eq in the module dealing with
hash-consing, so as to avoid having too many kinds of equalities with same name.
1 parent 920f154 commit 2e55758

File tree

10 files changed

+47
-47
lines changed

10 files changed

+47
-47
lines changed

checker/univ.ml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ module type Hashconsed =
3333
sig
3434
type t
3535
val hash : t -> int
36-
val equal : t -> t -> bool
36+
val eq : t -> t -> bool
3737
val hcons : t -> t
3838
end
3939

@@ -51,7 +51,7 @@ struct
5151
type t = _t
5252
type u = (M.t -> M.t)
5353
let hash = function Nil -> 0 | Cons (_, h, _) -> h
54-
let equal l1 l2 = match l1, l2 with
54+
let eq l1 l2 = match l1, l2 with
5555
| Nil, Nil -> true
5656
| Cons (x1, _, l1), Cons (x2, _, l2) -> x1 == x2 && l1 == l2
5757
| _ -> false
@@ -131,7 +131,7 @@ module HList = struct
131131
let rec remove x = function
132132
| Nil -> nil
133133
| Cons (y, _, l) ->
134-
if H.equal x y then l
134+
if H.eq x y then l
135135
else cons y (remove x l)
136136

137137
end
@@ -229,7 +229,7 @@ module Level = struct
229229
type _t = t
230230
type t = _t
231231
type u = unit
232-
let equal x y = x.hash == y.hash && RawLevel.hequal x.data y.data
232+
let eq x y = x.hash == y.hash && RawLevel.hequal x.data y.data
233233
let hash x = x.hash
234234
let hashcons () x =
235235
let data' = RawLevel.hcons x.data in
@@ -320,7 +320,7 @@ struct
320320
let hashcons hdir (b,n as x) =
321321
let b' = hdir b in
322322
if b' == b then x else (b',n)
323-
let equal l1 l2 =
323+
let eq l1 l2 =
324324
l1 == l2 ||
325325
match l1,l2 with
326326
| (b,n), (b',n') -> b == b' && n == n'
@@ -339,7 +339,7 @@ struct
339339
let hcons =
340340
Hashcons.simple_hcons H.generate H.hcons Level.hcons
341341
let hash = ExprHash.hash
342-
let equal x y = x == y ||
342+
let eq x y = x == y ||
343343
(let (u,n) = x and (v,n') = y in
344344
Int.equal n n' && Level.equal u v)
345345

@@ -1089,7 +1089,7 @@ struct
10891089
a
10901090
end
10911091

1092-
let equal t1 t2 =
1092+
let eq t1 t2 =
10931093
t1 == t2 ||
10941094
(Int.equal (Array.length t1) (Array.length t2) &&
10951095
let rec aux i =

kernel/constr.ml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -755,10 +755,10 @@ let hasheq t1 t2 =
755755
once and for all the table we'll use for hash-consing all constr *)
756756

757757
module HashsetTerm =
758-
Hashset.Make(struct type t = constr let equal = hasheq end)
758+
Hashset.Make(struct type t = constr let eq = hasheq end)
759759

760760
module HashsetTermArray =
761-
Hashset.Make(struct type t = constr array let equal = array_eqeq end)
761+
Hashset.Make(struct type t = constr array let eq = array_eqeq end)
762762

763763
let term_table = HashsetTerm.create 19991
764764
(* The associative table to hashcons terms. *)
@@ -928,7 +928,7 @@ struct
928928
List.equal (==) info1.ind_tags info2.ind_tags &&
929929
Array.equal (List.equal (==)) info1.cstr_tags info2.cstr_tags &&
930930
info1.style == info2.style
931-
let equal ci ci' =
931+
let eq ci ci' =
932932
ci.ci_ind == ci'.ci_ind &&
933933
Int.equal ci.ci_npar ci'.ci_npar &&
934934
Array.equal Int.equal ci.ci_cstr_ndecls ci'.ci_cstr_ndecls && (* we use [Array.equal] on purpose *)
@@ -970,7 +970,7 @@ module Hsorts =
970970
let hashcons huniv = function
971971
Prop c -> Prop c
972972
| Type u -> Type (huniv u)
973-
let equal s1 s2 =
973+
let eq s1 s2 =
974974
s1 == s2 ||
975975
match (s1,s2) with
976976
(Prop c1, Prop c2) -> c1 == c2

kernel/names.ml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ struct
102102
let hashcons hident = function
103103
| Name id -> Name (hident id)
104104
| n -> n
105-
let equal n1 n2 =
105+
let eq n1 n2 =
106106
n1 == n2 ||
107107
match (n1,n2) with
108108
| (Name id1, Name id2) -> id1 == id2
@@ -236,7 +236,7 @@ struct
236236
type t = _t
237237
type u = (Id.t -> Id.t) * (DirPath.t -> DirPath.t)
238238
let hashcons (hid,hdir) (n,s,dir) = (n,hid s,hdir dir)
239-
let equal ((n1,s1,dir1) as x) ((n2,s2,dir2) as y) =
239+
let eq ((n1,s1,dir1) as x) ((n2,s2,dir2) as y) =
240240
(x == y) ||
241241
(Int.equal n1 n2 && s1 == s2 && dir1 == dir2)
242242
let hash = hash
@@ -327,7 +327,7 @@ module ModPath = struct
327327
| MPfile dir -> MPfile (hdir dir)
328328
| MPbound m -> MPbound (huniqid m)
329329
| MPdot (md,l) -> MPdot (hashcons hfuns md, hstr l)
330-
let rec equal d1 d2 =
330+
let rec eq d1 d2 =
331331
d1 == d2 ||
332332
match d1,d2 with
333333
| MPfile dir1, MPfile dir2 -> dir1 == dir2
@@ -423,7 +423,7 @@ module KerName = struct
423423
let hashcons (hmod,hdir,hstr) kn =
424424
let { modpath = mp; dirpath = dp; knlabel = l; refhash; } = kn in
425425
{ modpath = hmod mp; dirpath = hdir dp; knlabel = hstr l; refhash; canary; }
426-
let equal kn1 kn2 =
426+
let eq kn1 kn2 =
427427
kn1.modpath == kn2.modpath && kn1.dirpath == kn2.dirpath &&
428428
kn1.knlabel == kn2.knlabel
429429
let hash = hash
@@ -552,7 +552,7 @@ module KerPair = struct
552552
let hashcons hkn = function
553553
| Same kn -> Same (hkn kn)
554554
| Dual (knu,knc) -> make (hkn knu) (hkn knc)
555-
let equal x y = (* physical comparison on subterms *)
555+
let eq x y = (* physical comparison on subterms *)
556556
x == y ||
557557
match x,y with
558558
| Same x, Same y -> x == y
@@ -693,7 +693,7 @@ module Hind = Hashcons.Make(
693693
type t = inductive
694694
type u = MutInd.t -> MutInd.t
695695
let hashcons hmind (mind, i) = (hmind mind, i)
696-
let equal (mind1,i1) (mind2,i2) = mind1 == mind2 && Int.equal i1 i2
696+
let eq (mind1,i1) (mind2,i2) = mind1 == mind2 && Int.equal i1 i2
697697
let hash = ind_hash
698698
end)
699699

@@ -702,7 +702,7 @@ module Hconstruct = Hashcons.Make(
702702
type t = constructor
703703
type u = inductive -> inductive
704704
let hashcons hind (ind, j) = (hind ind, j)
705-
let equal (ind1, j1) (ind2, j2) = ind1 == ind2 && Int.equal j1 j2
705+
let eq (ind1, j1) (ind2, j2) = ind1 == ind2 && Int.equal j1 j2
706706
let hash = constructor_hash
707707
end)
708708

@@ -851,7 +851,7 @@ struct
851851
type t = _t
852852
type u = Constant.t -> Constant.t
853853
let hashcons hc (c,b) = (hc c,b)
854-
let equal ((c,b) as x) ((c',b') as y) =
854+
let eq ((c,b) as x) ((c',b') as y) =
855855
x == y || (c == c' && b == b')
856856
let hash = hash
857857
end

kernel/sorts.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ module Hsorts =
9898
let u' = huniv u in
9999
if u' == u then c else Type u'
100100
| s -> s
101-
let equal s1 s2 = match (s1,s2) with
101+
let eq s1 s2 = match (s1,s2) with
102102
| (Prop c1, Prop c2) -> c1 == c2
103103
| (Type u1, Type u2) -> u1 == u2
104104
|_ -> false

kernel/univ.ml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ module type Hashconsed =
3535
sig
3636
type t
3737
val hash : t -> int
38-
val equal : t -> t -> bool
38+
val eq : t -> t -> bool
3939
val hcons : t -> t
4040
end
4141

@@ -53,7 +53,7 @@ struct
5353
type t = _t
5454
type u = (M.t -> M.t)
5555
let hash = function Nil -> 0 | Cons (_, h, _) -> h
56-
let equal l1 l2 = match l1, l2 with
56+
let eq l1 l2 = match l1, l2 with
5757
| Nil, Nil -> true
5858
| Cons (x1, _, l1), Cons (x2, _, l2) -> x1 == x2 && l1 == l2
5959
| _ -> false
@@ -135,12 +135,12 @@ module HList = struct
135135
let rec remove x = function
136136
| Nil -> nil
137137
| Cons (y, _, l) ->
138-
if H.equal x y then l
138+
if H.eq x y then l
139139
else cons y (remove x l)
140140

141141
let rec mem x = function
142142
| Nil -> false
143-
| Cons (y, _, l) -> H.equal x y || mem x l
143+
| Cons (y, _, l) -> H.eq x y || mem x l
144144

145145
let rec compare cmp l1 l2 = match l1, l2 with
146146
| Nil, Nil -> 0
@@ -251,7 +251,7 @@ module Level = struct
251251
type _t = t
252252
type t = _t
253253
type u = unit
254-
let equal x y = x.hash == y.hash && RawLevel.hequal x.data y.data
254+
let eq x y = x.hash == y.hash && RawLevel.hequal x.data y.data
255255
let hash x = x.hash
256256
let hashcons () x =
257257
let data' = RawLevel.hcons x.data in
@@ -400,7 +400,7 @@ struct
400400
let hashcons hdir (b,n as x) =
401401
let b' = hdir b in
402402
if b' == b then x else (b',n)
403-
let equal l1 l2 =
403+
let eq l1 l2 =
404404
l1 == l2 ||
405405
match l1,l2 with
406406
| (b,n), (b',n') -> b == b' && n == n'
@@ -419,7 +419,7 @@ struct
419419
let hcons =
420420
Hashcons.simple_hcons H.generate H.hcons Level.hcons
421421
let hash = ExprHash.hash
422-
let equal x y = x == y ||
422+
let eq x y = x == y ||
423423
(let (u,n) = x and (v,n') = y in
424424
Int.equal n n' && Level.equal u v)
425425

@@ -1287,7 +1287,7 @@ module Hconstraint =
12871287
type t = univ_constraint
12881288
type u = universe_level -> universe_level
12891289
let hashcons hul (l1,k,l2) = (hul l1, k, hul l2)
1290-
let equal (l1,k,l2) (l1',k',l2') =
1290+
let eq (l1,k,l2) (l1',k',l2') =
12911291
l1 == l1' && k == k' && l2 == l2'
12921292
let hash = Hashtbl.hash
12931293
end)
@@ -1299,7 +1299,7 @@ module Hconstraints =
12991299
type u = univ_constraint -> univ_constraint
13001300
let hashcons huc s =
13011301
Constraint.fold (fun x -> Constraint.add (huc x)) s Constraint.empty
1302-
let equal s s' =
1302+
let eq s s' =
13031303
List.for_all2eq (==)
13041304
(Constraint.elements s)
13051305
(Constraint.elements s')
@@ -1671,7 +1671,7 @@ struct
16711671
a
16721672
end
16731673

1674-
let equal t1 t2 =
1674+
let eq t1 t2 =
16751675
t1 == t2 ||
16761676
(Int.equal (Array.length t1) (Array.length t2) &&
16771677
let rec aux i =
@@ -2046,7 +2046,7 @@ module Huniverse_set =
20462046
type u = universe_level -> universe_level
20472047
let hashcons huc s =
20482048
LSet.fold (fun x -> LSet.add (huc x)) s LSet.empty
2049-
let equal s s' =
2049+
let eq s s' =
20502050
LSet.equal s s'
20512051
let hash = Hashtbl.hash
20522052
end)

lib/cSet.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ struct
5757
open Hashset.Combine
5858
type t = set
5959
type u = M.t -> M.t
60-
let equal s1 s2 = s1 == s2 || eqeq (spine s1 []) (spine s2 [])
60+
let eq s1 s2 = s1 == s2 || eqeq (spine s1 []) (spine s2 [])
6161
let hash s = Set.fold (fun v accu -> combine (H.hash v) accu) s 0
6262
let hashcons = umap
6363
end

lib/hashcons.ml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* of objects of type t (u usually has the form (t1->t1)*(t2->t2)*...).
1616
* [hashcons u x] is a function that hash-cons the sub-structures of x using
1717
* the hash-consing functions u provides.
18-
* [equal] is a comparison function. It is allowed to use physical equality
18+
* [eq] is a comparison function. It is allowed to use physical equality
1919
* on the sub-terms hash-consed by the hashcons function.
2020
* [hash] is the hash function given to the Hashtbl.Make function
2121
*
@@ -27,7 +27,7 @@ module type HashconsedType =
2727
type t
2828
type u
2929
val hashcons : u -> t -> t
30-
val equal : t -> t -> bool
30+
val eq : t -> t -> bool
3131
val hash : t -> int
3232
end
3333

@@ -53,7 +53,7 @@ module Make (X : HashconsedType) : (S with type t = X.t and type u = X.u) =
5353

5454
(* We create the type of hashtables for t, with our comparison fun.
5555
* An invariant is that the table never contains two entries equals
56-
* w.r.t (=), although the equality on keys is X.equal. This is
56+
* w.r.t (=), although the equality on keys is X.eq. This is
5757
* granted since we hcons the subterms before looking up in the table.
5858
*)
5959
module Htbl = Hashset.Make(X)
@@ -124,7 +124,7 @@ module Hlist (D:HashedType) =
124124
let hashcons (hrec,hdata) = function
125125
| x :: l -> hdata x :: hrec l
126126
| l -> l
127-
let equal l1 l2 =
127+
let eq l1 l2 =
128128
l1 == l2 ||
129129
match l1, l2 with
130130
| [], [] -> true
@@ -144,7 +144,7 @@ module Hstring = Make(
144144
type t = string
145145
type u = unit
146146
let hashcons () s =(* incr accesstr;*) s
147-
external equal : string -> string -> bool = "caml_string_equal" "noalloc"
147+
external eq : string -> string -> bool = "caml_string_equal" "noalloc"
148148
(** Copy from CString *)
149149
let rec hash len s i accu =
150150
if i = len then accu
@@ -191,7 +191,7 @@ module Hobj = Make(
191191
type t = Obj.t
192192
type u = (Obj.t -> Obj.t) * unit
193193
let hashcons (hrec,_) = hash_obj hrec
194-
let equal = comp_obj
194+
let eq = comp_obj
195195
let hash = Hashtbl.hash
196196
end)
197197

lib/hashcons.mli

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ module type HashconsedType =
1414
sig
1515
(** {6 Generic hashconsing signature}
1616
17-
Given an equivalence relation [equal], a hashconsing function is a
17+
Given an equivalence relation [eq], a hashconsing function is a
1818
function that associates the same canonical element to two elements
19-
related by [equal]. Usually, the element chosen is canonical w.r.t.
19+
related by [eq]. Usually, the element chosen is canonical w.r.t.
2020
physical equality [(==)], so as to reduce memory consumption and
2121
enhance efficiency of equality tests.
2222
@@ -32,15 +32,15 @@ module type HashconsedType =
3232
Usually a tuple of functions. *)
3333
val hashcons : u -> t -> t
3434
(** The actual hashconsing function, using its fist argument to recursively
35-
hashcons substructures. It should be compatible with [equal], that is
36-
[equal x (hashcons f x) = true]. *)
37-
val equal : t -> t -> bool
35+
hashcons substructures. It should be compatible with [eq], that is
36+
[eq x (hashcons f x) = true]. *)
37+
val eq : t -> t -> bool
3838
(** A comparison function. It is allowed to use physical equality
3939
on the sub-terms hashconsed by the [hashcons] function, but it should be
4040
insensible to shallow copy of the compared object. *)
4141
val hash : t -> int
4242
(** A hash function passed to the underlying hashtable structure. [hash]
43-
should be compatible with [equal], i.e. if [equal x y = true] then
43+
should be compatible with [eq], i.e. if [eq x y = true] then
4444
[hash x = hash y]. *)
4545
end
4646

lib/hashset.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
module type EqType = sig
1818
type t
19-
val equal : t -> t -> bool
19+
val eq : t -> t -> bool
2020
end
2121

2222
type statistics = {
@@ -183,7 +183,7 @@ module Make (E : EqType) =
183183
if i >= sz then ifnotfound index
184184
else if h = hashes.(i) then begin
185185
match Weak.get bucket i with
186-
| Some v when E.equal v d -> v
186+
| Some v when E.eq v d -> v
187187
| _ -> loop (i + 1)
188188
end else loop (i + 1)
189189
in

lib/hashset.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
module type EqType = sig
1818
type t
19-
val equal : t -> t -> bool
19+
val eq : t -> t -> bool
2020
end
2121

2222
type statistics = {

0 commit comments

Comments
 (0)