# The Duality of Similarity and Metric Spaces
## 5 Duality of Similarity and Metric Space
We can compute the areas in the regions \(d(A,B)=\mu(A\triangle B)=\int\int|f(x,y)-g(x,y)|dxdy\) and the functions \(d(f(x),g(x))=\mu(f\triangle g)=\int|f(x)-g(x)|dx\)Conversely, the shaded gray area at the bottom Figure 1 within overlapping regions \(A\) and \(B\) and under both graphs \(f\) and \(g\) represent the similarity between those objects. Analogically, we may deduce a calculation \(s(A,B)=\mu(A\cap B)=\int\int\min\{f(x,y),g(x,y)\}dxdy\) and \(s(f(x),g(x))=\mu(f\cap g)=\int\min\{f(x),g(x)\}dx\). This fundamental observation allows us to create a bridge between set theory and topology, such as the theories of metric spaces and similarity spaces. From the definition of the similarity \(s(x,y)\) it can be deduced that the number of features shared between two objects \(x\) and \(y\) is given by their intersection \(\mu(x\cap y)\). The idea behind definition is very simple, direct and intuitive too, assuming that a similarity metric is a measure \(s(x,y)=\mu(x\cap y)\). **Theorem 8** (Similarity of Two Objects). : _The intersection of two objects represented by subsets \(x\) and \(y\) is a similarity metric_  
\[s(x,y)=\mu(x\cap y)=\int\min\{\chi_{x},\chi_{y}\}d\mu=\frac{\mu(x)+\mu(y)-\mu( x\triangle y)}{2}=\frac{\mu(x)+\mu(y)-d(x,y)}{2}, \tag{8}\]  
Proof. : Appendix A.8. Now we can generalize our knowledge using the similarity axioms. **Corollary 1** (Similarity of Two Objects using Duality). : _The similarity metric of two objects given by subsets \(x,y\in\mathbf{X}\) is expressed_  
\[s(x,y)=\frac{s(x,x)+s(y,y)-d(x,y)}{2}, \tag{9}\]  
Proof. : Appendix A.9. As a result from the proof, self-similarity is equivalent to a measure on set \(\mu(x)\), e.g., cardinality of a countable set, \(s(x,x)=|x|\), respectively \(s(y,y)=|y|\). We can go back to the distance metric from the similarity metric, too. Figure 1: Top—symmetric difference (gray area); bottom—intersection (gray area); left—sets \(A\) and \(B\); right—sub-graphs of \(f\) and \(g\) (inspired by [15]). **Corollary 2** (Distance between Two Objects using Duality). : _The distance metric applied to two objects defined by subsets \(x,y\in\mathbf{X}\) is given by_  
\[d(x,y)=s(x,x)+s(y,y)-2s(x,y), \tag{10}\]  
Proof. : Expressing \(d(x,y)\) from Corollary 1. **Corollary 3** (Total Dissimilarity using Duality). : _The total dissimilarity between two objects is given_  
\[s(x,y)=\mu(x\cap y)=0\Longleftrightarrow\mu(x\triangle y)=\mu(x)+\mu(y) \Longleftrightarrow d(x,y)=s(x,x)+s(y,y), \tag{11}\]  
Proof. : Appendix A.10. Total dissimilarity should mean that there are no features shared between the two objects. In set theory, this is equivalent to being a pair of disjoint sets. **Corollary 4** (Duality of Axiomatic Systems). : _Consider a similarity space \((\mathbf{X},s)\) and a metric space \((\mathbf{X},d)\). We can define a similarity \(s\) on \(\mathbf{X}\), dual to metric \(d\), vice versa a distance metric \(d\) on \(\mathbf{X}\), dual to similarity \(s\), as follows:_  
\[ \begin{split} s(x,y)&=f(d(x,y))=\frac{s(x,x)+s(y,y) -d(x,y)}{2}\text{ by Corollary \ref{cor:Duality} }\\ d(x,y)&=f^{-1}(d(x,y))=s(x,x)+s(y,y)-2s(x,y)\text{ by Corollary \ref{cor:Duality} },\end{split}  \tag{12}\]  
Proof. : Appendix A.11. Comparing similarity axiom system with the partial metrics from Definition 2, we can see the relation \(p(x,y)=f^{-1}(d(x,y))=s(x,x)+s(y,y)-2s(x,y)\) with dependency on Corollary 2 and Corollary 4 which differs from the source [16]. **Theorem 9** (Rozinek Similarity). : _Rozinek similarity is a normalized similarity metric_  
\[R(x,y)=\frac{\mu(x)+\mu(y)-\mu(x\triangle y)}{\mu(x)+\mu(y)+\mu(x\triangle y )}=\frac{\mu(x)+\mu(y)-d(x,y)}{\mu(x)+\mu(y)+d(x,y)}, \tag{13}\]  
Proof. : Appendix A.12. **Theorem 10** (Generalized Rozinek Similarity). : _Generalized Rozinek similarity is a normalized similarity metric_  
\[R_{GS}(x,y)=\frac{s(x,x)+s(y,y)-d(x,y)}{s(x,x)+s(y,y)+d(x,y)}, \tag{14}\]  
Proof. : Appendix A.13. As has been proved, this similarity forms the bridge between Jaccard similarity (see Theorem 13) and similarity metrics derived from distances.