| 1 |
------------------------------------------------------------------------ |
| 2 |
-- The Agda standard library |
| 3 |
-- |
| 4 |
-- Some metric structures (not packed up with sets, operations, etc.) |
| 5 |
------------------------------------------------------------------------ |
| 6 |
|
| 7 |
-- The contents of this module should usually be accessed via |
| 8 |
-- `Function.Metric`. |
| 9 |
|
| 10 |
{-# OPTIONS --cubical-compatible --safe #-} |
| 11 |
|
| 12 |
open import Relation.Binary.Core using (Rel) |
| 13 |
open import Relation.Binary.Structures using (IsPartialOrder; IsEquivalence) |
| 14 |
|
| 15 |
module Function.Metric.Structures |
| 16 |
{a i ℓ₁ ℓ₂ ℓ₃} {A : Set a} {I : Set i} |
| 17 |
(_≈ₐ_ : Rel A ℓ₁) (_≈ᵢ_ : Rel I ℓ₂) (_≤_ : Rel I ℓ₃) (0# : I) where |
| 18 |
|
| 19 |
open import Algebra.Core using (Op₂) |
| 20 |
open import Function.Metric.Core |
| 21 |
open import Function.Metric.Definitions |
| 22 |
open import Level using (_⊔_) |
| 23 |
|
| 24 |
------------------------------------------------------------------------ |
| 25 |
-- Proto-metrics |
| 26 |
|
| 27 |
-- We do not insist that the ordering relation is total as otherwise |
| 28 |
-- we would exclude the real numbers. |
| 29 |
|
| 30 |
record IsProtoMetric (d : DistanceFunction A I) |
| 31 |
: Set (a ⊔ i ⊔ ℓ₁ ⊔ ℓ₂ ⊔ ℓ₃) where |
| 32 |
field |
| 33 |
isPartialOrder : IsPartialOrder _≈ᵢ_ _≤_ |
| 34 |
≈-isEquivalence : IsEquivalence _≈ₐ_ |
| 35 |
cong : Congruent _≈ₐ_ _≈ᵢ_ d |
| 36 |
nonNegative : NonNegative _≤_ d 0# |
| 37 |
|
| 38 |
open IsPartialOrder isPartialOrder public |
| 39 |
renaming (module Eq to EqI) |
| 40 |
|
| 41 |
module EqC = IsEquivalence ≈-isEquivalence |
| 42 |
|
| 43 |
------------------------------------------------------------------------ |
| 44 |
-- Pre-metrics |
| 45 |
|
| 46 |
record IsPreMetric (d : DistanceFunction A I) |
| 47 |
: Set (a ⊔ i ⊔ ℓ₁ ⊔ ℓ₂ ⊔ ℓ₃) where |
| 48 |
field |
| 49 |
isProtoMetric : IsProtoMetric d |
| 50 |
≈⇒0 : Definite _≈ₐ_ _≈ᵢ_ d 0# |
| 51 |
|
| 52 |
open IsProtoMetric isProtoMetric public |
| 53 |
|
| 54 |
------------------------------------------------------------------------ |
| 55 |
-- Quasi-semi-metrics |
| 56 |
|
| 57 |
record IsQuasiSemiMetric (d : DistanceFunction A I) |
| 58 |
: Set (a ⊔ i ⊔ ℓ₁ ⊔ ℓ₂ ⊔ ℓ₃) where |
| 59 |
field |
| 60 |
isPreMetric : IsPreMetric d |
| 61 |
0⇒≈ : Indiscernable _≈ₐ_ _≈ᵢ_ d 0# |
| 62 |
|
| 63 |
open IsPreMetric isPreMetric public |
| 64 |
|
| 65 |
------------------------------------------------------------------------ |
| 66 |
-- Semi-metrics |
| 67 |
|
| 68 |
record IsSemiMetric (d : DistanceFunction A I) |
| 69 |
: Set (a ⊔ i ⊔ ℓ₁ ⊔ ℓ₂ ⊔ ℓ₃) where |
| 70 |
field |
| 71 |
isQuasiSemiMetric : IsQuasiSemiMetric d |
| 72 |
sym : Symmetric _≈ᵢ_ d |
| 73 |
|
| 74 |
open IsQuasiSemiMetric isQuasiSemiMetric public |
| 75 |
|
| 76 |
------------------------------------------------------------------------ |
| 77 |
-- General metrics |
| 78 |
|
| 79 |
-- A general metric obeys a generalised form of the triangle inequality. |
| 80 |
-- It can be specialised to a standard metric/ultrametric/inframetric |
| 81 |
-- etc. by providing the correct operator. |
| 82 |
-- |
| 83 |
-- Furthermore we do not assume that _∙_ & 0# form a monoid as |
| 84 |
-- associativity does not hold for p-relaxed metrics/p-inframetrics and |
| 85 |
-- the identity laws do not hold for ultrametrics over negative |
| 86 |
-- codomains. |
| 87 |
-- |
| 88 |
-- See "Properties of distance spaces with power triangle inequalities" |
| 89 |
-- by Daniel J. Greenhoe, 2016 (arXiv) |
| 90 |
|
| 91 |
record IsGeneralMetric (_∙_ : Op₂ I) (d : DistanceFunction A I) |
| 92 |
: Set (a ⊔ i ⊔ ℓ₁ ⊔ ℓ₂ ⊔ ℓ₃) where |
| 93 |
field |
| 94 |
isSemiMetric : IsSemiMetric d |
| 95 |
triangle : TriangleInequality _≤_ _∙_ d |
| 96 |
|
| 97 |
open IsSemiMetric isSemiMetric public |