Comp 283, 2025 Summer Session 1

Course Site for Comp 283

Learning Objectives

Propositions and Basic Operations

A proposition is a sentence to which one and only one of the terms \(\texttt{True}\) or \(\texttt{False}\) can be applied.

Which of the following are propositions?

Negation

A Truth Table for negation would look like the following:

\[\begin{array}{|c|c|} \hline p & \neg p \\ \hline T & F \\ F & T \\ \hline \end{array}\]

What this is saying is:
“When \(p\) is \(\texttt{True}\), \(\neg p\) is \(\texttt{False}\),
and when \(p\) is \(\texttt{False}\), \(\neg p\) is \(\texttt{True}\).’’

Here is an example of a negated proposition:

Conjunction

A Truth Table for conjunction would look like the following: \(\begin{array}{|c|c|c|} \hline p & q & p \land q \\ \hline T & T & T \\ T & F & F \\ F & T & F \\ F & F & F \\ \hline \end{array}\)

Here is an example of conjunction:

The conjunction (\(p \land q\)) is \(\texttt{True}\) on sunny Mondays, but it is \(\texttt{False}\) on any non-sunny day (\(p\) is \(\texttt{False}\)), and it is \(\texttt{False}\) on any day that is not Monday (\(q\) is \(\texttt{False}\)).

Disjunction

A Truth Table for disjunction would look like the following: \(\begin{array}{|c|c|c|} \hline p & q & p \lor q \\ \hline T & T & T \\ T & F & T \\ F & T & T \\ F & F & F \\ \hline \end{array}\)

Here is an example of disjunction.

The disjunction (\(p \lor q\)) is \(\texttt{True}\) on sunny Mondays, on any sunny day (\(p\) is \(\texttt{True}\)), and on any Monday (\(q\) is \(\texttt{True}\)). It is \(\texttt{False}\) on any day where it is both not sunny and not Monday.

Exclusive Or

A Truth Table for exclusive or would look like the following: \(\begin{array}{|c|c|c|} \hline p & q& p \oplus q \\ \hline T & T & F \\ T & F & T \\ F & T & T \\ F & F & F \\ \hline \end{array}\)

Here is an example of exclusive or.

The exclusive or (\(p \oplus q\)) is \(\texttt{True}\) on any sunny day (\(p\) is \(\texttt{True}\)) and on any Monday (\(q\) is \(\texttt{True}\)), EXCEPT for on sunny Mondays (both \(p\) and \(q\) are \(\texttt{True}\)). Additionally, it is \(\texttt{False}\) on any day where it is both not sunny and not Monday.

Conditionals

The conditional statement \(p \rightarrow q\) is False when \(p\) is \(\texttt{True}\) and \(q\) is \(\texttt{False}\), and True otherwise. \(p\) is called the hypothesis and \(q\) the conclusion. This can also be called implication.

Some English phrases for this would be:

A Truth Table for implication would look like the following: \(\begin{array}{|c|c|c|} \hline p & q & p \rightarrow q \\ \hline T & T & T \\ T & F & F \\ F & T & T \\ F & F & T \\ \hline \end{array}\)

Here is an example of implication.

The implication (\(p \rightarrow q\)) is \(\texttt{False}\) if it is sunny and I do NOT walk to campus. Otherwise, it is \(\texttt{True}\).

If it is not sunny (\(p\) is \(\texttt{False}\)) and I still walk to campus (\(q\) is \(\texttt{True}\)), this implication is still \(\texttt{True}\).

Biconditionals

The biconditional statement (“if and only if” or “iff”) \(p \leftrightarrow q\) is \(\texttt{True}\) when \(p\) and \(q\) have the same truth value, and \(\texttt{False}\) otherwise.

A Truth Table for implication would look like the following: \(\begin{array}{|c|c|c|} \hline p & q & p \leftrightarrow q \\ \hline T & T & T \\ T & F & F \\ F & T & F \\ F & F & T \\ \hline \end{array}\)

Here is an example of a biconditional.

The biconditional (\(p \leftrightarrow q\)) is \(\texttt{True}\) if it is sunny and I walk to campus or if it is not sunny and I don’t walk to campus. Otherwise, it is \(\texttt{False}\).

Unlike the previous example, if it is not sunny (\(p\) is \(\texttt{False}\)) and I still walk to campus (\(q\) is \(\texttt{True}\)), this biconditional is \(\texttt{False}\).

Order Of Operations

Everything else can be written as a combination of the above three, but in general, it’s best to always clarify order of operations using parentheses!

