Vital records — a person dies at most once, and benefits know it instantly
SSA's Inspector General found tens of millions paid to beneficiaries who were dead — and, in the mirror failure, thousands of LIVING people marked dead in the Death Master File (sometimes twice, by different counties), freezing their bank accounts. Both failures come from death being a row any clerk can insert again. Here a person's death count is a memory invariant capped at 1: the second certificate is refused at the write. A registered certificate is terminal — soma verify proves no resurrection edit — and the benefits handler refuses payment the moment the count is 1.
A Soma program from the civic part of the verified corpus: 107 lines, cells VitalRecords, VitalRecordsTests. It passes soma check with soma 3.2.4.
How it is built
The cell VitalRecords declares 6 signals in its face: file_certificate(person: String) -> Map, register_death(person: String) -> Map, pay_benefit(person: String, amount: Int) -> Map, is_deceased(person: String) -> Bool, paid_total(person: String) -> Int and cert_state(person: String) -> String; keeps 2 memory slots: deaths (Map<String, Int>, persistent and consistent) under the invariant deaths >= 0 && deaths <= 1 and paid (Map<String, Int>, persistent and consistent) under the invariant paid >= 0. Its state machine certificate starts in no_record and allows 2 transitions: no_record -> filed and filed -> registered. registered is terminal. Handlers: cert_state (line 41), file_certificate (line 43), register_death (line 49), pay_benefit (line 64), is_deceased (line 74) and paid_total (line 76).
The file also holds 1 test cell (VitalRecordsTests) with 16 assertions, run by soma test.
The source
vital_records.cell
// ============================================================================
// VITAL RECORDS — a person dies at most once, and benefits know it instantly
// ============================================================================
// SSA's Inspector General found tens of millions paid to beneficiaries who
// were dead — and, in the mirror failure, thousands of LIVING people marked
// dead in the Death Master File (sometimes twice, by different counties),
// freezing their bank accounts. Both failures come from death being a row
// any clerk can insert again. Here a person's death count is a memory
// invariant capped at 1: the second certificate is refused at the write.
// A registered certificate is terminal — soma verify proves no resurrection
// edit — and the benefits handler refuses payment the moment the count is 1.
// ============================================================================
cell VitalRecords {
face {
signal file_certificate(person: String) -> Map
signal register_death(person: String) -> Map
signal pay_benefit(person: String, amount: Int) -> Map
signal is_deceased(person: String) -> Bool
signal paid_total(person: String) -> Int
signal cert_state(person: String) -> String
}
memory {
// person -> registered deaths. A second death is unrepresentable.
deaths: Map<String, Int> [persistent, consistent]
invariant deaths >= 0 && deaths <= 1
paid: Map<String, Int> [persistent, consistent]
invariant paid >= 0
}
// Per-person certificate lifecycle. registered has no exit:
// there is no un-dying in the record, only court-ordered new records.
state certificate {
initial: no_record
no_record -> filed
filed -> registered
}
on cert_state(person: String) { return get_status(person) }
on file_certificate(person: String) {
let r = try { transition(person, "filed") }
if r.error != () { return map("ok", false, "reason", "{r.error}") }
return map("ok", true, "person", person)
}
on register_death(person: String) {
if cert_state(person) != "filed" {
return map("ok", false, "reason", "no filed certificate for {person}")
}
let prior = deaths.get(person) ?? 0
// THE WALL: county B registering what county A already registered
// is refused by the ledger itself.
let w = try { deaths.set(person, prior + 1) }
if w.error != () {
return map("ok", false, "reason", "{person} already registered deceased")
}
transition(person, "registered")
return map("ok", true, "person", person)
}
on pay_benefit(person: String, amount: Int) {
if is_deceased(person) {
return map("ok", false, "reason", "{person} is deceased — payment stopped")
}
if amount <= 0 { return map("ok", false, "reason", "amount must be positive") }
let sofar = paid.get(person) ?? 0
paid.set(person, sofar + amount)
return map("ok", true, "person", person, "total", sofar + amount)
}
on is_deceased(person: String) { return (deaths.get(person) ?? 0) == 1 }
on paid_total(person: String) { return paid.get(person) ?? 0 }
}
cell test VitalRecordsTests {
rules {
// benefits flow while the person is alive
assert pay_benefit("ada", 1200).ok == true
assert pay_benefit("ada", 1200).ok == true
assert paid_total("ada") == 2400
// death is registered exactly once
assert register_death("ada").ok == false // no certificate filed
assert file_certificate("ada").ok == true
assert register_death("ada").ok == true
assert register_death("ada").ok == false // county B, refused
assert_fails deaths.set("ada", 2) // unrepresentable
assert_fails transition("ada", "filed") // no resurrection edit
assert_fails transition("ada", "no_record")
// the moment the count is 1, the checks stop
assert pay_benefit("ada", 1200).ok == false
assert paid_total("ada") == 2400 // not a cent more
// a living person is untouched by ada's record
assert is_deceased("bob") == false
assert pay_benefit("bob", 800).ok == true
// and a clerk cannot mark bob dead without a filed certificate
assert register_death("bob").ok == false
assert is_deceased("bob") == false
}
}What the toolchain says
$ soma check vital_records.cell
✓ All checks passed.$ soma test vital_records.cell
test VitalRecordsTests ...
✓ assert pay_benefit("ada", 1200).ok == true
✓ assert pay_benefit("ada", 1200).ok == true
✓ assert paid_total("ada") == 2400
✓ assert register_death("ada").ok == false
✓ assert file_certificate("ada").ok == true
✓ assert register_death("ada").ok == true
✓ assert register_death("ada").ok == false
✓ assert_fails deaths.set("ada", 2) — raised memory invariant violated on 'deaths': deaths >= 0 && deaths <= 1 — rejected write of 2 (key "ada"); the slot is unchanged
✓ assert_fails transition("ada", "filed") — raised invalid transition: registered → filed. Current state: 'registered'. Valid targets: []
✓ assert_fails transition("ada", "no_record") — raised invalid transition: registered → no_record. Current state: 'registered'. Valid targets: []
✓ assert pay_benefit("ada", 1200).ok == false
✓ assert paid_total("ada") == 2400
✓ assert is_deceased("bob") == false
✓ assert pay_benefit("bob", 800).ok == true
✓ assert register_death("bob").ok == false
✓ assert is_deceased("bob") == false
16 tests: 16 passed, 0 failed$ soma verify vital_records.cell
Verifying vital_records.cell...
State machine 'certificate': 3 states, initial 'no_record'
States: [filed, no_record, registered]
✓ 3 states, 2 transitions
✓ all states reachable from 'no_record'
✓ terminal states: [registered]
✓ no deadlocks
✓ liveness: every state can eventually reach a terminal state
✓ think-isolated: CTL safety properties hold regardless of LLM output (2 handlers, 2 literal transitions, 0 dynamic)
✓ termination: all 6 handlers structurally terminate
✓ refinement: handler `file_certificate` ⟶ {filed}
✓ refinement: handler `register_death` ⟶ {registered}
· transition sources: `file_certificate`, `register_death` call transition(id, target) without declaring the source — the runtime refuses a move the graph forbids, but the proof does not see where the handler starts; `transition(id, from, to)` names the edge (checked by `soma check`, refused at run time from any other state)
VitalRecords/invariants:
✓ invariant deaths >= 0 — writer 'register_death' proven by induction (writes prior + 1)
⚠ invariant deaths >= 0 && deaths <= 1 — runtime-checked (computed values): register_death → deaths [deaths <= 1] because `prior + 1` is only known to lie in [1, 2] — narrow it: `require (prior + 1) <= 1 else …`
✓ invariant paid >= 0 — writer 'pay_benefit' proven by induction (writes sofar + amount)
11 passed, 1 warnings, 0 failures
Temporal properties for 'certificate':
✓ deadlock_free — no deadlocks in any reachable state
Temporal: 1 passed, 0 failed
VERIFY OK