# How to express taking the next bit of an infinite string in small-step semantics?

I have to write a rule as part of a small step operational semantics (https://en.wikipedia.org/wiki/Operational_semantics).

Whenever this rule is applied, the next bit belonging to an infinite bit string must be taken. Therefore, in the premise of the rule, I have to express that the next bit of a (previously) fixed bit string is taken.

To represent the set of infinite (bit) strings, it is usually used the notation $\{0,1\}^{\omega}$.

So, the first idea is to write the premise of the rule in the following way: $b= nextBit(str) \quad str \in \{0,1\}^{\omega}$.

What do you think about that? In my opinion, it doesn't make explicit that the infinite string $str$ is chosen once and then fixed. Is it something like

$b = nextBit(str \rvert_{str \in \{0,1\}^{\omega}})$

reasonable or it is too fuzzy/ non standard?

How would you express it explicitly that $str$ is fixed and it doesn't change during the run?

In general, the only persistent pieces information in a deduction rule (like the ones in the wikipedia article) are the variables which are shared between one of the premises and the conclusion of the rule.

So in effect, a findOne function that operates on a given (fixed) string and returns the position of the first bit which is one would have to pass the string to the conclusion of the rule. Thus one possible formulation would be

$$\frac{\mathrm{findOne}(str)}{\mathrm{findAux}(str,0)}$$

where findAux is defined by

$$\frac{\mathrm{findAux}(str, n)\quad \mathrm{nextBit}(str)=0}{\mathrm{findAux}(\mathrm{getTail}(str),n+1)}$$

$$\frac{\mathrm{findAux}(str, n)\quad \mathrm{nextBit}(str)=1}{n}$$

And nextBit is defined by other rules. One often uses pattern notation instead, so if strings of bits are represented $1.0.0.1.1.0.0.1\ldots$ (so concatenation is "$.$"), the first rule would be

$$\frac{\mathrm{findAux}(0.str, n)}{\mathrm{findAux}(str,n+1)}$$

Note that the free variables $str$ and $n$ are implicitly universally quantified, so the first rule reads

For any value of $str$, the value of $\mathrm{findOne}(str)$ is the value of $\mathrm{findAux}(str, 0)$.

Having "side conditions" such as $str\in\{0,1\}^\omega$ can clarify, but is usually clear from the context. Note that the $str$ in the premisse and the conclusion are the same, by definition of what a deduction rule is.