Logical Equivalences

Logical expressions that result in the same truth values are considered logical equivalences.

Common Logical Equivalences

\[\begin{array}{l l} \textbf{Commutative Laws} & p \lor q \equiv q \lor p \\ & p \land q\equiv q \land p \\ \hline \textbf{Associative Laws} & (p \lor q) \lor r \equiv p \lor (q \lor r) \\ & (p \land q) \land r\equiv p \land (q \land r)\\ \hline \textbf{Distributive Laws}& p \land (q \lor r) \equiv (p \land q ) \lor (p \land r)\\ & p \lor (q \land r) \equiv (p \lor q) \land (p \lor r) \\ \hline \textbf{Identity Laws} & p \lor F\equiv p\\ & p \land T \equiv p\\ \hline \textbf{Negation Laws} & p\land \neg p\equiv F\\ & p\lor \neg p\equiv T\\ \hline \textbf{Idempotent Laws}& p \lor p \equiv p\\ & p\land p \equiv p\\ \hline \textbf{Domination Laws}& p \land F \equiv F\\ & p \lor T \equiv T\\ \hline \textbf{Absorption Laws} & p \land (p\lor q)\equiv p\\ & p \lor (p \land q) \equiv p\\ \hline \textbf{DeMorgan's Laws} & \neg (p \lor q) \equiv (\neg p) \land (\neg q)\\ & \neg (p \land q) \equiv (\neg p) \lor (\neg q)\\ \hline \textbf{Double Negation Law} & \neg (\neg p)\equiv p\\ \hline \textbf{Implication} & p \implies q \equiv \neg p \lor q\\ \end{array}\]

Proving Equivalences

Logical Equivalences can be proven two different ways:

  1. Using Truth Tables
  2. Directly, using other logical equivalences

Example 1

We can prove the first part of DeMorgan’s Law
(\(\neg (p \land q) \equiv \neg p \lor \neg q\)) using a truth table.

\[\begin{array}{|c|c|c|c|c|c|c|} \hline p & q & \neg p & \neg q & p \land q & \neg(p \land q) & \neg p \lor \neg q \\ \hline T & T \\ T & F \\ F & T \\ F & F \\ \hline \end{array}\] \[\begin{array}{|c|c|c|c|c|c|c|} \hline p & q & \neg p & \neg q & p \land q & \neg(p \land q) & \neg p \lor \neg q \\ \hline T & T & F & F & T & F & F\\ T & F & F & T & F & T & T\\ F & T & T & F & F & T & T\\ F & F & T & T & F & T & T \\ \hline \end{array}\]

The columns for \(\neg(p \land q)\) and \(\neg p \lor \neg q\) are equal, so this means \(\neg(p \land q)\) and \(\neg p \lor \neg q\) are logically equivalent!

Example 2

Prove \((a \land \neg b) \rightarrow c \equiv \neg a \lor b \lor c\) directly using existing logical equivalences. \(\begin{array}{|c|c|} \hline \textbf{Equivalence} & \textbf{Rule Used}\\ \hline (a \land \neg b) \rightarrow c & \textbf{Given} \\ \hline \equiv \neg (a \land \neg b) \lor c & \textbf{Implication} \\ \hline \equiv \neg a \lor \neg \neg b \lor c & \textbf{DeMorgan's} \\ \hline \equiv \neg a \lor b \lor c & \textbf{Double Negation}\\ \hline \end{array}\)

Other Considerations

A truth table computes all possible combinations of \(n\) propositions, so a truth table always has how many rows?

Example 1

propositions = \(\{p\}\)

truth values = \(\{\texttt{True}, \texttt{False}\}\)

Truth table:

\[\begin{array}{|c|} \hline p \\ \hline T \\ F \\ \hline \end{array}\]

2 rows…

Example 2

propositions = \(\{p, q\}\)

truth values = \(\{\texttt{True}, \texttt{False}\}\)

Truth table:

\[\begin{array}{|c|c|} \hline p & q \\ \hline T & T \\ T & F \\ F & T \\ F & F \\ \hline \end{array}\]

4 rows…

Example 3

propositions = \(\{p,q,...\}\) \(\leftarrow\) \(n\) propositions

truth values = \(\{\texttt{True}, \texttt{False}\}\)

\(2^n\) rows!

Tautologies

\[\begin{array}{|c|c|c|} \hline p & \neg p & p \lor \neg p \\ \hline T & F & T \\ F & T & T \\ \hline \end{array}\]

For all values, \(p \lor \neg p\) evaluates to \(\texttt{True}\)!

Translating English Sentences

To translate logic to and from English sentences, it is important to know the common phrases for the operators.

Example

Here’s an example of breaking up an English language sentence.

Using Logic For Problem Solving

The rest of these slides (notes) are optional, but they demonstrate how logic can be used for problem solving!

Knights and Knaves (Raymond Smullyan)

On an island, every inhabitant is a knight who always tells the truth, or a knave who always lies. You meet three inhabitants, Alice, Bob, and Chris.

Can you determine uniquely what each of Alice, Bob, and Chris are?

  1. Define convenient variables for propositions.
  2. Transform what they say into statements that always should evaluate to \(\texttt{True}\). These are the rules of our world.
  3. Make a truth table – With 3 people, we have \(2^3\) rows
  4. Check if a unique row makes both statements true.

\(1.\) Define convenient variables for propositions.

\(2.\) Transform what they say into statements that always should evaluate to \(\texttt{True}\). These are the rules of our world.

\(2.\) Transform what they say into statements that always should evaluate to \(\texttt{True}\). These are the rules of our world.

(Propositions:

\(\{A =\) “Alice is a knight”, \(B =\) “Bob is a knight”,\(C=\) “Chris is a knight”, \(\neg A =\) “Alice is a knave”, \(\neg B =\) “Bob is a knave”,\(\neg C=\) “Chris is a knave”})

\(2.\) Transform what they say into statements that always should evaluate to \(\texttt{True}\). These are the rules of our world.

(Propositions:

\(\{A =\) “Alice is a knight”, \(B =\) “Bob is a knight”,\(C=\) “Chris is a knight”, \(\neg A =\) “Alice is a knave”, \(\neg B =\) “Bob is a knave”,\(\neg C=\) “Chris is a knave”})

\(3.\) Make a truth table

Rules of the World: \(A \rightarrow (\neg B \lor C)\) and \(B \rightarrow (A \leftrightarrow \neg C)\)

\[\begin{array}{|c|c|c|c|c|} \hline A & B & C & A \rightarrow (\neg B \lor C) & B \rightarrow (A \leftrightarrow \neg C) \\ \hline T & T & T & T & F\\ T & T & F & F & T\\ \color{green}T & \color{green}F & \color{green}T & \color{green}T &\color{green}T\\ \color{green}T & \color{green}F & \color{green}F &\color{green} T &\color{green}T\\ \color{green}F & \color{green}T & \color{green}T & \color{green}T &\color{green}T\\ F & T & F & T &F\\ \color{green}F & \color{green}F & \color{green}T & \color{green}T &\color{green}T\\ \color{green}F & \color{green}F & \color{green}F & \color{green}T &\color{green}T\\ \hline \end{array}\]

\(4.\) Check if a unique row makes both statements true.

\[\begin{array}{|c|c|c|c|c|} \hline A & B & C & A \rightarrow (\neg B \lor C) & B \rightarrow (A \leftrightarrow \neg C) \\ \hline T & T & T & T & F\\ T & T & F & F & T\\ \color{green}T & \color{green}F & \color{green}T & \color{green}T &\color{green}T\\ \color{green}T & \color{green}F & \color{green}F &\color{green} T &\color{green}T\\ \color{green}F & \color{green}T & \color{green}T & \color{green}T &\color{green}T\\ F & T & F & T &F\\ \color{green}F & \color{green}F & \color{green}T & \color{green}T &\color{green}T\\ \color{green}F & \color{green}F & \color{green}F & \color{green}T &\color{green}T\\ \hline \end{array}\]

All of the values in green are assignments that could work! Let’s test one of these!

Testing A Solution…

\[A = T, B = F, C = T\]

So, Alice is a knight, Bob is a knave, and Chris is a knight.

Both of our rules hold in this world with these assignments, so we know that this solution works!

Why this isn’t a good problem…

This problem isn’t explicit enough, so we found ourselves making an assumption.

When we solved it, we assumed that if someone is lying, they don’t actually know whether or not what they are saying is the truth, so their claim could either be true or false. This is why we were able to use implication.

However, what if we assumed that if someone is lying, they know their claim is false?

If we assume that if someone is lying, they know their claim is false, then we would have to explain our rules using a biconditional.

Therefore, our answer is correct for what we assume the rules of the world are, but that might not match the author of the puzzle’s original intention. This shows the benefit of logic! We can use it to address these ambiguities!