-
Notifications
You must be signed in to change notification settings - Fork 68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make Rels less strict, add a StrictRels for the previous version #365
Draft
Taneb
wants to merge
2
commits into
agda:master
Choose a base branch
from
Taneb:nonstrict-rels
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{-# OPTIONS --without-K --safe #-} | ||
module Categories.Category.Dagger.Instance.StrictRels where | ||
|
||
open import Data.Product | ||
open import Function | ||
open import Relation.Binary.PropositionalEquality | ||
open import Level | ||
|
||
open import Categories.Category.Dagger | ||
open import Categories.Category.Instance.StrictRels | ||
|
||
StrictRelsHasDagger : ∀ {o ℓ} → HasDagger (StrictRels o ℓ) | ||
StrictRelsHasDagger = record | ||
{ _† = flip | ||
; †-identity = (lift ∘ sym ∘ lower) , (lift ∘ sym ∘ lower) | ||
; †-homomorphism = (map₂ swap) , (map₂ swap) | ||
; †-resp-≈ = λ p → (proj₁ p) , (proj₂ p) -- it's the implicits that need flipped | ||
; †-involutive = λ _ → id , id | ||
} | ||
|
||
StrictRelsDagger : ∀ o ℓ → DaggerCategory (suc o) (suc (o ⊔ ℓ)) (o ⊔ ℓ) | ||
StrictRelsDagger o ℓ = record | ||
{ C = StrictRels o ℓ | ||
; hasDagger = StrictRelsHasDagger | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,60 @@ | ||
{-# OPTIONS --without-K --safe #-} | ||
{-# OPTIONS --safe --without-K #-} | ||
|
||
module Categories.Category.Instance.Rels where | ||
|
||
open import Categories.Category | ||
open import Data.Product | ||
open import Function hiding (_⇔_) | ||
open import Function.Base | ||
open import Level | ||
open import Relation.Binary | ||
open import Relation.Binary.Construct.Composition | ||
open import Relation.Binary.PropositionalEquality | ||
|
||
open import Categories.Category.Core | ||
|
||
-- the category whose objects are sets and whose morphisms are binary relations. | ||
Rels : ∀ o ℓ → Category (suc o) (suc (o ⊔ ℓ)) (o ⊔ ℓ) | ||
Rels o ℓ = record | ||
{ Obj = Set o | ||
; _⇒_ = λ A B → REL A B (o ⊔ ℓ) | ||
; _≈_ = λ L R → L ⇔ R | ||
; id = λ x y → Lift ℓ (x ≡ y) | ||
; _∘_ = λ L R → R ; L | ||
; assoc = (λ { (b , fxb , c , gbc , hcy) → c , ((b , (fxb , gbc)) , hcy)}) | ||
, λ { (c , (b , fxb , gbc) , hcy) → b , fxb , c , gbc , hcy} | ||
; sym-assoc = (λ { (c , (b , fxb , gbc) , hcy) → b , fxb , c , gbc , hcy}) | ||
, (λ { (b , fxb , c , gbc , hcy) → c , ((b , (fxb , gbc)) , hcy)}) | ||
; identityˡ = (λ { (b , fxb , lift refl) → fxb}) , λ {_} {y} fxy → y , fxy , lift refl | ||
; identityʳ = (λ { (a , lift refl , fxy) → fxy}) , λ {x} {_} fxy → x , lift refl , fxy | ||
; identity² = (λ { (_ , lift p , lift q) → lift (trans p q)}) , λ { (lift refl) → _ , lift refl , lift refl } | ||
Rels : ∀ o ℓ → Category (suc (o ⊔ ℓ)) (suc (o ⊔ ℓ)) (o ⊔ ℓ) | ||
Rels o ℓ = record | ||
{ Obj = Setoid o ℓ | ||
; _⇒_ = λ A B → Σ[ _R_ ∈ REL (Setoid.Carrier A) (Setoid.Carrier B) (o ⊔ ℓ) ] (_R_ Respectsˡ Setoid._≈_ A × _R_ Respectsʳ Setoid._≈_ B) | ||
; _≈_ = λ f g → proj₁ f ⇔ proj₁ g | ||
; id = λ {A} → let open Setoid A in record | ||
{ fst = λ x y → Lift o (x ≈ y) | ||
; snd = record | ||
{ fst = λ x≈z y≈z → lift (trans (sym x≈z) (lower y≈z)) | ||
; snd = λ x≈z y≈x → lift (trans (lower y≈x) x≈z) | ||
} | ||
} | ||
; _∘_ = λ f g → record | ||
{ fst = proj₁ g ; proj₁ f | ||
; snd = record | ||
{ fst = λ y≈z y[g;f]x → proj₁ y[g;f]x , proj₁ (proj₂ g) y≈z (proj₁ (proj₂ y[g;f]x)) , proj₂ (proj₂ y[g;f]x) | ||
; snd = λ y≈z x[g;f]y → proj₁ x[g;f]y , proj₁ (proj₂ x[g;f]y) , proj₂ (proj₂ f) y≈z (proj₂ (proj₂ x[g;f]y)) | ||
} | ||
} | ||
; assoc = record | ||
{ fst = λ { (b , xfb , c , bgc , chy) → c , (b , xfb , bgc) , chy } | ||
; snd = λ { (c , (b , xfb , bgc) , chy) → b , xfb , c , bgc , chy } | ||
} | ||
; sym-assoc = record | ||
{ fst = λ { (c , (b , xfb , bgc) , chy) → b , xfb , c , bgc , chy } | ||
; snd = λ { (b , xfb , c , bgc , chy) → c , (b , xfb , bgc) , chy } | ||
} | ||
; identityˡ = λ {A} {B} {f} → record | ||
{ fst = λ af;≈b → proj₂ (proj₂ f) (lower (proj₂ (proj₂ af;≈b))) (proj₁ (proj₂ af;≈b)) | ||
; snd = λ afb → _ , afb , lift (Setoid.refl B) | ||
} | ||
; identityʳ = λ {A} {B} {f} → record | ||
{ fst = λ a≈;fb → proj₁ (proj₂ f) (Setoid.sym A (lower (proj₁ (proj₂ a≈;fb)))) (proj₂ (proj₂ a≈;fb)) | ||
; snd = λ afb → _ , lift (Setoid.refl A) , afb | ||
} | ||
; identity² = λ {A} → record | ||
{ fst = λ x≈;≈y → lift (Setoid.trans A (lower (proj₁ (proj₂ x≈;≈y))) (lower (proj₂ (proj₂ x≈;≈y)))) | ||
; snd = λ x≈y → _ , lift (Setoid.refl A) , x≈y | ||
} | ||
; equiv = record | ||
{ refl = id , id | ||
; sym = swap | ||
; trans = λ { (p₁ , p₂) (q₁ , q₂) → (q₁ ∘′ p₁) , p₂ ∘′ q₂} | ||
; trans = λ { (p₁ , p₂) (q₁ , q₂) → (q₁ ∘′ p₁) , (p₂ ∘′ q₂) } | ||
} | ||
; ∘-resp-≈ = λ f⇔h g⇔i → record | ||
{ fst = λ { (b , xgb , bfy) → b , proj₁ g⇔i xgb , proj₁ f⇔h bfy } | ||
; snd = λ { (b , xib , bhy) → b , proj₂ g⇔i xib , proj₂ f⇔h bhy } | ||
} | ||
; ∘-resp-≈ = λ f⇔h g⇔i → | ||
(λ { (b , gxb , fky) → b , proj₁ g⇔i gxb , proj₁ f⇔h fky }) , | ||
λ { (b , ixb , hby) → b , proj₂ g⇔i ixb , proj₂ f⇔h hby } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{-# OPTIONS --without-K --safe #-} | ||
module Categories.Category.Instance.StrictRels where | ||
|
||
open import Data.Product | ||
open import Function hiding (_⇔_) | ||
open import Level | ||
open import Relation.Binary | ||
open import Relation.Binary.Construct.Composition | ||
open import Relation.Binary.PropositionalEquality | ||
|
||
open import Categories.Category.Core | ||
|
||
-- the category whose objects are sets and whose morphisms are binary relations. | ||
StrictRels : ∀ o ℓ → Category (suc o) (suc (o ⊔ ℓ)) (o ⊔ ℓ) | ||
StrictRels o ℓ = record | ||
{ Obj = Set o | ||
; _⇒_ = λ A B → REL A B (o ⊔ ℓ) | ||
; _≈_ = λ L R → L ⇔ R | ||
; id = λ x y → Lift ℓ (x ≡ y) | ||
; _∘_ = λ L R → R ; L | ||
; assoc = (λ { (b , fxb , c , gbc , hcy) → c , ((b , (fxb , gbc)) , hcy)}) | ||
, λ { (c , (b , fxb , gbc) , hcy) → b , fxb , c , gbc , hcy} | ||
; sym-assoc = (λ { (c , (b , fxb , gbc) , hcy) → b , fxb , c , gbc , hcy}) | ||
, (λ { (b , fxb , c , gbc , hcy) → c , ((b , (fxb , gbc)) , hcy)}) | ||
; identityˡ = (λ { (b , fxb , lift refl) → fxb}) , λ {_} {y} fxy → y , fxy , lift refl | ||
; identityʳ = (λ { (a , lift refl , fxy) → fxy}) , λ {x} {_} fxy → x , lift refl , fxy | ||
; identity² = (λ { (_ , lift p , lift q) → lift (trans p q)}) , λ { (lift refl) → _ , lift refl , lift refl } | ||
; equiv = record | ||
{ refl = id , id | ||
; sym = swap | ||
; trans = λ { (p₁ , p₂) (q₁ , q₂) → (q₁ ∘′ p₁) , p₂ ∘′ q₂} | ||
} | ||
; ∘-resp-≈ = λ f⇔h g⇔i → | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. as you're already using pattern-matching lambdas, might as well continue to do so instead of using proj here? |
||
(λ { (b , gxb , fky) → b , proj₁ g⇔i gxb , proj₁ f⇔h fky }) , | ||
λ { (b , ixb , hby) → b , proj₂ g⇔i ixb , proj₂ f⇔h hby } | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please put explicit
using
in as many places as possible, strongly so on stdlib imports.