Polynomial-time modular evaluation of term words #
Each transition charges the encoded token, binary modulus, coordinate list, and residue stack.
It retains the unary variable ranks of the term encoding and charges the binary modular
arithmetic. This certifies one transition of the constructor-stream evaluator, adapting the
case dispatch of TermModularFrames in lean-canny at
970f28a5ecefc1327402ade16c068aa4b1b2c183 to the frontier encodings.
For a positive modulus, a framed token list can be evaluated from an empty stack in
polynomial time. The number and width of residues bound every intermediate encoding.
The strict token decoder and a singleton-stack check lift this certificate to raw term
words without fixing the ambient dimension. Every successful evaluation comes from a
complete term whose variable ranks fit within the input length.
Evaluate one constructor token in polynomial time. The modulus, coordinates and stack entries use binary naturals, and the token's variable rank uses the term encoding's unary rank. The result is an optional framed residue list.
Starting with an empty stack, evaluate a framed stream of constructor tokens from right to left in polynomial time for a positive binary modulus. The output is an optional framed list of binary residues. The bound also applies to streams that fail with underflow.
Uniform polynomial time on raw words, with a positive binary modulus and a framed list of binary coordinates. The result uses the standard option encoding of a binary residue.