| 1 |
------------------------------------------------------------------------ |
| 2 |
-- The Agda standard library |
| 3 |
-- |
| 4 |
-- Bundles for metrics over ℕ |
| 5 |
------------------------------------------------------------------------ |
| 6 |
|
| 7 |
-- Unfortunately, unlike definitions and structures, the bundles over |
| 8 |
-- general metric spaces cannot be reused as it is impossible to |
| 9 |
-- constrain the image set to ℕ. |
| 10 |
|
| 11 |
{-# OPTIONS --cubical-compatible --safe #-} |
| 12 |
|
| 13 |
module Function.Metric.Nat.Bundles where |
| 14 |
|
| 15 |
open import Data.Nat.Base hiding (suc; _⊔_) |
| 16 |
open import Function.Base using (const) |
| 17 |
open import Level using (Level; suc; _⊔_) |
| 18 |
open import Relation.Binary.Core using (Rel) |
| 19 |
open import Relation.Binary.PropositionalEquality.Core using (_≡_) |
| 20 |
open import Relation.Binary.PropositionalEquality.Properties |
| 21 |
using (isEquivalence) |
| 22 |
open import Function.Metric.Nat.Core using (DistanceFunction) |
| 23 |
open import Function.Metric.Nat.Structures |
| 24 |
using (IsProtoMetric; IsPreMetric; IsQuasiSemiMetric; IsSemiMetric |
| 25 |
; IsMetric; IsUltraMetric) |
| 26 |
open import Function.Metric.Bundles as Base using (GeneralMetric) |
| 27 |
|
| 28 |
------------------------------------------------------------------------ |
| 29 |
-- Proto-metric |
| 30 |
|
| 31 |
record ProtoMetric a ℓ : Set (suc (a ⊔ ℓ)) where |
| 32 |
infix 4 _≈_ |
| 33 |
field |
| 34 |
Carrier : Set a |
| 35 |
_≈_ : Rel Carrier ℓ |
| 36 |
d : DistanceFunction Carrier |
| 37 |
isProtoMetric : IsProtoMetric _≈_ d |
| 38 |
|
| 39 |
open IsProtoMetric isProtoMetric public |
| 40 |
|
| 41 |
------------------------------------------------------------------------ |
| 42 |
-- PreMetric |
| 43 |
|
| 44 |
record PreMetric a ℓ : Set (suc (a ⊔ ℓ)) where |
| 45 |
infix 4 _≈_ |
| 46 |
field |
| 47 |
Carrier : Set a |
| 48 |
_≈_ : Rel Carrier ℓ |
| 49 |
d : DistanceFunction Carrier |
| 50 |
isPreMetric : IsPreMetric _≈_ d |
| 51 |
|
| 52 |
open IsPreMetric isPreMetric public |
| 53 |
|
| 54 |
protoMetric : ProtoMetric a ℓ |
| 55 |
protoMetric = record |
| 56 |
{ isProtoMetric = isProtoMetric |
| 57 |
} |
| 58 |
|
| 59 |
------------------------------------------------------------------------ |
| 60 |
-- QuasiSemiMetric |
| 61 |
|
| 62 |
record QuasiSemiMetric a ℓ : Set (suc (a ⊔ ℓ)) where |
| 63 |
infix 4 _≈_ |
| 64 |
field |
| 65 |
Carrier : Set a |
| 66 |
_≈_ : Rel Carrier ℓ |
| 67 |
d : DistanceFunction Carrier |
| 68 |
isQuasiSemiMetric : IsQuasiSemiMetric _≈_ d |
| 69 |
|
| 70 |
open IsQuasiSemiMetric isQuasiSemiMetric public |
| 71 |
|
| 72 |
preMetric : PreMetric a ℓ |
| 73 |
preMetric = record |
| 74 |
{ isPreMetric = isPreMetric |
| 75 |
} |
| 76 |
|
| 77 |
open PreMetric preMetric public |
| 78 |
using (protoMetric) |
| 79 |
|
| 80 |
------------------------------------------------------------------------ |
| 81 |
-- SemiMetric |
| 82 |
|
| 83 |
record SemiMetric a ℓ : Set (suc (a ⊔ ℓ)) where |
| 84 |
infix 4 _≈_ |
| 85 |
field |
| 86 |
Carrier : Set a |
| 87 |
_≈_ : Rel Carrier ℓ |
| 88 |
d : DistanceFunction Carrier |
| 89 |
isSemiMetric : IsSemiMetric _≈_ d |
| 90 |
|
| 91 |
open IsSemiMetric isSemiMetric public |
| 92 |
|
| 93 |
quasiSemiMetric : QuasiSemiMetric a ℓ |
| 94 |
quasiSemiMetric = record |
| 95 |
{ isQuasiSemiMetric = isQuasiSemiMetric |
| 96 |
} |
| 97 |
|
| 98 |
open QuasiSemiMetric quasiSemiMetric public |
| 99 |
using (protoMetric; preMetric) |
| 100 |
|
| 101 |
------------------------------------------------------------------------ |
| 102 |
-- Metrics |
| 103 |
|
| 104 |
record Metric a ℓ : Set (suc (a ⊔ ℓ)) where |
| 105 |
infix 4 _≈_ |
| 106 |
field |
| 107 |
Carrier : Set a |
| 108 |
_≈_ : Rel Carrier ℓ |
| 109 |
d : DistanceFunction Carrier |
| 110 |
isMetric : IsMetric _≈_ d |
| 111 |
|
| 112 |
open IsMetric isMetric public |
| 113 |
|
| 114 |
semiMetric : SemiMetric a ℓ |
| 115 |
semiMetric = record |
| 116 |
{ isSemiMetric = isSemiMetric |
| 117 |
} |
| 118 |
|
| 119 |
open SemiMetric semiMetric public |
| 120 |
using (protoMetric; preMetric; quasiSemiMetric) |
| 121 |
|
| 122 |
------------------------------------------------------------------------ |
| 123 |
-- UltraMetrics |
| 124 |
|
| 125 |
record UltraMetric a ℓ : Set (suc (a ⊔ ℓ)) where |
| 126 |
infix 4 _≈_ |
| 127 |
field |
| 128 |
Carrier : Set a |
| 129 |
_≈_ : Rel Carrier ℓ |
| 130 |
d : DistanceFunction Carrier |
| 131 |
isUltraMetric : IsUltraMetric _≈_ d |
| 132 |
|
| 133 |
open IsUltraMetric isUltraMetric public |
| 134 |
|
| 135 |
semiMetric : SemiMetric a ℓ |
| 136 |
semiMetric = record |
| 137 |
{ isSemiMetric = isSemiMetric |
| 138 |
} |
| 139 |
|
| 140 |
open SemiMetric semiMetric public |
| 141 |
using (protoMetric; preMetric; quasiSemiMetric) |