Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,17 @@ Additions to existing modules
[_]⊢_ : (A → B) → Pred A ℓ → Pred B _
```

* In `Relation.Unary.Properties`
```agda
_map-⊢_ : P ⊆ Q → f ⊢ P ⊆ f ⊢ Q
map-⟨_⟩⊢_ : P ⊆ Q → ⟨ f ⟩⊢ P ⊆ ⟨ f ⟩⊢ Q
map-[_]⊢_ : P ⊆ Q → [ f ]⊢ P ⊆ [ f ]⊢ Q
⟨_⟩⊢⁻_ : ⟨ f ⟩⊢ P ⊆ Q → P ⊆ f ⊢ Q
⟨_⟩⊢⁺_ : P ⊆ f ⊢ Q → ⟨ f ⟩⊢ P ⊆ Q
[_]⊢⁻_ : Q ⊆ [ f ]⊢ P → f ⊢ Q ⊆ P
[_]⊢⁺_ : f ⊢ Q ⊆ P → Q ⊆ [ f ]⊢ P
```

* In `System.Random`:
```agda
randomIO : IO Bool
Expand Down
3 changes: 2 additions & 1 deletion src/Function/Related/TypeIsomorphisms.agda
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ open import Relation.Binary.PropositionalEquality.Properties
using (module ≡-Reasoning)
open import Relation.Nullary.Negation.Core using (¬_)
import Relation.Nullary.Indexed as I
open import Relation.Unary.Properties using (⟨_⟩⊢⁻_; ⟨_⟩⊢⁺_)

private
variable
Expand Down Expand Up @@ -360,6 +361,6 @@ Related-cong {A = A} {B = B} {C = C} {D = D} A≈B C≈D = mk⇔
-- restriction that the quantified variable is equal to the given one

∃-≡ : ∀ (P : A → Set b) {x} → P x ↔ (∃[ y ] y ≡ x × P y)
∃-≡ P {x} = mk↔ₛ′ (λ Px → x , refl , Px) (λ where (_ , refl , Py) → Py)
∃-≡ P {x} = mk↔ₛ′ (⟨ id ⟩⊢⁻ id) (⟨ id ⟩⊢⁺ id)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. I wish the proofs could get a similar treatment!

Copy link
Contributor Author

@jamesmckinna jamesmckinna Nov 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, ok... but downstream?

I think when I last looked at this, the proofs for the left adjoint behave nicely, while the corresponding ones for the right need (lots of) extensionality, to the point of being unilluminating/incomprehensible.

Also, they should be generalised to
'property of f implies related property of adjoint diagram'
(iso; injective; surjective... adjoint), but I got a headache working out the details...

The special case f = id is almost too special to be worth singling out, but... baby steps. It's one reason I went back on my original thought to rewrite the lemma statement to use the adjoint notation... it felt like overkill for too-small stakes.

Copy link
Contributor Author

@jamesmckinna jamesmckinna Nov 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, and the use of id to proxy for its definitionally-equal ⊆-refl (Yoneda lemma!) is a bit cheeky, but arguably it looks worse by using the (conceptually) type-correct version, cf. the functoriality proofs, which I wrote Yoneda-style, rather than flattening out the compositions to re duplicate the pattern-matching versions which precede them...

(λ where (_ , refl , _) → refl) (λ where _ → refl)

24 changes: 18 additions & 6 deletions src/Relation/Unary.agda
Original file line number Diff line number Diff line change
Expand Up @@ -261,24 +261,36 @@ P ⊥ Q = P ∩ Q ⊆ ∅
_⊥′_ : Pred A ℓ₁ → Pred A ℓ₂ → Set _
P ⊥′ Q = P ∩ Q ⊆′ ∅

-- Update.
-- Update/preimage/inverse image/functorial change-of-base
--
-- The notation, which elsewhere might be rendered
-- * `f⁻¹ P`, for preimage/inverse image
-- * `f* P`, for change-of-base/pullback along `f`
-- captures the Martin-Löf tradition of only mentioning updates to
-- the ambient context when describing a context-indexed family P:
-- e.g. (_, σ) ⊢ Tm τ is
-- "a term of type τ in the ambient context extended with a fresh σ".

_⊢_ : (A → B) → Pred B ℓ → Pred A ℓ
f ⊢ P = λ x → P (f x)

