BitEquiv
FIXED-WIDTH / REAL EVIDENCE
Unsigned expression verification

The average that lost a bit

One concrete input is enough to disprove equivalence. The values below were replayed independently of the solver.

Counterexample found
left expression
(x + y) >> 1
Every intermediate wraps to 8 bits.
right expression
(x & y) + ((x ^ y) >> 1)
Every intermediate wraps to 8 bits.

The declared domain

x: 0 … 255 y: 0 … 255

65536 possible assignments · 8-bit unsigned · nonempty domain

Concrete counterexample

Same inputs. Different bits.

x2120xd4
y760x4c
left output
16
0x10
0706051403020100
right output
144
0x90
1706051403020100

Highlighted cells differ. Bit positions are zero-based; bit 0 is the least significant bit.

Inspect the left evaluation trace
StepExpressionUnsigned value
1x212
2y76
3x + y32
411
5(x + y) >> 116
Inspect the right evaluation trace
StepExpressionUnsigned value
1x212
2y76
3x & y68
4x212
5y76
6x ^ y152
711
8(x ^ y) >> 176
9(x & y) + ((x ^ y) >> 1)144

What this establishes — and what it does not

Uniform-width unsigned bitvectors; wrapping arithmetic; logical right shift; overshift yields zero. Not C/LLVM semantics.

Only these expressions and declared input ranges; not the generating program. The solver and translation are trusted; no independently checkable proof certificate is emitted. A counterexample is not necessarily the smallest one. This report contains input expressions and witness values.

Reproduce this result

Save the JSON below as case.json, then run:

python -m bitequiv check case.json --json result.json --html result.html
{
  "width": 8,
  "variables": [
    "x",
    "y"
  ],
  "left": "(x + y) >> 1",
  "right": "(x & y) + ((x ^ y) >> 1)",
  "ranges": {
    "x": [
      0,
      255
    ],
    "y": [
      0,
      255
    ]
  },
  "title": "The average that lost a bit"
}

Use new output names; existing files are never overwritten. Solver limits constrain the query, not whole-process memory or runtime.