The fundamental building block of mathematics that we will be exploring in this course is logical statements/propositions. This section explores what they are and introduces operations that we do with them.
The last example raises an important distinction: not everything that looks like math is a logical statement. A question you might ask yourself is βwhat is the result?β If I wrote β1 + 2β, the result is a number. Youβd say itβs 3. If I wrote β1 - 3 = 4β, youβd say, βNo, thatβs false!β The result is a truth value.
We can negate a statement like β1- 3 = 4β. Itβs negation is β\(1-3 \ne 4\)β. We canβt negate something that isnβt a statement -- Asking the opposite of β1+3β is meaningless.
Let \(p\) and \(q\) be propositions. The conjunction of \(p\) and \(q\text{,}\) denoted \(p \wedge q\text{,}\) is the proposition β\(p\) and \(q\)β.
The logical disjunction is an βinclusive orβ. On the other hand, we define the βexclusive orβ of \(p\) and \(q\) to be the proposition β\(p\) or \(q\) but not bothβ. We wonβt be using it in Discrete 1, so we wonβt give it a special symbol.
Let \(p\) and \(q\) be propositions. The conditional statement is the compound proposition βif \(p\) then \(q\)β. The conditional is denoted by \(p \to q\text{.}\)
Write the following as a simple English expression, letting \(p\) be the statement βit rainsβ and \(q\) be the statement βI complain about the weatherβ.
Let \(p\) and \(q\) be propositions. The biconditional of \(p\) and \(q\text{,}\) is the statement β\(p\) if and only if \(q\)β, denoted \(p \leftrightarrow q\text{.}\)
Just as with arithmetic operations (\(+, -, \times, \div\)) on numbers, we need to define an order of operations so that compound propositions can be understood without grouping symbols. Though for clarity, we will generally write grouping symbols.
Truth tables allow us to uniquely determine the truth value of a compound proposition, based on the truth values of the simple statements from which it is made. Below are the truth tables for conjunction \(\wedge\text{,}\) disjunction \(\lor\text{,}\) conditional \(\to\text{,}\) biconditional \(\leftrightarrow\text{,}\) exclusive or \(\oplus\text{,}\) and negation \(\neg\text{.}\)
The objects that are logical propositions in mathematics are bool Boolean datatypes in computer science. For example, the clause 5 <= 3 will evaluate to False. This corresponds to the proposition \(p:=\)β5 \(\le\) 3β\(\equiv F\text{.}\)
if (collision == 1 && object==sword && !blocking){
// hit by a sword, take damage
health--;
}
corresponds to a logical statement of the form \((p \land q \land \neg r) \to s\text{.}\) Note that health--; isnβt a statement. Itβs an operation to decrement the health; it isnβt true or false.
Make a truth table for the statement \(\neg p \wedge (q \to p)\text{.}\) What can you conclude about \(p\) and \(q\) if you know the statement is true?
Converse: βIf I bring an umbrella then it rains today.β. Inverse: βIf it doesnβt rain today then I wonβt bring an umbrella.β Contrapositive: βIf I wonβt bring an umbrella, then it isnβt raining todayβ.
The conditional βWhenever I drive my car, I do not use my phoneβ is βIf I drive my car, then I donβt use my phone.β Now find the other statements.
The conditional βWhen I stay up too late, itβs necessary that I sleep until noonβ is βIf I stay up too late, then itβs necessary that I sleep until noon.β Now find the other statements.
This is a favorite of my daughter. You encounter a guard standing at a fork in the road. It is not known whether the guard is a knight or a knave, that is, that they will (always) tell the truth or (always) lie. One of the paths leads to great treasure, the other leads to a violent and scary death. You are allowed to ask one and only one question to the guard.