Gray code counter in Logical English

gray-code-counter-le.le · output · proof · check · playground


The question

A three-bit counter starts at 000. On a high clock signal it takes the next state computed by its logic gates. On a low signal it holds its state. What sequence does it produce, and does every step in the full cycle change exactly one bit?

Historical background

Frank Gray’s 1953 pulse-code communication patent describes reflected binary code, in which adjacent code words differ in one position. The counter here uses the circuit from William F. Clocksin’s case study on clocked sequential circuits. Its trace lets us check the one-bit property directly, including at wraparound. Frank Gray, Pulse code communication · William F. Clocksin, Clause and Effect, chapter 8

What we tell eyemind

The state is a list of three bits. The high-clock rule calculates the circuit’s AND, OR and NOT gates using multiplication, maximum and subtraction from one. The low-clock rule returns the same state. A recursive rule consumes one signal at a time and records the resulting state.

The one-bit check sums the absolute differences at the three positions of each consecutive pair. The sum must be one on every step, including the first move from the initial state.

What eyemind concludes

Nine high signals produce 001 → 011 → 010 → 110 → 111 → 101 → 100 → 000 → 001. The eighth signal closes the cycle and the ninth starts it again. In the intermittent run, the second and fourth signals are low, so those steps repeat the previous state.

struct('le:answer', 'one bit', 'counter runs', 'full cycle')

What the proof establishes

The saved proof is checked for both traces and for the one-bit check on the full cycle. The checker follows the same gate equations at each transition and verifies which run satisfies the one-bit condition.

Try it

node bin/eyemind.js examples/gray-code-counter-le.le
node bin/eyemind.js --check-proof examples/proof/gray-code-counter-le.js examples/gray-code-counter-le.le

Change the first signal of the full cycle to zero. Its first recorded state is then 000, and that run no longer has a one-bit change on every step.