Documentation

CslibFrontier.Algorithms.WordRAM.ThreeSum.Decision.VisitorCost

Charged cost transfer for an interleaved Chan–He visitor #

Traversal charges every pending descriptor, including skipped entries. Solver charges depend only on the number of emitted mathematical nodes. The fixed root and forest overheads reuse the existing traversal budgets; the callback and packed-tail release cost the actual host bound plus eight.

The ledger below combines proved instruction budgets, rather than asserting exact running time. It includes initialized frontend execution, all scalar and layout setup, the value-envelope loop, every root descriptor and stack transition, Boolean accumulation and the final halt. Its count bound is purely the finite reduction's existing theorem and uses no completed catalogue-producing native execution.

Main definitions #

Main results #

Four native argument copies, the certified host, Boolean receive and one packed-tail release.

Charge all root work and descriptor/control overhead, but callbacks only for emitted nodes.

Native large-branch budget: frontend, snapshot, prime setup, layout, envelope and forest. The frontend's own final halt is excluded because its code is inlined into the visitor.

theorem Cslib.Algorithms.WordRAM.ThreeSum.Decision.Visitor.largeCost_eq {r : ℕ} (κ : ℕ) (c : Host.Callee r) (n emitted : ℕ) :
largeCost κ c n emitted + 1 = ChanHe.Preprocessing.cost κ n + 4 * envelopeExponent κ + 8 + emitted * callbackTime κ c n

The reused preprocessing budget covers exactly the same root work and shared setup.

theorem Cslib.Algorithms.WordRAM.ThreeSum.Decision.Visitor.cost_ledger {r : ℕ} (κ : ℕ) (c : Host.Callee r) (n emitted : ℕ) :
largeCost κ c n emitted + 7 + 18 + 4 * emitted = ChanHe.Preprocessing.cost κ n + 4 * envelopeExponent κ + 32 + emitted * (Host.callerTime (instanceLength κ n) (c.time (Host.sideLength (instanceLength κ n)) (2 * (n + 2) ^ envelopeExponent κ + 1)) + 12)

Full initialized prefix/branch/halt costs seven. Four units per callback and eighteen fixed units remain as slack in the old budget; no solver call is charged for a skipped entry.

theorem Cslib.Algorithms.WordRAM.ThreeSum.Decision.Visitor.cost_le {r : ℕ} (κ : ℕ) (c : Host.Callee r) (n emitted : ℕ) (hcount : emitted ≤ instanceBound κ n) :
largeCost κ c n emitted + 7 ≤ cost κ c n

Any emitted-node count within the finite reduction's bound preserves the old cost envelope.

theorem Cslib.Algorithms.WordRAM.ThreeSum.Decision.Visitor.largeCost_le {r : ℕ} (κ : ℕ) (c : Host.Callee r) (n emitted : ℕ) (hcount : emitted ≤ instanceBound κ n) :
largeCost κ c n emitted ≤ cost κ c n - 7

The large branch leaves the existing seven-instruction outer prefix/branch/halt allowance.

theorem Cslib.Algorithms.WordRAM.ThreeSum.Decision.Visitor.allNodes_cost_le {r : ℕ} (κ : ℕ) (c : Host.Callee r) (n : ℕ) (input : Fin n → ℤ) :
largeCost κ c n (ThreeSum.ChanHe.allNodes n ((n + 2) ^ κ) input).length + 7 ≤ cost κ c n

The exact mathematical output count is covered without running the old native producer.