Problem: Track what values variables can take at each program point—but exact tracking is impossible.
Solution: Use intervals to over-approximate. Always contains all real values, maybe more.
Trade-off: Sound (no false negatives), but imprecise (may have false positives).
Interval Arithmetic
| Operation | Rule | Example |
|---|---|---|
| Add | ||
| Subtract | ||
| Scalar | (if ) | |
| Multiply | of |
Fundamental theorem: — computed interval always contains true range.
The Dependency Problem
Interval arithmetic forgets that the same variable appears twice.
Example: , compute .
- Real answer: always
- Interval: ← over-approximation!
Rule: if each variable appears once, result is exact.
Worked Example
x := [2,5];
y := x+3;
z := 2*y;
→ → →
Conditionals — analyse both branches, then join (union).
if (x>0) then y:=x else y:=-x with :
- Then ():
- Else ():
- Join:
Loops & Widening — loops can grow intervals forever. Widening forces convergence by jumping bounds to after a few iterations. Guarantees termination, loses precision.
Summary — Possibly skip
| What | Track ranges through program |
| Why | Prove properties (no overflow, etc.) |
| Core | Sound (over-approximates), may be imprecise |
| Dependency | Same var twice → precision loss |
| Conditionals | Both branches → join |
| Loops | Widening → termination |
Talking points
- “Why over-approximate?” — Safety. May get false alarms, never miss real bugs.
- “Downside?” — Precision loss (dependency problem, wide loops).
- “Where used?” — Static analysers, compilers, safety-critical systems.