The Buddha explains how a trainee and an arahant understand their respective attainments.
Sekhasutta - Trainee
Thus have I heard. At one time, the Blessed One was residing in Kosambi at Ghosita's park. There, the Blessed One addressed the bhikkhus: "Is there a method, bhikkhus, by which a trainee bhikkhu, standing on the plane of a trainee, can understand: 'I am a trainee,' and an arahant bhikkhu, standing on the plane of an arahant, can understand: 'I am an arahant'?"
The bhikkhus replied, "Venerable sir, our teachings are rooted in the Blessed One, guided by the Blessed One, and have the Blessed One as their refuge. It would be good, venerable sir, if the Blessed One himself would clarify the meaning of this statement."
The Blessed One said: "There is indeed a method, bhikkhus, by which a trainee bhikkhu, standing on the plane of a trainee, can understand: 'I am a trainee,' and an arahant bhikkhu, standing on the plane of an arahant, can understand: 'I am an arahant'.
What is the method, bhikkhus, by which a trainee bhikkhu, standing on the plane of a trainee, understands: 'I am a trainee'? Here, bhikkhus, a trainee bhikkhu understands as it truly is: 'This is suffering,' 'This is the origin of suffering,' 'This is the ending of suffering,' and 'This is the way of practice leading to the ending of suffering.' This too, bhikkhus, is a method by which a trainee bhikkhu, standing on the plane of a trainee, understands: 'I am a trainee.'
Furthermore, bhikkhus, a trainee bhikkhu reflects thus: 'Is there any other ascetic or brahmin outside this teaching who teaches a doctrine so true and factual as the Blessed One?' He understands thus: 'There is no other ascetic or brahmin outside this teaching who teaches a doctrine so true and factual as the Blessed One.' This too, bhikkhus, is a method by which a trainee bhikkhu, standing on the plane of a trainee, understands: 'I am a trainee.'"
Furthermore, bhikkhus, a trainee bhikkhu understands the five faculties: the faculty of confidence, the faculty of energy, the faculty of mindfulness, the faculty of collectedness, and the faculty of wisdom. He knows their tendencies, highest points, fruits, and final goals. He does not experience them with the body but sees them clearly with wisdom. This too, bhikkhus, is a method by which a trainee bhikkhu, standing on the plane of a trainee, understands: 'I am a trainee.'
What is the method, bhikkhus, by which an arahant bhikkhu, standing on the plane of an arahant, understands: 'I am an arahant'? Here, bhikkhus, an arahant bhikkhu understands the five faculties: the faculty of confidence, the faculty of energy, the faculty of mindfulness, the faculty of collectedness, and the faculty of wisdom. He knows their tendencies, highest points, fruits, and final goals. He experiences them with the body and sees them clearly with wisdom. This too, bhikkhus, is a method by which an arahant bhikkhu, standing on the plane of an arahant, understands: 'I am an arahant.'
Furthermore, bhikkhus, an arahant bhikkhu understands the six faculties: the eye faculty, the ear faculty, the nose faculty, the tongue faculty, the body faculty, and the mind faculty. He knows that these six faculties will cease entirely and no new faculties will arise anywhere. This too, bhikkhus, is a method by which an arahant bhikkhu, standing on the plane of an arahant, understands: 'I am an arahant.'"