Skip to content

probe::exc does not handle equivalent elements correctly #233

@Morwenn

Description

@Morwenn

Despite an early attempt at making probe::exc handle values that compare equivalent (#143), and a more recent fix for the specific case where the first and elements of a cycle compare equivalent (#230), it appears that the measure of presortedness still does not fully handle them.

Case in point, once again courtesy of RapidCheck, though with manual reduction: we have probe::exc({1, 1, 1, 0, 0}) == 3 when the expected result is $Exc(\langle 1, 1, 1, 0, 0 \rangle) = 2$.

I still need to analyze that case in detail, but my guess is that we end up with two cycles:

  • One that handles the lone $1$ in the middle.
  • Another one that handles the four remaining values.

And that's not an incorrect way to make cycles, but the issue is that we need three cycles so that $|X| - N_{cycles}$ returns $2$. That means that we need to maximize the number of cycles in the face of equivalent elements. It remains to be checked, but believe that we find a $\langle 1, 0, 1, 0 \rangle$ cycle: we don't have to consecutive elements that compare equivalent, therefore we count a single cycle.

I need to find a way to either maximize the number of cycles, or to take into account such scenarios specifically.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions