Backward Boolean evaluation of formula words #
This adapts the wire scan and its correctness proof from
LeanCanny.Computation.BooleanCircuitSpace and LeanCanny.ETR.FormulaBooleanCircuitCorrect
at lean-canny revision 970f28a5ecefc1327402ade16c068aa4b1b2c183.
Every operand follows its parent in the prefix token stream, so visiting tokens from right to
left gives each gate access to its previously computed operands. The scan accepts answers
indexed by gate, as in LeanCanny.ETR.FormulaBooleanCircuitSource.value_signature at that same
revision. Supplying the comparisons of term-word signs recovers the term-sign evaluator.
Correct signs for the comparison terms in the word suffice for the root value to characterize
membership in the real solution set.
The backward scan stays in polynomial space when comparison answers are computed in polynomial
space, keeping just one bit per processed gate.
Reading a child from the raw suffix bits is polynomial time in the input, with both positions in binary. The underlying lookup caps the offset at the suffix length.
The Boolean gate update is polynomial time in the raw word, binary position, comparison-answer bit, and raw suffix.
Supplying the comparison answer from the term signs gives the scan's next suffix.
Gate-indexed answers recover the term-sign scan when they give the requested comparison at each comparison gate.
A polynomial-space comparison-answer computation suffices for the whole backward gate scan. Each query receives the original encoded input and a binary gate index, and the scan stores a raw suffix bit for each gate it has processed.
The term-sign scan uses polynomial space if each indexed comparison with the supplied term signs is computable in polynomial space.
A gate reads the values already computed strictly to its right in the prefix stream.
Reading the value of an encoded subformula from the gate scan agrees with interpreting its comparisons using the signs of their encoded terms.
The first gate is the value of the total formula view, under signs assigned to term words.
The finite-signature scan uses polynomial space when the word and the list of signs in
gate order are available in polynomial time. The signs use the framed encList encSign
encoding, and each comparison looks up its sign at a binary gate index.
A finite gate signature covering the formula word's tokens gives the term-sign value
of the total formula view if its sign at every comparison agrees with the requested term's
sign. This adapts LeanCanny.ETR.FormulaBooleanCircuitSource.value_signature to the
frontier token view, which only requests signs at comparison gates.
The root gate holds at a real point if and only if the total formula view holds there, provided the sign reader gives the true sign for each comparison term in the word.
A gate signature matching the real sign of every requested term gives the truth of the
total formula view at that point. This is the token-view version of
LeanCanny.ETR.FormulaBooleanCircuitSource.signature_holds at the revision cited above.