Bounded retries and independent coordinates #
OracleComp.retry good program fuel runs program at most fuel times and returns the first
result satisfying good, or none when every run fails. It is the bounded form of a Las Vegas
loop: an oracle program is a finite tree of calls, so "repeat until success" is represented by its
truncation after fuel runs, and the truncation is visible as the none outcome. Checking good
is local computation and makes no call.
When one run fails with probability q (under answer distributions h, as in
OracleComp.evalWith):
- the loop fails with probability exactly
q ^ fuel(OracleComp.evalWith_retry_none); - it returns a good result
awith probabilityP(a) (1 + q + ⋯ + q ^ (fuel - 1)), whereP(a)is the probability that one run returnsa(OracleComp.evalWith_retry_some); - its expected cost is
c (1 + q + ⋯ + q ^ (fuel - 1))for a run of expected costc(OracleComp.expectedCost_retry), so at most2 cfor every fuel whenq ≤ 1 / 2(OracleComp.expectedCost_retry_le_two_mul): the expected number of runs is at most2.
OracleComp.pi runs a family of programs one after the other and collects their results. Over an
arbitrary interface its expected cost is the sum of the expected costs
(OracleComp.expectedCost_pi), and the probability that some coordinate is bad is at most the sum
of the probabilities (OracleComp.toOuterMeasure_evalWith_pi_exists_le, a union bound). These
complement the support and law statements of CslibFrontier.Languages.Probabilistic.Vector.
OracleComp.retrySome specializes OracleComp.retry to ProbComp (Option α) attempts, returning
the first some a (collapsed via Option.join) or none if all fuel attempts fail. It is the
ProbComp counterpart of BlockRejectionSpec.runTrials in
CslibFrontier.Probability.DDGTree.Rejection: while BlockRejectionSpec operates on fair-bit
width-block decoders, retrySome operates on arbitrary ProbComp (Option α) programs, proving
exact failure decay q ^ fuel (eval_retrySome_none), zero conditional bias against
conditionedSome (filter_eval_retrySome_isSome), and statistical distance bounds against
totalConditionedSome and differing retry caps (closeTo_retrySome_conditioned,
closeTo_retrySome_totalConditionedSome, closeTo_retrySome_retrySome).
Main definitions #
Cslib.OracleComp.retry: at mostfuelruns, returning the first good result.Cslib.OracleComp.retrySome,Cslib.OracleComp.conditionedSome,Cslib.OracleComp.totalConditionedSome:Option-returning bounded retries and conditioned 1-shot distributions.
Main results #
Cslib.OracleComp.mem_supportWith_retry: a returned result is good and a result of one run.Cslib.OracleComp.evalWith_retry_none: the loop fails with probabilityq ^ fuel.Cslib.OracleComp.toOuterMeasure_evalWith_retry_le: a union bound: if one run returns a good result inbadwith probability at mostε, the loop returns one with probability at mostfuel ε.Cslib.OracleComp.evalWith_retry_some: the loop returns a good resultawith probabilityP(a) (1 + q + ⋯ + q ^ (fuel - 1)), whereP(a)is the probability that one run returnsa.Cslib.OracleComp.mem_support_eval_retrySome,Cslib.OracleComp.eval_retrySome_none,Cslib.OracleComp.eval_retrySome_some,Cslib.OracleComp.eval_retrySome_some_eq_conditioned,Cslib.OracleComp.filter_eval_retrySome_isSome,Cslib.OracleComp.closeTo_retrySome_conditioned,Cslib.OracleComp.closeTo_retrySome_totalConditionedSome,Cslib.OracleComp.closeTo_retrySome_retrySome:Option-attempt failure decay, zero conditional bias, and statistical closeness bounds forretrySome.Cslib.OracleComp.expectedCost_retry,Cslib.OracleComp.expectedCost_retry_le_two_mul: the expected cost of the loop is a geometric sum, at most twice a run whenq ≤ 1 / 2.Cslib.OracleComp.expectedCost_pi,Cslib.OracleComp.toOuterMeasure_evalWith_pi_exists_le: expected cost and union bound forOracleComp.pi.
Run program at most fuel times and return the first result satisfying good, or none
when all fuel runs fail. Checking good makes no call.
A result returned by the loop satisfies good and is a possible result of one run.
The loop fails exactly when all its runs fail, with probability q ^ fuel, where q is the
probability that one run fails.
A run failing with probability at most q makes the loop fail with probability at most
q ^ fuel.
Union bound for retries. If one run returns a good result in bad with probability at
most ε, then the loop returns a result in bad with probability at most fuel ε.
The loop returns a with probability P(a) (1 + q + ⋯ + q ^ (fuel - 1)) when a is good,
and never otherwise, where P(a) is the probability that one run returns a and q is the
probability that one run fails.
One more allowed run costs a run, plus the remaining loop when the run fails.
The expected cost of the loop is a geometric sum: a run of expected cost c failing with
probability q gives c (1 + q + ⋯ + q ^ (fuel - 1)).
Expected cost of a retry loop. If one run fails with probability at most 1 / 2, the loop
costs at most twice a run in expectation, whatever the fuel.
Union bound for sequenced partial programs. A partial program followed, on success, by a partial continuation fails with probability at most the failure probability of the first program plus a bound on the failure probability of every continuation.
The expected cost of a partial program followed, on success, by a continuation is at most the expected cost of the first program plus a bound on the expected cost of every continuation.
The expected cost of running a family of programs is the sum of their expected costs.
Union bound for a family of programs: the probability that some coordinate is bad is at most the sum over the coordinates of the probability that it is bad.
Run up to fuel independent attempts of attempt : ProbComp (Option α) via
OracleComp.retry (fun o => o.isSome = true), returning the first some a (collapsed via
Option.join) or none if all attempts return none.
Condition a single attempt attempt : ProbComp (Option α) on succeeding (o.isSome = true),
yielding a zero-failure PMF (Option α) supported on some a.
Totalized conditioned single-attempt distribution returning conditionedSome attempt h when
some successful outcome is supported and PMF.pure none otherwise.
Exact zero-bias factorization: for every a : α,
(ProbComp.eval (retrySome attempt fuel)) (some a) equals
(1 - Pr[attempt = none] ^ fuel) * conditionedSome attempt hgood (some a).
Zero conditional bias: whenever retrySome attempt fuel has positive acceptance probability,
conditioning it on o.isSome = true produces the exact same distribution as
conditionedSome attempt hgood.
Statistical closeness between fuel-attempt bounded retry retrySome attempt fuel and the
rejection-free conditioned distribution conditionedSome attempt hgood: CloseTo ≤ q ^ fuel
whenever Pr[attempt = none] ≤ q.
Statistical closeness between retrySome attempt fuel and totalConditionedSome attempt:
holds unconditionally without requiring attempt to have supported successful outcomes.
Statistical closeness between two different retry caps fuel₁ and fuel₂ on the same
single-attempt sampler: CloseTo ≤ q ^ min fuel₁ fuel₂ whenever Pr[attempt = none] ≤ q.