Commit b92e991
fix(idris): rebuild logSafeBounded proof for Idris2 0.8.0
The pre-existing `logSafeBounded` proof in SafeAPIKey.idr did not
type-check on the bundled Idris2 0.8.0. Audit-by-build (not by reading
PROOF-NEEDS.md) was the only way to spot this. Three concrete defects,
each fixed independently here:
1. **Removed local `plusLteMonotone` helper** which wrapped
`lteTransitive (plusLteMonotoneRight _ lmn) (plusLteMonotoneLeft _
lpq)`. Idris2 0.8.0's `Data.Nat.plusLteMonotone` is exactly the
shape we want (`LTE m n -> LTE p q -> LTE (m + p) (n + q)`), so the
local wrapper is redundant. The wrapper called `lteTransitive` (no
longer in stdlib — it's now `Control.Relation.transitive` and
ambiguous in this import context) and passed wildcard arguments
that didn't match the current `plusLteMonotoneRight` /
`plusLteMonotoneLeft` signatures (`(p,q,r : Nat) -> LTE q r ->
LTE (q+p) (r+p)`). Using stdlib directly sidesteps all of it.
2. **Lifted both branches out of the `with`-block.** Inside the
with-block, the elaborator does not reduce `length "***"` (or
`length "..."`) at type level — the goal is exposed as
`LTE (integerToNat (prim__cast_IntInteger (prim__strLength
(if ...)))) 11` with the `if`-arm unreduced. Outside the
with-block the same lemmas type-check via `Refl`-equivalent
computation. The fix: extract `logSafeBoundedShort` and
`logSafeBoundedLong` as private helpers and let the with-block
just dispatch.
3. **Right-associated the long-path proof.** `(++)` is right-
associative in Idris (`a ++ b ++ c = a ++ (b ++ c)`), but the
original proof bound `(p1 ++ "...") ++ p3` (left-associative)
while the with-block's `False`-branch rewrites the goal to
`substr 0 4 s ++ ("..." ++ substr (...) 4 s)`. The new proof
composes `step23 (length "..." + length (substr ...) ≤ 3 + 4)`
then `step123 (length (substr 0 4 s) + length (...) ≤ 4 + 7)`,
producing exactly the right-associated form.
Also fixed two bound-name typos in `toLogSafeShortEq` and
`toLogSafeLongEq` where the outer pattern discarded the `prf` argument
that the `False`/`True` branch then referenced (`absurd prf` against
an undefined `prf`).
Build verification (per-module `--check`, full ipkg --build hangs on
this machine — see PR #108 notes):
Boj.SafetyLemmas green
Boj.SafeAPIKey green (this PR)
Boj.Safety green
Boj.APIContractCoverage green
Boj.CartridgeDispatch green
Boj.Catalogue green
Boj.CredentialIsolation green
Boj.Federation green
Boj.SafeCORS green
Boj.SafeHTTP green
Boj.SafePromptInjection green
Boj.SafeWebSocket green
Stacked on PR #108 (`feat/item11-proof-debt-honest-framing`) because
this proof depends on SafetyLemmas's comma-fix; when #108 merges, this
auto-rebases to main.
No new axioms introduced. The 5-class-(J) framing from PR #108 is
preserved.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 0221f4e commit b92e991
1 file changed
Lines changed: 59 additions & 21 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
145 | 145 | | |
146 | 146 | | |
147 | 147 | | |
148 | | - | |
| 148 | + | |
149 | 149 | | |
150 | 150 | | |
151 | 151 | | |
152 | 152 | | |
153 | 153 | | |
154 | 154 | | |
155 | 155 | | |
156 | | - | |
| 156 | + | |
157 | 157 | | |
158 | 158 | | |
159 | 159 | | |
160 | | - | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
161 | 166 | | |
162 | | - | |
163 | | - | |
164 | | - | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
165 | 216 | | |
166 | 217 | | |
167 | 218 | | |
| |||
173 | 224 | | |
174 | 225 | | |
175 | 226 | | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | | - | |
183 | | - | |
184 | | - | |
185 | | - | |
186 | | - | |
187 | | - | |
188 | | - | |
189 | | - | |
190 | | - | |
| 227 | + | |
| 228 | + | |
191 | 229 | | |
192 | 230 | | |
193 | 231 | | |
| |||
0 commit comments