-
Notifications
You must be signed in to change notification settings - Fork 257
Add some type relations and isomorphisms #2419
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
Changes from 5 commits
876c287
e468b94
e6f51de
6246d5e
b030bb4
8391682
22889c7
dd1b1dc
7850ace
7a5ddb9
8a8ca14
473195a
4f9ab4d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,7 @@ open import Axiom.Extensionality.Propositional using (Extensionality) | |
open import Data.Bool.Base using (true; false) | ||
open import Data.Empty.Polymorphic using (⊥; ⊥-elim) | ||
open import Data.Product.Base as Product | ||
using (_×_; Σ; curry; uncurry; _,_; -,_; <_,_>; proj₁; proj₂; ∃₂; ∃) | ||
using (_×_; Σ; curry; uncurry; _,_; -,_; <_,_>; proj₁; proj₂; ∃₂; ∃; ∃-syntax) | ||
open import Data.Product.Function.NonDependent.Propositional | ||
open import Data.Sum.Base as Sum | ||
open import Data.Sum.Properties using (swap-involutive) | ||
|
@@ -106,24 +106,44 @@ private | |
⊎-identity ℓ = ⊎-identityˡ ℓ , ⊎-identityʳ ℓ | ||
|
||
------------------------------------------------------------------------ | ||
-- Properties of × and ⊎ | ||
-- Properties of ∃ and ⊎ | ||
|
||
-- × distributes over ⊎ | ||
-- ∃ distributes over ⊎ | ||
|
||
×-distribˡ-⊎ : ∀ ℓ → _DistributesOverˡ_ {ℓ = ℓ} _↔_ _×_ _⊎_ | ||
×-distribˡ-⊎ ℓ _ _ _ = mk↔ₛ′ | ||
Σ-distribˡ-⊎ : {P : A → Set a} {Q : A → Set b} → | ||
(∃ λ a → P a ⊎ Q a) ↔ (∃ P ⊎ ∃ Q) | ||
Σ-distribˡ-⊎ = mk↔ₛ′ | ||
(uncurry λ x → [ inj₁ ∘′ (x ,_) , inj₂ ∘′ (x ,_) ]′) | ||
[ Product.map₂ inj₁ , Product.map₂ inj₂ ]′ | ||
[ (λ _ → refl) , (λ _ → refl) ] | ||
(uncurry λ _ → [ (λ _ → refl) , (λ _ → refl) ]) | ||
|
||
×-distribʳ-⊎ : ∀ ℓ → _DistributesOverʳ_ {ℓ = ℓ} _↔_ _×_ _⊎_ | ||
×-distribʳ-⊎ ℓ _ _ _ = mk↔ₛ′ | ||
(uncurry [ curry inj₁ , curry inj₂ ]′) | ||
[ Product.map₁ inj₁ , Product.map₁ inj₂ ]′ | ||
Σ-distribʳ-⊎ : {P : Set a} {Q : Set b} {R : P ⊎ Q → Set c} → | ||
(Σ (P ⊎ Q) R) ↔ (Σ P (R ∘ inj₁) ⊎ Σ Q (R ∘ inj₂)) | ||
Σ-distribʳ-⊎ = mk↔ₛ′ | ||
(uncurry [ curry inj₁ , curry inj₂ ]) | ||
[ Product.dmap inj₁ id , Product.dmap inj₂ id ] | ||
[ (λ _ → refl) , (λ _ → refl) ] | ||
(uncurry [ (λ _ _ → refl) , (λ _ _ → refl) ]) | ||
|
||
------------------------------------------------------------------------ | ||
-- Properties of × and ⊎ | ||
|
||
-- × distributes over ⊎ | ||
-- primed variants are more level polymorphic | ||
|
||
×-distribˡ-⊎′ : (A × (B ⊎ C)) ↔ (A × B ⊎ A × C) | ||
×-distribˡ-⊎′ = Σ-distribˡ-⊎ | ||
|
||
|
||
×-distribˡ-⊎ : ∀ ℓ → _DistributesOverˡ_ {ℓ = ℓ} _↔_ _×_ _⊎_ | ||
×-distribˡ-⊎ ℓ _ _ _ = ×-distribˡ-⊎′ | ||
|
||
×-distribʳ-⊎′ : ((A ⊎ B) × C) ↔ (A × C ⊎ B × C) | ||
×-distribʳ-⊎′ = Σ-distribʳ-⊎ | ||
|
||
×-distribʳ-⊎ : ∀ ℓ → _DistributesOverʳ_ {ℓ = ℓ} _↔_ _×_ _⊎_ | ||
×-distribʳ-⊎ ℓ _ _ _ = ×-distribʳ-⊎′ | ||
|
||
×-distrib-⊎ : ∀ ℓ → _DistributesOver_ {ℓ = ℓ} _↔_ _×_ _⊎_ | ||
×-distrib-⊎ ℓ = ×-distribˡ-⊎ ℓ , ×-distribʳ-⊎ ℓ | ||
|
||
|
@@ -332,3 +352,11 @@ True↔ ( true because [p]) irr = | |
mk↔ₛ′ (λ _ → invert [p]) (λ _ → _) (irr _) (λ _ → refl) | ||
True↔ (false because ofⁿ ¬p) _ = | ||
mk↔ₛ′ (λ()) (invert (ofⁿ ¬p)) (λ x → flip contradiction ¬p x) (λ ()) | ||
|
||
------------------------------------------------------------------------ | ||
-- Relating a predicate to an existentially quantified one with the | ||
-- 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) | ||
jamesmckinna marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
(λ where (_ , refl , _) → refl) (λ where _ → refl) |
Uh oh!
There was an error while loading. Please reload this page.