Range Algebra for Safe Array Splits
Abstract
We present a language-agnostic range algebra that derives correct index intervals for splitting arrays and implementing binary search, eliminating off-by-one and empty-range bugs. From two primitives -- and -- we obtain four canonical splits (Natural, Left+, Right+, Center-cut) with proofs of coverage and balance for all and any base index . We record invariants (normalization to left-closed/right-open intervals with len ), document cross-language division quirks, and give drop-in code patterns and property tests. The result is a small, memorable spec that can be copied verbatim into C/C++/Java/C\#/Go/Rust/Swift/JS/Python.
Cite
@article{arxiv.1402.4843,
title = {Range Algebra for Safe Array Splits},
author = {Aleksandar Perisic},
journal= {arXiv preprint arXiv:1402.4843},
year = {2025}
}
Comments
After I compressed the previous, much longer version, this one became an array of tautologies, which is difficult to justify as an article in any sense. The value is no different from a Boolean algebra, which is nonsensical to restate these days. It was even difficult to actually write in LaTeX without repeating the same symbols. It is not working as an article