Documentation

CslibFrontier.Crypto.Computational.Hybrid.SavedPrediction

Saving the randomness of a coordinate predictor #

A predictor description stores the sampled surrounding examples, a trial bit, and the test's coins. It contains no program for generating those examples, so its size does not recursively include earlier predictors used during training. The evaluator accepts arbitrary word codes; the decoder is total even when a boosting loop truncates a description. Replay is pointwise in the supplied observation; reusing a description also reuses its coins.

The saved test input is split into two encoded fragments around the missing labeled example. This avoids requiring an efficient inverse for an arbitrary observation or parameter encoding.

Main definitions #

Main results #

References #

Adapted from the cslib crypto branch at 5ff69ca93402e7c947208dc56396d6d86203ccd8.

Finite data needed to reuse one coordinate predictor on arbitrary observations.

  • active : Bool

    Padding coordinates reject the test.

  • trial : Bool

    The trial label inserted with the new observation.

  • front : List Bool

    Encoded test input before the inserted example.

  • back : List Bool

    Encoded test input after the inserted example.

  • coins : List Bool

    The test's saved random tape.

Encode a description using the shared pair representation.

Decode any word. Missing or malformed fields use the total pair projections.

Insert a labeled example directly into the saved encoded input.

@[simp]
theorem Cslib.Crypto.SavedPrediction.Description.length_input (desc : Description) (observation : List Bool) :
(desc.input observation).length = desc.front.length + desc.back.length + 4 * observation.length + 5
def Cslib.Crypto.SavedPrediction.evaluate (test : List Bool → List Bool → List Bool) (code observation : List Bool) :

Evaluate a saved predictor with a fixed total word evaluator for the original test.

def Cslib.Crypto.SavedPrediction.coinBudget (c d width : ℕ) (front back : List Bool) :

A tape long enough for every observation up to the supplied width.

noncomputable def Cslib.Crypto.SavedPrediction.save (c d width : ℕ) (trial : Bool) (front back : List Bool) :

Attach one random tape to an already sampled context.

theorem Cslib.Crypto.SavedPrediction.isPPTOn_save {Param : Type} {input : Param ↪ List Bool} {front back : Param → List Bool} {width : Param → ℕ} {trial : Param → Bool} (c d : ℕ) (hfront : Turing.MultiTapeTM.ComputableInPolyTime front input Turing.MultiTapeTM.encBits) (hback : Turing.MultiTapeTM.ComputableInPolyTime back input Turing.MultiTapeTM.encBits) (hwidth : Turing.MultiTapeTM.ComputableInPolyTime width input Turing.MultiTapeTM.encUnary) (htrial : Turing.MultiTapeTM.ComputableInPolyTime trial input Turing.MultiTapeTM.encBool) :
Probability.IsPPTOn input Turing.MultiTapeTM.encBits fun (a : Param) => save c d (width a) (trial a) (front a) (back a)

Drawing and saving the common tape has a strict PPT certificate.

@[reducible, inline]

A list of labeled examples (x, b), as the coordinate test reads them after its parameter: each example is the observation x encoded by encoding and paired with its label bit b, with x framed. The examples are framed and concatenated in order.

noncomputable def Cslib.Crypto.SavedPrediction.splice {α : Type} (sample : α ↪ List Bool) (base : List Bool) (replacement original : ProbComp (α × Bool)) (before after c d width : ℕ) (trial : Bool) :

Sample and save the surrounding examples before any target observation is supplied.

noncomputable def Cslib.Crypto.SavedPrediction.sample {α : Type} (encoding : α ↪ List Bool) (base : List Bool) (replacement original : ProbComp (α × Bool)) (count c d width : ℕ) :

Sample a reusable predictor description, including the fair trial and rejected padding.

