Documentation

CslibFrontier.Computability.Probabilistic.PPT.PairCapture

Pair-unpacked captured-input composition for efficient probabilistic programs #

IsPPTOn.bind_with, IsPPTOn.map_with, IsOraclePPTOn.bind_with and IsOraclePPTOn.map_with take curried continuations α → β → … and synthesize fun pair => second pair.1 pair.2 over encPair input middle. When chaining multi-step do blocks directly without fun_prop synthesis, passing an uncurried continuation α × β → … avoids repeated Prod.mk.eta normalization in the premise.

Main results #

theorem Cslib.Probability.IsPPTOn.bind_pair {α β γ : Type} {input : α ↪ List Bool} {left : β ↪ List Bool} {right : γ ↪ List Bool} {first : α → ProbComp β} {second : α × β → ProbComp γ} (hfirst : IsPPTOn input left first) (hsecond : IsPPTOn (Turing.MultiTapeTM.encPair input left) right second) :
IsPPTOn input right fun (a : α) => do let b ← first a second (a, b)

Sequence a closed strict PPT program with an uncurried continuation on (a, b) encoded by encPair input left.

theorem Cslib.Probability.IsPPTOn.map_pair {α β γ : Type} {input : α ↪ List Bool} {left : β ↪ List Bool} {right : γ ↪ List Bool} {first : α → ProbComp β} {second : α × β → γ} (hfirst : IsPPTOn input left first) (hsecond : Turing.MultiTapeTM.ComputableInPolyTime second (Turing.MultiTapeTM.encPair input left) right) :
IsPPTOn input right fun (a : α) => do let b ← first a pure (second (a, b))

Sequence a closed strict PPT program with an uncurried deterministic pure continuation on (a, b) encoded by encPair input left.

theorem Cslib.Probability.IsOraclePPTOn.bind_pair {Operation α β γ : Type} [DecidableEq Operation] {input : α ↪ List Bool} {middle : β ↪ List Bool} {output : γ ↪ List Bool} {first : α → WordOracleComp Operation β} {second : α × β → WordOracleComp Operation γ} (hfirst : IsOraclePPTOn input middle first) (hsecond : IsOraclePPTOn (Turing.MultiTapeTM.encPair input middle) output second) :
IsOraclePPTOn input output fun (a : α) => do let b ← first a second (a, b)

Sequence a strict oracle PPT program with an uncurried continuation on (a, b) encoded by encPair input middle.

theorem Cslib.Probability.IsOraclePPTOn.map_pair' {Operation α β γ : Type} [DecidableEq Operation] {input : α ↪ List Bool} {middle : β ↪ List Bool} {output : γ ↪ List Bool} {first : α → WordOracleComp Operation β} {second : α × β → γ} (hfirst : IsOraclePPTOn input middle first) (hsecond : Turing.MultiTapeTM.ComputableInPolyTime second (Turing.MultiTapeTM.encPair input middle) output) :
IsOraclePPTOn input output fun (a : α) => do let b ← first a pure (second (a, b))

Sequence a strict oracle PPT program with an uncurried deterministic pure continuation on (a, b) encoded by encPair input middle.