Documentation

CslibFrontier.Computability.Probabilistic.Oracle.SubstitutionGrowth

Stateful oracle substitution with bounded state growth #

Library infrastructure (no cited result): extends Cslib.Probability.IsOraclePPTOn.run_interpret_preprocess_open_of_polyBounded to handlers whose reply length may depend on the current encoded state as well as the caller and request, requiring only that each call adds at most an encoded-state increment polynomially bounded in the caller and request alone.

Because IsOraclePPTOn on the outer program gives one polynomial Q bounding both the number of external queries and the length of every external request (IsOraclePPTOn.query_bounds), the handler's encoded state stays bounded by |initial| + k * G after k ≤ Q calls. Combined with IsOraclePPTOn.length_le, ProbOracleComp.mem_support_iff_exists, and finite_operations on the handler certificate, every supported reply along a real execution stays polynomially bounded in the caller's input. Adding an explicit call counter and capping both the call count and the request length at Q reduces the certificate to IsOraclePPTOn.run_interpret_preprocess_open_of_polyBounded, while query-bounded simulation shows that the cap never triggers along executions of the program.

Specializations cover closed ProbComp handlers, handlers whose encoded state is uniformly bounded in the caller (of_state_le, requiring no invariant or support case split), memoryless ProbOracleComp.run oracles (including the empty-reply oracle), and parameterized IsOraclePPT programs.

Main results #

theorem Cslib.Probability.IsOraclePPTOn.run_interpret_preprocess_open_of_bounded_growth {Operation External α β Caller State : Type} [DecidableEq Operation] [DecidableEq External] {source : α ↪ List Bool} {input : Caller ↪ List Bool} {output : β ↪ List Bool} {operationEncoding : Operation ↪ List Bool} {stateEncoding : State ↪ List Bool} {program : α → WordOracleComp Operation β} {handler : Caller → Operation × List Bool → State → WordOracleComp External (List Bool × State)} {prepare : Caller → α} {initial : Caller → State} {growth : Caller → List Bool → ℕ} (hprogram : IsOraclePPTOn source output program) (hprepare : Turing.MultiTapeTM.ComputableInPolyTime prepare input source) (hhandler : IsOraclePPTOn (encHandlerCall input operationEncoding stateEncoding) (Turing.MultiTapeTM.encPair Turing.MultiTapeTM.encBits stateEncoding) fun (x : Caller × (Operation × List Bool) × State) => match x with | (caller, request, state) => handler caller request state) (hinitial : Turing.MultiTapeTM.ComputableInPolyTime initial input stateEncoding) (invariant : Caller → State → Prop) (hinit : ∀ (a : Caller), invariant a (initial a)) (hgrowth : Turing.MultiTapeTM.PolyBounded (fun (pair : Caller × List Bool) => ((Turing.MultiTapeTM.encPair input Turing.MultiTapeTM.encBits) pair).length) fun (x : Caller × List Bool) => match x with | (a, w) => growth a w) (hpreserve : ∀ (a : Caller) (request : Operation × List Bool) (state : State), invariant a state → ∀ result ∈ OracleComp.support (handler a request state), invariant a result.2 ∧ (stateEncoding result.2).length ≤ (stateEncoding state).length + growth a request.2) :
IsOraclePPTOn input (Turing.MultiTapeTM.encPair output stateEncoding) fun (a : Caller) => (OracleComp.interpret (OracleComp.sumHandler (fun (n : ℕ) => StateT.lift (ProbOracleComp.sample (ProbComp.unifFin n))) (handler a)) (program (prepare a))).run (initial a)

Library infrastructure (no cited result): open stateful substitution when each call adds encoded state polynomially bounded in the caller and request alone. Because the outer program's query bound caps both the number of calls and every request length, the handler's encoded state stays polynomially bounded in the caller's input along every execution, and IsOraclePPTOn.length_le together with ProbOracleComp.mem_support_iff_exists gives a uniform polynomial bound on all replies, reducing the certificate to Cslib.Probability.IsOraclePPTOn.run_interpret_preprocess_open_of_polyBounded.

