Given a random set of numbers:
{1,2,8,4,16}
How do you give a logical definition for the largest number? I know how to say there is a largest number in the set S:
$$ \exists y \forall x \epsilon S \to y>x $$
(or something to that effect) but not what it is. I'm looking for a numeric return, not a boolean.
First-order logic conflates functions and relations when it comes to defining them. If $M$ is a structure and $f:M^n\rightarrow M$ is an $n$-ary function on $M$, we say $f$ is definable in $M$ if there is some $(n+1)$-ary formula $\varphi(x_1,...,x_n)$ which defines the graph of $f$ - that is, such that for all $m_1,..., m_n, k\in M$ we have $$M\models\varphi(m_1,...,m_n,k)\quad\iff\quad f(m_1,...,m_n)=k.$$
In your case the relevant formula is "$x\in A$ and for all $y\in A$ we have $x\ge y$."
(In the above I'm assuming that we're working with $2$-sorted structures, intuitively consisting of "sets" and "elements;" note that this is all still first-order unless I quantify over sets!)