Hi, If your question is more about strict logic and less about "normal" English, I won't offer an opinion. Are you doing a course on logic? Otherwise, I'd say that I favour the version without a comma, unless the expressions that you are representing here by letters actually consist of a lot of words.
New words, one handy idiom, and a 2-minute quiz — delivered to your inbox to keep your streak alive.