  We investigate bounds in Ramsey's theorem for relations definable in NIP
structures. Applying model-theoretic methods to finitary combinatorics, we
generalize a theorem of Bukh and Matousek [B. Bukh, J. Matou\v{s}ek.
"Erd\H{o}s-Szekeres-type statements: Ramsey function and decidability in
dimension $1$", Duke Mathematical Journal 163.12 (2014): 2243-2270] from the
semialgebraic case to arbitrary polynomially bounded $o$-minimal expansions of
$\mathbb{R}$, and show that it doesn't hold in $\mathbb{R}_{\exp}$. This
provides a new combinatorial characterization of polynomial boundedness for
$o$-minimal structures. We also prove an analog for relations definable in
$P$-minimal structures, in particular for the field of the $p$-adics.
Generalizing [D. Conlon, J. Fox, J. Pach, B. Sudakov, A. Suk "Ramsey-type
results for semi-algebraic relations", Transactions of the American
Mathematical Society 366.9 (2014): 5043-5065], we show that in distal
structures the upper bound for $k$-ary definable relations is given by the
exponential tower of height $k-1$.
