Proves in Lean 4 with Mathlib endpoint theorems showing when ceiling checks at both ends certify an entire constant-rate ascent; these underpin a certified scorer.
Abstract
Planners implementing the Bühlmann ZHL-16C model with gradient factors (GF) are rarely tested against their own settings. We asked whether four open-source planners (dive-deco, OSTC4, hwOS, Subsurface) keep the GF line reconstructed from their settings and reported anchor depths, and which code is responsible when they do not. We proved in Lean 4 when endpoint ceiling checks certify a whole constant-rate ascent and built an interval-arithmetic scorer on these theorems. Each planner, built at a pinned commit on a host computer, planned 720 air profiles; observation builds logged internal state and comparison builds made one change each. dive-deco violated 372 of 720 schedules (required GF up to 0.101 above the line; schedules up to 2.30 m shallower than the ceiling); recomputing all compartments removed every violation. Subsurface violated 64 at surfacing through a 1-mbar rounding, removed by an unrounded final check. hwOS's own state left its line in 178 of 719 plans and none after an exact ceiling round-up; its displayed schedules violated in 90, then 57. In OSTC4, four 10-s exposure-table entries are mistyped; with tissues updated every second as in the firmware, 283 of 720 schedules violated on reference coefficients and 2 after correcting them; on OSTC4's own constants 407 and 225 did on rebuilt stop tables, but only 15 of 605 along the ascent the corrected planner adopted. In a US Navy trial pair with equal stop time, the deep-stop schedule had the lower certified GF (0.762 vs 0.943) and more decompression sickness (10/198 vs 3/192). A certified GF measures compliance with a model, not risk.
Problem
Dive planners implementing the Bühlmann ZHL-16C model with gradient factors are rarely tested against their own configured GF line. Users cannot tell whether a displayed schedule actually respects the settings they chose.
Approach
Lean 4 theorems with Mathlib (110 audited declarations, standard axioms only) establish when compliance at the endpoints of a constant-rate ascent implies compliance throughout. A Python interval-arithmetic scorer built on these theorems, tested against 59 regression cases, checks 720 air profiles from each of four open-source planners (dive-deco, OSTC4, hwOS, Subsurface). Each planner is built at a pinned commit. Observation builds log internal state, and comparison builds each make a single code change to isolate the cause of a violation.
Results
All four planners violate their own GF line. Examples include dive-deco in 372 of 720 schedules, Subsurface in 64 through a 1-mbar rounding, and OSTC4 through four mistyped exposure-table entries. Single code changes remove most or all violations. In a US Navy trial pair, the deep-stop schedule had the lower certified GF but more decompression sickness, showing that certified GF measures compliance with the model, not risk.
Figure 2: Violations on the grid. Each panel shows the 720 profiles: depth 18–60 m (rows) and, within each GF block, bottom times 10, 15, 20, 25, 30, 40, 50 and 60 min (columns). Red: the schedule violates the planner’s own GF line; grey: it complies; dark grey: the planner flagged the plan as incomplete (not scored as complete). Left: original code; right: the comparison build that makes one chan
planner
condition
violate
worst margin
after comparison build
dive-deco (bottom logged once)
own constants
24
-0.0264
0
dive-deco (bottom logged every 1 s)
own constants
372
-0.1007
0
OSTC4 (1 s)
reference coefficients
283
-0.0322
2
OSTC4 (1 s)
own constants
407
-0.0423
225
Selected violations against each planner's own GF line (720-profile grid)