Modular evaluation and size bounds for real-arithmetic terms #
The evaluator follows the arithmetic syntax, reducing every intermediate modulo the supplied modulus. For a positive modulus it gives the canonical residue of the integer polynomial. The same computation can consume the constructor tokens directly from right to left, using a stack of residues and rejecting operators with too few operands. The term's binary word length bounds the polynomial degree and the exponent of a dyadic coefficient norm bound, regardless of the ambient dimension.
Adapted from TermEvaluationContext and EncodedTermPolynomial in lean-canny at
970f28a5ecefc1327402ade16c068aa4b1b2c183, using the frontier syntax and constructor stream.
Main results #
Term.evalResidue_eq: canonical modular evaluation with zero-padded coordinates.Term.evalTokenStack_tokens: evaluation of a term's prefix tokens pushes its residue.Term.evalTokenStack_bounds: a bound on the length and entries of each successful stack.Term.toPolynomial_bounds: degree and coefficient norm bounds from the encoded term.
For a positive modulus the result is the canonical residue of the term polynomial with each coordinate read from the supplied list and missing coordinates set to zero.
Processing a complete term stream pushes its modular value above the initial stack.
Each successful suffix of the prefix stream grows the stack by at most one entry per token.
For positive p, every entry stays below p if the initial entries do.
The encoding length bounds both the total degree and the binary coefficient norm exponent of the term polynomial. Negative constants use their binary magnitudes in this bound.