Commit 8638068
feat(proof): backend-assurance harness for prim__strAppend (3/4) + prim__strSubstr (4/4) (#139)
## Summary
Continues the backend-assurance campaign for epic #87 Tier C. Slice
1/4 (`prim__eqChar`, covering `charEqSound` + `charEqSym`) landed via
#129. This PR bundles **slices 3/4 and 4/4** per explicit owner
direction — both `prim__strAppend` and `prim__strSubstr` are
length-arithmetic on opaque strings and share the same Chez-vs-BEAM
trusted-extraction argument shape, so a combined slice trades the
nominal "one PR per primitive" rule for review ergonomics.
Slice 2/4 (`prim__strToCharList`, covering `unpackLength`) remains
pending; ships as a follow-on PR.
Discharges **external evidence** for two class-(J) `believe_me`
axioms in `src/abi/Boj/SafetyLemmas.idr`:
| Site | Axiom | Type |
|------|-------|------|
| `:226` | `appendLengthSum` | `length (s ++ t) = length s + length t` |
| `:233` | `substrLengthBound` | `LTE (length (substr start len s)) len`
|
The in-language proof does **not** change. The `%unsafe` /
`believe_me` sites stay in source. The harness shrinks the trusted
base from "we trust the backend" to "we read the lowering and
randomly tested the operation against the property".
## Artefacts (matching the #129 template)
- `elixir/test/backend_assurance/prim_str_append_test.exs` — BEAM
property tests over the legal codepoint space (surrogates
excluded). 4 properties + 1 boundary table covering all four UTF-8
encoding widths (ASCII / Latin-1 / CJK / astral).
- `elixir/test/backend_assurance/prim_str_substr_test.exs` — BEAM
property tests for the length bound. 4 properties + boundary
table covering len=0, start-past-end, full-string slice tightness,
and multi-byte codepoint slices.
- `docs/backend-assurance/prim__strAppend.md` — trusted-extraction
prose. Chez argued from R6RS §6.7 (string model) + §11.12
(`string-append`); BEAM argued from UTF-8 prefix-free codepoint
counting via Elixir `<>` + `String.length/1`.
- `docs/backend-assurance/prim__strSubstr.md` — trusted-extraction
prose. Chez argued from R6RS §11.12 (`substring`) + codegen clamp;
BEAM argued from `String.slice/3` codepoint-counting clamp.
- `docs/backend-assurance/README.md` — coverage-table rows flipped
from _pending_ for both primitives.
- `PROOF-NEEDS.md` — backend-assurance evidence column filled.
Class column updated to **J ✓** marker for the externally-
validated rows (a bare **J** indicates harness not yet landed).
Audit-table rationales updated to note the harness; remaining-
axiomatic-surface justifications reworded; standing-note
"primitives landed" line bumped to reflect 3/4 done.
The existing CI workflow `.github/workflows/backend-assurance.yml`
already path-filters on `elixir/test/backend_assurance/**` and
`docs/backend-assurance/**`, so it picks up the new test modules
automatically — no workflow change in this PR.
## Constraints honoured
Per `docs/backend-assurance/README.md`:
- **No new `believe_me`.** External evidence only.
- **No in-language discharge.** Ruled out by 2026-05-18 audit.
- **Two backends.** Chez argued from R6RS; BEAM exercised by tests.
- **Honest framing.** Surrogates excluded; normalisation out of
scope and documented; negative `len`/`start` ruled out by upstream
`Nat` typing.
## Test plan
- [x] Elixir parse-check on both new test files (syntax-only, via
`Code.string_to_quoted!`)
- [x] BEAM operation smoke on boundary strings — `String.length` /
`String.slice/3` direct, outside the test harness. 25
`appendLengthSum` cases + 80 `substrLengthBound` cases all hold.
- [ ] CI backend-assurance workflow: BEAM property tests green
- [ ] CI: existing workflows unaffected (no path-filter collisions)
> **Note:** this session could not run `mix test --only
backend_assurance`
> locally — the asdf `elixir 1.18.4-otp-25` install on the work
> machine is empty (only `.mix` archives, no binary), and system
> `elixir 1.14` fails the project's `~> 1.15` requirement. Same gap
> pattern slice 1/4 followed; CI is the gate.
## Heads-up for the reviewer
`PROOF-NEEDS.md` now uses a **J ✓** marker on the audit-table
`Class` column for the three externally-validated axioms
(`charEqSound`, `charEqSym` from #129; `appendLengthSum`,
`substrLengthBound` from this PR). The fifth axiom (`unpackLength`)
remains bare **J** until slice 2/4 lands. The wording change is
deliberate per owner direction — the underlying classification is
still class (J); the marker reflects external validation.
Refs #87 (Tier C backend-assurance campaign).
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 1a4e12e commit 8638068
6 files changed
Lines changed: 552 additions & 15 deletions
File tree
- docs/backend-assurance
- elixir/test/backend_assurance
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
42 | 51 | | |
43 | 52 | | |
44 | 53 | | |
| |||
74 | 83 | | |
75 | 84 | | |
76 | 85 | | |
77 | | - | |
78 | | - | |
| 86 | + | |
| 87 | + | |
79 | 88 | | |
80 | | - | |
81 | | - | |
| 89 | + | |
| 90 | + | |
82 | 91 | | |
83 | 92 | | |
84 | 93 | | |
| |||
105 | 114 | | |
106 | 115 | | |
107 | 116 | | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
112 | 122 | | |
113 | 123 | | |
114 | 124 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | | - | |
32 | | - | |
| 31 | + | |
| 32 | + | |
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
0 commit comments