Skip to content

Commit 5b412e9

Browse files
committed
Merge branch 'v8.5'
2 parents d670c6b + dc36fd7 commit 5b412e9

File tree

19 files changed

+183
-89
lines changed

19 files changed

+183
-89
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: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -744,12 +744,10 @@ let hasheq t1 t2 =
744744
n1 == n2 && b1 == b2 && t1 == t2 && c1 == c2
745745
| App (c1,l1), App (c2,l2) -> c1 == c2 && array_eqeq l1 l2
746746
| Proj (p1,c1), Proj(p2,c2) -> p1 == p2 && c1 == c2
747-
| Evar (e1,l1), Evar (e2,l2) -> Evar.equal e1 e2 && array_eqeq l1 l2
747+
| Evar (e1,l1), Evar (e2,l2) -> e1 == e2 && array_eqeq l1 l2
748748
| Const (c1,u1), Const (c2,u2) -> c1 == c2 && u1 == u2
749-
| Ind ((sp1,i1),u1), Ind ((sp2,i2),u2) ->
750-
sp1 == sp2 && Int.equal i1 i2 && u1 == u2
751-
| Construct (((sp1,i1),j1),u1), Construct (((sp2,i2),j2),u2) ->
752-
sp1 == sp2 && Int.equal i1 i2 && Int.equal j1 j2 && u1 == u2
749+
| Ind (ind1,u1), Ind (ind2,u2) -> ind1 == ind2 && u1 == u2
750+
| Construct (cstr1,u1), Construct (cstr2,u2) -> cstr1 == cstr2 && u1 == u2
753751
| Case (ci1,p1,c1,bl1), Case (ci2,p2,c2,bl2) ->
754752
ci1 == ci2 && p1 == p2 && c1 == c2 && array_eqeq bl1 bl2
755753
| Fix ((ln1, i1),(lna1,tl1,bl1)), Fix ((ln2, i2),(lna2,tl2,bl2)) ->
@@ -769,10 +767,10 @@ let hasheq t1 t2 =
769767
once and for all the table we'll use for hash-consing all constr *)
770768

771769
module HashsetTerm =
772-
Hashset.Make(struct type t = constr let equal = hasheq end)
770+
Hashset.Make(struct type t = constr let eq = hasheq end)
773771

774772
module HashsetTermArray =
775-
Hashset.Make(struct type t = constr array let equal = array_eqeq end)
773+
Hashset.Make(struct type t = constr array let eq = array_eqeq end)
776774

777775
let term_table = HashsetTerm.create 19991
778776
(* The associative table to hashcons terms. *)
@@ -827,19 +825,19 @@ let hashcons (sh_sort,sh_ci,sh_construct,sh_ind,sh_con,sh_na,sh_id) =
827825
| Proj (p,c) ->
828826
let c, hc = sh_rec c in
829827
let p' = Projection.hcons p in
830-
(Proj (p', c), combinesmall 17 (combine (Projection.hash p') hc))
828+
(Proj (p', c), combinesmall 17 (combine (Projection.SyntacticOrd.hash p') hc))
831829
| Const (c,u) ->
832830
let c' = sh_con c in
833831
let u', hu = sh_instance u in
834-
(Const (c', u'), combinesmall 9 (combine (Constant.hash c) hu))
835-
| Ind ((kn,i) as ind,u) ->
832+
(Const (c', u'), combinesmall 9 (combine (Constant.SyntacticOrd.hash c) hu))
833+
| Ind (ind,u) ->
836834
let u', hu = sh_instance u in
837835
(Ind (sh_ind ind, u'),
838-
combinesmall 10 (combine (ind_hash ind) hu))
839-
| Construct ((((kn,i),j) as c,u))->
836+
combinesmall 10 (combine (ind_syntactic_hash ind) hu))
837+
| Construct (c,u) ->
840838
let u', hu = sh_instance u in
841839
(Construct (sh_construct c, u'),
842-
combinesmall 11 (combine (constructor_hash c) hu))
840+
combinesmall 11 (combine (constructor_syntactic_hash c) hu))
843841
| Case (ci,p,c,bl) ->
844842
let p, hp = sh_rec p
845843
and c, hc = sh_rec c in
@@ -942,7 +940,7 @@ struct
942940
List.equal (==) info1.ind_tags info2.ind_tags &&
943941
Array.equal (List.equal (==)) info1.cstr_tags info2.cstr_tags &&
944942
info1.style == info2.style
945-
let equal ci ci' =
943+
let eq ci ci' =
946944
ci.ci_ind == ci'.ci_ind &&
947945
Int.equal ci.ci_npar ci'.ci_npar &&
948946
Array.equal Int.equal ci.ci_cstr_ndecls ci'.ci_cstr_ndecls && (* we use [Array.equal] on purpose *)
@@ -984,7 +982,7 @@ module Hsorts =
984982
let hashcons huniv = function
985983
Prop c -> Prop c
986984
| Type u -> Type (huniv u)
987-
let equal s1 s2 =
985+
let eq s1 s2 =
988986
s1 == s2 ||
989987
match (s1,s2) with
990988
(Prop c1, Prop c2) -> c1 == c2

