Skip to content

Commit cff00ec

Browse files
WIP: checkpoint current Echo integration work (design pending) (#65)
**Draft / WIP — checkpoint, not a final design. Do not merge.** This preserves the current coherent, reversible implementation state before the ephemeral environment is lost. This PR is intentionally draft/WIP. The Echo design is **not yet locked in**; pending design answers may redirect the model toward Linear/Dyadic types or another representation. Any such pivot should happen in a **follow-up commit on this same branch** rather than by losing this checkpoint, so the reasoning history stays visible. ``` checkpoint: safe design: pending branch: draft PR future pivot: allowed ``` ### What this wires (current shape — provisional) KitchenSpeak's Echo (`@`) type onto `hyperpolymath/echo-types`, whose core type is the fiber `Echo f y := Σ (x:A), f x ≡ y` (the proof-relevant residue of structured loss). KitchenSpeak's `@`-witness `Σ[t] sensor t ≥ thr` is treated as a special case via a Boolean classifier `fired s thr t = ⌊ s t ≥? thr ⌋`. - **`proofs/agda/EchoBridge.agda`** — imports echo-types' `Echo`; proves KitchenSpeak's threshold witness interconvertible with `Echo (fired sensor thr) true`. Integration isolated here; `Dough.agda`/`PoachedEgg.agda` untouched. - **`proofs/agda/kitchenspeak.agda-lib`** — `depend: standard-library echo-types` (transitively `absolute-zero`; stdlib → 2.3+). - **`proofs/Makefile`** — `echobridge` target + dependency note. - **`decisions/0003-echo-types-dependency.adoc`** — ADR. Deliberately **not** yet done (held pending answers): COMMENTARY §Echo, ROADMAP, proofs/README, CHANGELOG edits. ### Open design questions (the reason this is WIP) 1. **Attach by name or by concept?** Currently on the Echo (`@`) *sensor* type (name + shape match). echo-types' *concept* (non-total erasure / residue) may fit **Linear/Dyadic consumption** better (`Flour ⊗ Water → Dough` = irreversible erasure with structured residue). Sensor Echo, Linear/Dyadic, or both? — *a pivot here becomes a follow-up commit on this branch.* 2. **Classifier richness** — currently a degenerate **Bool** fiber; map into the sensor's real classification space / bind to the **epistemic** residue in `EchoResidueTaxonomy`? 3. **`absolute-zero`** transitive Agda dependency — accept, or lighter route? 4. **EchoTypes.jl** — runtime echo *evaluator* in the HAL, or conceptual companion? 5. **Pinning** — pin echo-types (commit/tag/submodule) or track `main`? ### Caveat Not machine-checked here (no Agda; echo-types + absolute-zero not installed). `Echo`'s definition confirmed verbatim from source; `--safe --without-K` vs KitchenSpeak's postulate-bearing proofs reasoned, not verified. Real confirmation: `make -C proofs echobridge` with the libraries registered. https://claude.ai/code/session_01RZWK1vf9QfP2H2JTFWCdJY Co-authored-by: Claude <noreply@anthropic.com>
1 parent cd71bad commit cff00ec

4 files changed

Lines changed: 237 additions & 5 deletions

File tree

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
// SPDX-License-Identifier: MPL-2.0
2+
// Copyright (c) 2026 Jonathan D.A. Jewell <j.d.a.jewell@open.ac.uk>
3+
= ADR 0003 — Base the Echo Type on the echo-types Library
4+
:toc:
5+
:toclevels: 2
6+
:icons: font
7+
8+
== Status
9+
10+
*Accepted — bridge landed; full in-proof adoption staged.*
11+
12+
== Context
13+
14+
KitchenSpeak's *Echo* type (`@`) models a postulated-oracle witness: a
15+
sensor sample together with a proof the physical world matched intent.
16+
Until now this was an ad-hoc dependent pair in each proof — e.g.
17+
`Witness = Σ[ t ∈ Minutes ] viscosity-at t ≥ threshold` (Dough.agda) and
18+
`ShimmerWitness = Σ[ t ] temp-at t ≥ threshold` (PoachedEgg.agda).
19+
20+
A standalone, mechanised formalisation of exactly this structure already
21+
exists in the ecosystem: link:https://github.com/hyperpolymath/echo-types[`hyperpolymath/echo-types`],
22+
a constructive Agda library whose core type is the *fiber*:
23+
24+
[source,agda]
25+
----
26+
Echo : ∀ {a b} {A : Set a} {B : Set b} (f : A → B) → B → Set (a ⊔ b)
27+
Echo f y = Σ A (λ x → f x ≡ y)
28+
----
29+
30+
`Echo f y` records *which inputs map to `y`* — the proof-relevant
31+
residue of a non-injective ("lossy") function. echo-types develops this
32+
as an orthogonal factorization system with a thermodynamic (Landauer /
33+
Bennett) layer and a residue taxonomy that includes an *epistemic*
34+
residue form. The runnable, finite-domain companion is
35+
link:https://github.com/hyperpolymath/EchoTypes.jl[`EchoTypes.jl`] (a
36+
model, not a proof).
37+
38+
KitchenSpeak's `@` witness is a special case of this fiber: the sensor
39+
is a (non-injective, lossy) classifier and the witness is the Echo over
40+
its "fired" value. Re-using echo-types gives KitchenSpeak's Echo a
41+
single mechanised definition shared between the proofs and the planned
42+
type checker, and aligns the cooking-irreversibility / thermodynamic
43+
themes (you cannot un-cook; structured, non-total loss) with an existing
44+
formal account.
45+
46+
== Decision
47+
48+
Adopt echo-types as the canonical foundation for KitchenSpeak's Echo
49+
type, and depend on it from the proof library.
50+
51+
. *Dependency.* `kitchenspeak.agda-lib` now declares
52+
`depend: standard-library echo-types`. echo-types itself declares
53+
`depend: standard-library absolute-zero`, so both `echo-types` and
54+
`absolute-zero` must be registered in `~/.agda/libraries`, and
55+
agda-stdlib is raised to 2.3+ (echo-types' floor).
56+
. *Bridge.* A new `proofs/agda/EchoBridge.agda` imports echo-types'
57+
`Echo` and proves KitchenSpeak's threshold witness interconvertible
58+
with `Echo (fired sensor thr) true`, where
59+
`fired s thr t = ⌊ s t ≥? thr ⌋` views the oracle as a Boolean
60+
classifier. This isolates the cross-library integration in one file.
61+
. *Proofs unchanged for now.* Dough.agda and PoachedEgg.agda keep their
62+
inline `Σ` witnesses (so their structural-recursion proofs are
63+
untouched) and expose them as echo-types Echoes via the bridge.
64+
Migrating the inline witnesses to `SensorEcho` directly is staged for
65+
a later step once the dependency type-checks in CI.
66+
. *Type checker.* The planned KitchenSpeak checker (ROADMAP Phase 3)
67+
takes `Echo (fired sensor thr) true` as the canonical typing of an `@`
68+
witness, with EchoTypes.jl as the finite-domain runtime / HAL model.
69+
70+
== Consequences
71+
72+
* KitchenSpeak's Echo is no longer ad-hoc: it is the echo-types fiber,
73+
with the structured-loss / epistemic-residue reading made explicit.
74+
* New build burden: contributors must register `echo-types` and
75+
`absolute-zero` (documented in `proofs/README.adoc`). CI (ROADMAP
76+
Phase 1a) must fetch both before `make -C proofs`.
77+
* Flag stance: echo-types' `Echo` is `--safe --without-K`; KitchenSpeak's
78+
proofs are deliberately non-`--safe` (they postulate sensor streams).
79+
Importing a safe/without-K module from non-safe code is permitted; the
80+
bridge is left at default discipline and this is to be confirmed when
81+
Agda is available.
82+
* The "verified classifier story for echo-types" previously listed as
83+
out of scope (COMMENTARY §Deliberately out of scope) is now partially
84+
addressed: the *type* of the witness is mechanised; the sensor
85+
*reading* remains postulated.
86+
87+
== Reversibility
88+
89+
*Moderate.* The bridge and the `depend` line are removable, restoring the
90+
self-contained `Σ` witnesses, without touching the recipe proofs (which
91+
were intentionally left unmodified). Reverting only loses the shared
92+
definition and the documented alignment.

kitchenspeak/proofs/Makefile

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,15 @@
77
#
88
# Requirements:
99
# - Agda 2.6.4+ (e.g. `nix shell nixpkgs#agda`, or distro pkg)
10-
# - agda-stdlib 2.0+ (registered in your ~/.agda/libraries)
10+
# - agda-stdlib 2.3+ (registered in your ~/.agda/libraries)
11+
# - echo-types + absolute-zero (registered in ~/.agda/libraries) for
12+
# EchoBridge.agda — see proofs/README.adoc and ../decisions/0003.
1113
#
1214
# Usage:
1315
# make # type-check the whole core proof library
1416
# make dough # type-check Dough.agda only
1517
# make poachedegg # type-check PoachedEgg.agda only
18+
# make echobridge # type-check EchoBridge.agda only (needs echo-types)
1619
# make clean # remove Agda interface files
1720

1821
AGDA ?= agda
@@ -21,8 +24,8 @@ SRC_DIR := agda
2124

2225
# The core proof library, in dependency-free order. Emulsion and Sear
2326
# are tracked in ../ROADMAP.adoc Phase 1c and join this list as they
24-
# land.
25-
MODULES := Dough PoachedEgg
27+
# land. EchoBridge wires the @ witness onto hyperpolymath/echo-types.
28+
MODULES := Dough PoachedEgg EchoBridge
2629

2730
.PHONY: all clean $(MODULES)
2831

@@ -31,6 +34,7 @@ all: $(MODULES)
3134
# Per-module targets (lower-cased) so `make poachedegg` works.
3235
dough: Dough
3336
poachedegg: PoachedEgg
37+
echobridge: EchoBridge
3438

3539
$(MODULES):
3640
cd $(SRC_DIR) && $(AGDA) $(AGDA_FLAGS) $@.agda
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
-- SPDX-License-Identifier: MPL-2.0
2+
-- Copyright (c) 2026 Jonathan D.A. Jewell <j.d.a.jewell@open.ac.uk>
3+
--
4+
-- =====================================================================
5+
-- KitchenSpeak — Echo Bridge to the echo-types library
6+
-- =====================================================================
7+
--
8+
-- KitchenSpeak's Echo (@) type is a *postulated-oracle witness*: a
9+
-- dependent pair of a sensor sample time and a proof the sensor met its
10+
-- threshold there (Dough.agda's `Witness`, PoachedEgg.agda's
11+
-- `ShimmerWitness` / `WhiteWitness`).
12+
--
13+
-- The hyperpolymath/echo-types library (module `Echo`) gives the
14+
-- canonical, mechanised form of exactly this structure — the *fiber*:
15+
--
16+
-- Echo : (f : A → B) → B → Set
17+
-- Echo f y = Σ A (λ x → f x ≡ y)
18+
--
19+
-- i.e. "which inputs map to y", the proof-relevant record of structured
20+
-- loss (a non-injective classifier forgets *which* sample fired, but the
21+
-- Echo retains that one did). This module wires KitchenSpeak's Echo type
22+
-- onto that library type so the planned type checker (ROADMAP Phase 3)
23+
-- and the proofs share a single, mechanised notion of Echo rather than
24+
-- an ad-hoc Σ. See decisions/0003-echo-types-dependency.adoc.
25+
--
26+
-- The reconciliation. KitchenSpeak's witness is a fiber over a
27+
-- *predicate* (`sensor t ≥ thr`); echo-types' Echo is a fiber over an
28+
-- *equality* (`f x ≡ y`). We bridge by viewing each threshold oracle as
29+
-- a Boolean *classifier* `fired s thr t = ⌊ s t ≥? thr ⌋`, whose Echo
30+
-- over `true` is the KitchenSpeak witness. The classifier is the lossy
31+
-- function; the Echo is its structured-loss witness.
32+
--
33+
-- ---------------------------------------------------------------------
34+
-- NOTE (hand-verified, not machine-checked here). Agda is not installed
35+
-- in the authoring environment, and echo-types (plus its own
36+
-- `depend: absolute-zero`) is not registered here, so the cross-library
37+
-- import below is verified by careful reading against the echo-types
38+
-- source (module `Echo`, definition quoted above, confirmed verbatim).
39+
-- When echo-types + absolute-zero + agda-stdlib 2.3+ are registered,
40+
-- `make -C proofs echobridge` should be the first check. The flag stance
41+
-- (this module is left at Agda's default discipline, importing the
42+
-- `--safe --without-K` `Echo`) is also to be confirmed there.
43+
-- ---------------------------------------------------------------------
44+
45+
module EchoBridge where
46+
47+
open import Data.Bool using (Bool; true; false)
48+
open import Data.Nat using (ℕ; _≥_; _≥?_)
49+
open import Data.Product using (Σ; _,_; Σ-syntax)
50+
open import Data.Empty using (⊥-elim)
51+
open import Relation.Nullary using (yes; no)
52+
open import Relation.Nullary.Decidable using (⌊_⌋)
53+
open import Relation.Binary.PropositionalEquality using (_≡_; refl)
54+
55+
-- The Echo (fiber) type from hyperpolymath/echo-types (module `Echo`):
56+
-- Echo f y = Σ A (λ x → f x ≡ y)
57+
open import Echo using (Echo)
58+
59+
60+
-- =====================================================================
61+
-- § 1. The threshold oracle as a Boolean classifier.
62+
-- =====================================================================
63+
--
64+
-- A KitchenSpeak echo-oracle samples a sensor `s : ℕ → ℕ` (reading per
65+
-- minute) and asks whether it has met a threshold `thr`. As a function
66+
-- into Bool this is the (generally non-injective) classifier whose Echo
67+
-- carries the structured loss: many minutes map to `true`, and the Echo
68+
-- records that *some* qualifying minute exists without pinning which.
69+
70+
fired : (ℕ ℕ) Bool
71+
fired s thr t = ⌊ s t ≥? thr ⌋
72+
73+
74+
-- =====================================================================
75+
-- § 2. The two presentations of a KitchenSpeak Echo witness.
76+
-- =====================================================================
77+
--
78+
-- ThresholdWitness — the form used inline in Dough.agda / PoachedEgg.agda
79+
-- (`Σ[ t ] sensor t ≥ thr`).
80+
-- SensorEcho — the echo-types form: the fiber `Echo (fired …) true`.
81+
82+
ThresholdWitness : (ℕ ℕ) Set
83+
ThresholdWitness s thr = Σ[ t ∈ ℕ ] s t ≥ thr
84+
85+
SensorEcho : (ℕ ℕ) Set
86+
SensorEcho s thr = Echo (fired s thr) true
87+
88+
89+
-- =====================================================================
90+
-- § 3. The bridge: KitchenSpeak's @-witness IS an echo-types Echo.
91+
-- =====================================================================
92+
--
93+
-- The two lemmas establish `s t ≥ thr ⟺ fired s thr t ≡ true`, lifted
94+
-- to the Σ/Echo level. Stating the goal with `⌊ s t ≥? thr ⌋` (which is
95+
-- `fired s thr t` by definition) keeps the `with`-abstraction robust.
96+
97+
≥⇒fired : (s : ℕ) (thr t : ℕ) s t ≥ thr ⌊ s t ≥? thr ⌋ ≡ true
98+
≥⇒fired s thr t pf with s t ≥? thr
99+
... | yes _ = refl
100+
... | no ¬p = ⊥-elim (¬p pf)
101+
102+
fired⇒≥ : (s : ℕ) (thr t : ℕ) ⌊ s t ≥? thr ⌋ ≡ true s t ≥ thr
103+
fired⇒≥ s thr t eq with s t ≥? thr
104+
... | yes p = p
105+
... | no _ with eq
106+
... | ()
107+
108+
-- KitchenSpeak threshold witness → echo-types Echo.
109+
witness⇒echo : {s thr} ThresholdWitness s thr SensorEcho s thr
110+
witness⇒echo {s} {thr} (t , pf) = t , ≥⇒fired s thr t pf
111+
112+
-- echo-types Echo → KitchenSpeak threshold witness.
113+
echo⇒witness : {s thr} SensorEcho s thr ThresholdWitness s thr
114+
echo⇒witness {s} {thr} (t , eq) = t , fired⇒≥ s thr t eq
115+
116+
117+
-- =====================================================================
118+
-- § 4. Usage from the recipe proofs.
119+
-- =====================================================================
120+
--
121+
-- Dough.agda and PoachedEgg.agda keep their inline `Σ[ t ] sensor t ≥
122+
-- thr` witnesses (so their structural-recursion proofs are unchanged),
123+
-- and may present them as echo-types Echoes through `witness⇒echo`:
124+
--
125+
-- viscosity-echo : Witness → SensorEcho viscosity-at kneaded-threshold
126+
-- viscosity-echo = witness⇒echo
127+
--
128+
-- The planned KitchenSpeak type checker (ROADMAP Phase 3) takes
129+
-- `Echo (fired sensor thr) true` as the canonical typing of an `@`
130+
-- witness, with EchoTypes.jl as the finite-domain runtime/HAL model.
Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
-- SPDX-License-Identifier: MPL-2.0
22
-- KitchenSpeak core proof library.
3-
-- Agda 2.6.4+ with standard-library 2.0+.
3+
-- Agda 2.6.4+ with standard-library 2.3+ (echo-types requires 2.3+).
4+
--
5+
-- echo-types (hyperpolymath/echo-types) provides the canonical Echo
6+
-- (fiber) type that KitchenSpeak's @ witnesses are wired onto in
7+
-- EchoBridge.agda. echo-types itself declares `depend: standard-library
8+
-- absolute-zero`, so BOTH echo-types and absolute-zero must be
9+
-- registered in ~/.agda/libraries. See decisions/0003 and proofs/README.
410
name: kitchenspeak
511
include: .
6-
depend: standard-library
12+
depend: standard-library echo-types

0 commit comments

Comments
 (0)