Skip to content

Commit 2829245

Browse files
committed
Add phased Agda scope expansion, coherence bridges, and CI
0 parents  commit 2829245

22 files changed

Lines changed: 1754 additions & 0 deletions

.github/workflows/agda.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Agda
2+
3+
on:
4+
push:
5+
branches:
6+
- "**"
7+
pull_request:
8+
9+
jobs:
10+
check:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v4
15+
16+
- name: Install Agda and standard library
17+
run: |
18+
sudo apt-get update
19+
sudo apt-get install -y agda agda-stdlib
20+
21+
- name: Configure Agda standard library
22+
run: |
23+
STDLIB_LIB="$(find /usr/share -name 'standard-library.agda-lib' | head -n 1)"
24+
if [ -z "$STDLIB_LIB" ]; then
25+
echo "Could not locate standard-library.agda-lib"
26+
exit 1
27+
fi
28+
29+
mkdir -p "$HOME/.agda"
30+
printf '%s\n' "$STDLIB_LIB" > "$HOME/.agda/libraries"
31+
printf '%s\n' "standard-library" > "$HOME/.agda/defaults"
32+
33+
- name: Typecheck full suite
34+
run: agda -i proofs/agda proofs/agda/All.agda

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.agdai

README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# echo-types
2+
3+
Constructive Agda formalization of echo types / fibers:
4+
5+
`Echo f y := Σ (x : A) , (f x ≡ y)`
6+
7+
This repository provides a minimal, explicit development in ordinary intensional dependent type theory (`--safe --without-K`) with:
8+
9+
- fiber introduction (`echo-intro`)
10+
- action on fibers over a fixed base (`map-over`)
11+
- identity law (`map-over-id`)
12+
- composition law (`map-over-comp`)
13+
- action along commuting squares (`map-square`)
14+
15+
## Controlled Scope Broadening
16+
17+
The formal scope is extended in controlled phases:
18+
19+
- Phase A (`proofs/agda/EchoIndexed.agda`): role-indexed echoes `Echoᵢ` with trace-level witness separation.
20+
- Phase B (`proofs/agda/EchoEpistemicResidue.agda`): residue-based epistemic echoes `EchoR` with strict weakening/no-section results.
21+
- Phase C (`proofs/agda/EchoRelational.agda`): relational semantics `Step : S → O → Set` and output fibers `Σ s , Step s o`.
22+
- Phase D (`proofs/agda/EchoCategorical.agda`): slice/fibration packaging over the compiled deterministic and relational layers.
23+
24+
## Build
25+
26+
```bash
27+
cd /var/mnt/eclipse/repos/echo-types
28+
agda -i proofs/agda proofs/agda/Echo.agda
29+
agda -i proofs/agda proofs/agda/All.agda
30+
for f in proofs/agda/*.agda; do agda -i proofs/agda "$f"; done
31+
```

