Let $X$ be a metrizable topological space, $A\subseteq X\times X$ a nonempty closed subset which is reflexive, symmetric and transitive, $d:A\to \mathbb{R}\_+$ a continuous function that satisfies the metric axioms. Does there exist a metric on $X$ which extends $d$ and defines the topology on $X$?


If it makes any difference I can suppose $X$ locally compact second countable.


Edit: As explained in the comments, one needs to add the condition that $d$ defines the topology on $A$. If one restricts to $X$ compact then all such subtleties disappear, and continuity of an extension of $d$ suffices to ensure that it defines the topology.


Edit2: To clarify further the question.


There are two variants of the questions. For both we suppose $A$ is a closed equivalence relation, $d:A\to \mathbb{R}\_+$ continuous and satisfies the metric hypothesis.


Q1: Does there exists an extension $d:X\times X\to \mathbb{R}\_+$ which is continuous and a metric.


Q2: Does there exists an extension $d:X\times X\to \mathbb{R}\_+$ which is a metric and defines the topology on $X$.


Remark that if $X$ is compact Q1 and Q2 are the same.


Q2 is false without further hypothesis on $d$. The further hypothesis is as follows. Since $X$ is metrizable, it can be equipped with the notion of Cauchy sequence (depends on the choice of a metric). The additional hypothesis is that there exists a metric on $X$ such that if $x\_n$ is a sequence with $(x\_n,x\_m)\in A$ for all $n,m$, then $x\_n$ is Cauchy for the metric on $X$ if and only if it is Cauchy for the metric $d:A\to \mathbb{R}\_+$.


I am interested in both Q1 and Q2.



Extending a partially defined metric on a metrizable space
Here is a counterexample to Q2, with your stated extra condition.


Let $X$ consist of the half-open unit interval $(0,1]$ on the $x$-axis in the plane, together with the full unit interval $[0,1]$ at height $1$. That is,
$$X=B\sqcup T$$
where $B$ is the bottom line segment, having points of the form $(x,0)$ for $0<x\leq 1$, and $T$ is the top line segment, having points of the form $(x,1)$, where $0\leq x\leq 1$. We put the ordinary Euclidean metric on $X$ as embedded in the plane.


Let $A$ be the set of pairs arising from the equivalence relation relating each point on $B$ to the corresponding point on $T$ vertically above. So $A$ has the trivial pairs and the vertical pairs. This is a closed set in $X\times X$, since a convergent sequence of vertical pairs converges to a vertical pair. Note that the point $t=(0,1)$ at upper left is not part of any nontrivial vertical line in $X$, and appears in $A$ only reflexively.


Define $d$ on $A$ so that the vertical distance on the right side is $1$, but the vertical distances decay continuously to $0$ as one approaches the left side (and trivial distances are $0$). This is a continuous function on $A$ in the space $X\times X$, and it obeys the metric conditions on $A$ (note that there are no nontrivial triangles occuring in $A$).


This set $A$ trivially fulfills your Cauchy sequence condition, since if $x\_n$ is a sequence of points and $(x\_n,x\_m)\in A$ for all $n,m$, then every two points of the sequence must either be identical or vertically related, and so the sequence has at most two points on it. So it is Cauchy with respect to $d$ if and only if it is Cauchy in $X$.


But there can be no metric on $X$ extending $d$ and generating the topology of $X$, since the upper-left point $t$ is not in the closure of $B$ in $X$, but in any metrization of $X$ the point $t$ would have other points on $T$ that were close to points vertically below in $B$, according to $d$, so every neighborhood of $t$ would have to contain points in $B$. Contradiction.