theorem Cslib.Crypto.SavedPrediction.eval_splice {α : Type} (encoding : α ↪ List Bool) (base : List Bool) (replacement original : ProbComp (α × Bool)) (before after c d width : ℕ) (trial : Bool) (test : List (α × Bool) → ProbComp Bool) (raw : List Bool → List Bool → List Bool) (hrealize : ∀ (values : List (α × Bool)) (budget : ℕ), c * (((Turing.MultiTapeTM.encPair Turing.MultiTapeTM.encBits (encLabeledExamples encoding)) (base, values)).length + 1) ^ d ≤ budget → (test values).eval = PMF.map (fun (coins : List Bool) => (raw coins ((Turing.MultiTapeTM.encPair Turing.MultiTapeTM.encBits (encLabeledExamples encoding)) (base, values))).headD false) (BitString.uniformList budget)) (observation : α) (hwidth : (encoding observation).length ≤ width) :
((fun (code : List Bool) => evaluate raw code (encoding observation)) <$> splice encoding base replacement original before after c d width trial).eval = (trialPredictor (fun (trial : Bool) => spliceTest replacement original before after test (observation, trial)) trial).eval

Replaying a saved splice has exactly the original trial predictor's distribution. Only the target observation needs a size bound; the surrounding samples choose their own coin budget.

theorem Cslib.Crypto.SavedPrediction.eval_sample {α : Type} (encoding : α ↪ List Bool) (base : List Bool) (replacement original : ProbComp (α × Bool)) (count c d width : ℕ) (test : List (α × Bool) → ProbComp Bool) (raw : List Bool → List Bool → List Bool) (hrealize : ∀ (values : List (α × Bool)) (budget : ℕ), c * (((Turing.MultiTapeTM.encPair Turing.MultiTapeTM.encBits (encLabeledExamples encoding)) (base, values)).length + 1) ^ d ≤ budget → (test values).eval = PMF.map (fun (coins : List Bool) => (raw coins ((Turing.MultiTapeTM.encPair Turing.MultiTapeTM.encBits (encLabeledExamples encoding)) (base, values))).headD false) (BitString.uniformList budget)) (observation : α) (hwidth : (encoding observation).length ≤ width) :
((fun (code : List Bool) => evaluate raw code (encoding observation)) <$> sample encoding base replacement original count c d width).eval = (bitPredictor fun (trial : Bool) => sequenceTest replacement original count test (observation, trial)).eval

Sampling all predictor randomness once preserves every bounded observation's prediction law, including rejected padding coordinates.

def Cslib.Crypto.SavedPrediction.contextBound (baseSize count width : ℕ) :

Encoded surrounding examples and the public test parameter occupy this many bits.

def Cslib.Crypto.SavedPrediction.codeBound (baseSize count c d width : ℕ) :

The complete description bound depends on sample sizes and the fixed test clock, not on the program or stored state used to generate the surrounding examples.

The saved-description budget is polynomial time in the parameter and sample sizes. The clock coefficients belong to the fixed test, so the exponent is constant.

theorem Cslib.Crypto.SavedPrediction.length_splice_le {α : Type} (encoding : α ↪ List Bool) (base : List Bool) (replacement original : ProbComp (α × Bool)) (before after c d width : ℕ) (trial : Bool) (hreplacement : ∀ value ∈ replacement.eval.support, (encoding value.1).length ≤ width) (horiginal : ∀ value ∈ original.eval.support, (encoding value.1).length ≤ width) {code : List Bool} (hcode : code ∈ (splice encoding base replacement original before after c d width trial).eval.support) :
code.length ≤ codeBound base.length (before + after) c d width

Saving a fixed coordinate has a uniform description bound on every execution.

theorem Cslib.Crypto.SavedPrediction.length_sample_le {α : Type} (encoding : α ↪ List Bool) (base : List Bool) (replacement original : ProbComp (α × Bool)) (count c d width : ℕ) (hreplacement : ∀ value ∈ replacement.eval.support, (encoding value.1).length ≤ width) (horiginal : ∀ value ∈ original.eval.support, (encoding value.1).length ≤ width) {code : List Bool} (hcode : code ∈ (sample encoding base replacement original count c d width).eval.support) :
code.length ≤ codeBound base.length count c d width

Every generated description fits a bound independent of the source algorithms' internal state. Padding descriptions satisfy the same bound, including when count = 0.

