|
| 1 | +{-# OPTIONS --safe --without-K #-} |
| 2 | + |
| 3 | +-- Echo non-propositionality from non-injective fibres. |
| 4 | +-- |
| 5 | +-- Strengthens the truncation argument (one of the two load-bearing |
| 6 | +-- distinctness arguments post-EI-2) by formalising once-and-for-all |
| 7 | +-- the lemma that several example modules currently prove pointwise: |
| 8 | +-- |
| 9 | +-- * `EchoCharacteristic.echo-true≢echo-false` (collapse : Bool → ⊤) |
| 10 | +-- * `EchoExamples.echo-plus3≢echo-minus3` (square9 : SignedNine → ℕ) |
| 11 | +-- * `EchoTropical.echo-a≢echo-b` (score : Candidate → ℕ) |
| 12 | +-- |
| 13 | +-- All three witness the same fact: a non-injective `f : A → B` with |
| 14 | +-- two distinct preimages of some `y` produces a non-propositional |
| 15 | +-- `Echo f y`. This module proves that fact for an arbitrary `f` and |
| 16 | +-- recovers each existing pointwise lemma as a corollary. |
| 17 | + |
| 18 | +module EchoTruncation where |
| 19 | + |
| 20 | +open import Echo |
| 21 | + |
| 22 | +open import Level using (Level) |
| 23 | +open import Data.Product.Base using (Σ; _,_; proj₁) |
| 24 | +open import Relation.Binary.PropositionalEquality using (_≡_; _≢_; refl; cong) |
| 25 | +open import Relation.Nullary using (¬_) |
| 26 | + |
| 27 | +private |
| 28 | + variable |
| 29 | + ℓa ℓb : Level |
| 30 | + A : Set ℓa |
| 31 | + B : Set ℓb |
| 32 | + |
| 33 | +-- A type is propositional ("a mere proposition") when any two |
| 34 | +-- inhabitants are equal. Standard HoTT terminology, kept universe- |
| 35 | +-- polymorphic so call sites need no level juggling. |
| 36 | +isProp : ∀ {ℓ} (T : Set ℓ) → Set ℓ |
| 37 | +isProp T = (x y : T) → x ≡ y |
| 38 | + |
| 39 | +---------------------------------------------------------------------- |
| 40 | +-- Generic distinctness lemmas. |
| 41 | + |
| 42 | +-- Two echoes whose underlying witnesses are distinct are themselves |
| 43 | +-- distinct. The load-bearing step is `cong proj₁`, factoring through |
| 44 | +-- `Σ` rather than `Echo`, so the lemma works at any level and for |
| 45 | +-- any non-injective f. This encapsulates the `λ q → ne (cong proj₁ q)` |
| 46 | +-- fragment that recurs across every example module. |
| 47 | +echo-witnesses-distinct : |
| 48 | + {f : A → B} {y : B} {e1 e2 : Echo f y} → |
| 49 | + proj₁ e1 ≢ proj₁ e2 → |
| 50 | + e1 ≢ e2 |
| 51 | +echo-witnesses-distinct ne q = ne (cong proj₁ q) |
| 52 | + |
| 53 | +-- From two distinct preimages of `y`, exhibit two distinct echoes |
| 54 | +-- at `y`. Witness/existential form: more useful than `echo-not-prop` |
| 55 | +-- when one wants the actual elements rather than just the negation. |
| 56 | +preimages⇒distinct-echoes : |
| 57 | + (f : A → B) {y : B} |
| 58 | + (x1 x2 : A) (p1 : f x1 ≡ y) (p2 : f x2 ≡ y) → |
| 59 | + x1 ≢ x2 → |
| 60 | + Σ (Echo f y) (λ e1 → Σ (Echo f y) (λ e2 → e1 ≢ e2)) |
| 61 | +preimages⇒distinct-echoes f {y = y} x1 x2 p1 p2 ne = |
| 62 | + e1 , e2 , |
| 63 | + echo-witnesses-distinct {f = f} {y = y} {e1 = e1} {e2 = e2} ne |
| 64 | + where |
| 65 | + e1 : Echo f y |
| 66 | + e1 = x1 , p1 |
| 67 | + e2 : Echo f y |
| 68 | + e2 = x2 , p2 |
| 69 | + |
| 70 | +-- Headline: `Echo f y` is not a proposition whenever `f` has two |
| 71 | +-- distinct preimages of `y`. The general post-EI-2 truncation |
| 72 | +-- argument formalised once; per-example lemmas follow as corollaries |
| 73 | +-- below. |
| 74 | +echo-not-prop : |
| 75 | + (f : A → B) {y : B} |
| 76 | + (x1 x2 : A) (p1 : f x1 ≡ y) (p2 : f x2 ≡ y) → |
| 77 | + x1 ≢ x2 → |
| 78 | + ¬ isProp (Echo f y) |
| 79 | +echo-not-prop f x1 x2 p1 p2 ne prop = |
| 80 | + ne (cong proj₁ (prop (x1 , p1) (x2 , p2))) |
| 81 | + |
| 82 | +---------------------------------------------------------------------- |
| 83 | +-- Corollaries: each pre-existing pointwise distinctness lemma is a |
| 84 | +-- special case of `echo-witnesses-distinct` / `echo-not-prop`. |
| 85 | + |
| 86 | +-- Substitution note: the bootstrapping brief named the carrier |
| 87 | +-- modules `TropicalArgmin.agda`, `EpistemicUpdate.agda`, and |
| 88 | +-- `LinearErasure.agda`. Those files do not exist under those names; |
| 89 | +-- the closest existing carriers of pointwise echo-distinctness for |
| 90 | +-- non-injective f are `EchoTropical`, `EchoCharacteristic`, and |
| 91 | +-- `EchoExamples`. The corollaries below use the latter set. |
| 92 | + |
| 93 | +-- 1. `collapse : Bool → ⊤` (the maximally collapsing example). |
| 94 | +module CollapseExample where |
| 95 | + open import Data.Bool.Base using (Bool; true; false) |
| 96 | + open import Data.Unit.Base using (⊤; tt) |
| 97 | + open import EchoCharacteristic using |
| 98 | + (collapse; echo-true; echo-false; true≢false) |
| 99 | + |
| 100 | + echo-true≢echo-false : echo-true ≢ echo-false |
| 101 | + echo-true≢echo-false = |
| 102 | + echo-witnesses-distinct |
| 103 | + {f = collapse} {y = tt} |
| 104 | + {e1 = echo-true} {e2 = echo-false} |
| 105 | + true≢false |
| 106 | + |
| 107 | + collapse-not-prop : ¬ isProp (Echo collapse tt) |
| 108 | + collapse-not-prop = |
| 109 | + echo-not-prop collapse true false refl refl true≢false |
| 110 | + |
| 111 | +-- 2. `square9 : SignedNine → ℕ` (sign-forgetting square). |
| 112 | +module Square9Example where |
| 113 | + open import Data.Nat.Base using (ℕ) |
| 114 | + open import EchoExamples using |
| 115 | + (SignedNine; plus3; minus3; plus3≢minus3; square9; |
| 116 | + echo-plus3; echo-minus3) |
| 117 | + |
| 118 | + echo-plus3≢echo-minus3 : echo-plus3 ≢ echo-minus3 |
| 119 | + echo-plus3≢echo-minus3 = |
| 120 | + echo-witnesses-distinct |
| 121 | + {f = square9} {y = 9} |
| 122 | + {e1 = echo-plus3} {e2 = echo-minus3} |
| 123 | + plus3≢minus3 |
| 124 | + |
| 125 | + square9-not-prop : ¬ isProp (Echo square9 9) |
| 126 | + square9-not-prop = |
| 127 | + echo-not-prop square9 plus3 minus3 refl refl plus3≢minus3 |
| 128 | + |
| 129 | +-- 3. `score : Candidate → ℕ` (tropical / argmin scoring). |
| 130 | +module TropicalExample where |
| 131 | + open import Data.Nat.Base using (ℕ; zero) |
| 132 | + open import EchoTropical using |
| 133 | + (Candidate; a; b; a≢b; score; echo-a; echo-b) |
| 134 | + |
| 135 | + echo-a≢echo-b : echo-a ≢ echo-b |
| 136 | + echo-a≢echo-b = |
| 137 | + echo-witnesses-distinct |
| 138 | + {f = score} {y = zero} |
| 139 | + {e1 = echo-a} {e2 = echo-b} |
| 140 | + a≢b |
| 141 | + |
| 142 | + tropical-score-not-prop : ¬ isProp (Echo score zero) |
| 143 | + tropical-score-not-prop = |
| 144 | + echo-not-prop score a b refl refl a≢b |
0 commit comments