Commit 47239ed
committed
Fix Idris2 ABI proofs to genuinely compile and verify (0.7.0)
The src/interface/abi ABI was scaffolded from a template and never
compiler-checked. This makes all three modules plus a new Proofs module
build cleanly under Idris2 0.7.0 with zero errors and zero warnings,
using only genuine, machine-checked proofs (no believe_me / postulate /
holes / assert_total).
Types.idr:
- thisPlatform: replace unsupported %runElab (no ElabReflection) with a
plain value (Linux).
- DecEq SignatureAlgorithm / HashAlgorithm / AttestationResult: replace
the non-compiling "decEq _ _ = No absurd" catch-all with explicit
off-diagonal cases (No (\case Refl impossible)) for every distinct pair.
- createHandle: solve the {auto 0 nonNull : So (ptr /= 0)} obligation via
Data.So.choose instead of leaving it unsolved.
- chainLength: define structurally (the index n is erased and was not
accessible).
- cSizeOf / cAlignOf: drop the unmatchable CInt _/CSize _ clauses (type-
function applications cannot be pattern-matched; the primitive Bits32/
Bits64 cases already cover them).
- EnvelopeHeader._pad: rename to padField (Idris record fields may not
start with underscore).
Layout.idr:
- paddingFor: use Data.Nat.minus (Nat has no Neg) instead of (-).
- Concrete StructLayout values: supply the erased auto-implicit proofs
explicitly ({sizeCorrect = Oh} and {aligned = DivideBy k Refl} with
totalSize = k * alignment).
- verifyLayout: build the StructLayout with real proofs; add a sound
decDivides : (n m : Nat) -> Maybe (Divides n m) (q = div m n; DivideBy q
only when decEq m (q*n) holds).
- checkCABI: implement via a sound decFieldsAligned over the field Vect
(decDivides on each field's alignment vs offset); return Right/Left.
- envelope/provenance CABI proofs: build FieldsAligned witnesses directly
(qualify the layout name as Layout.* so it is not auto-bound implicit).
- offsetInBounds: change the unsound universally-quantified So return type
to Maybe (So ...) via choose.
- Remove alignUpCorrect (its DivideBy ... Refl body was unprovable by Refl
and its (align > 0) used Bool where a Type was required).
- Rename signature-level Vect n Field binders to Vect k Field to avoid
shadowing StructLayout's implicit n.
Proofs.idr (new module, real theorems):
- C-ABI compliance for every concrete layout (envelopeHeaderCompliant,
digestBufferCompliant, ed25519SignatureCompliant, ed448SignatureCompliant,
provenanceEntryCompliant) via direct DivideBy witnesses per field.
- Result-code encoding pinned: okIsZero, signatureInvalidIsFive,
okNotChainBroken.
Build wiring:
- Move flat src/interface/abi/{Types,Layout,Foreign}.idr to the nested
A2mliser/ABI/ layout matching the A2mliser.ABI.* namespaces.
- Add src/interface/abi/a2mliser-abi.ipkg.
- .gitignore: add **/build/, *.ttc, *.ttm; do not commit the build dir.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DF9CcCuL4YJoqs26eHsYiA1 parent 21906d2 commit 47239ed
6 files changed
Lines changed: 282 additions & 41 deletions
File tree
- src/interface/abi
- A2mliser/ABI
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
21 | 26 | | |
22 | 27 | | |
23 | 28 | | |
| |||
File renamed without changes.
Lines changed: 84 additions & 26 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
| 19 | + | |
18 | 20 | | |
19 | 21 | | |
20 | 22 | | |
| |||
28 | 30 | | |
29 | 31 | | |
30 | 32 | | |
31 | | - | |
| 33 | + | |
32 | 34 | | |
33 | 35 | | |
34 | 36 | | |
| |||
41 | 43 | | |
42 | 44 | | |
43 | 45 | | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | 46 | | |
50 | 47 | | |
51 | 48 | | |
| |||
77 | 74 | | |
78 | 75 | | |
79 | 76 | | |
80 | | - | |
| 77 | + | |
81 | 78 | | |
82 | 79 | | |
83 | 80 | | |
| |||
86 | 83 | | |
87 | 84 | | |
88 | 85 | | |
89 | | - | |
| 86 | + | |
90 | 87 | | |
91 | 88 | | |
92 | 89 | | |
93 | | - | |
| 90 | + | |
94 | 91 | | |
95 | 92 | | |
96 | 93 | | |
97 | 94 | | |
98 | | - | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
99 | 108 | | |
100 | | - | |
| 109 | + | |
101 | 110 | | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
106 | 118 | | |
107 | 119 | | |
108 | 120 | | |
| |||
135 | 147 | | |
136 | 148 | | |
137 | 149 | | |
| 150 | + | |
| 151 | + | |
138 | 152 | | |
139 | 153 | | |
140 | 154 | | |
| |||
150 | 164 | | |
151 | 165 | | |
152 | 166 | | |
| 167 | + | |
| 168 | + | |
153 | 169 | | |
154 | 170 | | |
155 | 171 | | |
| |||
164 | 180 | | |
165 | 181 | | |
166 | 182 | | |
| 183 | + | |
| 184 | + | |
167 | 185 | | |
168 | 186 | | |
169 | 187 | | |
| |||
174 | 192 | | |
175 | 193 | | |
176 | 194 | | |
| 195 | + | |
| 196 | + | |
177 | 197 | | |
178 | 198 | | |
179 | 199 | | |
| |||
201 | 221 | | |
202 | 222 | | |
203 | 223 | | |
| 224 | + | |
| 225 | + | |
204 | 226 | | |
205 | 227 | | |
206 | 228 | | |
| |||
234 | 256 | | |
235 | 257 | | |
236 | 258 | | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
237 | 272 | | |
238 | 273 | | |
239 | 274 | | |
240 | 275 | | |
241 | | - | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
242 | 279 | | |
243 | | - | |
| 280 | + | |
| 281 | + | |
244 | 282 | | |
245 | | - | |
246 | | - | |
247 | | - | |
248 | | - | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
249 | 296 | | |
250 | | - | |
251 | | - | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
252 | 305 | | |
253 | 306 | | |
254 | 307 | | |
| |||
262 | 315 | | |
263 | 316 | | |
264 | 317 | | |
265 | | - | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
266 | 321 | | |
267 | | - | |
268 | | - | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 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 | + | |
0 commit comments