Skip to content

Commit c94e38a

Browse files
committed
Fix DyadicEchoBridge universe error and wire in Dyadic
Three defects kept this file from typechecking: 1. Lines 29-32, 42: the body `Echo (λ _ → ⊤) ⊤` conflated the unit *type* (⊤ : Set) with the unit *value* (tt : ⊤). Echo expects a function A → B and a value y : B, not a function into Set. Changed to `Echo {A = ⊤} (λ _ → tt) tt` — pinning A explicitly because the inferred source type is not constrained anywhere else. 2. ProtocolProvenance pattern-matched on a SessionEcho input whose type depends on the Session constructor. The End case has type ⊤, not Echo, so the single-clause catch-all "ProtocolProvenance echo = echo" could not typecheck. Split into five clauses, synthesising a canonical Echo in the End case via echo-intro. 3. ProvenancePreservation returned the left echo verbatim, but its type was SessionEcho at (S1 >>= S2) rather than at S1. Pattern- match on S1 and synthesise a fresh canonical echo at the concatenated head; pass the right-hand echo through when S1 = End. Also wired Dyadic + DyadicEchoBridge into All.agda so they join the verified suite and cannot silently regress again. https://claude.ai/code/session_01JRLz84fAaWvRBKyXuc4tyK
1 parent 9b8695d commit c94e38a

2 files changed

Lines changed: 28 additions & 13 deletions

File tree

proofs/agda/All.agda

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ open import EchoCategorical
2222
open import EchoScope
2323
open import EchoOrdinal
2424
open import EchoJanusBridge
25+
open import Dyadic
26+
open import DyadicEchoBridge
2527

2628
open import Ordinal.Base
2729
open import Ordinal.Closure

proofs/agda/DyadicEchoBridge.agda

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,25 @@ SessionAsFunction {p} (Select S1 S2) q = SessionAsFunction S1 q ⊎ SessionAsFun
2626
-- Simplified echo over session types (avoiding universe issues)
2727
SessionEcho : {p} (q : Party) Session p Set
2828
SessionEcho q End =
29-
SessionEcho q (Send A S) = Echo (λ _ ⊤) ⊤
30-
SessionEcho q (Recv A S) = Echo (λ _ ⊤) ⊤
31-
SessionEcho q (Choice S1 S2) = Echo (λ _ ⊤) ⊤
32-
SessionEcho q (Select S1 S2) = Echo (λ _ ⊤) ⊤
29+
SessionEcho q (Send A S) = Echo {A = ⊤} (λ _ tt) tt
30+
SessionEcho q (Recv A S) = Echo {A = ⊤} (λ _ tt) tt
31+
SessionEcho q (Choice S1 S2) = Echo {A = ⊤} (λ _ tt) tt
32+
SessionEcho q (Select S1 S2) = Echo {A = ⊤} (λ _ tt) tt
3333

3434
-- Example: Echo over Alice's send protocol
3535
AliceSendEcho : SessionEcho Alice AliceSendsUnit
36-
AliceSendEcho = echo-intro (λ _ tt) tt
37-
38-
-- Protocol provenance: echo retains session structure
39-
ProtocolProvenance : {p} {S : Session p} {q : Party}
40-
SessionEcho q S Echo (λ _ ⊤) ⊤
41-
ProtocolProvenance echo = echo
36+
AliceSendEcho = echo-intro {A = ⊤} (λ _ tt) tt
37+
38+
-- Protocol provenance: echo retains session structure. For non-End
39+
-- sessions SessionEcho q S is already Echo {A = ⊤} (λ _ → tt) tt; for End it
40+
-- is ⊤ and we synthesize the canonical echo.
41+
ProtocolProvenance : {p} {S : Session p} {q : Party}
42+
SessionEcho q S Echo {A = ⊤} (λ _ tt) tt
43+
ProtocolProvenance {S = End} _ = echo-intro {A = ⊤} (λ _ tt) tt
44+
ProtocolProvenance {S = Send _ _} echo = echo
45+
ProtocolProvenance {S = Recv _ _} echo = echo
46+
ProtocolProvenance {S = Choice _ _} echo = echo
47+
ProtocolProvenance {S = Select _ _} echo = echo
4248

4349
-- Dyadic echo: session with echo-indexed provenance
4450
DyadicEcho : {p} Session p Set
@@ -50,12 +56,19 @@ AliceSendWithProvenance = Alice , AliceSendEcho
5056

5157
-- Bob's receive protocol with provenance
5258
BobReceiveWithProvenance : DyadicEcho BobReceivesUnit
53-
BobReceiveWithProvenance = Bob , echo-intro (λ _ tt) tt
59+
BobReceiveWithProvenance = Bob , echo-intro {A = ⊤} (λ _ tt) tt
5460

55-
-- Provenance preservation under session concatenation
61+
-- Provenance preservation under session concatenation. We synthesize
62+
-- a fresh echo at the concatenated session, since SessionEcho at a
63+
-- Send/Recv/Choice/Select head is always Echo {A = ⊤} (λ _ → tt) tt and at
64+
-- End it is ⊤.
5665
ProvenancePreservation : {p} {S1 S2 : Session p}
5766
DyadicEcho S1 DyadicEcho S2 DyadicEcho (S1 >>= S2)
58-
ProvenancePreservation (q1 , echo1) (q2 , echo2) = q1 , echo1
67+
ProvenancePreservation {S1 = End} _ (q2 , echo2) = q2 , echo2
68+
ProvenancePreservation {S1 = Send _ _} (q1 , _) _ = q1 , echo-intro {A = ⊤} (λ _ tt) tt
69+
ProvenancePreservation {S1 = Recv _ _} (q1 , _) _ = q1 , echo-intro {A = ⊤} (λ _ tt) tt
70+
ProvenancePreservation {S1 = Choice _ _} (q1 , _) _ = q1 , echo-intro {A = ⊤} (λ _ tt) tt
71+
ProvenancePreservation {S1 = Select _ _} (q1 , _) _ = q1 , echo-intro {A = ⊤} (λ _ tt) tt
5972

6073
-- Echo-safe dyadic protocols: protocols where echoes preserve safety
6174
EchoSafe : {p} Session p Set

0 commit comments

Comments
 (0)