Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 23 additions & 9 deletions bootstrap/bin/hocc/remergeables.ml
Original file line number Diff line number Diff line change
Expand Up @@ -187,31 +187,45 @@ let distinct spines ({snapshot; _} as t) =
let cores_map = List.fold ~init:snapshot
~f:(fun cores_map ((StateNub.{isocore_set_sn=issn0; _} as statenub0),
StateNub.{isocore_set_sn=issn1; _}) ->
let distinct_pair = Bitset.of_array [|issn0; issn1|] in
let core = Lr1Itemset.core StateNub.(statenub0.lr1itemsetclosure).kernel in
match Map.get core cores_map with
| None -> begin
let core_rels = {
mergeable_sets=[];
issn2set=Map.empty (module Uns);
distinct=Map.of_alist (module Uns) [
(issn0, distinct_pair);
(issn1, distinct_pair);
(issn0, Bitset.singleton issn1);
(issn1, Bitset.singleton issn0);
];
issn2statenub=Map.empty (module Uns);
} in
Map.insert_hlt ~k:core ~v:core_rels cores_map
end
| Some ({distinct; _} as core_rels) -> begin
let amend_distinct distinct_set_opt = begin
| Some ({issn2set; distinct; _} as core_rels) -> begin
let mergeable_of_issn issn = begin
match Map.get issn issn2set with
| None -> Bitset.singleton issn
| Some mergeable -> mergeable
end in
let amend_distinct distinct distinct_set_opt = begin
match distinct_set_opt with
| None -> Some distinct_pair
| Some distinct_set -> Some (Bitset.union distinct_pair distinct_set)
| None -> Some distinct
| Some distinct_set -> Some (Bitset.union distinct distinct_set)
end in
let mergeable_of_issn0 = mergeable_of_issn issn0 in
let mergeable_of_issn1 = mergeable_of_issn issn1 in
let distinct =
distinct
|> Map.amend issn0 ~f:amend_distinct
|> Map.amend issn1 ~f:amend_distinct
|> (fun distinct ->
Bitset.fold ~init:distinct ~f:(fun distinct issn0 ->
Map.amend issn0 ~f:(amend_distinct mergeable_of_issn1) distinct
) mergeable_of_issn0
)
|> (fun distinct ->
Bitset.fold ~init:distinct ~f:(fun distinct issn1 ->
Map.amend issn1 ~f:(amend_distinct mergeable_of_issn0) distinct
) mergeable_of_issn1
)
in
let core_rels = {core_rels with distinct} in
Map.update_hlt ~k:core ~v:core_rels cores_map
Expand Down
Loading