You could use perl:
perl -wne 'print if (/term1/ && /term2/) || (/term1/ && (/term3/ xor /term4/))'
Where the Perlswitches are as follows:
perl -wne 'print if (/term1/ && /term2/) || (/term1/ && (/term3/ xor /term4/))'
-w turns on warnings
-n runs perl against each line of input (looping)
-e executes perl passed in the command line