kernel/cooking.ml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,15 @@ module RefHash =
4444
struct
4545
type t = my_global_reference
4646
let equal gr1 gr2 = match gr1, gr2 with
47-
| ConstRef c1, ConstRef c2 -> Constant.CanOrd.equal c1 c2
48-
| IndRef i1, IndRef i2 -> eq_ind i1 i2
49-
| ConstructRef c1, ConstructRef c2 -> eq_constructor c1 c2
47+
| ConstRef c1, ConstRef c2 -> Constant.SyntacticOrd.equal c1 c2
48+
| IndRef i1, IndRef i2 -> eq_syntactic_ind i1 i2
49+
| ConstructRef c1, ConstructRef c2 -> eq_syntactic_constructor c1 c2
5050
| _ -> false
5151
open Hashset.Combine
5252
let hash = function
53-
| ConstRef c -> combinesmall 1 (Constant.hash c)
54-
| IndRef i -> combinesmall 2 (ind_hash i)
55-
| ConstructRef c -> combinesmall 3 (constructor_hash c)
53+
| ConstRef c -> combinesmall 1 (Constant.SyntacticOrd.hash c)
54+
| IndRef i -> combinesmall 2 (ind_syntactic_hash i)
55+
| ConstructRef c -> combinesmall 3 (constructor_syntactic_hash c)
5656
end
5757

5858
module RefTable = Hashtbl.Make(RefHash)

kernel/names.ml

Lines changed: 49 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ struct
111111
let hashcons hident = function
112112
| Name id -> Name (hident id)
113113
| n -> n
114-
let equal n1 n2 =
114+
let eq n1 n2 =
115115
n1 == n2 ||
116116
match (n1,n2) with
117117
| (Name id1, Name id2) -> id1 == id2
@@ -245,7 +245,7 @@ struct
245245
type t = _t
246246
type u = (Id.t -> Id.t) * (DirPath.t -> DirPath.t)
247247
let hashcons (hid,hdir) (n,s,dir) = (n,hid s,hdir dir)
248-
let equal ((n1,s1,dir1) as x) ((n2,s2,dir2) as y) =
248+
let eq ((n1,s1,dir1) as x) ((n2,s2,dir2) as y) =
249249
(x == y) ||
250250
(Int.equal n1 n2 && s1 == s2 && dir1 == dir2)
251251
let hash = hash
@@ -341,7 +341,7 @@ module ModPath = struct
341341
| MPfile dir -> MPfile (hdir dir)
342342
| MPbound m -> MPbound (huniqid m)
343343
| MPdot (md,l) -> MPdot (hashcons hfuns md, hstr l)
344-
let rec equal d1 d2 =
344+
let rec eq d1 d2 =
345345
d1 == d2 ||
346346
match d1,d2 with
347347
| MPfile dir1, MPfile dir2 -> dir1 == dir2
@@ -441,7 +441,7 @@ module KerName = struct
441441
let hashcons (hmod,hdir,hstr) kn =
442442
let { modpath = mp; dirpath = dp; knlabel = l; refhash; } = kn in
443443
{ modpath = hmod mp; dirpath = hdir dp; knlabel = hstr l; refhash; canary; }
444-
let equal kn1 kn2 =
444+
let eq kn1 kn2 =
445445
kn1.modpath == kn2.modpath && kn1.dirpath == kn2.dirpath &&
446446
kn1.knlabel == kn2.knlabel
447447
let hash = hash
@@ -495,7 +495,7 @@ module KerPair = struct
495495
| Dual (kn,_) -> kn
496496

497497
let same kn = Same kn
498-
let make knu knc = if knu == knc then Same knc else Dual (knu,knc)
498+
let make knu knc = if KerName.equal knu knc then Same knc else Dual (knu,knc)
499499

500500
let make1 = same
501501
let make2 mp l = same (KerName.make2 mp l)
@@ -542,6 +542,23 @@ module KerPair = struct
542542
let hash x = KerName.hash (canonical x)
543543
end
544544

