Commit 66cfd79
committed
Fix Idris2 ABI proofs to genuinely compile and verify under 0.7.0
Make the src/interface/abi formal proofs compile cleanly (zero errors,
zero warnings) under Idris2 0.7.0 and add machine-checked theorems.
Buildability / layout:
- Move flat Types/Layout/Foreign.idr into nested namespace dirs
src/interface/abi/Affinescriptiser/ABI/ so file paths match the
Affinescriptiser.ABI.* module namespaces.
- Add src/interface/abi/affinescriptiser-abi.ipkg packaging all four modules.
- .gitignore: add **/build/, *.ttc, *.ttm; do not commit the idris build dir.
Types.idr:
- thisPlatform: replace %runElab (ElabReflection not enabled) with plain WASM.
- DecEq Result: replace the non-compiling "No absurd" catch-all with explicit
off-diagonal cases (No (\case Refl impossible)) for every distinct pair.
- createHandle / trackResource: solve the {auto 0 nonNull : So (ptr /= 0)}
obligation via choose (ptr /= 0) instead of leaving it unsolved.
- Add missing Eq Linearity instance (used by the Verify helpers).
- CPtr: drop the non-existent Bits (ptrSize p) family; map platforms to the
concrete Bits32/Bits64 primitives.
- cSizeOf / cAlignOf: drop the unsound type-level matches on (CInt _)/(CSize _)
(a reducible type-application cannot be pattern-matched, and it caused a
type-checker memory blowup); keep the concrete Bits32/Bits64/Double clauses.
- WASMOffsetValid: compare the 4GiB bound at Integer (via natToInteger) so the
4294967296 literal is not normalised to a unary Nat (which OOM-kills the
checker); the proposition is unchanged.
Layout.idr:
- paddingFor: use minus (Data.Nat) instead of Nat subtraction with (-).
- Add sound decDivides : (n m : Nat) -> Maybe (Divides n m) and
decFieldsAligned, then implement checkCABI via decFieldsAligned instead of
the ?fieldsAlignedProof hole.
- Replace the bogus Refl-based alignUpCorrect (and its Bool-as-type hypothesis)
with alignUpDivides, deciding divisibility honestly via decDivides.
- offsetInBounds: change the unsound universally-quantified So return type to
Maybe (So ...) implemented via choose.
- verifyLayout: supply the StructLayout erased proofs (sizeCorrect via choose,
aligned via decDivides) instead of omitting them.
- trackedFDLayout: supply {sizeCorrect = Oh} and {aligned = DivideBy 5 Refl}
(totalSize 20 = 5 * 4).
- WASM memory-magnitude constants (wasmPageSize/wasmMaxPages/wasmMaxMemory) are
Integer so the 4GiB product does not unary-normalise; FitsInPage/TableInBounds
compare via natToInteger.
- Rename the StructLayout-shadowed Vect length variable in standalone
signatures to k; qualify Layout.wasmPageSize/Layout.wasmMaxMemory to avoid
implicit-bind warnings.
Proofs.idr (new): machine-checked theorems, all marked export:
- trackedFDCompliant : CABICompliant Layout.trackedFDLayout, built directly
with one DivideBy per field (offsets 0,4,8,12,16 = k*4).
- okIsZero / affineViolationIsFive / resourceLeakIsSix pin the result-code
encoding by Refl.
- mutexIsLinear / fdIsAffine pin the default-linearity policy.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DF9CcCuL4YJoqs26eHsYiA1 parent cca6b7e commit 66cfd79
6 files changed
Lines changed: 251 additions & 42 deletions
File tree
- src/interface/abi
- Affinescriptiser/ABI
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
21 | 26 | | |
22 | 27 | | |
23 | 28 | | |
| |||
File renamed without changes.
Lines changed: 68 additions & 22 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
| 20 | + | |
19 | 21 | | |
20 | 22 | | |
21 | 23 | | |
| |||
29 | 31 | | |
30 | 32 | | |
31 | 33 | | |
32 | | - | |
| 34 | + | |
33 | 35 | | |
34 | 36 | | |
35 | 37 | | |
36 | 38 | | |
37 | 39 | | |
38 | 40 | | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
39 | 57 | | |
40 | 58 | | |
41 | 59 | | |
42 | 60 | | |
43 | 61 | | |
44 | 62 | | |
45 | | - | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
46 | 68 | | |
47 | | - | |
48 | | - | |
49 | | - | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
50 | 72 | | |
51 | 73 | | |
52 | 74 | | |
53 | 75 | | |
54 | 76 | | |
55 | | - | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
56 | 81 | | |
57 | | - | |
| 82 | + | |
58 | 83 | | |
59 | 84 | | |
60 | 85 | | |
61 | 86 | | |
62 | | - | |
| 87 | + | |
63 | 88 | | |
64 | 89 | | |
65 | | - | |
| 90 | + | |
66 | 91 | | |
67 | | - | |
| 92 | + | |
68 | 93 | | |
69 | 94 | | |
70 | 95 | | |
| |||
151 | 176 | | |
152 | 177 | | |
153 | 178 | | |
154 | | - | |
| 179 | + | |
155 | 180 | | |
156 | 181 | | |
157 | 182 | | |
| |||
160 | 185 | | |
161 | 186 | | |
162 | 187 | | |
163 | | - | |
| 188 | + | |
164 | 189 | | |
165 | 190 | | |
166 | 191 | | |
167 | | - | |
| 192 | + | |
168 | 193 | | |
169 | 194 | | |
170 | 195 | | |
171 | 196 | | |
172 | 197 | | |
173 | 198 | | |
174 | | - | |
| 199 | + | |
175 | 200 | | |
176 | 201 | | |
177 | | - | |
178 | | - | |
179 | | - | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
180 | 207 | | |
181 | 208 | | |
182 | 209 | | |
| |||
185 | 212 | | |
186 | 213 | | |
187 | 214 | | |
188 | | - | |
| 215 | + | |
189 | 216 | | |
190 | 217 | | |
191 | 218 | | |
| |||
208 | 235 | | |
209 | 236 | | |
210 | 237 | | |
211 | | - | |
| 238 | + | |
212 | 239 | | |
213 | 240 | | |
214 | 241 | | |
| |||
230 | 257 | | |
231 | 258 | | |
232 | 259 | | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
233 | 272 | | |
234 | 273 | | |
235 | 274 | | |
236 | 275 | | |
237 | | - | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
238 | 279 | | |
239 | 280 | | |
240 | 281 | | |
| |||
254 | 295 | | |
255 | 296 | | |
256 | 297 | | |
| 298 | + | |
| 299 | + | |
257 | 300 | | |
258 | 301 | | |
259 | 302 | | |
| |||
269 | 312 | | |
270 | 313 | | |
271 | 314 | | |
272 | | - | |
273 | | - | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 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 | + | |
0 commit comments