docs/assessment.adoc

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
= Echo Types Assessment (M5)
2+
3+
Date: 2026-04-18
4+
5+
== Binary Conclusion
6+
7+
*Established as distinct concept* (within the current formal scope of this repository).
8+
9+
== Basis for Verdict
10+
11+
The roadmap required three independent criteria for identity beyond raw sigma/fiber syntax.
12+
All three are currently met.
13+
14+
=== 1. Distinct phenomenon isolated
15+
16+
Target phenomenon: *structured loss under non-injective computation*.
17+
18+
Evidence:
19+
20+
* `collapse-non-injective` and `no-section-collapse` in `proofs/agda/EchoCharacteristic.agda`
21+
* `no-section-visible` in `proofs/agda/EchoCharacteristic.agda`
22+
23+
These show outputs can be operationally irreversible while the echo layer remains proof-relevant.
24+
25+
=== 2. Characteristic theorem family exists
26+
27+
Evidence in `proofs/agda/Echo.agda`, `proofs/agda/EchoCharacteristic.agda`,
28+
and `proofs/agda/EchoResidue.agda`:
29+
30+
* echo introduction and transport laws (`echo-intro`, `map-over`, `map-over-id`, `map-over-comp`, `map-square`)
31+
* distinct echoes over same visible value (`echo-true≢echo-false`, `stateA≢stateB`)
32+
* strict weakening to residue plus non-recoverability (`strict-weakening-collapse`, `no-section-collapse-to-residue`)
33+
34+
This is more than definitional unpacking: it exhibits irreversible-but-not-forgetful behavior.
35+
36+
=== 3. Canonical examples succeed
37+
38+
Evidence in `proofs/agda/EchoExamples.agda`:
39+
40+
* sign-loss squaring model (`square9`)
41+
* structured projection with forgotten component (`visible`)
42+
* quotient/collapse representative class behavior (`quot`)
43+
* residue identification under collapse (`collapse-residue-identifies`)
44+
45+
These examples are compiled Agda objects/lemmas, not prose-only claims.
46+
47+
== Scope Note
48+
49+
This verdict is about proof-theoretic identity in ordinary intensional DTT (`--safe --without-K`) as developed here.
50+
It does not claim a completed full categorical semantics formalization yet.

echo-types.agda-lib

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
name: echo-types
2+
include: proofs/agda
3+
depend: standard-library

