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

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 raw

Failing example

una
module demo

pub kind Seats = Int in 0..5000

pub cap_seats(raw: Int) -> Seats = if raw > 5000 then 5000 else raw

Fixed 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