-- Diamond/Box: for given `f`, these are the left- and right adjoints to `f ⊢_`
-- These are specialization of Diamond/Box in
-- Relation.Unary.Closure.Base.
-- Change-of-base has left- and right- adjoints (Lawvere).
--
-- We borrow the 'diamond'/'box' notation from modal logic, cf.
-- `Relation.Unary.Closure.Base`, rather than Lawvere's ∃f, ∀f.
-- In some settings (eg statistics/probability), the left adjoint
-- is called 'image' or 'pushforward', but the right adjoint
-- doesn't seem to have a non-symbolic name.

-- Diamond

⟨_⟩⊢_ : (A → B) → Pred A ℓ → Pred B _
⟨ f ⟩⊢ P = λ b → ∃ λ a → f ab × P a
⟨ f ⟩⊢ P = λ y → ∃ λ x → f xy × P x

-- Box

[_]⊢_ : (A → B) → Pred A ℓ → Pred B _
[ f ]⊢ P = λ b → ∀ a → f ab → P a
[ f ]⊢ P = λ y → ∀ {x} → f xy → P x

------------------------------------------------------------------------
-- Predicate combinators
Expand Down
37 changes: 37 additions & 0 deletions src/Relation/Unary/Properties.agda
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,43 @@ U-Universal = λ _ → _
⊥⇒¬≬ : Binary._⇒_ {A = Pred A ℓ₁} {B = Pred A ℓ₂} _⊥_ (¬_ ∘₂ _≬_)
⊥⇒¬≬ P⊥Q = P⊥Q ∘ Product.proj₂

------------------------------------------------------------------------
-- Properties of adjoints to update: functoriality and adjointness

module _ {P : Pred B ℓ₁} {Q : Pred B ℓ₂} where

_map-⊢_ : (f : A → B) → P ⊆ Q → f ⊢ P ⊆ f ⊢ Q
f map-⊢ P⊆Q = P⊆Q

module _ {P : Pred A ℓ₁} {Q : Pred B ℓ₂} (f : A → B) where

-- ⟨ f ⟩⊢_ is left adjoint to f ⊢_ for given f

⟨_⟩⊢⁻_ : ⟨ f ⟩⊢ P ⊆ Q → P ⊆ f ⊢ Q
⟨_⟩⊢⁻_ ⟨f⟩⊢P⊆Q Px = ⟨f⟩⊢P⊆Q (_ , refl , Px)

⟨_⟩⊢⁺_ : P ⊆ f ⊢ Q → ⟨ f ⟩⊢ P ⊆ Q
⟨_⟩⊢⁺_ P⊆f⊢Q (_ , refl , Px) = P⊆f⊢Q Px

-- [ f ]⊢_ is right adjoint to f ⊢_ for given f

[_]⊢⁻_ : Q ⊆ [ f ]⊢ P → f ⊢ Q ⊆ P
[_]⊢⁻_ Q⊆[f]⊢P Qfx = Q⊆[f]⊢P Qfx refl

[_]⊢⁺_ : f ⊢ Q ⊆ P → Q ⊆ [ f ]⊢ P
[_]⊢⁺_ f⊢Q⊆P Qfx refl = f⊢Q⊆P Qfx

module _ {P : Pred A ℓ₁} {Q : Pred A ℓ₂} (f : A → B) where

map-⟨_⟩⊢_ : P ⊆ Q → ⟨ f ⟩⊢ P ⊆ ⟨ f ⟩⊢ Q
map-⟨_⟩⊢_ P⊆Q = ⟨ f ⟩⊢⁺ ⊆-trans {k = f ⊢ ⟨f⟩⊢Q} P⊆Q (⟨ f ⟩⊢⁻ ⊆-refl {x = ⟨f⟩⊢Q})
where ⟨f⟩⊢Q = ⟨ f ⟩⊢ Q

map-[_]⊢_ : P ⊆ Q → [ f ]⊢ P ⊆ [ f ]⊢ Q
map-[_]⊢_ P⊆Q = [ f ]⊢⁺ ⊆-trans {i = f ⊢ [f]⊢P} ([ f ]⊢⁻ ⊆-refl {x = [f]⊢P}) P⊆Q
where [f]⊢P = [ f ]⊢ P


------------------------------------------------------------------------
-- Decidability properties

Expand Down