Does James like algebra or analysis? I recently started studying logic. Unfortunately, I'm really struggling when it comes to word problems. I would really appreciate if someone could help me understand and solve the following problem.

James is cunning. He sometimes lies and sometimes he tells the truth.
  When we ask him about his favourite subject, he says:
  
  
*
  
*"If I like analysis, I definitely don't like algebra."
  
*"If I didn't lie in the previous sentence, I'm doing it now and I like algebra."
James of course likes  at least one of these two subjects, but which?

Thanks for any help.
 A: Introducing two atomic propositions,


*

*$p$: James likes analysis.

*$q$: James likes algebra.


Let us translate.

  
*
  
*"If I like analysis, I definitely don't like algebra."
  

$$p \to \neg q$$


  
*"If I didn't lie in the previous sentence, I'm doing it now and I like algebra."
  

$$(p \to \neg q) \to \neg q$$
Using modus ponens (implication elimination), we conclude $\neg q$. Thus, James does not like algebra. Since he must like at least one course, he likes analysis.
A: Premise 1: "If I like analysis, I definitely don't like algebra."

Premise 2: "If I didn't lie in the previous sentence, I'm doing it now and I like algebra."

Premise 2 (P2) is contingent on Premise 1 (P1) since the claim in P2 changes the truth value of P1.
The question is whether James likes analysis or algebra.  We'll symbolize this as an alternation:
A = Analysis
B = Algebra

A v B

I will use a tilde (~) to symbolize "not," the vel (v) is "or," ampersand (&) for "and," and finally the greater than to symbolize implication (>) for an "if, then" statement.  Let C stand for P1, and D stand for P2.
P1: A > ~B
P2: ~D > (B)

Assumption: B.

P1: B, (A > ~B).

DeMorgen's and equivalence result in ~(A v ~B), leading to (~A & B). Separating the conjunction, we now have:
B, ~A, and B.


P2: ~D > B.

Using D as a substitution of Premise 2, we see that B is then true.  The contrapositive of P2 is D.
Using an equivalence rule, P2 becomes:
~(~D v B).  Distributing the negation, and using another equivalence we then have:
D & ~B.

This is a contradiction for the assumption that B is true.  We now repeat the process by assuming that A is true.
P1: A > ~B
P2: ~D > (B)

Assumption: A.

P1: A, A > ~B.
P2: A, ~(~D v B)

By P1, we have:
A, (A > ~B), ~B

By P2 we have:
A, D, ~B

Now we have proven that James likes Analysis, since no contradiction results from assuming he does.
A: This relies on assuming "He sometimes lies and sometimes he tells the truth" to mean he always does one or the other.  e.g. he can not say "I am lying" as that is neither a lie nor the truth:
"If A then B" is true if A is false, is true if both are true, and is only false if A is true and B is false.
Suppose he doesn't like analysis.
Then sentence one is true.
"I am lying now and X" must be false as it can not but true.
Sentence 2 has a true clause and a false conclusion.  So it is false. So he is lying.
So "I am lying and X" is false but he is lying, so X is not true.
So he doesn't like algebra.  But he also doesn't like analysis.  It was stated he likes at least one (why "of course"?) so this is a contradiction.
So he likes analysis.
If sentence one is true he doesn't like algebra.
If sentence one is false he maybe likes algebra.
If sentence one is true sentence two is false and he doesn't like algebra.
If sentence one is false sentence two would be true no matter what.
So he likes analysis. Maybe he likes algebra and maybe he doesn't.
