boundlab.prop.ub#

boundlab.prop.ub(e)[source]#

Compute an upper bound via backward bound propagation.

This function propagates linear weights backward through the expression DAG in direction "<=" and accumulates resulting bias terms.

Parameters:

e (Expr) – The expression to bound.

Returns:

A tensor \(u\) such that \(x \le u\) for all concrete values represented by e.

Return type:

torch.Tensor

Notes

Results are memoized in _UB_CACHE keyed by expression id.

Examples

>>> import torch
>>> import boundlab.expr as expr
>>> x = expr.ConstVal(torch.tensor([0.0])) + expr.LpEpsilon([1])
>>> ub(x).shape
torch.Size([1])