Skip to content

How to automatically find counterexample #62

Answered by Seelengrab
jariji asked this question in Helpdesk
Discussion options

You must be logged in to vote

On a 64-bit system, Int has $2^\mathrm{64}$ distinct values. The likelihood that two numbers with the same absolute value are picked is pretty small, about $1/2^\mathrm{63}$ if my Math is right (both 0 and typemin already map to themselves, so are not relevant). Therefore, the easiest way to increase the likelihood of finding a collision is to use a smaller datatype, e.g. Int8:

julia> data = map(Set, Data.Vectors(Data.Integers{Int8}(); max_size=8))

julia> @check false_negative(f=Data.Just(abs), x=data) = length_map(f, x)
Found counterexample
  Context: false_negative

  Arguments:
      f::typeof(abs) = abs
      x::Set{Int8} = Set(Int8[-127, 127])

This works because abs behaves the same…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@jariji
Comment options

Answer selected by jariji
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants