Common binary prefixes through exclusive or #
Two naturals A < B agree above bit s = (A ^^^ B).size, i.e. on the common prefix of their
binary expansions, and the dyadic point (2 (A / 2^s) + 1) 2^(s-1), the common prefix followed by
a 1, separates them. This is the arithmetic content of the compression code in the completeness
proof of Bogdanov and Trevisan, Claim 20.
Main results #
Nat.div_two_pow_eq_iff_xor_lt: two naturals have the same quotient by2 ^ kexactly when their exclusive or is below2 ^ k.Nat.lt_commonPrefix_mid_le: the split ofA < Bat their highest differing bit.
References #
Splitting at the highest differing bit. For A < B and s = (A ^^^ B).size, the two
numbers have the same quotient Z by 2 ^ s, and the dyadic point (2 Z + 1) 2^(s-1) lies
strictly above A and at most B.