Skip to content

Fix predicate typo that disabled five bisimulation operations - #182

Open
matthiasgoergens wants to merge 1 commit into
janestreet:masterfrom
matthiasgoergens:fix-bisimulation-predicate-mod-zero
Open

Fix predicate typo that disabled five bisimulation operations#182
matthiasgoergens wants to merge 1 commit into
janestreet:masterfrom
matthiasgoergens:fix-bisimulation-predicate-mod-zero

Conversation

@matthiasgoergens

@matthiasgoergens matthiasgoergens commented Jul 30, 2026

Copy link
Copy Markdown

core/test/test_doubly_linked_bisimulation.ml defines its test predicate as:

let pred = function
  | Even -> fun n -> n mod 0 = 0
  | Odd -> fun n -> n mod 0 = 1

n mod 0 raises Division_by_zero for every n. It looks like a typo for n mod 2.

Five operations take that predicate — Exists, Filter_inplace, For_all, Find_elt and Find. On a non-empty list both Doubly_linked and the Foil reference raise, and the simulation loop treats a mutual raise as agreement, so the step is skipped rather than compared. On an empty list the predicate is never reached and they pass trivially. Either way, those five operations have not been testing anything.

How it was found

While surveying hand-written bisimulation tests in OCaml, as background for tapecheck, a port of Hypothesis's choice-tape shrinking engine to base_quickcheck. The pattern being looked for was tests that silently narrow what they can detect.

Happy to drop this if the predicate was deliberate for some reason I have missed.

test_doubly_linked_bisimulation.ml's [pred] used [n mod 0] rather than
[n mod 2]. In OCaml [n mod 0] raises Division_by_zero for every [n], so
the predicate raised on any input.

Five operations pass that predicate in: Exists, Filter_inplace, For_all,
Find_elt and Find. On a non-empty list both the real Doubly_linked and
the Foil reference raised identically, so [force] took its
[Error _, Error _ -> raise Both_raised] branch and the step was
discarded by [Both_raised | Skip -> ()] at the bottom of the loop.
Those five operations therefore ran, blew up on both sides, and were
silently skipped rather than compared.

Signed-off-by: Matthias Goergens <matthias.goergens@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant