Home / Docs / Diagnostics
U5001: Obligation refuted
Release v0.4.0
The solver found values for which a proof obligation fails: a refinement at a value, a requires clause at a call, an ensures clause, a nonzero divisor, or the arms of a when over ranges (spec/12 §3, §6).
The diagnostic points at the value, the call, the failing return, the division or the when keyword, and names the obligation with its goal. When the goal names any value, it gives a counterexample: values of the names involved for which the goal is false.
How to fix it
- Make the goal hold on every path, with a guard or a stronger type or contract that the solver may assume.
- Or correct the goal.
The repairs list these first. checked(value, goal) else fail <Variant> is the last repair, marked as an escape (ADR 0095): a runtime test replaces the proof, counts against the module's escape budget and is listed in the build report.
The repair at a glance
diff
module demo
pub kind Seats = Int in 0..5000
- pub cap_seats(raw: Int) -> Seats = if raw > 5000 then 5000 else raw
+ pub cap_seats(raw: Int) -> Seats = if raw < 0 then 0 else if raw > 5000 then 5000 else rawFailing example
una
module demo
pub kind Seats = Int in 0..5000
pub cap_seats(raw: Int) -> Seats = if raw > 5000 then 5000 else rawFixed example
una
module demo
pub kind Seats = Int in 0..5000
pub cap_seats(raw: Int) -> Seats = if raw < 0 then 0 else if raw > 5000 then 5000 else raw