@@ -232,6 +232,71 @@ module CostInstance {ℓ} (K : CostAlgebra ℓ) where
232232 cost-residue f cost c cost-meets =
233233 record { lower = λ {y} (x , p) → x , p , cost-meets x }
234234
235+ ----------------------------------------------------------------------
236+ -- Search instance (2026-05-28, Tier-2 grid completion).
237+ --
238+ -- `EchoSearch.EchoS enum f y n` is the bounded-`n` witness-search
239+ -- echo: a step index `k < n` at which the enumerator returns a
240+ -- preimage of `y` under `f`. Lowering from `Echo f y` requires
241+ -- a search-completeness witness — for every echo at `y`, an
242+ -- enumerator step `k < n` produces its source element.
243+ --
244+ -- The search-completeness assumption is exactly the per-fibre
245+ -- "enum exhausts A within n steps" property. Compared to
246+ -- `cost-residue` (where the budget-meets witness is a numeric
247+ -- bound on cost), `search-residue` requires structural location
248+ -- information (a specific step). Both fit the same parametric
249+ -- shape: an external witness supplied at the ResidueForm boundary.
250+ --
251+ -- Closes the "EchoSearch structurally compatible but not packaged"
252+ -- gap noted in the companion remark. Fourth non-endpoint,
253+ -- non-generic decoration instance.
254+ ----------------------------------------------------------------------
255+
256+ open import EchoSearch using (EchoS; SearchStrategy)
257+ open import Data.Nat.Base using (ℕ; _<_)
258+ open import Data.Product.Base using (_×_; proj₁)
259+ open import Relation.Binary.PropositionalEquality using (cong; trans)
260+
261+ search-residue :
262+ ∀ {a b} {A : Set a} {B : Set b}
263+ (enum : SearchStrategy A) (f : A → B) (n : ℕ)
264+ (search-complete : ∀ {y : B} (e : Echo f y) →
265+ Σ ℕ (λ k → (k < n) × (enum k ≡ proj₁ e))) →
266+ ResidueForm f (λ y → EchoS enum f y n)
267+ search-residue enum f n search-complete =
268+ record { lower = λ {y} e@(x , p) →
269+ let (k , k<n , eq) = search-complete e
270+ in k , k<n , trans (cong f eq) p }
271+
272+ ----------------------------------------------------------------------
273+ -- Epistemic instance (2026-05-28, Tier-2 grid completion).
274+ --
275+ -- For a role `r : Role` from `EchoChoreo`, the indistinguishability
276+ -- class at observation value `y` is exactly the fibre
277+ -- `Echo (obs r) y` — every global indistinguishable-at-r from a
278+ -- representative IS a fibre element. The "knowledge-equivalence-
279+ -- class residue" interpretation thus DEFINITIONALLY collapses to
280+ -- `identity-residue` specialised to `obs r`.
281+ --
282+ -- Pinning under a separate name makes the epistemic reading
283+ -- discoverable at the taxonomy boundary without introducing a
284+ -- distinct carrier (which would require either propositional
285+ -- truncation of the class — same earn-back as `(epi, mono)` image
286+ -- factorisation, handled by `EchoImageFactorizationProp` — or a
287+ -- setoid carrier with an explicit equivalence relation).
288+ --
289+ -- Closes the "EchoEpistemic structurally compatible but
290+ -- relational" gap noted in the companion remark. Fifth instance
291+ -- (degenerate-but-named: definitionally equal to `identity-residue
292+ -- (obs r)`, but the name pins the epistemic reading).
293+ ----------------------------------------------------------------------
294+
295+ open import EchoChoreo using (Role; obs)
296+
297+ epistemic-residue : (r : Role) → ResidueForm (obs r) (Echo (obs r))
298+ epistemic-residue r = identity-residue (obs r)
299+
235300----------------------------------------------------------------------
236301-- Companion remark.
237302--
@@ -265,25 +330,40 @@ module CostInstance {ℓ} (K : CostAlgebra ℓ) where
265330-- parametric record sits inside the `K`-parameterised
266331-- sub-module to keep the carrier signature tidy.
267332--
268- -- 6. *EchoSearch*. Search-bound-indexed refinement (enumerator-
269- -- bounded). Search bound 0 = trivial-residue; unbounded search
270- -- = identity-residue.
333+ -- 6. *EchoSearch*. LANDED 2026-05-28 as `search-residue` above.
334+ -- Per-output carrier `EchoS enum f y n` (bounded-`n` search
335+ -- witness); lowering requires a search-completeness witness
336+ -- `∀ {y} (e : Echo f y) → Σ ℕ λ k → (k < n) × (enum k ≡ proj₁ e)`
337+ -- passed at the boundary (mirrors `cost-residue`'s
338+ -- `cost-meets` parameter). Degenerate endpoints: search bound
339+ -- 0 trivialises (no echo lowers — the `EchoS f y 0` is empty
340+ -- via `echo-search-bound-zero`); unbounded search via a
341+ -- surjective enumerator recovers identity-residue.
271342--
272343-- 7. *EchoIndexed*. LANDED 2026-05-27 as `indexed-residue`
273344-- above. Per-output carrier `Σ I (λ idx → Echoᵢ I ι f idx y)`;
274345-- lowering `(x, p) ↦ (ι x, x, refl, p)`.
275346--
276- -- 8. *EchoEpistemic*. Knowledge-equivalence-class residue
277- -- (`Indist`, `Knows`). Lowering quotients the echo by
278- -- indistinguishability; structurally compatible but uses a
279- -- relational rather than Σ-shape residue.
280- --
281- -- All eight are structurally compatible with `ResidueForm`. The
282- -- four instances pinned above demonstrate the pattern at the two
283- -- endpoints + the generic Σ-cert + one worked non-trivial
284- -- instance; adding the remaining seven as packaged `ResidueForm`
285- -- instances is mechanical wiring (each module already has the
286- -- `lower` map; the wiring just exposes it through the record).
347+ -- 8. *EchoEpistemic*. LANDED 2026-05-28 as `epistemic-residue`
348+ -- above. Definitionally `identity-residue (obs r)`: the
349+ -- indistinguishability class at observation `y` IS the fibre
350+ -- `Echo (obs r) y`. Pinned under a distinct name so the
351+ -- epistemic reading is discoverable at the taxonomy boundary;
352+ -- no new carrier (a setoid carrier with explicit equivalence
353+ -- relation or a propositional-truncation of the class would
354+ -- both be separate earn-back lifts).
355+ --
356+ -- All eight are now packaged. Endpoint instances (1-3:
357+ -- trivial-residue + identity-residue + echoR-residue) cover the
358+ -- generic shapes; six non-endpoint instances ship the worked
359+ -- decoration-specific wiring (linear-affine-residue,
360+ -- indexed-residue, module CostInstance.cost-residue,
361+ -- search-residue, epistemic-residue, and choreo-residue via
362+ -- echoR-residue with `C = Role`). Each instance's `lower` either
363+ -- discharges definitionally (`linear-affine` / `indexed` /
364+ -- `epistemic`) or requires a parametric witness at the boundary
365+ -- (`cost-meets` for cost / `search-complete` for search) that
366+ -- locates the relevant point in the decoration's quantitative axis.
287367--
288368-- The DECORATION RECIPE (`order` / `order-prop` / `join` /
289369-- `degrade-compose` / `degrade-via-join`) that each of the eight
0 commit comments