alpha-2027 · draft-alpha-2027 · tests/language/ByteBitOperations.alphaView source

Feature contract: byte-shift-left — SurfaceByteShiftLeft → byteShiftLeft (arity 2)#

One of the five byte bit operations of Language & Testing Evolution L21 (the primitives the standard library's Std.Byte bit functions and every word, hash and codec above them are built on). A byte is eight bits; these are the machine operations on it, on every lane.

1. Lexical and grammar rules, including precedence and termination#

(byte-shift-left a b): a fixed binary head, both operands terms of type Byte. Draft edition alpha-2027 only; under alpha-2026 the form is ALPHA-EDITION-UNSUPPORTED-FORM.

2. Scope and binding rules, including generated names#

Binds nothing; no generated names.

3. Type and quantity requirements#

Byte -> Byte -> Byte. Both operands are checked against Byte (a Nat operand is ALPHA-TYPE-MISMATCH). Runtime usages are the union of the operands' usages.

4. Effects, totality, and evaluation-order rules#

Pure and total. (byte-shift-left a n) shifts the byte a left by the byte n bit positions, keeping the low eight bits; an amount of eight or more yields zero. As a value: (a << n) mod 256, or 0 when n >= 8. The result is a byte literal when BOTH operands normalize to byte literals; otherwise the node is a stuck neutral term (no unfolding rule relates it to the Std.Byte eliminators — recorded, not implied). A shift amount is a Byte, so the amount is bounded by construction and the "eight or more" rule is total.

5. Elaboration into existing core or a specifically versioned new core extension#

Elaborates to the trusted-core node RByteShiftLeft (Alpha.Core byteShiftLeft), a new core extension serialized as alpha-checked-interface-v7 (tags 71–75; v6 readers do not accept v7 — every cached interface is recomputed once). The shift semantics are one function shared by the kernel, erasure and every lane (byteShiftLeftValue / byteShiftRightValue in Alpha.Core.Trusted.Syntax).

6. Representation and target support, where relevant#

Runtime-capable on every lane that realizes bytes: erasure carries the node to the runtime graph (RuntimeByteShiftLeft, opcode RuntimeByteShiftLeftOpcode), the runtime machine evaluates it on byte values, the native scalar lane lowers it to one x86-64 instruction (and/or/xor on registers; a shift by the count in cl with the eight-or-more rule folded into a mask and a zero branch), and the encoder/decoder round-trip those instructions. The direct lane (functional projection) does not realize it yet and says so by name.

7. Error codes and primary/secondary origins#

ALPHA-TYPE-MISMATCH (operand not Byte, at the operand's span); ALPHA-EDITION-UNSUPPORTED-FORM (the head under alpha-2026, at the form's span).

8. Formatting and migration rules#

Printed as the S-expression (byte-shift-left a b) by the generic head renderer. No migration from alpha-2026 (the form did not exist); Std.Byte's functions of the same meaning are re-authored over it under alpha-2027 with an old-versus-new correspondence law suite.

9. Positive, negative, execution, and edge-case tests#

tests/language/ByteBitOperations.alpha (refl laws for every head, the shift edges 7, 8 and 200, and an open operand that checks) through debug/byte-bit-operations-check.py (alpha-2027 acceptance, alpha-2026 rejection, a wrong-value control rejected, programs built and executed with the folded and the runtime-computed results as their exit status); bootstrap tests in alpha-core (folds, typing), alpha-compiler (runtime graph opcodes, native scalar / evaluator / interpreter agreement with the reference machine) and alpha-target-x86_64 (instruction encode/decode canonicity).

10. Compatibility with the old edition, serialized forms, and cache keys#

alpha-2026 corpus unchanged (the head is not a form there). Serialized cores carry the v7 schema; the receipt identity moves with the compiler identity as for any kernel change.