I am not a lawyer. Hopefully my question makes sense.
The question arises out of a specific case, but I want to broaden it to any jurisdiction where you have expertise (America, Europe and anywhere) and to the general principle.
Can a court, in deciding that a law (e.g. an act of parliament or Congress) is unconstitutional, look to the political behaviour of the people passing the law or to the ground realities in the world where the law would be applied, to say that because of these conditions this law would violate constitutional principles even if in different conditions this law would not? In other words, can the court look beyond just the text of the law and the most basic of common sense?
The rest is TLDR. If you have enough interest, you are welcome to comment on the specifics. The above question could stand alone, with or without the following.
My mind recently thought back to arguments in India about the Citizenship Amendment Act. Again I am not in the legal profession. I'm not even from India. But it intrigued me at the time.
The act promises citizenship to immigrants who came in before 2014 - plus of course their descendants - from six religions from three neighbouring countries, on the grounds that they allegedly faced persecution.
https://en.wikipedia.org/wiki/Citizenship_(Amendment)_Act,_2019
The opposition said, both in Parliament and before the judges, that this is contrary to Article 14 of the Constitution, which provides for equality before the law. How, say they, does the government arbitrarily list these minorities and these countries? In particular, minority factions of Muslims are not included - how can that be? And are there not other kinds of persecution? So why is the government not making citizens of all persecuted people who have fled to India's territory?
Harish Salve is one of India's foremost lawyers. In televised interviews he rebuts this with the argument: suppose that we decided to pass a law granting Sri Lankan Tamils citizenship if they come to our shores - Sri Lanka had a very volatile history in that regard. Are you going to object to that too? "Hey what about every other kind of deserving person? Why does this bill not mention the rest? Discrimnation!" That would be absurd.
The opposition parties could counterargue that if you look at the BJP's overt agenda and if you look at the backstory of the act (namely the Assam census), you will see that the governing party has no further plans on citizenship requirements and therefore the entire question of discrimination in the granting of citizenship can be answered by this act alone. Another common charge by the opposition is that Muslims who may be bona fide citizens but can't prove their ancestry (because good documentation is not always kept) are in danger, whereas persons from allegedly preferred religions can use this act to protect themselves.
However, these are part of reality and not of the law, so should the judges take them into account?