|
| 1 | +{-# OPTIONS --safe --without-K #-} |
| 2 | + |
| 3 | +-- A concrete `Tolerance` + `PseudoMetric` instance for `EchoApprox.Approx`, |
| 4 | +-- whose sole purpose is to give `Smoke.agda` a typeable identifier per |
| 5 | +-- headline lemma of the parameterised `EchoApprox.Approx` module. |
| 6 | +-- |
| 7 | +-- Repo invariant (`CLAUDE.md`, "Working rules"): |
| 8 | +-- |
| 9 | +-- "Every headline theorem must be pinned in `Smoke.agda` via |
| 10 | +-- `using` clause." |
| 11 | +-- |
| 12 | +-- Lemmas living inside the parameterised submodule `EchoApprox.Approx` |
| 13 | +-- cannot be named in `Smoke.agda` until *some* `PseudoMetric` is |
| 14 | +-- supplied, so the invariant is silently violated for every |
| 15 | +-- `echo-approx-*` and `echo-strict→approx` lemma. This module closes |
| 16 | +-- that gap. |
| 17 | +-- |
| 18 | +-- Design call: the trivial / collapse-to-strict pseudometric on `⊤`. |
| 19 | +-- |
| 20 | +-- * `Tol` := `⊤`, `zero` := `tt`, `_+_` := `λ _ _ → tt` |
| 21 | +-- * `_≤_` := `λ _ _ → ⊤` |
| 22 | +-- * `dist` := `λ _ _ → tt` on the carrier `B := ⊤` |
| 23 | +-- |
| 24 | +-- Every order / monotonicity / triangle obligation discharges to `tt`. |
| 25 | +-- Every approximate echo `EchoR ε f y = Σ A (λ x → dist (f x) y ≤ ε)` |
| 26 | +-- collapses to `Σ A (λ _ → ⊤)`, so each pinned lemma here is a trivial |
| 27 | +-- sanity check that the parameterised module's term is well-typed at |
| 28 | +-- *some* instance. That is exactly the hygiene contract the invariant |
| 29 | +-- asks for — proof-of-life, not new content. |
| 30 | +-- |
| 31 | +-- We choose `A := ⊤` and `B := ⊤` so each pinned name resolves to a |
| 32 | +-- single top-level identifier with no remaining type parameters, which |
| 33 | +-- lets `Smoke.agda` enumerate them in a `using` clause one-for-one. |
| 34 | +-- |
| 35 | +-- A non-trivial pseudometric (e.g. the discrete metric over `Bool`) |
| 36 | +-- would also work, but adds nothing the trivial one does not give for |
| 37 | +-- the purposes of `Smoke.agda` pinning. When a genuine metric instance |
| 38 | +-- lands in the repo, the per-lemma pins below can be re-pointed at it. |
| 39 | + |
| 40 | +module EchoApproxInstance where |
| 41 | + |
| 42 | +open import Level using (Level) |
| 43 | +open import Data.Unit.Base using (⊤; tt) |
| 44 | +open import Relation.Binary.PropositionalEquality using (refl) |
| 45 | + |
| 46 | +open import EchoApprox using (Tolerance; PseudoMetric; module Approx) |
| 47 | + |
| 48 | +---------------------------------------------------------------------- |
| 49 | +-- The trivial tolerance carrier |
| 50 | +---------------------------------------------------------------------- |
| 51 | + |
| 52 | +-- All fields are tt / Unit; every law obligation is met by `tt`. |
| 53 | +trivialTolerance : Tolerance Level.zero |
| 54 | +trivialTolerance = record |
| 55 | + { Tol = ⊤ |
| 56 | + ; zero = tt |
| 57 | + ; _+_ = λ _ _ → tt |
| 58 | + ; _≤_ = λ _ _ → ⊤ |
| 59 | + ; ≤-refl = tt |
| 60 | + ; ≤-trans = λ _ _ → tt |
| 61 | + ; +-mono-≤ = λ _ _ → tt |
| 62 | + } |
| 63 | + |
| 64 | +---------------------------------------------------------------------- |
| 65 | +-- The trivial pseudometric on the carrier `⊤` |
| 66 | +---------------------------------------------------------------------- |
| 67 | + |
| 68 | +-- Distance is constantly `tt`; self-distance is `refl`; triangle is `tt`. |
| 69 | +trivialPseudoMetric : PseudoMetric ⊤ trivialTolerance |
| 70 | +trivialPseudoMetric = record |
| 71 | + { dist = λ _ _ → tt |
| 72 | + ; dist-self = λ _ → refl |
| 73 | + ; dist-tri = λ _ _ _ → tt |
| 74 | + } |
| 75 | + |
| 76 | +---------------------------------------------------------------------- |
| 77 | +-- Per-lemma proof-of-life pins for `Approx` at the trivial instance. |
| 78 | +-- |
| 79 | +-- Top-level identifiers, one per `EchoApprox.Approx` headline, with |
| 80 | +-- `A := ⊤` and `B := ⊤` so each is a closed term that `Smoke.agda` |
| 81 | +-- can enumerate in a `using` clause. Definitions use `=` (no explicit |
| 82 | +-- type signature) so the original term's type is inferred — which is |
| 83 | +-- exactly the typeability check the hygiene invariant asks for. |
| 84 | +---------------------------------------------------------------------- |
| 85 | + |
| 86 | +private |
| 87 | + open module ApproxT⊤ = |
| 88 | + Approx {A = ⊤} {B = ⊤} {T = trivialTolerance} trivialPseudoMetric |
| 89 | + |
| 90 | +approx-EchoR = EchoR |
| 91 | +approx-intro = echo-approx-intro |
| 92 | +approx-strict→approx = echo-strict→approx |
| 93 | +approx-relax = echo-approx-relax |
| 94 | +approx-NonExpansive = NonExpansive |
| 95 | +approx-compose = echo-approx-compose |
| 96 | +approx-comp-sound = echo-approx-comp-sound |
| 97 | +approx-comp-retract-to = echo-approx-comp-retract-to |
| 98 | +approx-comp-retract-A = echo-approx-comp-retract-A |
0 commit comments