When and how should a layperson...
I wouldn't say "should" (i.e. are "required" to), of course. But "may" (i.e. are "allowed" to)?
I think that monks "must not" i.e. they're required not to, by the vinaya:
- It's a most serious offence to lie about an attainment (i.e. to declare that one has one, knowing that claim to be false)
- It's also a lesser offence for a monk to declare any super-mundane attainment to a lay-person, whether that's true or false.
The reason for the latter rule was that lay-people would prefer (perhaps to get more merit) to give to monks with super-mundane attainments, which would disadvantage other monks. This latter rule or reasoning maybe doesn't apply to laypeople.
I think that the former rule results in monks being reluctant to declare an attainment even amongst themselves.
Anyway you might keep that in mind: if the vinaya is good rules for monks then maybe it's good or instructive for lay-people too, and lay-people might want to emulate the good conduct of monks to whatever extent they can, on the other hand the vinaya isn't always and directly applicable, and perhaps it's good and necessary that laypeople do some things which monks are forbidden to.
casual visitors may themselves see that the path can be followed
My personal experience says that's true -- i.e. my seeing "sotāpanna" or something like that, on one of the user profiles on this forum, help to guide me to learn more about the path (the doctrine), for example the "four stages of enlightenment" and the "fetters" -- at a time when I hadn't previously been introduced to the Pali canon.
Or (I can't find a reference now, but someone posted on this site once to say that) one of the effects of repeating "nam myoho renge kyo" is that people who don't know might ask, "what are you saying?" -- so maybe it's like that a bit.
I sympathise with this answer too.
people living today have found that the teachings work
For that to work, the person making the claim maybe needs to be credible.
and may themselves be inspired to study the Dhamma
For that to work, the person making the claim maybe needs to be admirable.
I'm reminded of a joke or story from long ago, I don't remember who it's attributed to (Gandhi, perhaps)
"Have you ever thought of becoming a Christian?"
"Well if you mean 'Christian' like your Christ -- I don't have the courage to. But if you mean 'Christian' like you, I wouldn't want to be."
Anyway the theory, that it may inspire others, isn't very convincing if the exemplar isn't inspirational.
You could even argue the opposite, that a "bad" example might put people off ("No, if that's what being a Buddhist is, I wouldn't want to be like that."). Let's hope that people will find true Dhamma anyway.
So is it considered wrong to write such declarations publically
I'd like to answer instead, about making a declaration privately.
I was told, in private,
Don't let anyone tell you that you're not enlightened.
To me that phrase has several meanings:
If you tell me, "You're not enlightened", then why should I care what you think? You don't know me, I haven't met you, I don't even know if you know what enlightenment is.
There's an English proverb: "Don't let the bastards grind you down", it's a bit like that -- friendly advice.
"Don't let them tell you" doesn't have to mean disputing with them, though -- see SN 7.2.
Some people may try to control you by "putting you down", by saying things like ...
-- "You're poor, but I can make you rich"
-- "You're oppressed and disadvantaged, but I can make you free and powerful"
... or ...
-- "You haven't done enough for me, you need to do more"
Some people might be susceptible to, become victims to, that kind of message.
I suppose that "cults" might form that way.
Or some people get into "abusive" relationships when they needn't.
Anyway, I take the message as advice to not accept that.
If I don't allow you to tell me that I'm not enlightened, part of the reason is, "Don't tell me because I will be the judge of that" -- i.e. that I'm more able than you are to know whether I'm enlightened, I have the experience and knowledge and should trust my judgement rather than yours.
For example if I experience a fetter then perhaps I'll know that experience (and you won't).
So maybe I'm the one, the only one, who should be telling myself, "You're not enlightened."
But the advice said, "Don't let anyone tell you that you're not enlightened", that "anyone" is "me too".
So according to the advice I mustn't let myself tell myself, "You're not enlightened, e.g. for this and that reason."
To "not let" that, I have to change the fact or the view.
So that's good advice -- "don't see yourself as unenlightened, and if you do then don't let yourself remain unenlightened."
Given that "putting oneself in the place of another" is orthodox, I also don't think I should tell anyone else that they're not enlightened.
That doesn't mean I should surrender all judgement -- I might still decide that a lie is a lie, or that a good deed is a good deed.
And actually the Buddha probably did assess the enlightenment of everyone (using the "divine eye").
Even so, if someone "declares their achievement publicly", I'm not sure I should make that any concern of mine. If I must assess it (which I should if I consider the speech as doctrine) then, as quoted here, "Those monks’ speech, monks, is not to be rejoiced over, not to be scorned at."
There's probably Mahayana doctrine too, that people have "buddha-nature", and that the word "enlightenment" is empty.
Perhaps there's some disagreement or misunderstanding among Buddhists of what a word like "stream entry" even means. You might think it's impossible to misunderstand, that there are whole books about the definition. But I think that the suttas tell of people attaining stream-entry just from hearing a dhamma talk -- conversely,
For instance, 'stream-entry' according to some Mahayana is synonymous with the First Bhumi or becoming an Arya being. That is, it is marked by the direct perception of emptiness while in meditative equipoise. I don't believe this is the Theravada account at all.
Given that stream entry is associated with the eradication of identity-view, I'm not sure it's sensible to view it as "their enlightenment" or "their achievements".
Maybe it's sensible to view is as a property of the dhamma -- i.e. that stream-entry is a consequence of the dhamma's being well-expounded, Svākkhāto bhagavatā dhammo.
I think one of the troubles some people have is thinking that enlightenment is something else i.e., "There's me, here -- and enlightenment is somewhere else, unattainable" (and thus it's kind of a craving, instead of being a wholesome desire). So, "you're not unenlightened" might help get over that.
If you're going to have a teacher maybe they should teach you how to be good and to be better (and less so someone who would teach you that you're bad).
Also a statement like "I'm enlightened (and you're not)" might be understood as a conceit -- and if that's helpful then good ...
Conceit is one of those qualities we all have — and it's a slippery friend. There are times when it's useful, as in that passage where Ananda teaches a nun that we practice to overcome conceit and yet we have to use conceit in the practice. The example he gives is that when you hear of someone who has put an end to suffering, has made it all the way to the goal, you can reflect, "That person is a human being; I'm a human being. That person can do it; so can I." To that extent, you need conceit in the practice. If you believe that you can't do the practice, or if it seems way beyond you, you end up giving up, you set your sights low. And as we all know, you never hit higher than you aim. So to that extent, conceit is helpful.
... otherwise maybe don't fuss about it.
Also I'm not sure its right to call stream-entry an "achievement".
Perhaps it's a process, or the beginning of a process, towards becoming more enlightened.
The suttas talk about enlightenment as an achievement ("there is no more left to be done"), but I believe that means a full or complete enlightenment -- which maybe isn't what you were talking about since you tagged the question stream-entry.