prodigy.analysis.lowerbounds.subinvariant¶
Verification of user-provided EVT sub-invariants (lower induction).
For a loop while (G) { B } with input distribution g and Phi_g(nu) = g + [[B]](<nu>_G):
if nu >= 0, nu <= Phi_g(nu) (coefficient-wise) and |nu| = nu(1, ..., 1) < inf,
then <nu>_{not G} <= [[while (G) { B }]](g) and |[[loop]](g)| - |<nu>_{not G}| <= |Phi_g(nu)| - |nu|.
No termination assumption is needed. Phi_g(nu) is computed with Prodigy’s own forward semantics. The
coefficient-wise sign conditions are decided exactly when the generating functions have product denominators
prod_i (1 - r_i X_i^{p_i}) (finite positivity check); otherwise Prodigy’s positivity heuristics are used and
the result may be inconclusive.
- to_product_form(expr, variables)[source]¶
Write a rational generating function as
P / prod_i (1 - r_i X_i^{p_i})(at most one factor per variable,r_i >= 0), or return None if this is not possible.
- nonneg_by_construction(expr_str, variables)[source]¶
Sufficient criterion for non-negative coefficients: the expression is
P / prod_i Q_i^k_iwherePhas non-negative coefficients and everyQ_i = c_i - R_ihas a constantc_i > 0andR_inon-negative coefficients, as1/(c - R) = sum_n R^n / c^(n+1). Covers denominators that are not products of univariate factors, e.g.x*y/(1 - 9/50*(x + y)).
- decide_nonneg(expr_str, variables, config)[source]¶
Coefficient-wise nonnegativity: exact for product denominators, then a sufficient criterion for rational functions, otherwise Prodigy’s heuristics.
- rational_mass(expr_str, variables)[source]¶
Total mass of a rational generating function with NONNEGATIVE coefficients, or
Noneif the closed form is not rational. Letf(t) = F(t, ..., t)in lowest terms. By Pringsheim’s theorem, the radius of convergence offis its smallest pole on the positive real axis; hence the masssum of coefficients = lim_{t -> 1-} f(t)is infinite ifffhas a pole in(0, 1], and equalsf(1)otherwise. Evaluating the closed form at1directly is unsound:(1 + X)/(1 - 2X) = 1 + 3X + 6X^2 + ...evaluates to-2.
- evt_subinvariant_verification(loop, prog_info, distribution, invariant, config, analyzer, details=None)[source]¶
Verify an EVT sub-invariant
nuof finite mass and return the lower bound<nu>_{not G}on the output distribution of the loop (raisesVerificationErrorif the conditions cannot be established).details, if given, receivesmass(|nu|),gap(|Phi(nu)| - |nu|, which bounds the mass that the lower bound misses),exit_massand how non-negativity was established (nonneg_nu,nonneg_gap).- Parameters:
loop (
WhileInstr)prog_info (
ProgramInfo)distribution (
Distribution)invariant (
Distribution)config (
ForwardAnalysisConfig)analyzer (
Callable[[SkipInstr|AbortInstr|WhileInstr|IfInstr|AsgnInstr|ChoiceInstr|LoopInstr|TickInstr|ObserveInstr|QueryInstr|ProbabilityQueryInstr|ExpectationInstr|PlotInstr|PrintInstr|OptimizationQuery|Sequence[SkipInstr|AbortInstr|WhileInstr|IfInstr|AsgnInstr|ChoiceInstr|LoopInstr|TickInstr|ObserveInstr|QueryInstr|ProbabilityQueryInstr|ExpectationInstr|PlotInstr|PrintInstr|OptimizationQuery],ProgramInfo,Distribution,Distribution,ForwardAnalysisConfig],Tuple[Distribution,Distribution]])
- Return type: