Debian Codegraph @

src/Data/Product/Properties/Dependent.agda

raw
1 ------------------------------------------------------------------------
2 -- The Agda standard library
3 --
4 -- Properties of 'very dependent' map / zipWith over products
5 ------------------------------------------------------------------------
6
7 {-# OPTIONS --cubical-compatible --safe #-}
8
9 module Data.Product.Properties.Dependent where
10
11 open import Data.Product using (Σ; _×_; _,_; map-Σ; map-Σ′; zipWith)
12 open import Function.Base using (id; flip)
13 open import Level using (Level)
14 open import Relation.Binary.PropositionalEquality.Core
15 using (_≡_; _≗_; cong₂; refl)
16
17 private
18 variable
19 a b p q r s : Level
20 A B C : Set a
21
22 ------------------------------------------------------------------------
23 -- map-Σ
24
25 module _ {B : A → Set b} {P : A → Set p} {Q : {x : A} → P x → B x → Set q} where
26
27 map-Σ-cong : {f g : (x : A) → B x} → {h k : ∀ {x} → (y : P x) → Q y (f x)} →
28 (∀ x → f x ≡ g x) →
29 (∀ {x} → (y : P x) → h y ≡ k y) →
30 (v : Σ A P) → map-Σ f h v ≡ map-Σ g k v
31 map-Σ-cong f≗g h≗k (x , y) = cong₂ _,_ (f≗g x) (h≗k y)
32
33 ------------------------------------------------------------------------
34 -- map-Σ′
35
36 module _ {B : A → Set b} {P : Set p} {Q : P → Set q} where
37
38 map-Σ′-cong : {f g : (x : A) → B x} → {h k : (x : P) → Q x} →
39 (∀ x → f x ≡ g x) →
40 ((y : P) → h y ≡ k y) →
41 (v : A × P) → map-Σ′ f h v ≡ map-Σ′ g k v
42 map-Σ′-cong f≗g h≗k (x , y) = cong₂ _,_ (f≗g x) (h≗k y)
43
44 ------------------------------------------------------------------------
45 -- zipWith
46
47 module _ {P : A → Set p} {Q : B → Set q} {R : C → Set r} {S : (x : C) → R x → Set s} where
48
49 zipWith-flip : (_∙_ : A → B → C) → (_∘_ : ∀ {x y} → P x → Q y → R (x ∙ y)) →
50 (_*_ : (x : C) → (y : R x) → S x y) →
51 {x : Σ A P} → {y : Σ B Q} →
52 zipWith _∙_ _∘_ _*_ x y ≡ zipWith (flip _∙_) (flip _∘_) _*_ y x
53 zipWith-flip _∙_ _∘_ _*_ = refl