theorem Cslib.Probability.IsOraclePPTOn.run_interpret_preprocess_of_bounded_growth {Operation α β Caller State : Type} [DecidableEq Operation] {source : α ↪ List Bool} {input : Caller ↪ List Bool} {output : β ↪ List Bool} {operationEncoding : Operation ↪ List Bool} {stateEncoding : State ↪ List Bool} {program : α → WordOracleComp Operation β} {handler : Caller → Operation × List Bool → State → ProbComp (List Bool × State)} {prepare : Caller → α} {initial : Caller → State} {growth : Caller → List Bool → ℕ} (hprogram : IsOraclePPTOn source output program) (hprepare : Turing.MultiTapeTM.ComputableInPolyTime prepare input source) (hhandler : IsPPTOn (encHandlerCall input operationEncoding stateEncoding) (Turing.MultiTapeTM.encPair Turing.MultiTapeTM.encBits stateEncoding) fun (x : Caller × (Operation × List Bool) × State) => match x with | (caller, req, state) => handler caller req state) (hinitial : Turing.MultiTapeTM.ComputableInPolyTime initial input stateEncoding) (invariant : Caller → State → Prop) (hinit : ∀ (a : Caller), invariant a (initial a)) (hgrowth : Turing.MultiTapeTM.PolyBounded (fun (pair : Caller × List Bool) => ((Turing.MultiTapeTM.encPair input Turing.MultiTapeTM.encBits) pair).length) fun (x : Caller × List Bool) => match x with | (a, w) => growth a w) (hpreserve : ∀ (a : Caller) (req : Operation × List Bool) (state : State), invariant a state → ∀ result ∈ (handler a req state).eval.support, invariant a result.2 ∧ (stateEncoding result.2).length ≤ (stateEncoding state).length + growth a req.2) :
IsPPTOn input (Turing.MultiTapeTM.encPair output stateEncoding) fun (a : Caller) => (OracleComp.interpret (OracleComp.sumHandler (fun (n : ℕ) => StateT.lift (ProbComp.unifFin n)) (handler a)) (program (prepare a))).run (initial a)

Closed ProbComp stateful substitution under polynomially bounded additive state growth, without a user-supplied reply-length bound.

theorem Cslib.Probability.IsOraclePPTOn.run_interpret_preprocess_open_of_state_le {Operation External α β Caller State : Type} [DecidableEq Operation] [DecidableEq External] {source : α ↪ List Bool} {input : Caller ↪ List Bool} {output : β ↪ List Bool} {operationEncoding : Operation ↪ List Bool} {stateEncoding : State ↪ List Bool} {program : α → WordOracleComp Operation β} {handler : Caller → Operation × List Bool → State → WordOracleComp External (List Bool × State)} {prepare : Caller → α} {initial : Caller → State} {bound : Caller → ℕ} (hprogram : IsOraclePPTOn source output program) (hprepare : Turing.MultiTapeTM.ComputableInPolyTime prepare input source) (hhandler : IsOraclePPTOn (encHandlerCall input operationEncoding stateEncoding) (Turing.MultiTapeTM.encPair Turing.MultiTapeTM.encBits stateEncoding) fun (x : Caller × (Operation × List Bool) × State) => match x with | (caller, req, state) => handler caller req state) (hinitial : Turing.MultiTapeTM.ComputableInPolyTime initial input stateEncoding) (hbound : Turing.MultiTapeTM.PolyBounded (fun (a : Caller) => (input a).length) bound) (hstate : ∀ (a : Caller) (state : State), (stateEncoding state).length ≤ bound a) :
IsOraclePPTOn input (Turing.MultiTapeTM.encPair output stateEncoding) fun (a : Caller) => (OracleComp.interpret (OracleComp.sumHandler (fun (n : ℕ) => StateT.lift (ProbOracleComp.sample (ProbComp.unifFin n))) (handler a)) (program (prepare a))).run (initial a)

Open stateful substitution when every encoded state is bounded by a polynomial bound in the caller alone, requiring no invariant, growth allowance, or support case split.

