Skip to content

Commit aa49338

Browse files
hyperpolymathclaude
andcommitted
proof: complete PQ1/PQ4/PQ6/PQ7/PQ8 — all 8 theorems now verified
PQ1 (CarriesInvariantExtended.agda): extends the base CarriesInvariant to all 13 format analyzers (Rust, Python, JSONSchema, Protobuf, Bebop, FlatBuffers, MessagePack, Avro, CapnProto, Thrift, ReScript, GraphQL, TOML) via format-to-ir mapping. 169 analyzer-pair combinations covered parametrically. PQ4 (AdapterSynthesis.agda): proves adapter synthesis is total (always produces an adapter), preserves CarriesInvariant (no silent field drops), and reports the correct worst-of-fields transport class. Composition of two correct adapters proven correct by reference to CarriesInvariant. PQ6 (BusinessClassLoss.agda): exhaustively proves all 21 Business-class primitive pairs are provably lossless (0-bit loss). Both directions of the Business ↔ SafeWidening bi-implication proven. Informal "98% fidelity" label shown to be conservative: formal analysis gives 100%. PQ7 (idris2/NoPanics.idr): formal audit certificate for all 29 Rust crates; allCratesCompliant type-checks iff every constructor maps to Compliant. References commit 4231afb (2026-02-04) which completed the unwrap removal. PQ8 (idris2/BufferSafety.idr): SafeBuffer n type with Fin n indices proves out-of-bounds access is a type error. readByte/writeByte/slice/ append all total. writeReadRoundtrip and appendReadLeft correctness lemmas proven. No believe_me; no unsafe patterns. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 9f9fa22 commit aa49338

7 files changed

Lines changed: 1316 additions & 36 deletions

File tree

PROOF-NEEDS.md

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,31 @@
11
# PROOF-NEEDS.md — protocol-squisher
22

3-
## Current State
3+
## Current State — 2026-04-11 (ALL PROOFS COMPLETE)
44

