-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
# Description This PR defines a type of biimplications, and proves some basic properties. ## Checklist Before submitting a merge request, please check the items below: - [x] I've read [the contributing guidelines](https://github.com/plt-amy/1lab/blob/main/CONTRIBUTING.md). - [x] The imports of new modules have been sorted with `support/sort-imports.hs` (or `nix run --experimental-features nix-command -f . sort-imports`). - [x] All new code blocks have "agda" as their language. If your change affects many files without adding substantial content, and you don't want your name to appear on those pages (for example, treewide refactorings or reformattings), start the commit message and PR title with `chore:`.
- Loading branch information
Showing
17 changed files
with
207 additions
and
40 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
--- | ||
description: | | ||
Biimplications. | ||
--- | ||
<!-- | ||
```agda | ||
open import 1Lab.Reflection.Record | ||
open import 1Lab.Extensionality | ||
open import 1Lab.HLevel.Closure | ||
open import 1Lab.HLevel | ||
open import 1Lab.Equiv | ||
open import 1Lab.Type | ||
|
||
open import Meta.Invariant | ||
``` | ||
--> | ||
```agda | ||
module 1Lab.Biimp where | ||
``` | ||
|
||
# Biimplications | ||
|
||
:::{.definition #biimplication} | ||
A **biimplication** $A \leftrightarrow B$ between a pair of types $A, B$ | ||
is a pair of functions $A \to B, B \to A$. | ||
::: | ||
|
||
```agda | ||
record _↔_ {ℓ} {ℓ'} (A : Type ℓ) (B : Type ℓ') : Type (ℓ ⊔ ℓ') where | ||
no-eta-equality | ||
constructor biimp | ||
field | ||
to : A → B | ||
from : B → A | ||
|
||
open _↔_ | ||
``` | ||
|
||
<!-- | ||
```agda | ||
private variable | ||
ℓ ℓ' : Level | ||
A B C : Type ℓ | ||
``` | ||
--> | ||
|
||
<!-- | ||
```agda | ||
module Biimp (f : A ↔ B) where | ||
open _↔_ f public | ||
``` | ||
--> | ||
|
||
If $A$ and $B$ [[n-types]], then the type of biimplications $A \leftrightarrow B$ | ||
is also an n-type. | ||
|
||
<!-- | ||
```agda | ||
private unquoteDecl eqv = declare-record-iso eqv (quote _↔_) | ||
``` | ||
--> | ||
|
||
```agda | ||
↔-is-hlevel : ∀ n → is-hlevel A n → is-hlevel B n → is-hlevel (A ↔ B) n | ||
↔-is-hlevel n A-hl B-hl = | ||
Iso→is-hlevel n eqv $ | ||
×-is-hlevel n | ||
(Π-is-hlevel n λ _ → B-hl) | ||
(Π-is-hlevel n λ _ → A-hl) | ||
``` | ||
|
||
<!-- | ||
```agda | ||
instance | ||
H-Level-↔ | ||
: ∀ {n} | ||
→ ⦃ _ : H-Level A n ⦄ ⦃ _ : H-Level B n ⦄ | ||
→ H-Level (A ↔ B) n | ||
H-Level-↔ {n = n} .H-Level.has-hlevel = | ||
↔-is-hlevel n (hlevel n) (hlevel n) | ||
|
||
instance | ||
Extensional-↔ | ||
: ∀ {ℓr} | ||
→ ⦃ _ : Extensional ((A → B) × (B → A)) ℓr ⦄ | ||
→ Extensional (A ↔ B) ℓr | ||
Extensional-↔ ⦃ e ⦄ = iso→extensional eqv e | ||
``` | ||
--> | ||
|
||
## Working with biimplications | ||
|
||
There is an identity biimplication, and biimplications compose. | ||
|
||
```agda | ||
id↔ : A ↔ A | ||
id↔ .to = id | ||
id↔ .from = id | ||
|
||
_∙↔_ : A ↔ B → B ↔ C → A ↔ C | ||
(f ∙↔ g) .to = g .to ∘ f .to | ||
(f ∙↔ g) .from = f .from ∘ g .from | ||
``` | ||
|
||
Moreover, every biimplication $A \leftrightarrow B$ induces a biimplication | ||
$B \leftrightarrow A$. | ||
|
||
```agda | ||
_↔⁻¹ : A ↔ B → B ↔ A | ||
(f ↔⁻¹) .to = f .from | ||
(f ↔⁻¹) .from = f .to | ||
``` | ||
|
||
## Biimplications and equivalences | ||
|
||
Every [[equivalence]] is a biimplication. | ||
|
||
```agda | ||
equiv→biimp : A ≃ B → A ↔ B | ||
equiv→biimp f .to = Equiv.to f | ||
equiv→biimp f .from = Equiv.from f | ||
``` | ||
|
||
:::{.definition #logical-equivalence} | ||
|
||
Every biimplication between [[propositions]] is an [[equivalence]]. | ||
In light of this, biimplications are often referred to as | ||
**logical equivalences**. | ||
|
||
```agda | ||
biimp→equiv : is-prop A → is-prop B → A ↔ B → A ≃ B | ||
biimp→equiv A-prop B-prop f = | ||
prop-ext A-prop B-prop (f .to) (f .from) | ||
``` | ||
::: | ||
|
||
<!-- | ||
```agda | ||
infix 21 _↔_ | ||
infixr 30 _∙↔_ | ||
infix 31 _↔⁻¹ | ||
``` | ||
--> |
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
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
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
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
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
Oops, something went wrong.