IndisputableMonolith.Patterns.GrayCycleBRGC
The GrayCycleBRGC module supplies the binary reflected Gray code construction that realizes an explicit adjacent Hamiltonian cycle on the d-dimensional hypercube of patterns. Researchers building concrete Gray covers or cycles in the Patterns framework cite it to obtain a dimension-independent explicit example. The module defines the brgcPath function via the standard XOR-shift formula and proves its injectivity together with the single-bit transition property between successive steps.
claimThe BRGC path in dimension $d$ is the sequence $k=0,1,2^d-1$ mapped to the pattern whose coordinates are the bits of $k$ XOR $(k$ right-shift $1)$, yielding an adjacent cycle of length $2^d$ on the hypercube.
background
The Patterns module defines Pattern d as the set of functions Fin d → Bool. The GrayCycle module upgrades this to an adjacent cycle: a closed walk of length 2^d that visits every pattern exactly once, with each consecutive pair differing in precisely one coordinate. The supplied upstream GrayCycle doc states the state space, adjacency, and cycle requirements explicitly. GrayCycleBRGC specializes this abstract notion by importing the standard BRGC formula gray(n) = n XOR (n >>> 1) and the supporting bit-manipulation lemmas.
proof idea
This is a definition module that introduces brgcPath together with auxiliary operations such as snocBit and cast_add_one. It contains targeted lemmas (brgcPath_injective, oneBitDiff_snocBit_same, oneBitDiff_snocBit_flip) that establish injectivity and the single-bit difference property; the overall structure is definitional with short algebraic verifications rather than long tactic scripts.
why it matters in Recognition Science
GrayCycleBRGC is imported by GrayCycleGeneral, which lifts the construction to a full GrayCycle d for arbitrary dimension via the BRGC formula. It therefore supplies the concrete adjacent cycle required for the workstream A generalization described in the downstream doc-comment. The module closes the explicit-construction gap between the abstract GrayCycle interface and the standard binary-reflected code used throughout the Patterns domain.
scope and limits
- Does not treat Gray codes of length other than 2^d.
- Does not compare BRGC to alternative Gray-code constructions.
- Does not address non-adjacent or weighted variants of the cycle.
- Does not prove uniqueness of the resulting cycle up to rotation.
used by (1)
depends on (2)
declarations in this module (14)
-
def
snocBit -
lemma
snocBit_castSucc -
lemma
snocBit_last -
lemma
twoPow_succ_eq_add -
def
brgcPath -
lemma
cast_add_one -
theorem
brgcPath_injective -
theorem
oneBitDiff_snocBit_same -
theorem
oneBitDiff_snocBit_flip -
lemma
natAdd_eq_addNat -
lemma
rev_add_one_eq -
theorem
brgc_oneBit_step -
def
brgcGrayCycle -
def
brgcGrayCover