Debian Codegraph @

src/Function/Properties.agda

raw
1 ------------------------------------------------------------------------
2 -- The Agda standard library
3 --
4 -- Basic properties of the function type
5 ------------------------------------------------------------------------
6
7 {-# OPTIONS --cubical-compatible --safe #-}
8
9 module Function.Properties where
10
11 open import Axiom.Extensionality.Propositional using (Extensionality)
12 open import Function.Base using (flip; _∘_)
13 open import Function.Bundles using (_↔_; mk↔ₛ′; Inverse)
14 open import Level using (Level)
15 open import Relation.Binary.PropositionalEquality.Core
16 using (trans; cong; cong′)
17
18 private
19 variable
20 a b c d p : Level
21 A : Set a
22 B : Set b
23
24 ------------------------------------------------------------------------
25 -- Implicit and explicit function spaces are isomorphic
26
27 Π↔Π : {B : A → Set b} → ((x : A) → B x) ↔ ({x : A} → B x)
28 Π↔Π = mk↔ₛ′ (λ f {x} → f x) (λ f _ → f) cong′ cong′
29
30 ------------------------------------------------------------------------
31 -- Function spaces can be reordered
32
33 ΠΠ↔ΠΠ : (R : A → B → Set p) →
34 ((x : A) (y : B) → R x y) ↔ ((y : B) (x : A) → R x y)
35 ΠΠ↔ΠΠ _ = mk↔ₛ′ flip flip cong′ cong′
36
37 ------------------------------------------------------------------------
38 -- Assuming extensionality then → preserves ↔
39
40 →-cong-↔ : {A : Set a} {B : Set b} {C : Set c} {D : Set d} →
41 Extensionality a c → Extensionality b d →
42 A ↔ B → C ↔ D → (A → C) ↔ (B → D)
43 →-cong-↔ extAC extBD A↔B C↔D = mk↔ₛ′
44 (λ h → C↔D.to ∘ h ∘ A↔B.from)
45 (λ g → C↔D.from ∘ g ∘ A↔B.to )
46 (λ h → extBD λ x → trans (C↔D.strictlyInverseˡ _) (cong h (A↔B.strictlyInverseˡ x)))
47 (λ g → extAC λ x → trans (C↔D.strictlyInverseʳ _) (cong g (A↔B.strictlyInverseʳ x)))
48 where module A↔B = Inverse A↔B; module C↔D = Inverse C↔D