<p>As an alternative to the more commonly used CPOs, Arnold and Nivat explored (complete) metric spaces as domains of denotational semantics [1].
In his thesis Bonsangue [2] explored dualities between such denotational semantics and axiomatic semantics. I mention it here because it gives a very comprehensive overall picture.</p>

<p>[1]: A Arnold, M Nivat: <em>Metric Interpretations of Infinite Trees and Semantics of non Deterministic Recursive Programs.</em> Theor. Comput. Sci. 11: 181-205 (1980).<br>
  [2]: MM Bonsangue <a href="http://www.liacs.nl/~marcello/Papers/Book/ENTCS-8.pdf"><i>Topological Duality in Semantics</i></a> volume 8 of ENTCS, Elsevier 1998.</p>

CC BY-SA 2.5
2011-02-04T10:05:20.660Z
Fantastic -- I didn't know this thesis was online!
Neel Krishnaswami
CC BY-SA 2.5
2011-02-04T12:14:54.680Z
I let Marcello (Bonsangue) know that he's being talked about. (Perhaps he'll join.)
Dave Clarke
CC BY-SA 2.5
2011-02-03T23:00:07.140Z
2011-02-03T23:00:07.140Z
Kai
<p>Here's one (from, coincidentally, the top of my reading queue):</p>

<p>Swarat Chaudhuri, Sumit Gulwani and Roberto Lublinerman. <a href="http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.159.6359" rel="nofollow">Continuity Analysis of Programs.</a> POPL 2010.</p>

<p>The authors give a denotational semantics for an imperative language with simple loops, interpreting expressions as functions from values in an underlying product metric space. The point is to determine which programs represent continuous functions, even in the presence of "if" and loops. They even allow questions about continuity restricted to certain inputs and outputs. (This is important for analyzing Dijkstra's algorithm, which is continuous in its path length, but not in the actual path.)</p>

<p>I haven't seen anything yet that <em>requires</em> a metric space - it seems it could have been done using general topology so far - but I'm only on page 3. :)</p>

CC BY-SA 2.5
2011-02-04T16:23:50.850Z
of course there's no poset or lattice here, like in the previous answer. that's what I'm missing.
Suresh Venkat
CC BY-SA 2.5
2011-02-04T15:20:09.067Z
2011-02-04T15:20:09.067Z
Neil Toronto
<p>Apologies for adding another answer, but this one is unrelated to my other one above. </p>

<p>A metric spaces I routinely use to irritate (or is it educate?) students of concurrency is that of infinite traces. The topology it induces is precisely the one Alpern and Schneider [1] used to characterize <i>safety</i> and <i>liveness</i> properties as limit-closed and dense, respectively.</p>

<p>The distance between two traces is smaller if their common prefix is longer:
$$   \begin{array}{@{}rcl}
      d : \Sigma^\omega\times\Sigma^\omega &amp; \longrightarrow &amp; \mathbb{R}_{{}\ge 0}\\ 
      % 
      (\sigma,\tau) &amp; \mapsto &amp;
      2^{-\sup \{~i\in\mathbb{N} ~|~ \sigma|_i = \tau|_i~\}}
    \end{array}
$$
where $\sigma|_i$ denotes $\sigma$'s prefix of length $i$ and $2^{-\infty} = 0$.</p>

<p>In retrospect I realize that this answer also lacks the essential ingredient of a lattice or poset structure. Such a lattice structure is however present when moving one level up to what Clarkson and Schneider call <i>hyperproperties</i> [2]. At the time of writing it is unclear to me how to lift the metric though.</p>

<p>[1] B Alpern and FB Schneider. <i>Defining liveness.</i> IPL, 21(4):181–185, 1985.<br>
   [2] MR Clarkson and FB Schneider. <i>Hyperproperties.</i> CSF, p51-65, IEEE, 2008.</p>

