◀ THE FOLD0ROOT.AI // WORLD II · GLITCH · OFF BY ONE◆ .dlw.fold
THE FOLD / GLITCH / OFF BY ONE / THE PRIORITY ENCODER

THE PRIORITY ENCODER

the highest one wins, and someone must say if none do
1 WHAT IT IS · WHAT IT DOES · FACT OR FICTION
n inputs collapse to log n outputs naming the highest set bit. But index 0 is a real answer, so a separate line has to declare whether the answer means anything.

LIT verified live. the highest set bit wins when several are set, and an empty input reports index 0 — which is also the answer for an input of 1, so the index alone is genuinely ambiguous and the VALID line is what distinguishes them; exhaustively correct on all 256 eight-bit inputs, compressing 8 inputs to 3 outputs plus one flag.
2 HOW IT WAS WEAVED · AI + HUMAN
Priority encoders sit in every interrupt controller, every allocator and every floating-point normaliser. The valid line is the interesting part: it is the standard hardware answer to a problem software solves badly with sentinel values, and it exists because there is no spare index to mean “nothing”.

AVAN (AI) checked the ambiguity directly by comparing the encoding of 0 with the encoding of 1, since that single collision is the entire reason the extra wire is there.
3 ONE DIMENSION
Eight inputs, three outputs, and one flag.
4 TWO DIMENSIONS · INTERACTIVE
Set bits and watch which one claims the output.
5 THREE DIMENSIONS + AVAN’S INVERSE
The green forward object.
AVAN’s addition (the inverse-companion): the forward reading is that a valid line resolves the ambiguity. The inverse is that every consumer must remember to read it. The encoder is honest — it publishes both the index and whether the index means anything — but the wire is separate, easy to leave unconnected, and its absence produces a plausible answer rather than an error. Read backwards, an out-of-band validity signal is the hardware version of returning a value and an error code, and it fails the same way: silently, whenever someone checks only the first.
LIT the highest set bit wins when several are set, and an empty input reports index 0 - which is also the answer for an input of 1, so the index alone is genuinely ambiguous and the VALID line is what distinguishes them; exhaustively correct on all 256 eight-bit inputs, compressing 8 inputs to 3 outputs plus one flag

FIG Priority encoders sit in every interrupt controller, every allocator and every floating-point normaliser. The valid line is the interesting part: it is the standard hardware answer to a problem software solves badly with sentinel values, and it exists because there is no spare index to mean 'nothing'. AVAN checked the ambiguity directly by comparing the encoding of 0 with the encoding of 1, since that single collision is the entire reason the extra wire is there.
◆ sealed .dlw.fold → folded to ROOT_0 · a sphere of OFF BY ONE · David Lee Wise (ROOT0), with AVAN