Threshold transcript trees and native scalar stages #
A native weighted threshold program has a decision tree whose queries are native threshold lines reading only original inputs. It computes any output determined by the restricted transcript, has depth at most the number of input-reading gates, and has at most as many leaves as attained transcripts. Only nonempty answer branches are constructed.
The same tree gives a separable comparison tree for every split of the input coordinates by
relabeling its queries. This preserves its exact structural depth and leaf count. All threshold
comparisons retain the convention that equality returns true.
The circuit-to-tree construction is semantic and noncomputable; no efficient compiler is asserted.
In the other direction, ScalarStage.append emits a native adaptive scalar stage: one input-free
indicator per supplied history pattern followed by one scalar query. A unique matching pattern
selects its threshold; no match selects a baseline that can pad a terminated path with false.
Earlier gate values and input coefficients are preserved. The helpers add no input-reading gates,
and the query adds exactly one when its direct input vector is nonzero. With zero direct vector,
zero selected thresholds and baseline one, the same stage recognizes whether any supplied pattern
matches. These are stage-local results, not yet a whole-tree compiler or its global size/activity
bound.
Main definitions #
Cslib.Circuits.Boolean.WeightedThreshold.gateQuery: a native input-only threshold line, with fixed earlier gate contributions absorbed into its threshold.Cslib.Circuits.Boolean.WeightedThreshold.inputOfSplit: assemble the two sides of an input.Cslib.Circuits.Boolean.WeightedThreshold.lineComparison: express an input-only threshold line as a separable comparison across a coordinate split.Cslib.Circuits.Boolean.WeightedThreshold.gateComparison: express a gate query with fixed earlier gate values as a separable comparison across a coordinate split.Cslib.Circuits.Boolean.WeightedThreshold.ScalarStage.prefixLine,.prefixBank,.queryLine,.append: native prefix indicators, their bank, a scalar query, and an adaptive stage.
Main results #
Cslib.Circuits.Boolean.WeightedThreshold.gateComparison_eval_eq,Cslib.Circuits.Boolean.WeightedThreshold.gateQuery_eval_eq: earlier gate values suffice to evaluate comparisons and queries.Cslib.Circuits.Boolean.WeightedThreshold.exists_linear_transcript_tree: a transcript determines a tree of native linear threshold queries, independent of any coordinate split.Cslib.Circuits.Boolean.WeightedThreshold.exists_transcript_tree: the corresponding separable comparison tree for any split.Cslib.Circuits.Boolean.WeightedThreshold.exists_gate_readout_tree: every fixed readout of the complete gate valuation is covered.Cslib.Circuits.Boolean.WeightedThreshold.exists_circuit_tree: designated gate outputs are computed simultaneously.Cslib.Circuits.Boolean.WeightedThreshold.ScalarStage.prefixLine_eval,.eval_append_last,.eval_append_of_match,.eval_append_of_no_match: indicator, selection and padding semantics.Cslib.Circuits.Boolean.WeightedThreshold.ScalarStage.eval_append_readout: the same constructor realizes the OR of its supplied pattern indicators without reading original inputs.Cslib.Circuits.Boolean.WeightedThreshold.ScalarStage.eval_append_castSucc,.inputWeight_append_castSucc,.inputWeight_append_flag,.inputWeight_append_last,.card_inputGates_append: preservation and exact direct-input cost of an emitted stage.
References #
With preceding gate values fixed, a gate is a native threshold line on original inputs. Its coefficients are aggregated by actual input wire, so cancelled slots contribute zero.
Instances For
Earlier gate values suffice to evaluate the input-only query; current and later values do not affect it because their coefficients vanish.
Any output determined by the restricted transcript has a native linear-query tree. The tree is independent of coordinate splits; its leaves count only attainable transcripts.
A native input-only threshold line is separable across every coordinate split. Repeated argument slots are aggregated by actual input wire.
Instances For
With preceding gate values fixed, the remaining gate equation is a separable comparison of its direct input contributions.
Instances For
Earlier gate values suffice to evaluate the comparison; current and later values do not affect it because their coefficients vanish.
Any output determined by the restricted transcript has a separable comparison tree of depth at most the input-reading count and with at most one leaf per attainable transcript.
A fixed readout of all native gate values satisfies the transcript-tree bounds.
A circuit whose outputs select gates has a comparison tree computing all designated outputs simultaneously, under the same depth and attainable-transcript leaf bounds.
Native scalar stages selected by transcript prefixes #
A single input-free gate testing whether selected earlier gates match a Boolean pattern.
The selection may repeat wires; an inconsistent pattern then evaluates to false.
Instances For
The prefix gate tests equality of the selected history with the pattern.
Append a bank of prefix indicators, all reading the original program's selected gates. The program index charges exactly one new gate per supplied pattern.
Instances For
Each newly appended bank gate computes its own pattern indicator.
Every new bank gate has zero direct input vector, including with repeated history wires.
Append one adaptive scalar stage: a bank of m prefix indicators and one query.
A matching pattern contributes baseline - threshold, so a unique match selects that threshold.
No match leaves the baseline unchanged. The output gate is Fin.last (g + m).
Instances For
Appending a scalar stage preserves every earlier gate value.
Exact semantics of the emitted query, without assuming distinct or reachable patterns.
A unique matching prefix selects its threshold, with equality returning true.
No matching live prefix pads the transcript with false when the score is below baseline.
With zero direct vector and selected thresholds, baseline one computes the OR of the pattern indicators. This input-free readout uses the same stage constructor and permits repeated patterns as well as an empty accepting bank.
The scalar stage preserves all prior direct input coefficients.
The helper gates of a scalar stage have zero direct input coefficients.
The new query's direct input vector is exactly w.
A scalar stage adds exactly one input-reading gate when w ≠ 0, and none when w = 0.
Its program index counts m + 1 new gates; the m prefix helpers are input-free.