The fallacy of the true Scotsman consists of attempting to defend a generalization by denying the validity of the counterexamples provided. By altering the definition of who or what belongs to a group or category, the speaker can easily dismiss any example proving that the generalization is invalid.
The true Scotsman's fallacy occurs when someone tries to deflect criticism from their argument, which takes the form of a generalization. According to this fallacious reasoning, any example that would serve as evidence contradicting the initial generalization is automatically dismissed as unrepresentative.
In other words, the error arises when someone tries to defend their ingroup against criticism (ingroup bias) by excluding members who disagree with the ingroup. Put another way, instead of accepting that some members might think or act disagreeably, these members are treated as imposters.
In its fundamental form, error concerns the relationship between a universal generalization and a case that disagrees with that generalization.
A universal generalization would be "all X are Y", where X can be any group membership and Y can be any quality or characteristic.
A counterexample would be “some X are not Y”.
Logically, if you claim that all X's are Y and someone finds an X that is not Y, you must accept it and abandon your initial claim.
Under the fallacy of no real Scotsman, instead of accepting this, you deny that this specific X was ever a member of the group. This is achieved by emphasizing that we are only talking about “authentic” examples of the group in question, whatever that may be.
It is important to note that arguments like “no true X would do Y” are not always fallacious. When there is a universally accepted definition, such statements are valid.
For example, if someone claims to be vegan but eats cheese, then it is legitimate to say that this person is not a "real" vegan because the definition of veganism involves not consuming any animal products.
Here we must verify whether the counterexample contradicts the definition or not. If it does not, then it is a fallacy.