Developer finds logic bug caused reasoning engine to falsely prove 114 is prime
A developer building zelph, an open-source C++ reasoning engine, discovered their primality test was incorrectly certifying composite numbers as prime and even generating false proofs. The first bug stemmed from number literals being parsed as atoms rather than digit lists, meaning no arithmetic could run and negation checks passed trivially. A deeper second bug revealed that negation-as-failure conditions were being evaluated before all relevant facts had been derived, allowing wrong conclusions to be locked in permanently due to the engine's monotonic, append-only fact store. The flaw was effectively a logic-layer race condition determined by hash set iteration order in a single-threaded system — a known issue in formal logic called stratification, documented since the 1980s. The fix involved separating rule evaluation into two phases: first running all positive rules to completion, then evaluating negation-dependent rules against the fully saturated fact base.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in