-
Notifications
You must be signed in to change notification settings - Fork 156
New notion of equivalence: Bijective relations #1252
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
Open
anshwad10
wants to merge
10
commits into
agda:master
Choose a base branch
from
anshwad10:bifunctional-rel
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.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
bf1e4fc
Bifunctional relations
anshwad10 648993b
Define based identity systems, prove equivalence of functional relati…
anshwad10 643c0a3
yo dawg I heard u liek hcomp so we put a hcomp in your hcomp so you c…
anshwad10 5600413
Actually define bijective relations
anshwad10 896d912
more bijective relations
anshwad10 3f16baa
composition of BijectiveRelations
anshwad10 7fcb3e0
Explicit construction of `EquivIsoBijectiveRel`, `pathIsoBijectiveRel`
anshwad10 bf41a31
more
anshwad10 5479bcf
rename trr and trl
anshwad10 861451e
fix whitespace
anshwad10 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 hidden or 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,150 @@ | ||
| {- | ||
|
|
||
| Bijective Relations ([BijectiveRel]) | ||
|
|
||
| - Path to BijectiveRel ([pathToBijectiveRel]) | ||
| - BijectiveRel is equivalent to Equiv ([BijectiveRel≃Equiv]) | ||
|
|
||
| -} | ||
| module Cubical.Foundations.Equiv.BijectiveRel where | ||
|
|
||
| open import Cubical.Foundations.Prelude | ||
| open import Cubical.Foundations.Isomorphism | ||
| open import Cubical.Foundations.Equiv | ||
| open import Cubical.Foundations.Univalence | ||
| open import Cubical.Foundations.Univalence.Dependent | ||
| open import Cubical.Foundations.GroupoidLaws | ||
| open import Cubical.Foundations.Function | ||
| open import Cubical.Foundations.HLevels | ||
| open import Cubical.Functions.FunExtEquiv | ||
| open import Cubical.Relation.Binary | ||
| open import Cubical.Reflection.RecordEquiv | ||
| open import Cubical.Reflection.StrictEquiv | ||
| open import Cubical.Data.Sigma | ||
|
|
||
| private variable | ||
| ℓ ℓ' ℓ'' : Level | ||
| A B C : Type ℓ | ||
| R S : Rel A B ℓ | ||
|
|
||
| open HeterogenousRelation | ||
|
|
||
| record isBijectiveRel {A : Type ℓ} {B : Type ℓ'} (R : Rel A B ℓ'') : Type (ℓ-max ℓ (ℓ-max ℓ' ℓ'')) where | ||
| field | ||
| rContr : isFunctionalRel R | ||
| lContr : isFunctionalRel (flip R) | ||
|
|
||
| fun : A → B | ||
| fun a = rContr a .fst .fst | ||
|
|
||
| inv : B → A | ||
| inv b = lContr b .fst .fst | ||
|
|
||
| funR : ∀ a → R a (fun a) | ||
| funR a = rContr a .fst .snd | ||
|
|
||
| invR : ∀ b → R (inv b) b | ||
| invR b = lContr b .fst .snd | ||
|
|
||
| rightIsId : ∀ a → isIdentitySystem (fun a) (R a) (funR a) | ||
| rightIsId a = isContrTotal→isIdentitySystem (rContr a) | ||
|
|
||
| module _ (a : A) where | ||
| open isIdentitySystem (rightIsId a) using () | ||
| renaming (isoPath to rightIsoPath; equivPath to rightEquivPath) public | ||
|
|
||
| leftIsId : ∀ b → isIdentitySystem (inv b) (flip R b) (invR b) | ||
| leftIsId b = isContrTotal→isIdentitySystem (lContr b) | ||
|
|
||
| module _ (b : B) where | ||
| open isIdentitySystem (leftIsId b) using () | ||
| renaming (isoPath to leftIsoPath; equivPath to leftEquivPath) public | ||
|
|
||
| isEquivFun : isEquiv fun | ||
| isEquivFun .equiv-proof b = isOfHLevelRetractFromIso 0 (Σ-cong-iso-snd (λ a → rightIsoPath a b)) (lContr b) | ||
|
|
||
| isEquivInv : isEquiv inv | ||
| isEquivInv .equiv-proof a = isOfHLevelRetractFromIso 0 (Σ-cong-iso-snd (λ b → leftIsoPath b a)) (rContr a) | ||
|
|
||
| open isBijectiveRel | ||
|
|
||
| unquoteDecl isBijectiveRelIsoΣ = declareRecordIsoΣ isBijectiveRelIsoΣ (quote isBijectiveRel) | ||
|
|
||
| isPropIsBijectiveRel : {R : Rel A B ℓ''} → isProp (isBijectiveRel R) | ||
| isPropIsBijectiveRel x y i .rContr a = isPropIsContr (x .rContr a) (y .rContr a) i | ||
| isPropIsBijectiveRel x y i .lContr a = isPropIsContr (x .lContr a) (y .lContr a) i | ||
|
|
||
| BijectiveRel : ∀ (A : Type ℓ) (B : Type ℓ') ℓ'' → Type (ℓ-max (ℓ-max ℓ ℓ') (ℓ-suc ℓ'')) | ||
| BijectiveRel A B ℓ'' = Σ[ R ∈ Rel A B ℓ'' ] isBijectiveRel R | ||
|
|
||
| BijectiveRelIsoΣ : Iso (BijectiveRel A B ℓ'') (Σ[ R ∈ Rel A B ℓ'' ] isFunctionalRel R × isFunctionalRel (flip R)) | ||
| BijectiveRelIsoΣ = Σ-cong-iso-snd λ _ → isBijectiveRelIsoΣ | ||
|
|
||
| BijectiveRelPathP : {A : I → Type ℓ} {B : I → Type ℓ'} {R₀ : BijectiveRel (A i0) (B i0) ℓ''} {R₁ : BijectiveRel (A i1) (B i1) ℓ''} | ||
| → PathP (λ i → Rel (A i) (B i) ℓ'') (R₀ .fst) (R₁ .fst) | ||
| → PathP (λ i → BijectiveRel (A i) (B i) ℓ'') R₀ R₁ | ||
| BijectiveRelPathP = ΣPathPProp λ _ → isPropIsBijectiveRel | ||
|
|
||
| BijectiveRelEq : {R₀ R₁ : BijectiveRel A B ℓ''} → (∀ a b → R₀ .fst a b ≃ R₁ .fst a b) → R₀ ≡ R₁ | ||
| BijectiveRelEq h = BijectiveRelPathP (funExt₂ λ a b → ua (h a b)) | ||
|
|
||
| BijectiveRel→Equiv : BijectiveRel A B ℓ → A ≃ B | ||
| BijectiveRel→Equiv (R , Rbij) .fst = fun Rbij | ||
| BijectiveRel→Equiv (R , Rbij) .snd = isEquivFun Rbij | ||
|
|
||
| Equiv→BijectiveRel : A ≃ B → BijectiveRel A B _ | ||
| Equiv→BijectiveRel e .fst = graphRel (e .fst) | ||
| Equiv→BijectiveRel e .snd .rContr a = isContrSingl (e .fst a) | ||
| Equiv→BijectiveRel e .snd .lContr = e .snd .equiv-proof | ||
|
|
||
| EquivIsoBijectiveRel : (A B : Type ℓ) → Iso (A ≃ B) (BijectiveRel A B ℓ) | ||
| EquivIsoBijectiveRel A B .Iso.fun = Equiv→BijectiveRel | ||
| EquivIsoBijectiveRel A B .Iso.inv = BijectiveRel→Equiv | ||
| EquivIsoBijectiveRel A B .Iso.rightInv (R , Rbij) = BijectiveRelEq $ rightEquivPath Rbij | ||
| EquivIsoBijectiveRel A B .Iso.leftInv e = equivEq refl | ||
|
|
||
| Equiv≃BijectiveRel : (A B : Type ℓ) → (A ≃ B) ≃ (BijectiveRel A B ℓ) | ||
| Equiv≃BijectiveRel A B = isoToEquiv (EquivIsoBijectiveRel A B) | ||
|
|
||
| isBijectiveIdRel : isBijectiveRel (idRel A) | ||
| isBijectiveIdRel .rContr = isContrSingl | ||
| isBijectiveIdRel .lContr = isContrSingl' | ||
|
|
||
| idBijectiveRel : BijectiveRel A A _ | ||
| idBijectiveRel = _ , isBijectiveIdRel | ||
|
|
||
| isBijectiveInvRel : isBijectiveRel R → isBijectiveRel (invRel R) | ||
| isBijectiveInvRel Rbij .rContr = Rbij .lContr | ||
| isBijectiveInvRel Rbij .lContr = Rbij .rContr | ||
|
|
||
| invBijectiveRel : BijectiveRel A B ℓ' → BijectiveRel B A ℓ' | ||
| invBijectiveRel (_ , Rbij) = _ , isBijectiveInvRel Rbij | ||
|
|
||
| isBijectiveCompRel : isBijectiveRel R → isBijectiveRel S → isBijectiveRel (compRel R S) | ||
| isBijectiveCompRel Rbij Sbij .rContr = isFunctionalCompRel (Rbij .rContr) (Sbij .rContr) | ||
| isBijectiveCompRel Rbij Sbij .lContr = isCofunctionalCompRel (Rbij .lContr) (Sbij .lContr) | ||
|
|
||
| compBijectiveRel : BijectiveRel A B ℓ → BijectiveRel B C ℓ' → BijectiveRel A C _ | ||
| compBijectiveRel (_ , Rbij) (_ , Sbij) = _ , isBijectiveCompRel Rbij Sbij | ||
|
|
||
| isBijectivePathP : (A : I → Type ℓ) → isBijectiveRel (PathP A) | ||
| isBijectivePathP A .rContr = isContrSinglP A | ||
| isBijectivePathP A .lContr = isContrSinglP' A | ||
|
|
||
| pathToBijectiveRel : A ≡ B → BijectiveRel A B _ | ||
| pathToBijectiveRel P = _ , isBijectivePathP λ i → P i | ||
|
|
||
| BijectiveRelToPath : BijectiveRel A B ℓ → A ≡ B | ||
| BijectiveRelToPath R = ua (BijectiveRel→Equiv R) | ||
|
|
||
| path→BijectiveRel→Equiv : (P : A ≡ B) → BijectiveRel→Equiv (pathToBijectiveRel P) ≡ pathToEquiv P | ||
| path→BijectiveRel→Equiv P = equivEq refl | ||
|
|
||
| pathIsoBijectiveRel : Iso (A ≡ B) (BijectiveRel A B _) | ||
| pathIsoBijectiveRel .Iso.fun = pathToBijectiveRel | ||
| pathIsoBijectiveRel .Iso.inv = BijectiveRelToPath | ||
| pathIsoBijectiveRel .Iso.rightInv (R , Rbij) = BijectiveRelEq λ a b → ua-ungluePath-Equiv _ ∙ₑ rightEquivPath Rbij a b | ||
| pathIsoBijectiveRel .Iso.leftInv P = cong ua (path→BijectiveRel→Equiv P) ∙ ua-pathToEquiv P | ||
|
|
||
| path≡BijectiveRel : (A ≡ B) ≡ BijectiveRel A B _ | ||
| path≡BijectiveRel = isoToPath pathIsoBijectiveRel |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
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.
Do we really need all of this duplication of singlP?
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.
I needed
contrSinglP'to defineisBijectivePathP; I could instead definecontrSinglP'by transporting the proof ofcontrSinglPbut I don't think there is a way to do that which computes as nicely?