theorem Cslib.Probability.IsOraclePPTOn.run_interpret_preprocess_of_state_le {Operation α β Caller State : Type} [DecidableEq Operation] {source : α ↪ List Bool} {input : Caller ↪ List Bool} {output : β ↪ List Bool} {operationEncoding : Operation ↪ List Bool} {stateEncoding : State ↪ List Bool} {program : α → WordOracleComp Operation β} {handler : Caller → Operation × List Bool → State → ProbComp (List Bool × State)} {prepare : Caller → α} {initial : Caller → State} {bound : Caller → ℕ} (hprogram : IsOraclePPTOn source output program) (hprepare : Turing.MultiTapeTM.ComputableInPolyTime prepare input source) (hhandler : IsPPTOn (encHandlerCall input operationEncoding stateEncoding) (Turing.MultiTapeTM.encPair Turing.MultiTapeTM.encBits stateEncoding) fun (x : Caller × (Operation × List Bool) × State) => match x with | (caller, req, state) => handler caller req state) (hinitial : Turing.MultiTapeTM.ComputableInPolyTime initial input stateEncoding) (hbound : Turing.MultiTapeTM.PolyBounded (fun (a : Caller) => (input a).length) bound) (hstate : ∀ (a : Caller) (state : State), (stateEncoding state).length ≤ bound a) :
IsPPTOn input (Turing.MultiTapeTM.encPair output stateEncoding) fun (a : Caller) => (OracleComp.interpret (OracleComp.sumHandler (fun (n : ℕ) => StateT.lift (ProbComp.unifFin n)) (handler a)) (program (prepare a))).run (initial a)

Closed ProbComp stateful substitution when every encoded state is bounded by a polynomial bound in the caller alone, requiring no invariant, growth allowance, or support case split.

theorem Cslib.Probability.IsOraclePPTOn.isPPTOn_run {Operation α β Caller : Type} [DecidableEq Operation] {source : α ↪ List Bool} {input : Caller ↪ List Bool} {output : β ↪ List Bool} {operationEncoding : Operation ↪ List Bool} {program : α → WordOracleComp Operation β} {oracle : Caller → Operation × List Bool → ProbComp (List Bool)} {prepare : Caller → α} (hprogram : IsOraclePPTOn source output program) (hprepare : Turing.MultiTapeTM.ComputableInPolyTime prepare input source) (horacle : IsPPTOn (Turing.MultiTapeTM.encPair input (Turing.MultiTapeTM.encPair operationEncoding Turing.MultiTapeTM.encBits)) Turing.MultiTapeTM.encBits fun (x : Caller × Operation × List Bool) => match x with | (caller, req) => oracle caller req) :
IsPPTOn input output fun (a : Caller) => ProbOracleComp.run (program (prepare a)) (oracle a)

Running an oracle-PPT program via ProbOracleComp.run against an efficient memoryless ProbComp oracle is closed PPT, without a user-supplied reply-length bound.

theorem Cslib.Probability.IsOraclePPTOn.isPPTOn_runEmptyOracle {Operation α β : Type} [DecidableEq Operation] {source : α ↪ List Bool} {output : β ↪ List Bool} {program : α → WordOracleComp Operation β} (hprogram : IsOraclePPTOn source output program) :
IsPPTOn source output fun (a : α) => ProbOracleComp.run (program a) fun (x : Operation × List Bool) => pure []

Running any IsOraclePPTOn program against fun _ => pure [] is closed PPT.

theorem Cslib.Probability.IsOraclePPT.run_interpret_preprocess_open_of_bounded_growth {Operation External β Caller State : Type} [DecidableEq Operation] [DecidableEq External] {input : Caller ↪ List Bool} {output : β ↪ List Bool} {operationEncoding : Operation ↪ List Bool} {stateEncoding : State ↪ List Bool} {program : ℕ → List Bool → WordOracleComp Operation β} {handler : Caller → Operation × List Bool → State → WordOracleComp External (List Bool × State)} {prepare : Caller → ℕ × List Bool} {initial : Caller → State} {growth : Caller → List Bool → ℕ} (hprogram : IsOraclePPT output program) (hprepare : Turing.MultiTapeTM.ComputableInPolyTime prepare input (Turing.MultiTapeTM.encPair Turing.MultiTapeTM.encUnary Turing.MultiTapeTM.encBits)) (hhandler : IsOraclePPTOn (encHandlerCall input operationEncoding stateEncoding) (Turing.MultiTapeTM.encPair Turing.MultiTapeTM.encBits stateEncoding) fun (x : Caller × (Operation × List Bool) × State) => match x with | (caller, req, state) => handler caller req state) (hinitial : Turing.MultiTapeTM.ComputableInPolyTime initial input stateEncoding) (invariant : Caller → State → Prop) (hinit : ∀ (a : Caller), invariant a (initial a)) (hgrowth : Turing.MultiTapeTM.PolyBounded (fun (pair : Caller × List Bool) => ((Turing.MultiTapeTM.encPair input Turing.MultiTapeTM.encBits) pair).length) fun (x : Caller × List Bool) => match x with | (a, w) => growth a w) (hpreserve : ∀ (a : Caller) (req : Operation × List Bool) (state : State), invariant a state → ∀ result ∈ OracleComp.support (handler a req state), invariant a result.2 ∧ (stateEncoding result.2).length ≤ (stateEncoding state).length + growth a req.2) :
IsOraclePPTOn input (Turing.MultiTapeTM.encPair output stateEncoding) fun (a : Caller) => (OracleComp.interpret (OracleComp.sumHandler (fun (n : ℕ) => StateT.lift (ProbOracleComp.sample (ProbComp.unifFin n))) (handler a)) (program (prepare a).1 (prepare a).2)).run (initial a)