theorem Cslib.Crypto.SavedPrediction.exists_evaluator {α Param : Type} {input : Param ↪ List Bool} {output : α ↪ List Bool} {test : Param → List (α × Bool) → ProbComp Bool} (htest : Probability.IsPPTOn (Turing.MultiTapeTM.encPair input (encLabeledExamples output)) Turing.MultiTapeTM.encBool fun (pair : Param × List (α × Bool)) => test pair.1 pair.2) :
∃ (c : ℕ) (d : ℕ) (predict : List Bool → List Bool → Bool), Turing.MultiTapeTM.ComputableInPolyTime (fun (pair : List Bool × List Bool) => predict pair.1 pair.2) (Turing.MultiTapeTM.encPair Turing.MultiTapeTM.encBits Turing.MultiTapeTM.encBits) Turing.MultiTapeTM.encBool ∧ ∀ (a : Param) (replacement original : ProbComp (α × Bool)) (count width : ℕ) (observation : α), (output observation).length ≤ width → ((fun (code : List Bool) => predict code (output observation)) <$> sample output (input a) replacement original count c d width).eval = (bitPredictor fun (trial : Bool) => sequenceTest replacement original count (test a) (observation, trial)).eval

A PPT test supplies one fixed efficient evaluator for all saved descriptions. No decoder for either the public parameter or observation representation is required.

theorem Cslib.Crypto.SavedPrediction.isPPTOn_splice {α Param : Type} {input : Param ↪ List Bool} {output : α ↪ List Bool} {base : Param → List Bool} {replacement original : Param → ProbComp (α × Bool)} {before after width : Param → ℕ} {trial : Param → Bool} (c d : ℕ) (hbase : Turing.MultiTapeTM.ComputableInPolyTime base input Turing.MultiTapeTM.encBits) (hreplacement : Probability.IsPPTOn input (Turing.MultiTapeTM.encPair output Turing.MultiTapeTM.encBool) replacement) (horiginal : Probability.IsPPTOn input (Turing.MultiTapeTM.encPair output Turing.MultiTapeTM.encBool) original) (hbefore : Turing.MultiTapeTM.ComputableInPolyTime before input Turing.MultiTapeTM.encUnary) (hafter : Turing.MultiTapeTM.ComputableInPolyTime after input Turing.MultiTapeTM.encUnary) (hwidth : Turing.MultiTapeTM.ComputableInPolyTime width input Turing.MultiTapeTM.encUnary) (htrial : Turing.MultiTapeTM.ComputableInPolyTime trial input Turing.MultiTapeTM.encBool) :
Probability.IsPPTOn input Turing.MultiTapeTM.encBits fun (a : Param) => splice output (base a) (replacement a) (original a) (before a) (after a) c d (width a) (trial a)

Saving context and coins is strict PPT whenever the sources and numerical bounds are.

theorem Cslib.Crypto.SavedPrediction.isPPTOn_sample {α Param : Type} {input : Param ↪ List Bool} {output : α ↪ List Bool} {base : Param → List Bool} {replacement original : Param → ProbComp (α × Bool)} {count width : Param → ℕ} (c d : ℕ) (hbase : Turing.MultiTapeTM.ComputableInPolyTime base input Turing.MultiTapeTM.encBits) (hreplacement : Probability.IsPPTOn input (Turing.MultiTapeTM.encPair output Turing.MultiTapeTM.encBool) replacement) (horiginal : Probability.IsPPTOn input (Turing.MultiTapeTM.encPair output Turing.MultiTapeTM.encBool) original) (hcount : Turing.MultiTapeTM.ComputableInPolyTime count input Turing.MultiTapeTM.encUnary) (hwidth : Turing.MultiTapeTM.ComputableInPolyTime width input Turing.MultiTapeTM.encUnary) :
Probability.IsPPTOn input Turing.MultiTapeTM.encBits fun (a : Param) => sample output (base a) (replacement a) (original a) (count a) c d (width a)

The random-coordinate description sampler is a uniform strict PPT program.