boundlab.prop.ublb#

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

Compute both upper and lower bounds for the given expression.

Uses backward propagation in reverse topological order. When an expression has the SYMMETRIC_TO_0 flag (e.g. LpEpsilon), its upper bound result is reused for the lower bound via negation.

Parameters:

e (Expr) – The expression to bound.

Returns:

A tuple (upper_bound, lower_bound).

Return type:

tuple[torch.Tensor, torch.Tensor]

Notes

For symmetric leaf expressions (flag SYMMETRIC_TO_0), only one side needs to be computed; the opposite side is obtained by negation.

Examples

>>> import torch
>>> import boundlab.expr as expr
>>> x = expr.ConstVal(torch.tensor([2.0])) + expr.LpEpsilon([1])
>>> u, l = ublb(x)
>>> (u >= l).all().item()
True