Parameterized IsOraclePPTOn.run_interpret_preprocess_open_of_bounded_growth.

theorem Cslib.Probability.IsOraclePPT.run_interpret_preprocess_of_bounded_growth {Operation β Caller State : Type} [DecidableEq Operation] {input : Caller ↪ List Bool} {output : β ↪ List Bool} {operationEncoding : Operation ↪ List Bool} {stateEncoding : State ↪ List Bool} {program : ℕ → List Bool → WordOracleComp Operation β} {handler : Caller → Operation × List Bool → State → ProbComp (List Bool × State)} {prepare : Caller → ℕ × List Bool} {initial : Caller → State} {growth : Caller → List Bool → ℕ} (hprogram : IsOraclePPT output program) (hprepare : Turing.MultiTapeTM.ComputableInPolyTime prepare input (Turing.MultiTapeTM.encPair Turing.MultiTapeTM.encUnary Turing.MultiTapeTM.encBits)) (hhandler : IsPPTOn (encHandlerCall input operationEncoding stateEncoding) (Turing.MultiTapeTM.encPair Turing.MultiTapeTM.encBits stateEncoding) fun (x : Caller × (Operation × List Bool) × State) => match x with | (caller, req, state) => handler caller req state) (hinitial : Turing.MultiTapeTM.ComputableInPolyTime initial input stateEncoding) (invariant : Caller → State → Prop) (hinit : ∀ (a : Caller), invariant a (initial a)) (hgrowth : Turing.MultiTapeTM.PolyBounded (fun (pair : Caller × List Bool) => ((Turing.MultiTapeTM.encPair input Turing.MultiTapeTM.encBits) pair).length) fun (x : Caller × List Bool) => match x with | (a, w) => growth a w) (hpreserve : ∀ (a : Caller) (req : Operation × List Bool) (state : State), invariant a state → ∀ result ∈ (handler a req state).eval.support, invariant a result.2 ∧ (stateEncoding result.2).length ≤ (stateEncoding state).length + growth a req.2) :
IsPPTOn input (Turing.MultiTapeTM.encPair output stateEncoding) fun (a : Caller) => (OracleComp.interpret (OracleComp.sumHandler (fun (n : ℕ) => StateT.lift (ProbComp.unifFin n)) (handler a)) (program (prepare a).1 (prepare a).2)).run (initial a)

Parameterized IsOraclePPTOn.run_interpret_preprocess_of_bounded_growth.

