Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

avoid reporting duplicate counterexamples #398

Open
karmacoma-eth opened this issue Oct 29, 2024 · 0 comments
Open

avoid reporting duplicate counterexamples #398

karmacoma-eth opened this issue Oct 29, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@karmacoma-eth
Copy link
Collaborator

karmacoma-eth commented Oct 29, 2024

There are a couple cases where this can happen:

  • trivially, by adding the same assert multiple times:
    function test_duplicata1(uint256 x) external pure {
        uint256 mul = x * 42;
        assertNotEq(mul, 0);
        assertNotEq(mul, 0);
        assertNotEq(mul, 0);
    }

results in

Counterexample: 
    p_x_uint256_7e92c74_00 = 0x0000000000000000000000000000000000000000000000000000000000000000
Counterexample: 
    p_x_uint256_7e92c74_00 = 0x0000000000000000000000000000000000000000000000000000000000000000
Counterexample: 
    p_x_uint256_7e92c74_00 = 0x0000000000000000000000000000000000000000000000000000000000000000
  • by introducing spurious paths before a single assert:
    function test_duplicata2(uint256 x) external pure {
        uint256 acc = 0;

        unchecked {
            // just introduce some extra paths
            acc += (x & (0xFF << 8) > 0) ? 2 : 3;
            acc += (x & (0xFF << 16) > 0) ? 5 : 3;

            assertNotEq((x & 0xff) * uint256(acc), 0);
        }
    }
  • by having genuinely different asserts that result in the same cex values
    function test_duplicata3(uint256 x) external pure {
        assertNotEq(x, 0);
        assertNotEq(x & 0xff, 0);
        assertNotEq(x & 0xff << 8, 0);
    }
  • ...

It seems a little odd and spammy to see the same cex repeated verbatim in the output.

Suggested behavior

  • by default, only print the first counterexample (requires fixing --early-exit and making it the default)
  • when not in early exit, make sure we only print unique cex values
@karmacoma-eth karmacoma-eth added the enhancement New feature or request label Oct 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant