Documentation

CslibFrontier.Logics.RealArithmetic.TokenEvaluationPolyTime

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.

Evaluate a raw term word using natural-number variable ranks and zero-padded coordinates. Return a residue only if strict token decoding and stack evaluation leave a singleton stack.

theorem Cslib.Logic.RealArithmetic.Term.evalTermWord_encTerm {n : ℕ} (p : ℕ) (point : List ℕ) (t : Term n) :
evalTermWord p point ((encTerm n) t) = some (evalResidue p point t)

Evaluation of a canonical term word returns its syntax-directed modular residue.

theorem Cslib.Logic.RealArithmetic.Term.evalTermWord_eq_some_iff {p value : ℕ} {point : List ℕ} {word : List Bool} :
evalTermWord p point word = some value ↔ ∃ (t : Term word.length), (encTerm word.length) t = word ∧ evalResidue p point t = value

Raw evaluation succeeds with a residue exactly on words encoding a single term with that residue. The input length suffices as the ambient dimension for the reconstructed term.

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.