theorem Cslib.Probability.IsOraclePPT.run_interpret_preprocess_open_of_state_le {Operation External β Caller State : Type} [DecidableEq Operation] [DecidableEq External] {input : Caller ↪ List Bool} {output : β ↪ List Bool} {operationEncoding : Operation ↪ List Bool} {stateEncoding : State ↪ List Bool} {program : ℕ → List Bool → WordOracleComp Operation β} {handler : Caller → Operation × List Bool → State → WordOracleComp External (List Bool × State)} {prepare : Caller → ℕ × List Bool} {initial : Caller → State} {bound : Caller → ℕ} (hprogram : IsOraclePPT output program) (hprepare : Turing.MultiTapeTM.ComputableInPolyTime prepare input (Turing.MultiTapeTM.encPair Turing.MultiTapeTM.encUnary Turing.MultiTapeTM.encBits)) (hhandler : IsOraclePPTOn (encHandlerCall input operationEncoding stateEncoding) (Turing.MultiTapeTM.encPair Turing.MultiTapeTM.encBits stateEncoding) fun (x : Caller × (Operation × List Bool) × State) => match x with | (caller, req, state) => handler caller req state) (hinitial : Turing.MultiTapeTM.ComputableInPolyTime initial input stateEncoding) (hbound : Turing.MultiTapeTM.PolyBounded (fun (a : Caller) => (input a).length) bound) (hstate : ∀ (a : Caller) (state : State), (stateEncoding state).length ≤ bound a) :
IsOraclePPTOn input (Turing.MultiTapeTM.encPair output stateEncoding) fun (a : Caller) => (OracleComp.interpret (OracleComp.sumHandler (fun (n : ℕ) => StateT.lift (ProbOracleComp.sample (ProbComp.unifFin n))) (handler a)) (program (prepare a).1 (prepare a).2)).run (initial a)

Parameterized IsOraclePPTOn.run_interpret_preprocess_open_of_state_le.

theorem Cslib.Probability.IsOraclePPT.run_interpret_preprocess_of_state_le {Operation β Caller State : Type} [DecidableEq Operation] {input : Caller ↪ List Bool} {output : β ↪ List Bool} {operationEncoding : Operation ↪ List Bool} {stateEncoding : State ↪ List Bool} {program : ℕ → List Bool → WordOracleComp Operation β} {handler : Caller → Operation × List Bool → State → ProbComp (List Bool × State)} {prepare : Caller → ℕ × List Bool} {initial : Caller → State} {bound : Caller → ℕ} (hprogram : IsOraclePPT output program) (hprepare : Turing.MultiTapeTM.ComputableInPolyTime prepare input (Turing.MultiTapeTM.encPair Turing.MultiTapeTM.encUnary Turing.MultiTapeTM.encBits)) (hhandler : IsPPTOn (encHandlerCall input operationEncoding stateEncoding) (Turing.MultiTapeTM.encPair Turing.MultiTapeTM.encBits stateEncoding) fun (x : Caller × (Operation × List Bool) × State) => match x with | (caller, req, state) => handler caller req state) (hinitial : Turing.MultiTapeTM.ComputableInPolyTime initial input stateEncoding) (hbound : Turing.MultiTapeTM.PolyBounded (fun (a : Caller) => (input a).length) bound) (hstate : ∀ (a : Caller) (state : State), (stateEncoding state).length ≤ bound a) :
IsPPTOn input (Turing.MultiTapeTM.encPair output stateEncoding) fun (a : Caller) => (OracleComp.interpret (OracleComp.sumHandler (fun (n : ℕ) => StateT.lift (ProbComp.unifFin n)) (handler a)) (program (prepare a).1 (prepare a).2)).run (initial a)

Parameterized IsOraclePPTOn.run_interpret_preprocess_of_state_le.

theorem Cslib.Probability.IsOraclePPT.isPPTOn_run {Operation β Caller : Type} [DecidableEq Operation] {input : Caller ↪ List Bool} {output : β ↪ List Bool} {operationEncoding : Operation ↪ List Bool} {program : ℕ → List Bool → WordOracleComp Operation β} {oracle : Caller → Operation × List Bool → ProbComp (List Bool)} {prepare : Caller → ℕ × List Bool} (hprogram : IsOraclePPT output program) (hprepare : Turing.MultiTapeTM.ComputableInPolyTime prepare input (Turing.MultiTapeTM.encPair Turing.MultiTapeTM.encUnary Turing.MultiTapeTM.encBits)) (horacle : IsPPTOn (Turing.MultiTapeTM.encPair input (Turing.MultiTapeTM.encPair operationEncoding Turing.MultiTapeTM.encBits)) Turing.MultiTapeTM.encBits fun (x : Caller × Operation × List Bool) => match x with | (caller, req) => oracle caller req) :
IsPPTOn input output fun (a : Caller) => ProbOracleComp.run (program (prepare a).1 (prepare a).2) (oracle a)

Parameterized IsOraclePPTOn.isPPTOn_run.