Skip to content

Commit d02a8cf

Browse files
committed
add: adjoint properties for agda#2840
1 parent 645e8d6 commit d02a8cf

File tree

4 files changed

+50
-3
lines changed

4 files changed

+50
-3
lines changed

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,20 @@ Additions to existing modules
221221
contradiction′ : ¬ A → A → Whatever
222222
```
223223

224+
* In `Relation.Unary`
225+
```agda
226+
⟨_⟩⊢_ : (A → B) → Pred A ℓ → Pred B _
227+
[_]⊢_ : (A → B) → Pred A ℓ → Pred B _
228+
```
229+
230+
* In `Relation.Unary.Properties`
231+
```agda
232+
⟨_⟩⊢ˡ : (f : A → B) → ⟨ f ⟩⊢ P ⊆ Q → P ⊆ f ⊢ Q
233+
⟨_⟩⊢ʳ : (f : A → B) → P ⊆ f ⊢ Q → ⟨ f ⟩⊢ P ⊆ Q
234+
[_]⊢ˡ : (f : A → B) → Q ⊆ [ f ]⊢ P → f ⊢ Q ⊆ P
235+
[_]⊢ʳ : (f : A → B) → f ⊢ Q ⊆ P → Q ⊆ [ f ]⊢ P
236+
```
237+
224238
* In `System.Random`:
225239
```agda
226240
randomIO : IO Bool

src/Function/Related/TypeIsomorphisms.agda

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ open import Relation.Binary.PropositionalEquality.Properties
3939
using (module ≡-Reasoning)
4040
open import Relation.Nullary.Negation.Core using (¬_)
4141
import Relation.Nullary.Indexed as I
42+
open import Relation.Unary using (⟨_⟩⊢_)
43+
open import Relation.Unary.Properties using (⟨_⟩⊢ˡ; ⟨_⟩⊢ʳ)
4244

4345
private
4446
variable
@@ -359,7 +361,7 @@ Related-cong {A = A} {B = B} {C = C} {D = D} A≈B C≈D = mk⇔
359361
-- Relating a predicate to an existentially quantified one with the
360362
-- restriction that the quantified variable is equal to the given one
361363

362-
∃-≡ : (P : A Set b) {x} P x ↔ (∃[ y ] y ≡ x × P y)
363-
∃-≡ P {x} = mk↔ₛ′ (λ Px x , refl , Px) (λ where (_ , refl , Py) Py)
364+
∃-≡ : (P : A Set b) {x} P x ↔ (⟨ id ⟩⊢ P) x
365+
∃-≡ P {x} = mk↔ₛ′ (⟨ id ⟩⊢ˡ id) (⟨ id ⟩⊢ʳ id)
364366
(λ where (_ , refl , _) refl) (λ where _ refl)
365367

src/Relation/Unary.agda

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,11 +261,25 @@ P ⊥ Q = P ∩ Q ⊆ ∅
261261
_⊥′_ : Pred A ℓ₁ Pred A ℓ₂ Set _
262262
P ⊥′ Q = P ∩ Q ⊆′ ∅
263263

264-
-- Update.
264+
-- Update/functorial change-of-base
265+
266+
-- The notation captures the Martin-Löf tradition of only mentioning
267+
-- updates to the ambient context when describing a context-indexed
268+
-- family P e.g. (_, σ) ⊢ Tm τ is
269+
-- "a term of type τ in the ambient context extended with a fresh σ".
265270

266271
_⊢_ : (A B) Pred B ℓ Pred A ℓ
267272
f ⊢ P = λ x P (f x)
268273

274+
-- Change-of-base has left- and right- adjoints (Lawvere).
275+
-- We borrow the 'diamond'/'box' notation from modal logic, cf.
276+
-- `Relation.Unary.Closure.Base`
277+
⟨_⟩⊢_ : (A B) Pred A ℓ Pred B _
278+
⟨ f ⟩⊢ P = λ y λ x f x ≡ y × P x
279+
280+
[_]⊢_ : (A B) Pred A ℓ Pred B _
281+
[ f ]⊢ P = λ y {x} f x ≡ y P x
282+
269283
------------------------------------------------------------------------
270284
-- Predicate combinators
271285

src/Relation/Unary/Properties.agda

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,23 @@ U-Universal = λ _ → _
220220
⊥⇒¬≬ : Binary._⇒_ {A = Pred A ℓ₁} {B = Pred A ℓ₂} _⊥_ (¬_ ∘₂ _≬_)
221221
⊥⇒¬≬ P⊥Q = P⊥Q ∘ Product.proj₂
222222

223+
------------------------------------------------------------------------
224+
-- Adjoint properties for change-of-base
225+
226+
module _ {P : Pred A ℓ₁} {Q : Pred B ℓ₂} (f : A B) where
227+
228+
⟨_⟩⊢ˡ : ⟨ f ⟩⊢ P ⊆ Q P ⊆ f ⊢ Q
229+
⟨_⟩⊢ˡ ⟨f⟩⊢P⊆Q Px = ⟨f⟩⊢P⊆Q (_ , refl , Px)
230+
231+
⟨_⟩⊢ʳ : P ⊆ f ⊢ Q ⟨ f ⟩⊢ P ⊆ Q
232+
⟨_⟩⊢ʳ P⊆f⊢Q (x , refl , Px) = P⊆f⊢Q Px
233+
234+
[_]⊢ˡ : Q ⊆ [ f ]⊢ P f ⊢ Q ⊆ P
235+
[_]⊢ˡ Q⊆[f]⊢P Qfx = Q⊆[f]⊢P Qfx refl
236+
237+
[_]⊢ʳ : f ⊢ Q ⊆ P Q ⊆ [ f ]⊢ P
238+
[_]⊢ʳ f⊢Q⊆P Qfx refl = f⊢Q⊆P Qfx
239+
223240
------------------------------------------------------------------------
224241
-- Decidability properties
225242

0 commit comments

Comments
 (0)