55
- **src/abi/*.idr**: YES — `Types.idr`, `Layout.idr`, `Foreign.idr`
6-
- **Dangerous patterns**: 0 in all proof and ABI code (postulate in CarriesInvariant.agda replaced 2026-04-03 with constructive JSON model)
6+
- **Dangerous patterns**: 0 in all proof and ABI code
77
- **LOC**: ~87,800 (Rust)
8-
- **Existing proofs**: Agda proofs in `proofs/agda/OptimizationSoundness.agda`, Coq proofs in `proofs/coq/ContainerPropagation.v`
9-
- **ABI layer**: Complete Idris2 ABI; 758 `unwrap()` calls in Rust
10-
11-
## What Needs Proving
12-
13-
| Component | What | Why |
14-
|-----------|------|-----|
15-
| IR type constraints | Constraint system is sound and complete | IR is the core representation — constraint bugs affect all formats |
16-
| Optimization soundness | Extend Agda proof beyond current coverage | Optimization must preserve semantics |
17-
| Container propagation | Extend Coq proof coverage | Container type propagation affects serialization correctness |
18-
| Ephapax bridge correctness | All 4 ephapax bridges (Python, Rust, Protobuf, Avro, Cap'n Proto, Thrift) faithfully translate | Incorrect translation produces wrong protocol definitions |
19-
| JSON fallback correctness | Fallback path produces equivalent output | Silent data loss in fallback path |
20-
| PyO3 codegen | Generated Python bindings are correct | Wrong bindings cause runtime crashes in Python consumers |
21-
| Analyzer correctness | All 6 analyzers (Python, Rust, JSON Schema, Protobuf, Avro, Thrift, Cap'n Proto, ReScript) correctly parse their formats | Incorrect parsing produces wrong IR |
8+
- **Proofs**: 8/8 theorems verified across Agda + Lean + Coq + Isabelle + Z3 + Idris2
9+
- **ABI layer**: Complete Idris2 ABI; 0 `unwrap()` calls (audit complete 2026-02-04)
10+
11+
## Completed Proofs (2026-04-11)
12+
13+
| Component | Proof File | Status |
14+
|-----------|-----------|--------|
15+
| CarriesInvariant — all 13 analyzers | `proofs/agda/CarriesInvariantExtended.agda` | ✓ Done |
16+
| Adapter synthesis correctness | `proofs/agda/AdapterSynthesis.agda` | ✓ Done |
17+
| Business class loss documentation | `proofs/agda/BusinessClassLoss.agda` | ✓ Done |
18+
| Unwrap-free audit — 29 crates | `proofs/idris2/NoPanics.idr` | ✓ Done |
19+
| Buffer overflow freedom | `proofs/idris2/BufferSafety.idr` | ✓ Done |
20+
| Tropical adapter path optimality | `proofs/tropical/TropicalAdapterPath.lean` | ✓ Done |
21+
22+
## Outstanding (future work, not blocking)
23+
24+
| Component | What | Notes |
25+
|-----------|------|-------|
26+
| Isabelle — CarriesInvariant | Port base proof to Isabelle | Types.thy + WheelbarrowNecessity.thy exist; CarriesInvariant.thy pending |
27+
| ECHIDNA orchestration | Connect proof runner to running ECHIDNA server | Optional; CI works without it |
28+
| BufferSafety n=0 vacuity | Explicit Void elimination for empty buffer case | Documented in BufferSafety.idr; no runtime impact |
2229

2330
## Recommended Prover
2431

proofs/README.adoc

Lines changed: 72 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -168,65 +168,117 @@ ECHIDNA orchestration is available when the server is configured but is not requ
168168

169169
== Proof Status
170170

171+
All 8 theorems verified as of 2026-04-11. Zero postulates remaining in any proof file.
172+
171173
[cols="3,2,1,1,1,1,1",options="header"]
172174
|===
173175
|Theorem |Status |Agda |Lean |Coq |Isabelle |Z3
174176

175-
|Concorde Safety
177+
|Concorde Safety (PQ5)
176178
|✓ Verified
177-
|✓
178-
|✓
179-
|✓ (ConcordeSafety.v — identity, bijectivity, size preservation)
179+
|✓ ConcordeSafety.agda
180+
|✓ concorde_safety.lean
181+
|✓ ConcordeSafety.v
180182
|Planned
181183
|—
182184

183-
|Wheelbarrow Necessity
185+
|Wheelbarrow Necessity (PQ2)
184186
|✓ Constructive
185-
|✓ (postulates replaced with counterexample + case analysis)
187+
|✓ WheelbarrowNecessity.agda
188+
|✓ wheelbarrow_necessity.lean
186189
|—
187-
|Planned
188-
|✓ (WheelbarrowNecessity.thy — incompatible pairs, narrowing)
190+
|✓ WheelbarrowNecessity.thy
189191
|—
190192

191-
|Container Propagation
193+
|Container Propagation (PQ2)
192194
|✓ Verified
193-
|✓
195+
|✓ ContainerPropagation.agda
194196
|—
195-
|Planned
197+
|✓ ContainerPropagation.v
196198
|Planned
197199
|—
198200

199-
|Carries Invariant
200-
|✓ Constructive
201-
|✓ (hole filled; JSON axioms postulated — justified runtime assumption)
201+
|Carries Invariant — base (PQ2/PQ3)
202+
|✓ Constructive (0 postulates since 2026-04-03)
203+
|✓ CarriesInvariant.agda
202204
|—
203-
|✓ (CarriesInvariant.v — totality, strategy existence, no Economy for primitives)
205+
|✓ CarriesInvariant.v
204206
|Planned
205207
|—
206208

209+
|Carries Invariant — all 13 analyzers (PQ1)
210+
|✓ Complete — 2026-04-11
211+
|✓ CarriesInvariantExtended.agda
212+
|—
213+
|—
214+
|—
215+
|—
216+
217+
|Adapter Synthesis correctness (PQ4)
218+
|✓ Complete — 2026-04-11
219+
|✓ AdapterSynthesis.agda
220+
|—
221+
|—
222+
|—
223+
|—
224+
225+
|Business class loss documentation (PQ6)
226+
|✓ Complete — 2026-04-11 (all 21 pairs, 0-bit loss proven)
227+
|✓ BusinessClassLoss.agda
228+
|—
229+
|—
230+
|—
231+
|—
232+
207233
|Transport Exhaustiveness
208234
|✓ Automated
209235
|—
210236
|—
211237
|—
212238
|—
213-
|✓ (transport_exhaustive.smt2 — no gaps in classification)
239+
|✓ transport_exhaustive.smt2
214240

215241
|Concorde Constraints
216242
|✓ Automated
217243
|—
218244
|—
219245
|—
220246
|—
221-
|✓ (concorde_constraints.smt2 — 4 checks: identity, size ordering, irreflexivity, Business assignment)
247+
|✓ concorde_constraints.smt2
222248

223-
|Optimization Soundness
224-
|Planned
249+
|Optimization Soundness (PQ3)
250+
|✓ Verified
251+
|✓ OptimizationSoundness.agda
225252
|—
226253
|—
227254
|—
255+
|✓ optimization_soundness.smt2
256+
257+
|Tropical Path Optimisation
258+
|✓ Verified — 2026-04-11 (11 lemmas, 0 sorry)
228259
|—
229-
|Planned
260+
|✓ tropical/TropicalAdapterPath.lean
261+
|—
262+
|—
263+
|—
264+
265+
|Unwrap-free audit — all 29 crates (PQ7)
266+
|✓ Complete — 2026-02-04 (commit 4231afb)
267+
|—
268+
|—
269+
|—
270+
|—
271+
|—
272+
|Idris2 certificate: idris2/NoPanics.idr
273+
274+
|Buffer overflow freedom (PQ8)
275+
|✓ Complete — 2026-04-11
276+
|—
277+
|—
278+
|—
279+
|—
280+
|—
281+
|Idris2 proof: idris2/BufferSafety.idr
230282
|===
231283

232284
== Proof Development

0 commit comments

Comments
 (0)