Skip to main content

disjoint_cover

Function disjoint_cover 

Source
pub fn disjoint_cover<T: Clone>(
    whole: &Candidate<T>,
    pool: &[Candidate<T>],
) -> Coverage<T>
Expand description

Is whole’s token multiset the clean disjoint union of a subset of pool? Generic over opaque tokens and location-agnostic — pool may live anywhere in either tree, because the tokens carry the correspondence, not the structure. Call it with whole = an input and pool = the output residue to detect a split; swap the sides to detect a merge.

Conservative by construction: any pool member that shares at least one token with whole is treated as a participant, and the cover is Coverage::Clean only when every participant is fully inside whole (no foreign atoms), participants are pairwise disjoint (no token owned by two — the ambiguity flag), their union reconstructs whole exactly (residual 0), there are at least two of them, and none equals the whole. Anything else is a Coverage::NearMiss.