Debian Codegraph @

src/Function/Metric/Bundles.agda

raw
1 ------------------------------------------------------------------------
2 -- The Agda standard library
3 --
4 -- Bundles for metrics
5 ------------------------------------------------------------------------
6
7 -- The contents of this module should be accessed via `Function.Metric`.
8
9 {-# OPTIONS --cubical-compatible --safe #-}
10
11 module Function.Metric.Bundles where
12
13 open import Algebra.Core using (Op₂)
14 open import Level using (Level; suc; _⊔_)
15 open import Relation.Binary.Core using (Rel)
16
17 open import Function.Metric.Structures
18 open import Function.Metric.Core
19
20 ------------------------------------------------------------------------
21 -- ProtoMetric
22
23 record ProtoMetric (a i ℓ₁ ℓ₂ ℓ₃ : Level)
24 : Set (suc (a ⊔ i ⊔ ℓ₁ ⊔ ℓ₂ ⊔ ℓ₃)) where
25 infix 4 _≈_ _≈ᵢ_ _≤_
26 field
27 Carrier : Set a
28 Image : Set i
29 _≈_ : Rel Carrier ℓ₁
30 _≈ᵢ_ : Rel Image ℓ₂
31 _≤_ : Rel Image ℓ₃
32 0# : Image
33 d : DistanceFunction Carrier Image
34 isProtoMetric : IsProtoMetric _≈_ _≈ᵢ_ _≤_ 0# d
35
36 open IsProtoMetric isProtoMetric public
37
38 ------------------------------------------------------------------------
39 -- PreMetric
40
41 record PreMetric (a i ℓ₁ ℓ₂ ℓ₃ : Level)
42 : Set (suc (a ⊔ i ⊔ ℓ₁ ⊔ ℓ₂ ⊔ ℓ₃)) where
43 infix 4 _≈_ _≈ᵢ_ _≤_
44 field
45 Carrier : Set a
46 Image : Set i
47 _≈_ : Rel Carrier ℓ₁
48 _≈ᵢ_ : Rel Image ℓ₂
49 _≤_ : Rel Image ℓ₃
50 0# : Image
51 d : DistanceFunction Carrier Image
52 isPreMetric : IsPreMetric _≈_ _≈ᵢ_ _≤_ 0# d
53
54 open IsPreMetric isPreMetric public
55
56 protoMetric : ProtoMetric a i ℓ₁ ℓ₂ ℓ₃
57 protoMetric = record
58 { isProtoMetric = isProtoMetric
59 }
60
61 ------------------------------------------------------------------------
62 -- QuasiSemiMetric
63
64 record QuasiSemiMetric (a i ℓ₁ ℓ₂ ℓ₃ : Level)
65 : Set (suc (a ⊔ i ⊔ ℓ₁ ⊔ ℓ₂ ⊔ ℓ₃)) where
66
67 infix 4 _≈_ _≈ᵢ_ _≤_
68 field
69 Carrier : Set a
70 Image : Set i
71 _≈_ : Rel Carrier ℓ₁
72 _≈ᵢ_ : Rel Image ℓ₂
73 _≤_ : Rel Image ℓ₃
74 0# : Image
75 d : DistanceFunction Carrier Image
76 isQuasiSemiMetric : IsQuasiSemiMetric _≈_ _≈ᵢ_ _≤_ 0# d
77
78 open IsQuasiSemiMetric isQuasiSemiMetric public
79
80 preMetric : PreMetric a i ℓ₁ ℓ₂ ℓ₃
81 preMetric = record
82 { isPreMetric = isPreMetric
83 }
84
85 open PreMetric preMetric public
86 using (protoMetric)
87
88 ------------------------------------------------------------------------
89 -- SemiMetric
90
91 record SemiMetric (a i ℓ₁ ℓ₂ ℓ₃ : Level)
92 : Set (suc (a ⊔ i ⊔ ℓ₁ ⊔ ℓ₂ ⊔ ℓ₃)) where
93 infix 4 _≈_ _≈ᵢ_ _≤_
94 field
95 Carrier : Set a
96 Image : Set i
97 _≈_ : Rel Carrier ℓ₁
98 _≈ᵢ_ : Rel Image ℓ₂
99 _≤_ : Rel Image ℓ₃
100 0# : Image
101 d : DistanceFunction Carrier Image
102 isSemiMetric : IsSemiMetric _≈_ _≈ᵢ_ _≤_ 0# d
103
104 open IsSemiMetric isSemiMetric public
105
106 quasiSemiMetric : QuasiSemiMetric a i ℓ₁ ℓ₂ ℓ₃
107 quasiSemiMetric = record
108 { isQuasiSemiMetric = isQuasiSemiMetric
109 }
110
111 open QuasiSemiMetric quasiSemiMetric public
112 using (protoMetric; preMetric)
113
114 ------------------------------------------------------------------------
115 -- GeneralMetric
116
117 -- Note that this package is not necessarily a metric in the classical
118 -- sense as there is no way to ensure that the _∙_ operator really
119 -- represents addition. See `Function.Metric.Nat` and
120 -- `Function.Metric.Rational` for more specialised `Metric` and
121 -- `UltraMetric` packages.
122
123 -- See the discussion accompanying the `IsGeneralMetric` structure for
124 -- more details.
125
126 record GeneralMetric (a i ℓ₁ ℓ₂ ℓ₃ : Level)
127 : Set (suc (a ⊔ i ⊔ ℓ₁ ⊔ ℓ₂ ⊔ ℓ₃)) where
128 infix 4 _≈_ _≈ᵢ_ _≤_
129 infixl 6 _∙_
130 field
131 Carrier : Set a
132 Image : Set i
133 _≈_ : Rel Carrier ℓ₁
134 _≈ᵢ_ : Rel Image ℓ₂
135 _≤_ : Rel Image ℓ₃
136 0# : Image
137 _∙_ : Op₂ Image
138 d : DistanceFunction Carrier Image
139 isGeneralMetric : IsGeneralMetric _≈_ _≈ᵢ_ _≤_ 0# _∙_ d
140
141 open IsGeneralMetric isGeneralMetric public
142
143 semiMetric : SemiMetric a i ℓ₁ ℓ₂ ℓ₃
144 semiMetric = record
145 { isSemiMetric = isSemiMetric
146 }
147
148 open SemiMetric semiMetric public
149 using (protoMetric; preMetric; quasiSemiMetric)