|
| 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 --without-K --safe #-} |
| 12 | + |
| 13 | +open import Data.Rational.Base hiding (_⊔_) |
| 14 | +open import Function using (const) |
| 15 | +open import Level using (Level; suc; _⊔_) |
| 16 | +open import Relation.Binary.Core |
| 17 | +open import Relation.Binary.PropositionalEquality |
| 18 | + using (_≡_; isEquivalence) |
| 19 | + |
| 20 | +open import Function.Metric.Rational.Core |
| 21 | +open import Function.Metric.Rational.Structures |
| 22 | +open import Function.Metric.Bundles as Base |
| 23 | + using (GeneralMetric) |
| 24 | + |
| 25 | +module Function.Metric.Rational.Bundles where |
| 26 | + |
| 27 | +------------------------------------------------------------------------ |
| 28 | +-- Proto-metric |
| 29 | + |
| 30 | +record ProtoMetric a ℓ : Set (suc (a ⊔ ℓ)) where |
| 31 | + field |
| 32 | + Carrier : Set a |
| 33 | + _≈_ : Rel Carrier ℓ |
| 34 | + d : DistanceFunction Carrier |
| 35 | + isProtoMetric : IsProtoMetric _≈_ d |
| 36 | + |
| 37 | + open IsProtoMetric isProtoMetric public |
| 38 | + |
| 39 | +------------------------------------------------------------------------ |
| 40 | +-- PreMetric |
| 41 | + |
| 42 | +record PreMetric a ℓ : Set (suc (a ⊔ ℓ)) where |
| 43 | + field |
| 44 | + Carrier : Set a |
| 45 | + _≈_ : Rel Carrier ℓ |
| 46 | + d : DistanceFunction Carrier |
| 47 | + isPreMetric : IsPreMetric _≈_ d |
| 48 | + |
| 49 | + open IsPreMetric isPreMetric public |
| 50 | + |
| 51 | + protoMetric : ProtoMetric a ℓ |
| 52 | + protoMetric = record |
| 53 | + { isProtoMetric = isProtoMetric |
| 54 | + } |
| 55 | + |
| 56 | +------------------------------------------------------------------------ |
| 57 | +-- QuasiSemiMetric |
| 58 | + |
| 59 | +record QuasiSemiMetric a ℓ : Set (suc (a ⊔ ℓ)) where |
| 60 | + field |
| 61 | + Carrier : Set a |
| 62 | + _≈_ : Rel Carrier ℓ |
| 63 | + d : DistanceFunction Carrier |
| 64 | + isQuasiSemiMetric : IsQuasiSemiMetric _≈_ d |
| 65 | + |
| 66 | + open IsQuasiSemiMetric isQuasiSemiMetric public |
| 67 | + |
| 68 | + preMetric : PreMetric a ℓ |
| 69 | + preMetric = record |
| 70 | + { isPreMetric = isPreMetric |
| 71 | + } |
| 72 | + |
| 73 | + open PreMetric preMetric public |
| 74 | + using (protoMetric) |
| 75 | + |
| 76 | +------------------------------------------------------------------------ |
| 77 | +-- SemiMetric |
| 78 | + |
| 79 | +record SemiMetric a ℓ : Set (suc (a ⊔ ℓ)) where |
| 80 | + field |
| 81 | + Carrier : Set a |
| 82 | + _≈_ : Rel Carrier ℓ |
| 83 | + d : DistanceFunction Carrier |
| 84 | + isSemiMetric : IsSemiMetric _≈_ d |
| 85 | + |
| 86 | + open IsSemiMetric isSemiMetric public |
| 87 | + |
| 88 | + quasiSemiMetric : QuasiSemiMetric a ℓ |
| 89 | + quasiSemiMetric = record |
| 90 | + { isQuasiSemiMetric = isQuasiSemiMetric |
| 91 | + } |
| 92 | + |
| 93 | + open QuasiSemiMetric quasiSemiMetric public |
| 94 | + using (protoMetric; preMetric) |
| 95 | + |
| 96 | +------------------------------------------------------------------------ |
| 97 | +-- Metrics |
| 98 | + |
| 99 | +record Metric a ℓ : Set (suc (a ⊔ ℓ)) where |
| 100 | + field |
| 101 | + Carrier : Set a |
| 102 | + _≈_ : Rel Carrier ℓ |
| 103 | + d : DistanceFunction Carrier |
| 104 | + isMetric : IsMetric _≈_ d |
| 105 | + |
| 106 | + open IsMetric isMetric public |
| 107 | + |
| 108 | + semiMetric : SemiMetric a ℓ |
| 109 | + semiMetric = record |
| 110 | + { isSemiMetric = isSemiMetric |
| 111 | + } |
| 112 | + |
| 113 | + open SemiMetric semiMetric public |
| 114 | + using (protoMetric; preMetric; quasiSemiMetric) |
| 115 | + |
| 116 | +------------------------------------------------------------------------ |
| 117 | +-- UltraMetrics |
| 118 | + |
| 119 | +record UltraMetric a ℓ : Set (suc (a ⊔ ℓ)) where |
| 120 | + field |
| 121 | + Carrier : Set a |
| 122 | + _≈_ : Rel Carrier ℓ |
| 123 | + d : DistanceFunction Carrier |
| 124 | + isUltraMetric : IsUltraMetric _≈_ d |
| 125 | + |
| 126 | + open IsUltraMetric isUltraMetric public |
| 127 | + |
| 128 | + semiMetric : SemiMetric a ℓ |
| 129 | + semiMetric = record |
| 130 | + { isSemiMetric = isSemiMetric |
| 131 | + } |
| 132 | + |
| 133 | + open SemiMetric semiMetric public |
| 134 | + using (protoMetric; preMetric; quasiSemiMetric) |
0 commit comments