i know that if A and B are compact then there exists $(a,b)\in A\times B, d(a,b) = d(A,B)$ I want to find an example where this is not true if A is compact and B closed
I put $A=[1,2]$ and $B=]-\infty,0[ $ in $\mathbb{R}^*=]-\infty,0[\cup ]0,+\infty[$
is it correct ?
here B is closed but not bounded then it is not compact right?
and d(A,B)=1 but d(a,b)>1
is it true ?
Yes, this is correct. In fact, you could have taken $B=[-1,0[$. While it is not closed in $\mathbb{R}$, it is closed in your $\mathbb{R}^*$.