By a retract of a group $G$, we mean a subgroup $H$ of $G$ for which there is a homomorphism $r:G\to H$ such that $r\circ i=1_H$, where $i:H\to G$ in the inclusion. By a proper retract, I mean a retract $H$ such that $H\neq G$.
Let $\mathcal{X}$ be a class of groups closed under taking retracts. Is there a function $\alpha :\mathcal{X}\to \mathbb{R}$ satisfying:
(C1) If $K$ and $H$ are in $\mathcal{X}$, and $K$ is isomorphic to $H$, then $\alpha (K)=\alpha (H)$.
(C2) If $K$ is in $\mathcal{X}$, and $H$ is a proper retract of $K$, then $\alpha (H)\lneq \alpha (K)$.
We can easily check that:
(1) If $F$ is a free group of finite rank $r_F$ and $H$ be a proper retract of $F$, then we have $r_H\lneq r_F$.
(2) If $A$ is a finitely generated abelian group and $n_A$ denotes the number of direct summands in the canonical form of $A$ and $H$ be a proper retract of $A$, then we have $n_H\lneq n_A$.
Based on Lemma 1.3 of "Finiteness conditions on CW-complexes" by C.T.C. Wall, if $G$ is a finitely presented group, and $H$ a retract of $G$, then $H$ is finitely presented. Hence the class of finitely presented groups is closed under taking retracts.
Based on the above observations I have the following question:
Is there such a function for the class of finitely presented groups?