545+
module SyntacticOrd = struct
546+
type t = kernel_pair
547+
let compare x y = match x, y with
548+
| Same knx, Same kny -> KerName.compare knx kny
549+
| Dual (knux,kncx), Dual (knuy,kncy) ->
550+
let c = KerName.compare knux knuy in
551+
if not (Int.equal c 0) then c
552+
else KerName.compare kncx kncy
553+
| Same _, _ -> -1
554+
| Dual _, _ -> 1
555+
let equal x y = x == y || compare x y = 0
556+
let hash = function
557+
| Same kn -> KerName.hash kn
558+
| Dual (knu, knc) ->
559+
Hashset.Combine.combine (KerName.hash knu) (KerName.hash knc)
560+
end
561+
545562
(** Default (logical) comparison and hash is on the canonical part *)
546563
let equal = CanOrd.equal
547564
let hash = CanOrd.hash
@@ -553,7 +570,7 @@ module KerPair = struct
553570
let hashcons hkn = function
554571
| Same kn -> Same (hkn kn)
555572
| Dual (knu,knc) -> make (hkn knu) (hkn knc)
556-
let equal x y = (* physical comparison on subterms *)
573+
let eq x y = (* physical comparison on subterms *)
557574
x == y ||
558575
match x,y with
559576
| Same x, Same y -> x == y
@@ -613,34 +630,48 @@ let index_of_constructor (ind, i) = i
613630
let eq_ind (m1, i1) (m2, i2) = Int.equal i1 i2 && MutInd.equal m1 m2
614631
let eq_user_ind (m1, i1) (m2, i2) =
615632
Int.equal i1 i2 && MutInd.UserOrd.equal m1 m2
633+
let eq_syntactic_ind (m1, i1) (m2, i2) =
634+
Int.equal i1 i2 && MutInd.SyntacticOrd.equal m1 m2
616635

617636
let ind_ord (m1, i1) (m2, i2) =
618637
let c = Int.compare i1 i2 in
619638
if Int.equal c 0 then MutInd.CanOrd.compare m1 m2 else c
620639
let ind_user_ord (m1, i1) (m2, i2) =
621640
let c = Int.compare i1 i2 in
622641
if Int.equal c 0 then MutInd.UserOrd.compare m1 m2 else c
642+
let ind_syntactic_ord (m1, i1) (m2, i2) =
643+
let c = Int.compare i1 i2 in
644+
if Int.equal c 0 then MutInd.SyntacticOrd.compare m1 m2 else c
623645

624646
let ind_hash (m, i) =
625647
Hashset.Combine.combine (MutInd.hash m) (Int.hash i)
626648
let ind_user_hash (m, i) =
627649
Hashset.Combine.combine (MutInd.UserOrd.hash m) (Int.hash i)
650+
let ind_syntactic_hash (m, i) =
651+
Hashset.Combine.combine (MutInd.SyntacticOrd.hash m) (Int.hash i)
628652

629653
let eq_constructor (ind1, j1) (ind2, j2) = Int.equal j1 j2 && eq_ind ind1 ind2
630654
let eq_user_constructor (ind1, j1) (ind2, j2) =
631655
Int.equal j1 j2 && eq_user_ind ind1 ind2
656+
let eq_syntactic_constructor (ind1, j1) (ind2, j2) =
657+
Int.equal j1 j2 && eq_syntactic_ind ind1 ind2
632658

633659
let constructor_ord (ind1, j1) (ind2, j2) =
634660
let c = Int.compare j1 j2 in
635661
if Int.equal c 0 then ind_ord ind1 ind2 else c
636662
let constructor_user_ord (ind1, j1) (ind2, j2) =
637663
let c = Int.compare j1 j2 in
638664
if Int.equal c 0 then ind_user_ord ind1 ind2 else c
665+
let constructor_syntactic_ord (ind1, j1) (ind2, j2) =
666+
let c = Int.compare j1 j2 in
667+
if Int.equal c 0 then ind_syntactic_ord ind1 ind2 else c
639668

640669
let constructor_hash (ind, i) =
641670
Hashset.Combine.combine (ind_hash ind) (Int.hash i)
642671
let constructor_user_hash (ind, i) =
643672
Hashset.Combine.combine (ind_user_hash ind) (Int.hash i)
673+
let constructor_syntactic_hash (ind, i) =
674+
Hashset.Combine.combine (ind_syntactic_hash ind) (Int.hash i)
644675

