From e8af74ad7913773c4dfb688167b15b6e15e4397a Mon Sep 17 00:00:00 2001 From: Pierre-Marie Pédrot Date: Tue, 10 Feb 2015 19:50:19 +0100 Subject: Clarifying the implementation of universe hashconsing. --- checker/univ.ml | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) (limited to 'checker') diff --git a/checker/univ.ml b/checker/univ.ml index 5fed6dcd5a..8d0ae8f1e7 100644 --- a/checker/univ.ml +++ b/checker/univ.ml @@ -211,27 +211,26 @@ module Level = struct let hash x = x.hash - let hcons x = - let data' = RawLevel.hcons x.data in - if data' == x.data then x - else { x with data = data' } - let data x = x.data (** Hashcons on levels + their hash *) - let make = - let module Self = struct - type _t = t - type t = _t - let equal = equal - let hash = hash - end in - let module WH = Weak.Make(Self) in - let pool = WH.create 4910 in fun x -> - let x = { hash = RawLevel.hash x; data = x } in - try WH.find pool x - with Not_found -> WH.add pool x; x + module Self = struct + type _t = t + type t = _t + type u = raw_level -> raw_level + let equal x y = x.hash == y.hash && x.data == y.data + let hash x = x.hash + let hashcons hraw x = + let data' = hraw x.data in + if x.data == data' then x else { x with data = data' } + end + + let hcons = + let module H = Hashcons.Make(Self) in + Hashcons.simple_hcons H.generate H.hcons RawLevel.hcons + + let make l = hcons { hash = RawLevel.hash l; data = l } let set = make Set let prop = make Prop -- cgit v1.2.3 From ac65eef8bbc2e405f1964f35c6a129dfa1755888 Mon Sep 17 00:00:00 2001 From: Pierre-Marie Pédrot Date: Wed, 11 Feb 2015 17:06:13 +0100 Subject: Fixing bug #4019, and checker blow-up at once. --- checker/univ.ml | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'checker') diff --git a/checker/univ.ml b/checker/univ.ml index 8d0ae8f1e7..3bcb3bc950 100644 --- a/checker/univ.ml +++ b/checker/univ.ml @@ -174,6 +174,16 @@ struct | _, Level _ -> 1 | Var n, Var m -> Int.compare n m + let hequal x y = + x == y || + match x, y with + | Prop, Prop -> true + | Set, Set -> true + | Level (n,d), Level (n',d') -> + n == n' && d == d' + | Var n, Var n' -> n == n' + | _ -> false + let hcons = function | Prop as x -> x | Set as x -> x @@ -218,17 +228,17 @@ module Level = struct module Self = struct type _t = t type t = _t - type u = raw_level -> raw_level - let equal x y = x.hash == y.hash && x.data == y.data + type u = unit + let equal x y = x.hash == y.hash && RawLevel.hequal x.data y.data let hash x = x.hash - let hashcons hraw x = - let data' = hraw x.data in + let hashcons () x = + let data' = RawLevel.hcons x.data in if x.data == data' then x else { x with data = data' } end let hcons = let module H = Hashcons.Make(Self) in - Hashcons.simple_hcons H.generate H.hcons RawLevel.hcons + Hashcons.simple_hcons H.generate H.hcons () let make l = hcons { hash = RawLevel.hash l; data = l } -- cgit v1.2.3