CC BY-SA 2.5
2011-02-05T08:53:01.233Z
Here we can type in LaTeX just like we normally do - put dollar signs around \sum_{k=1}^n k = \frac{k(k+1)}{2} and we will get $\sum_{k=1}^n k = {n(n+1)}/{2}$. See [this meta post](http://meta.cstheory.stackexchange.com/q/3/1800) for more information.
Hsien-Chih Chang 張顯之
CC BY-SA 2.5
2011-02-05T10:50:57.777Z
@HCH thanks, I've edited my post accordingly and removed the blatant cry for formatting advice.
Kai
CC BY-SA 2.5
2011-02-05T12:31:19.537Z
Nice formula!
Hsien-Chih Chang 張顯之
CC BY-SA 2.5
2011-02-05T08:18:31.997Z
2011-02-05T10:52:19.383Z
2011-02-05T10:52:19.383Z
Kai
<p>First, a comment. Your question sort of depends on how geometrically you intend to mean the word "metric". It's reasonably common to use ultrametrics in semantics and static analysis, but ultrametrics tend to have a combinatorial rather than a geometric interpretation. (This is a variant of the observation that domain theory has the flavor of a combinatorial rather than geometric use of topology.)</p>

<p>That said, I'll give you an example of how this comes up in program proofs. First, recall that in a program proof, we want to show that a formula describing a program holds. In general, this formula does not necessarily have to be interpreted with the booleans, but can be drawn from the elements of some lattice of truth values. Then a true formula is just one which is equal to the top of the lattice. </p>

<p>Furthermore, when specifying very self-referential programs (for example, programs that make extensive use of self-modifying code) matters can get very difficult. We typically want to give a recursive specification of the program, but there might not be an obvious inductive structure upon which to hang the definition. To solve this problem, it's often helpful to equip the truth value lattice with extra metric structure. Then, if you can show that the predicate whose fixed point you want is strictly contractive, you can appeal to Banach's fixed point theorem to conclude that the recursive predicate you want is well-defined. </p>

<p>The case I am most familiar with is called "step-indexing". In this setting, we take our lattice $\Omega$ of truth values to be downwards-closed subsets of $\mathbb{N}$, whose elements we can loosely interpret as "the lengths of the evaluation sequences on which the property holds". Meets and joins are intersections and unions, as usual, and since the lattice is complete we can define the Heyting implication as well. The lattice can also be equipped with an ultrametric by letting the distance between two lattice elements be $2^{-n}$, where $n$ is the smallest element in one set but not the other.</p>

<p>Then, Banach's contraction map thoerem tells us that a contractive predicate $p : \Omega \to \Omega$ has a unique fixed point. Intuitively, this says that if we can define a predicate which holds for $n+1$ steps using a version which holds for $n$ steps, then we actually have an unambiguous definition of a predicate. If we then show that the predicate equals $\top = \mathbb{N}$, then we know that the predicate always holds of the program.</p>

CC BY-SA 2.5
2011-02-03T17:59:38.710Z
ah interesting. In answer to your question, all I care about is that the metric is just that: it satisfies triangle inequality. So ultrametrics are perfectly fine. However, (and this is my shortcoming in the question) it seems to me that the use of the metric here is structural, so as to gain access to Banach. You don't care about the metric in an of itself (and so things like approximating the metric or computing it are irrelevant). Is that right ?
Suresh Venkat
CC BY-SA 2.5
2011-02-04T10:08:37.740Z
Yes, we don't tend to care much about the metric. This is actually a source of discomfort with metric or step-indexed models -- why are we tracking information we don't really care about? Showing that a model was stable under a class of approximations to the metric (perhaps conservative with respect to contractiveness) would actually increase comfort with it.
Neel Krishnaswami
CC BY-SA 2.5
2011-02-03T17:26:36.413Z
2011-02-03T17:26:36.413Z
Neel Krishnaswami
<p>Since the term is overloaded, a brief definition first. A poset is a set $X$ endowed with a partial order $\le$. Given two elements $a,b \in X$, we can define $x \vee y$ (join) as their least upper bound in $X$, and similarly define $x \wedge y$ (meet)(join)as a greatest lower bound. </p>

<blockquote>
  <p>A lattice is a poset in which any two
  elements have a unique meet and a
  unique join.</p>
</blockquote>

<p>Lattices (in this form) show up in theoryCS in (briefly) the theory of submodularity (with the subset lattice) and clustering (the partition lattice), as well as in domain theory (which I don't understand too well) and static analysis. </p>

<p>But I'm interested in applications which use metric structures on lattices. A simple example comes from clustering, where any antimonotone submodular function $f : X \rightarrow R$ (antimonotone means that if $x \le y, f(x) \le f(y)$) induces a metric 
$$d(x,y) = 2f(x \wedge y) - f(x) - f(y)$$</p>

<p>This metric has been used extensively as a way to compare two different clusterings of a data set. </p>

<p>Are there other applications of lattices that care about metric structures ? I've been interested in the domain theory/static analysis application, but so far I've not seen any need for <em>metrics</em>.</p>

<reference-request><co.combinatorics><metrics><lattice><order-theory>
Applications of metric structures on posets/lattices in theoryCS
Suresh Venkat
# Applications of metric structures on posets/lattices in theoryCS

(Asked by: username_0 on 2011-02-03)

Since the term is overloaded, a brief definition first. A poset is a set $X$ endowed with a partial order $\le$. Given two elements $a,b \in X$, we can define $x \vee y$ (join) as their least upper bound in $X$, and similarly define $x \wedge y$ (meet)(join)as a greatest lower bound.

> A lattice is a poset in which any two
> elements have a unique meet and a
> unique join.

Lattices (in this form) show up in theoryCS in (briefly) the theory of submodularity (with the subset lattice) and clustering (the partition lattice), as well as in domain theory (which I don't understand too well) and static analysis.

But I'm interested in applications which use metric structures on lattices. A simple example comes from clustering, where any antimonotone submodular function $f : X \rightarrow R$ (antimonotone means that if $x \le y, f(x) \le f(y)$) induces a metric
$$d(x,y) = 2f(x \wedge y) - f(x) - f(y)$$

This metric has been used extensively as a way to compare two different clusterings of a data set.

Are there other applications of lattices that care about metric structures ? I've been interested in the domain theory/static analysis application, but so far I've not seen any need for *metrics*.

**Tags:** reference-request, co.combinatorics, metrics, lattice, order-theory


---

## 4 answers

### Answer by username_2 on 2011-02-03. Score: 12 | Accepted answer

First, a comment. Your question sort of depends on how geometrically you intend to mean the word "metric". It's reasonably common to use ultrametrics in semantics and static analysis, but ultrametrics tend to have a combinatorial rather than a geometric interpretation. (This is a variant of the observation that domain theory has the flavor of a combinatorial rather than geometric use of topology.)

That said, I'll give you an example of how this comes up in program proofs. First, recall that in a program proof, we want to show that a formula describing a program holds. In general, this formula does not necessarily have to be interpreted with the booleans, but can be drawn from the elements of some lattice of truth values. Then a true formula is just one which is equal to the top of the lattice.

Furthermore, when specifying very self-referential programs (for example, programs that make extensive use of self-modifying code) matters can get very difficult. We typically want to give a recursive specification of the program, but there might not be an obvious inductive structure upon which to hang the definition. To solve this problem, it's often helpful to equip the truth value lattice with extra metric structure. Then, if you can show that the predicate whose fixed point you want is strictly contractive, you can appeal to Banach's fixed point theorem to conclude that the recursive predicate you want is well-defined.

The case I am most familiar with is called "step-indexing". In this setting, we take our lattice $\Omega$ of truth values to be downwards-closed subsets of $\mathbb{N}$, whose elements we can loosely interpret as "the lengths of the evaluation sequences on which the property holds". Meets and joins are intersections and unions, as usual, and since the lattice is complete we can define the Heyting implication as well. The lattice can also be equipped with an ultrametric by letting the distance between two lattice elements be $2^{-n}$, where $n$ is the smallest element in one set but not the other.

Then, Banach's contraction map thoerem tells us that a contractive predicate $p : \Omega \to \Omega$ has a unique fixed point. Intuitively, this says that if we can define a predicate which holds for $n+1$ steps using a version which holds for $n$ steps, then we actually have an unambiguous definition of a predicate. If we then show that the predicate equals $\top = \mathbb{N}$, then we know that the predicate always holds of the program.

> **Comments:**
> **username_0**: ah interesting. In answer to your question, all I care about is that the metric is just that: it satisfies triangle inequality. So ultrametrics are perfectly fine. However, (and this is my shortcoming in the question) it seems to me that the use of the metric here is structural, so as to gain access to Banach. You don't care about the metric in an of itself (and so things like approximating the metric or computing it are irrelevant). Is that right ?  
> **username_2**: Yes, we don't tend to care much about the metric. This is actually a source of discomfort with metric or step-indexed models -- why are we tracking information we don't really care about? Showing that a model was stable under a class of approximations to the metric (perhaps conservative with respect to contractiveness) would actually increase comfort with it.  

---

### Answer by username_1 on 2011-02-03. Score: 9

As an alternative to the more commonly used CPOs, Arnold and Nivat explored (complete) metric spaces as domains of denotational semantics [1].
In his thesis Bonsangue [2] explored dualities between such denotational semantics and axiomatic semantics. I mention it here because it gives a very comprehensive overall picture.

[1]: A Arnold, M Nivat: *Metric Interpretations of Infinite Trees and Semantics of non Deterministic Recursive Programs.* Theor. Comput. Sci. 11: 181-205 (1980).  
[2]: MM Bonsangue [*Topological Duality in Semantics*](http://www.liacs.nl/~marcello/Papers/Book/ENTCS-8.pdf) volume 8 of ENTCS, Elsevier 1998.

> **Comments:**
> **username_2**: Fantastic -- I didn't know this thesis was online!  
> **username_3**: I let Marcello (Bonsangue) know that he's being talked about. (Perhaps he'll join.)  

---

### Answer by username_4 on 2011-02-04. Score: 5

Here's one (from, coincidentally, the top of my reading queue):

Swarat Chaudhuri, Sumit Gulwani and Roberto Lublinerman. [Continuity Analysis of Programs.](http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.159.6359) POPL 2010.

The authors give a denotational semantics for an imperative language with simple loops, interpreting expressions as functions from values in an underlying product metric space. The point is to determine which programs represent continuous functions, even in the presence of "if" and loops. They even allow questions about continuity restricted to certain inputs and outputs. (This is important for analyzing Dijkstra's algorithm, which is continuous in its path length, but not in the actual path.)

I haven't seen anything yet that *requires* a metric space - it seems it could have been done using general topology so far - but I'm only on page 3. :)

> **Comments:**
> **username_0**: of course there's no poset or lattice here, like in the previous answer. that's what I'm missing.  

---

### Answer by username_1 on 2011-02-05. Score: 3

Apologies for adding another answer, but this one is unrelated to my other one above.

A metric spaces I routinely use to irritate (or is it educate?) students of concurrency is that of infinite traces. The topology it induces is precisely the one Alpern and Schneider [1] used to characterize *safety* and *liveness* properties as limit-closed and dense, respectively.

The distance between two traces is smaller if their common prefix is longer:
$$ \begin{array}{@{}rcl}
d : \Sigma^\omega\times\Sigma^\omega & \longrightarrow & \mathbb{R}\_{{}\ge 0}\\
%
(\sigma,\tau) & \mapsto &
2^{-\sup \{~i\in\mathbb{N} ~|~ \sigma|\_i = \tau|\_i~\}}
\end{array}
$$
where $\sigma|\_i$ denotes $\sigma$'s prefix of length $i$ and $2^{-\infty} = 0$.

In retrospect I realize that this answer also lacks the essential ingredient of a lattice or poset structure. Such a lattice structure is however present when moving one level up to what Clarkson and Schneider call *hyperproperties* [2]. At the time of writing it is unclear to me how to lift the metric though.

[1] B Alpern and FB Schneider. *Defining liveness.* IPL, 21(4):181–185, 1985.  
[2] MR Clarkson and FB Schneider. *Hyperproperties.* CSF, p51-65, IEEE, 2008.

> **Comments:**
> **username_5**: Here we can type in LaTeX just like we normally do - put dollar signs around \sum_{k=1}^n k = \frac{k(k+1)}{2} and we will get $\sum_{k=1}^n k = {n(n+1)}/{2}$. See [this meta post](http://meta.cstheory.stackexchange.com/q/3/1800) for more information.  
> **username_1**: @HCH thanks, I've edited my post accordingly and removed the blatant cry for formatting advice.  
> **username_5**: Nice formula!  

---

