test(core): K-U7 review: None-iff-overflow proof, covers that can fail, a sharper bridge

- Kani net_pay_none_iff_a_prefix_overflows proves what the doc claimed:
  None exactly when some running difference leaves the i64 range, else
  the exact i128 result. It found that i64's Amount::checked_sub negates
  first, so a deduction of i64::MIN (no negation) is refused where the
  difference would fit (-1 - i64::MIN). Conservative, and Decimal's range
  is symmetric, so the engine is unaffected; the harness assumes it away
  and asserts the refusal at the fixed case; the kernel doc says so.
- payroll_plan_balances: covers that the assumes did not already force
  (net of one unit, payables holding employer shares alone, federal or
  state posted); the harness doc says it rebuilds the plan on i64 rather
  than calling payroll_entry_plan, and what that does and does not prove.
- Docs name the Lean theorems that carry any number of employees
  (payroll_run_net_eq, payroll_run_plan_balances) where they had
  claimed it.
- Bridge: compare to_string as well as value (Decimal equality ignores
  scale); a strategy near Decimal::MAX/MIN where the reference also
  returns None, which required the reference to check every running
  difference as the kernel's fold does, not only the last.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
swaitsandClaude Sonnet 5.5 committed 2026-11-09 13:50:54 -07:00
1 parent 46dccd5d76
commit b31824b2ca
4 files changed
+210 -45

No files matched your search

+7 -3
View File
@@ -36,9 +36,13 @@ use super::Amount;
/// payroll line whose net is negative, so a posted run's net pay
/// is never below zero. A net below zero is still a value here:
/// the refusal is the caller's rule, not arithmetic's.
/// 4. None on overflow; NEVER a rounded or wrapped result, never a
/// panic. The fold is left to right, so [MAX, MAX, -MAX] from a
/// zero gross is None while the same figures summed first would
/// 4. None on overflow (proved: `net_pay_none_iff_a_prefix_overflows`
/// says None exactly when some running difference leaves the
/// range; on `i64` a deduction of `i64::MIN`, which has no
/// negation, is refused too); NEVER a rounded or wrapped
/// result, never a panic.
/// The fold is left to right, so [MAX, MAX, -MAX] from a zero
/// gross is None while the same figures summed first would
/// cancel: each step must be exact, as `total`'s fold is.
/// SCENARIOS:
/// 1. IF gross 5,000.00 and withholdings 750.00, 250.00, 310.00,