d:\textbf M \times \textbf M\rightarrow \textbf R