Debian Codegraph @

src/Function/Construct/Constant.agda

raw
1 ------------------------------------------------------------------------
2 -- The Agda standard library
3 --
4 -- The constant function
5 ------------------------------------------------------------------------
6
7 {-# OPTIONS --cubical-compatible --safe #-}
8
9 module Function.Construct.Constant where
10
11 open import Function.Base using (const)
12 open import Function.Bundles using (Func)
13 import Function.Definitions as Definitions using (Congruent)
14 import Function.Structures as Structures using (IsCongruent)
15 open import Level using (Level)
16 open import Relation.Binary.Core using (Rel)
17 open import Relation.Binary.Bundles using (Setoid)
18 open import Relation.Binary.Structures as B hiding (IsEquivalence)
19
20 private
21 variable
22 a b ℓ₁ ℓ₂ : Level
23 A B : Set a
24
25 ------------------------------------------------------------------------
26 -- Properties
27
28 module _ (_≈₁_ : Rel A ℓ₁) (_≈₂_ : Rel B ℓ₂) where
29
30 open Definitions
31
32 congruent : ∀ {b} → b ≈₂ b → Congruent _≈₁_ _≈₂_ (const b)
33 congruent refl _ = refl
34
35 ------------------------------------------------------------------------
36 -- Structures
37
38 module _
39 {≈₁ : Rel A ℓ₁} {≈₂ : Rel B ℓ₂}
40 (isEq₁ : B.IsEquivalence ≈₁)
41 (isEq₂ : B.IsEquivalence ≈₂) where
42
43 open Structures ≈₁ ≈₂
44 open B.IsEquivalence
45
46 isCongruent : ∀ b → IsCongruent (const b)
47 isCongruent b = record
48 { cong = congruent ≈₁ ≈₂ (refl isEq₂)
49 ; isEquivalence₁ = isEq₁
50 ; isEquivalence₂ = isEq₂
51 }
52
53 ------------------------------------------------------------------------
54 -- Setoid bundles
55
56 module _ (S : Setoid a ℓ₂) (T : Setoid b ℓ₂) where
57
58 open Setoid
59
60 function : Carrier T → Func S T
61 function b = record
62 { to = const b
63 ; cong = congruent (_≈_ S) (_≈_ T) (refl T)
64 }