645676
module InductiveOrdered = struct
646677
type t = inductive
@@ -685,7 +716,7 @@ module Hind = Hashcons.Make(
685716
type t = inductive
686717
type u = MutInd.t -> MutInd.t
687718
let hashcons hmind (mind, i) = (hmind mind, i)
688-
let equal (mind1,i1) (mind2,i2) = mind1 == mind2 && Int.equal i1 i2
719+
let eq (mind1,i1) (mind2,i2) = mind1 == mind2 && Int.equal i1 i2
689720
let hash = ind_hash
690721
end)
691722

@@ -694,7 +725,7 @@ module Hconstruct = Hashcons.Make(
694725
type t = constructor
695726
type u = inductive -> inductive
696727
let hashcons hind (ind, j) = (hind ind, j)
697-
let equal (ind1, j1) (ind2, j2) = ind1 == ind2 && Int.equal j1 j2
728+
let eq (ind1, j1) (ind2, j2) = ind1 == ind2 && Int.equal j1 j2
698729
let hash = constructor_hash
699730
end)
700731

@@ -828,13 +859,22 @@ struct
828859

829860
let hash (c, b) = (if b then 0 else 1) + Constant.hash c
830861

862+
module SyntacticOrd = struct
863+
type t = constant * bool
864+
let compare (c, b) (c', b') =
865+
if b = b' then Constant.SyntacticOrd.compare c c' else -1
866+
let equal (c, b as x) (c', b' as x') =
867+
x == x' || b = b' && Constant.SyntacticOrd.equal c c'
868+
let hash (c, b) = (if b then 0 else 1) + Constant.SyntacticOrd.hash c
869+
end
870+
831871
module Self_Hashcons =
832872
struct
833873
type _t = t
834874
type t = _t
835875
type u = Constant.t -> Constant.t
836876
let hashcons hc (c,b) = (hc c,b)
837-
let equal ((c,b) as x) ((c',b') as y) =
877+
let eq ((c,b) as x) ((c',b') as y) =
838878
x == y || (c == c' && b == b')
839879
let hash = hash
840880
end

kernel/names.mli

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,12 @@ sig
325325
val hash : t -> int
326326
end
327327

328+
module SyntacticOrd : sig
329+
val compare : t -> t -> int
330+
val equal : t -> t -> bool
331+
val hash : t -> int
332+
end
333+
328334
val equal : t -> t -> bool
329335
(** Default comparison, alias for [CanOrd.equal] *)
330336

@@ -399,6 +405,12 @@ sig
399405
val hash : t -> int
400406
end
401407

408+
module SyntacticOrd : sig
409+
val compare : t -> t -> int
410+
val equal : t -> t -> bool
411+
val hash : t -> int
412+
end
413+
402414
val equal : t -> t -> bool
403415
(** Default comparison, alias for [CanOrd.equal] *)
404416

@@ -442,16 +454,22 @@ val inductive_of_constructor : constructor -> inductive
442454
val index_of_constructor : constructor -> int
443455
val eq_ind : inductive -> inductive -> bool
444456
val eq_user_ind : inductive -> inductive -> bool
457+
val eq_syntactic_ind : inductive -> inductive -> bool
445458
val ind_ord : inductive -> inductive -> int
446459
val ind_hash : inductive -> int
447460
val ind_user_ord : inductive -> inductive -> int
448461
val ind_user_hash : inductive -> int
462+
val ind_syntactic_ord : inductive -> inductive -> int
463+
val ind_syntactic_hash : inductive -> int
449464
val eq_constructor : constructor -> constructor -> bool
450465
val eq_user_constructor : constructor -> constructor -> bool
466+
val eq_syntactic_constructor : constructor -> constructor -> bool
451467
val constructor_ord : constructor -> constructor -> int
452-
val constructor_user_ord : constructor -> constructor -> int
453468
val constructor_hash : constructor -> int
469+
val constructor_user_ord : constructor -> constructor -> int
454470
val constructor_user_hash : constructor -> int
471+
val constructor_syntactic_ord : constructor -> constructor -> int
472+
val constructor_syntactic_hash : constructor -> int
455473

456474
(** Better to have it here that in Closure, since required in grammar.cma *)
457475
type evaluable_global_reference =
@@ -665,6 +683,12 @@ module Projection : sig
665683

666684
val make : constant -> bool -> t
667685

686+
module SyntacticOrd : sig
687+
val compare : t -> t -> int
688+
val equal : t -> t -> bool
689+
val hash : t -> int
690+
end
691+
668692
val constant : t -> constant
669693
val unfolded : t -> bool
670694
val unfold : t -> t

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

0 commit comments

Comments
 (0)