# Idea
## Example 1
Let $p$ be the proposition "I like cats."
Let $q$ be the proposition "I like dogs."
What logical notation represents the sentence, "I like dogs only if I do not like cats"?
> [!NOTE]- Solution
> $q \rightarrow \neg p$
>
> "*Only if*" indicates that $q$ (I like dogs) is true only if $\neg p$ is true (I don't like cats).
>
> In logical notation, it means the following: If I like dogs ($q$), then it is true that I do not like cats $\neg p$.
## Example 2
Some person or people stole cookies from the cookie jar. The suspects are Albert, Betty and Clive. At least one of them committed the crime but Clive was only involved if Albert was involved and Betty would not be involved on her own.
So, who stole cookies from the cookie jar?
- Let $a$ represent the proposition "Albert stole cookies from the cookie jar".
- Let $b$ represent the proposition "Betty stole cookies from the cookie jar".
- Let $c$ represent the proposition "Clive stoke cookies from the cookie jar".
Propositions
- Some person or people stole cookies from the cookie jar: $a \lor b \lor c$
- Clive was only involved if Albert: $c \rightarrow a$
- Betty would not be involved on her own: $b \rightarrow (a \lor c)$
- Combined: $(a \lor b \lor c) \land (c \rightarrow a) \land (b \rightarrow (a \lor c))$
Creating the [[truth table]] in R
```r
library(tidyverse); library(data.table)
d0 <- expand_grid(a = c(0, 1), b = c(0, 1), c = c(0, 1))
setDT(d0)
d0
d0[, a_or_b_or_c := as.numeric(a | b | c)]
d0[, .(c, a)]
d0[, c_implies_a := c(1, 0, 1, 0, 1, 1, 1, 1)]
d0[, a_or_c := as.numeric(a | c)]
d0[, .(b, a_or_c)]
d0[, b_implies_a_or_c := c(1, 1, 0, 1, 1, 1, 1, 1)]
d0[, .(b, a_or_c, b_implies_a_or_c)]
d0[, .(c_implies_a, b_implies_a_or_c)]
d0[, combined := as.numeric(c_implies_a & b_implies_a_or_c & a_or_b_or_c)]
d0
a b c a_or_b_or_c c_implies_a a_or_c b_implies_a_or_c combined
1: 0 0 0 0 1 0 1 0
2: 0 0 1 1 0 1 1 0
3: 0 1 0 1 1 0 0 0
4: 0 1 1 1 0 1 1 0
5: 1 0 0 1 1 1 1 1
6: 1 0 1 1 1 1 1 1
7: 1 1 0 1 1 1 1 1
8: 1 1 1 1 1 1 1 1
```
## Example 3
Write using logical connectives (from [[propositional logic systems]]): For hiking on the trail to be safe, it is necessary but not sufficient that berries not be ripe along the trail and for grizzly bears not to have been seen in the area.
- $p$: Grizzly bears have been seen in the area.
- $q$: Hiking is safe on the trail.
- $r$: Berries are ripe along the trail.
> [!NOTE]- Solution
> $
\underbrace{q \rightarrow (\neg r \land \neg p) }_{\text {it is neccessary }} \underbrace{\land}_{\text {and/but }}\underbrace{\neg(\neg r \wedge \neg p) \rightarrow q}_{\text {it is not sufficient }}$
# References