Is my translation of unless into propositional logic correct? I have the following sentences:
I won't go the library unless I need a book

p: I will go the library
q: I need a book

I replaced unless with if not as follows:
I won't go the library if I don't need a book
Then: $\lnot q \rightarrow p$ is my translation correct here?
And what if I paraphrased the sentence to the following:
If I won't go the library then I (don't) need a book.
$\lnot p \rightarrow \lnot q $
Would it still be correct?
 A: "$A$ unless $B$" is usually read in English as

$A$, if not $B$.

Thus, for I won't go the library unless I need a book, will be:

I won't go the library, if I do not need a book.

With:

$p$: I will go the library
$q$: I need a book

will be:


$\lnot q \to \lnot p$


that is the same as:

$p \to q$.



$\lnot q \to \lnot p$

is not equivalent to:

$\lnot p \to \lnot q$,

and this is consistent with the fact that:

If I won't go the library, then I don't need a book

is not the same as the previous:

I won't go the library, if I do not need a book.



Trough the truth-functional equivalence between "if $B$, then $A$" and "not $B$ or $A$", we have that :

"$A$ unless $B$" is equivalent to "$B$ or $A$".

A: Let's think about your sentence carefully:

I won't go the library unless I need a book.

This sounds like you hate the library, and that as a general rule of thumb, you should not be expected to be caught dead there, except for one extenuating circumstance (you need a book). Let's evaluate your proposed translations.

Translation 1 ($\neg q \to p$): If I don't need a book, then I'll go to the library.

This definitely doesn't make sense. After all, you hate libraries. And you don't even need a book!

Translation 2 ($\neg p \to \neg q$): If I won't go to the library, then I don't need a book.

This isn't quite as bad of a translation, but it doesn't necessarily follow from the original sentence. Perhaps the library is merely your last resort for getting a book, and so it's possible that there are other alternatives (like borrowing your friend's old copy, for example). Thus, you are able to successfully avoid a trip to the dreaded library and yet simultaneously satisfy your need for a book.

Correct Translation ($p \to q$): If I go to the library, then I need a book.

This works. There are only three possible combinations and one impossible combination:


*

*Possible #1: You are not at the library and you don't need a book. (happens all the time)

*Possible #2: You are not at the library and you need a book. (hopefully there are alternatives)

*Possible #3: You are at the library and you need a book. (rarely happens, but you had no other choice)

*Impossible: You are at the library and you don't need a book. (...then why are you there?)