proofs/agda/All.agda

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{-# OPTIONS --safe --without-K #-}
2+
3+
module All where
4+
5+
open import Echo
6+
open import EchoCharacteristic
7+
open import EchoResidue
8+
open import EchoExamples
9+
10+
open import EchoChoreo
11+
open import EchoEpistemic
12+
open import EchoLinear
13+
open import EchoGraded
14+
open import EchoTropical
15+
16+
open import EchoIndexed
17+
open import EchoEpistemicResidue
18+
open import EchoRelational
19+
open import EchoCategorical
20+
open import EchoScope

proofs/agda/Echo.agda

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
{-# OPTIONS --safe --without-K #-}
2+
3+
module Echo where
4+
5+
open import Level using (Level; _⊔_)
6+
open import Function.Base using (_∘_; id)
7+
open import Data.Product.Base using (Σ; _,_)
8+
open import Relation.Binary.PropositionalEquality using (_≡_; refl; trans; cong)
9+
10+
-- Echo_f(y) := Σ (x : A) , (f x ≡ y)
11+
Echo : {a b} {A : Set a} {B : Set b} (f : A B) B Set (a ⊔ b)
12+
Echo {A = A} f y = Σ A (λ x f x ≡ y)
13+
14+
-- Introduction into own fiber.
15+
echo-intro : {a b} {A : Set a} {B : Set b} (f : A B) (x : A) Echo f (f x)
16+
echo-intro f x = x , refl
17+
18+
-- Morphisms over a fixed codomain B.
19+
MapOver :
20+
{a a' b} {A : Set a} {A' : Set a'} {B : Set b}
21+
(f : A B) (f' : A' B) Set (a ⊔ a' ⊔ b)
22+
MapOver {A = A} {A' = A'} f f' = Σ (A A') (λ u x f' (u x) ≡ f x)
23+
24+
-- Action on fibers over fixed base B.
25+
map-over :
26+
{a a' b} {A : Set a} {A' : Set a'} {B : Set b}
27+
{f : A B} {f' : A' B}
28+
MapOver f f' {y : B} Echo f y Echo f' y
29+
map-over (u , commute) (x , p) = u x , trans (commute x) p
30+
31+
-- Identity law (pointwise on each fiber element).
32+
map-over-id :
33+
{a b} {A : Set a} {B : Set b} {f : A B} {y : B} (e : Echo f y)
34+
map-over (id , (λ x refl)) e ≡ e
35+
map-over-id (x , p) = refl
36+
37+
trans-assoc :
38+
{a} {A : Set a} {x y z w : A}
39+
(p : x ≡ y) (q : y ≡ z) (r : z ≡ w)
40+
trans (trans p q) r ≡ trans p (trans q r)
41+
trans-assoc refl q r = refl
42+
43+
-- Composition law (pointwise on each fiber element).
44+
map-over-comp :
45+
{a a' a'' b}
46+
{A : Set a} {A' : Set a'} {A'' : Set a''} {B : Set b}
47+
{f : A B} {f' : A' B} {f'' : A'' B}
48+
(u1 : A A') (c1 : x f' (u1 x) ≡ f x)
49+
(u2 : A' A'') (c2 : x f'' (u2 x) ≡ f' x)
50+
{y : B} (e : Echo f y)
51+
map-over {f = f} {f' = f''}
52+
(u2 ∘ u1 , (λ x trans (c2 (u1 x)) (c1 x))) e
53+
≡ map-over {f = f'} {f' = f''} (u2 , c2)
54+
(map-over {f = f} {f' = f'} (u1 , c1) e)
55+
map-over-comp u1 c1 u2 c2 (x , p)
56+
rewrite trans-assoc (c2 (u1 x)) (c1 x) p = refl
57+
58+
-- Action along a commuting square: f' ∘ u = v ∘ f.
59+
map-square :
60+
{a a' b b'}
61+
{A : Set a} {A' : Set a'} {B : Set b} {B' : Set b'}
62+
(f : A B) (f' : A' B') (u : A A') (v : B B')
63+
(square : x f' (u x) ≡ v (f x)) {y : B}
64+
Echo f y Echo f' (v y)
65+
map-square f f' u v square (x , p) = u x , trans (square x) (cong v p)

proofs/agda/EchoCategorical.agda

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
{-# OPTIONS --safe --without-K #-}
2+
3+
module EchoCategorical where
4+
5+
open import Echo
6+
open import EchoRelational using (EchoStep; RelMap; map-rel; map-rel-id; map-rel-comp)
7+
8+
open import Level using (Level; _⊔_)
9+
open import Function.Base using (id; _∘_)
10+
open import Data.Product.Base using (Σ; _,_; proj₁)
11+
open import Relation.Binary.PropositionalEquality using (_≡_; refl; trans; subst)
12+
13+
-- Phase D (part 1): slice-style packaging for deterministic maps.
14+
record SliceHom
15+
{a a' b} {A : Set a} {A' : Set a'} {B : Set b}
16+
(f : A B) (f' : A' B) : Set (a ⊔ a' ⊔ b) where
17+
field
18+
arrow : A A'
19+
commute : x f' (arrow x) ≡ f x
20+
21+
open SliceHom public
22+
23+
slice-to-mapover :
24+
{a a' b} {A : Set a} {A' : Set a'} {B : Set b}
25+
{f : A B} {f' : A' B}
26+
SliceHom f f' MapOver f f'
27+
slice-to-mapover h = arrow h , commute h
28+
29+
mapover-to-slice :
30+
{a a' b} {A : Set a} {A' : Set a'} {B : Set b}
31+
{f : A B} {f' : A' B}
32+
MapOver f f' SliceHom f f'
33+
mapover-to-slice (u , c) = record { arrow = u ; commute = c }
34+
35+
slice-id :
36+
{a b} {A : Set a} {B : Set b} (f : A B)
37+
SliceHom f f
38+
slice-id f = record
39+
{ arrow = id
40+
; commute = λ _ refl
41+
}
42+
43+
slice-comp :
44+
{a a' a'' b}
45+
{A : Set a} {A' : Set a'} {A'' : Set a''} {B : Set b}
46+
{f : A B} {f' : A' B} {f'' : A'' B}
47+
SliceHom f f' SliceHom f' f'' SliceHom f f''
48+
slice-comp h₁ h₂ = record
49+
{ arrow = arrow h₂ ∘ arrow h₁
50+
; commute = λ x trans (commute h₂ (arrow h₁ x)) (commute h₁ x)
51+
}
52+
53+
slice-act :
54+
{a a' b} {A : Set a} {A' : Set a'} {B : Set b}
55+
{f : A B} {f' : A' B}
56+
SliceHom f f' {y : B} Echo f y Echo f' y
57+
slice-act h = map-over (slice-to-mapover h)
58+
59+
slice-act-id :
60+
{a b} {A : Set a} {B : Set b}
61+
{f : A B} {y : B} (e : Echo f y)
62+
slice-act (slice-id f) e ≡ e
63+
slice-act-id = map-over-id
64+
65+
slice-act-comp :
66+
{a a' a'' b}
67+
{A : Set a} {A' : Set a'} {A'' : Set a''} {B : Set b}
68+
{f : A B} {f' : A' B} {f'' : A'' B}
69+
(h₁ : SliceHom f f') (h₂ : SliceHom f' f'')
70+
{y : B} (e : Echo f y)
71+
slice-act (slice-comp h₁ h₂) e ≡
72+
slice-act h₂ (slice-act h₁ e)
73+
slice-act-comp h₁ h₂ = map-over-comp (arrow h₁) (commute h₁) (arrow h₂) (commute h₂)
74+
75+
-- Phase D (part 2): fibration-style packaging for relational semantics.
76+
module Fibration {s o r} {S : Set s} {O : Set o} (Step : S O Set r) where
77+
78+
Fiber : O Set (s ⊔ r)
79+
Fiber = EchoStep Step
80+
81+
Total : Set (s ⊔ o ⊔ r)
82+
Total = Σ O Fiber
83+
84+
π : Total O
85+
π = proj₁
86+
87+
fiber-to-echo :
88+
{out : O} Fiber out Echo π out
89+
fiber-to-echo {out} e = (out , e) , refl
90+
91+
echo-to-fiber :
92+
{out : O} Echo π out Fiber out
93+
echo-to-fiber ((out' , e) , p) = subst Fiber p e
94+
95+
echo-to-fiber∘fiber-to-echo :
96+
{out : O} (e : Fiber out)
97+
echo-to-fiber (fiber-to-echo e) ≡ e
98+
echo-to-fiber∘fiber-to-echo e = refl
99+
100+
fiber-map :
101+
{s' r'} {S' : Set s'} {Step' : S' O Set r'}
102+
RelMap Step Step' {out : O} Fiber out EchoStep Step' out
103+
fiber-map = map-rel
104+
105+
fiber-map-id :
106+
{out : O} (e : Fiber out)
107+
fiber-map (id , (λ {st} {out} p p)) e ≡ e
108+
fiber-map-id e = map-rel-id {Step = Step} e
109+
110+
rel-fiber-map-comp :
111+
{s' s'' r' r''}
112+
{S' : Set s'} {S'' : Set s''}
113+
{Step' : S' O Set r'}
114+
{Step'' : S'' O Set r''}
115+
(u₁ : S S') (pres₁ : {st out} Step st out Step' (u₁ st) out)
116+
(u₂ : S' S'') (pres₂ : {st out} Step' st out Step'' (u₂ st) out)
117+
{out : O} (e : Fiber out)
118+
map-rel {Step = Step} {Step' = Step''}
119+
(u₂ ∘ u₁ , λ p pres₂ (pres₁ p)) e
120+
≡ map-rel {Step = Step'} {Step' = Step''} (u₂ , pres₂)
121+
(map-rel {Step = Step} {Step' = Step'} (u₁ , pres₁) e)
122+
rel-fiber-map-comp {Step' = Step'} {Step'' = Step''} u₁ pres₁ u₂ pres₂ e =
123+
map-rel-comp {Step = Step} {Step' = Step'} {Step'' = Step''}
124+
u₁ pres₁ u₂ pres₂ e

0 commit comments

Comments
 (0)