Just for clarification: Regarding a Monk declaring his attainments to a layperson, the offence is far from defeat, it is a dukkata - a wrong doing. If one reads the BMC one will see that dukkatas are handed out for a lot of misdemeanors and the punishment is usually confession. We have to remember that here supernormal powers are also included under the category of attainment. If I recall correctly the particular rule in question was formulated because a lay person was encouraging monks to perform a magical feat - bringing down a bowl from a high place or something in order to be fed from a rather delicious banquet. The meaning is to prevent monks with attainments from profiting off of them. It's quite easy to envision a scenario whereby an elite clique of magical monks would be receiving the lions share of a town's alms, while other monks who had not the will or capacity would go hungry.
Regarding a monk declaring his attainments to another monk, there is no offense provided the attainment is real. Concerning the parajika offense of a false claim to attainment, there is no offense should the claimer be simply over estimating himself, or if he is temporarily insane - hallucinating from a fever or something. That's how I remember it anyway.
"For a disciple who has conviction in the Teacher's message & lives to penetrate it, what accords with the Dhamma is this:
'The Blessed One is the Teacher, I am a disciple. He is the one who knows, not I." -