1.1. Propositional Logic - Discrete Structures For Computing
1.1. Propositional Logic - Discrete Structures For Computing
Contents
1.1.1. The Language of Propositions
1.1.2. Applications
1.1.3. Logical Equivalences
1.1.4. Exercises
Propositional Logic is the logical system built around propositions. From such
propositions one can build logical arguments and implications.
In this section we will explore the language of propositions, their applications, and
deriving logical equivalences.
Propositions
Definition (Proposition)
To get acquainted with propositions, let us see some examples and counterexamples.
Examples of propositions
It is raining today.
1+1=2
1+1=4
Notice that propositions need not be a true statement. Propositions only need to be
declarative. Their truth value may be true or false. However, all propositions must
have a particular truth value. The statement cannot be both true and false. The
statement must be able to be interpreted as true or false.
From the previous definition and examples, propositions are therefore not questions,
general statements, demands, or hypotheses. Propositions do not have any variables,
quantifiers, or parameters (e.g. the words “some” or “any” typically do not appear).
Consider now a few non-examples.
Let’s go!
x+2=3
y = x2 − 1
1. I am a dolphin.
2. Supercalifragilisticexpialidocious.
5. 11+56∗3−8 = 9
19
Constructing Propositions
An entire proposition is often denoted by a single propositional variable. Propositional
variables are typically among p, q, r, s, t, ….
We also denote truth values in particular ways. “True” may be denoted by T . “False”
may be denoted by F . When a proposition (or proposition variable) is known to always
be true, we can replace it by T . When a proposition (or proposition variable) is known
to always be false, we can replace it by F .
Connectives
We can combine propositions (and propositional variables) into compound
propositions or propositional formulas. This is akin to compound sentences and other
logical connectives in natural language.
Negation: ¬
Conjunction: ∧
Disjunction: ∨
Implication: →
Biconditional: ↔
Negation
The negation of a proposition results in a proposition with the opposite truth value. It
is akin to adding “not” into a sentence, or starting a sentence with “it is not that case
that…”.
Given a proposition p its negation is ¬p and has the following truth values.
F T
T F
Negation
Notice in these examples that negation does not necessarily make a proposition false.
Rather, it makes the proposition have the opposite truth value.
Conjunction
The conjunction of two propositions is the logical “and” of the two propositions. The
conjunction of two proposition is only true if both the propositions are individually
true, otherwise the conjunction is false.
Given proposition p and q their conjunction is denoted p ∧ q and has the following
truth values.
p q p∧q
F F F
F T F
T F F
T T T
Conjunction
Let p be “birds lay eggs” and q be “my eyes are blue”. p ∧ q is then “birds lay
eggs and my eyes are blue”.
Disjunction
The disjunction of two propositions is the “or” of the two propositions. The disjunction
is true if at least one of the propositions is individually true, otherwise the disjunction
is false.
p q p∨q
F F F
F T T
T F T
T T T
Disjunction
Notice that in this previous example, it is may be true that it is both raining and that I
am wearing sunglasses. While that may be silly, p ∨ q is still true! In logic, we only
require that at least one of the propositions in a disjunction is true. That means both
are allowed to simultaneously be true.
Caution
Language “or”
In logic, “or” is not exclusive. You can have a cookie, a piece of cake, or both!
If you want logical exclusive or, we use the symbol ⊕. However, we will not use that in
this course.
Implication
Implication is one of the most challenging connectives to understand. Yet it is
arguably the most important for creating logical arguments (see Logical
Equivalences).
Implication
Let p be “it is raining” and q be “the ground is wet”. p → q can be read “if it
is raining, then the ground is wet”.
p q p→q
F F T
F T T
T F F
T T T
Some of these observations may seem counter-intuitive at first. Let us clarify with
some examples.
Let p be “that animal is a panda bear” and q be “that animal is black and
white”. p → q can be read as “if that animal is a panda bear, then that animal
is black and white”.
If p is true, and that animal is indeed a panda bear (and the implication is
correct),
then it is also black and white. If q is true, and the animal is black and white,
it might be a panda bear, but it might also be a cow.
If p, then q q whenever p
p implies q q follows from p
q when p p is sufficient for q
q, if p q is necessary for p
p is sufficient for q
q is necessary for p
Fig. 1.1 Being in the inner circle is sufficient for being in the outer circle. Being in
the outer circle is necessary for being in the inner circle.
Biconditional
For two propositions p and q, they can be connected by a biconditional as p ↔ q.
p q p↔q
F F T
F T F
T F F
T T T
“p if and only if q”
“if p then q, and if q then p”
“p is necessary and sufficient for q”
Biconditional
“The venn diagram is a circle” exactly means that the two subjects form a
biconditional.
Checkpoint Solution
Propositional Formulas
In the previous section we saw 5 different logical connectives: ¬, ∧, ∨, →, and ↔.
Much like arithmetic formulas using addition, multiplication, division, etc.,
propositional formulas may use several connectives simultaneously.
Much like logical connectives, propositional formulas will result in different truth
values depending on the particular truth assignment on its consituent propositional
variables. When at least one truth assignment exists so that a formula is true, that
formula is said to be satisfiable.
Definition (satisfiable)
A propositional formula is satisfiable if its truth value can be true under some
truth assignment. If every possible truth assignment makes the formula have
false as its truth value, that formula is said to be unsatisfiable.
Truth Tables
Truth tables are tools for determining the truth values of propositional formulas.
p q r p∧q (p ∧ q) ∨ r
F F F F F
F F T F T
F T F F F
F T T F T
T F F F F
T F T F T
T T F T T
T T T T T
In a truth table, you begin by filling out the columns corresponding to each
propositional variable. These columns represent every possible combination of truth
values on those variables. Then, you add columns for each sub-formula, one at a time,
building up to the final formula.
¬q
¬q ∧ r
p∧q
(p ∧ q) ∧ r
(p ∧ q ∧ r) ∨ (¬q ∧ r)
( (p ∧ q ∧ r) ∨ (¬q ∧ r) ) → p
F F F F F F T
F F T F T T F
F T F F F F T
F T T F F F T
T F F F F F T
T F T F T T T
T T F F F F T
T T T T F T T
Checkpoint Solution
Converse: q → p
Inverse: ¬p → ¬q
Contrapositive: ¬q → ¬p
Notice from this previous example than an implication and its inverse are not exactly
the same. If the conditional “if it is raining, then I wear a jacket” is true, that is not the
same as its inverse. Indeed, you might still wear a jacket even if its not raining. Maybe
Important
1.1.2. Applications
There are many many applications of propositional logic. You will explore many more
of them in other courses on logic, computer architecture, theoretical computer
science, and more.
p∧q →r
(p ∧ q) ∨ (r ∧ t)
Note the ambiguity of the previous example. Did the English sentence assume an
exlusive or? Probably. Then, a correct translation might be (p ∧ q) ⊕ (r ∧ t).
Boolean Searches
Boolean, from mathematician George Boole, refers to a special kind of mathematics
that deals with turth values: true and false. Boolean algebra is a set of rules for
manipulating formulas containing variables and truth values. This is very similar to, but
slightly distinct from propositional logic. We will not explore Boolean algebra in this
course.
Boolean searches are about using logical connectives to help search through datasets
and filter pieces of data. This includes databases and internet search engines.
AND is used to find records which contain both “foo” and “bar”.
OR is used to find records which contain “foo” or “bar” or both.
NOT is used to exclude records which do contain a keyword.
If we are looking for places to find beer in London, England we might search:
In most search engines, the AND is implicit, and we can simply search
“London England Beer”.
If we are looking for places to find beer or cider in London, England we might
search:
The ANDs are implicit: “London AND England AND (Beer OR Cider)”
If we are looking for places to find beer in London, Ontario we might try to
exclude entries for London, England. Searching for:
Search engines often use the minus sign to denote NOT: “London Beer -
England”
Formal Specifications
In software, computer, and electrical engineering, the requirements of a system,
software, or defice must often meet very precise specifications.
These specifications are sometimes easy to express. For example, “the circuit carries
115-125 volts”. For softare in particular, its requirements are often expressed as
(ambiguous) natural language requirements. Those requirements must be translated
into precise logical statements.
Logical Specification
“Mute all notifications during buisness hours when the user’s status is not
available.”
p ∧ ¬q → r
Propositional logic can also be used to determine if the collection of all requirements
for a system is consistent.
Notice that consistency is not the same as every formula in a set being satisfiable.
The formulas must be simultaneously satisfied by the same truth assignment.
p1 ∧ p2 ∧ p3 ∧ ⋯ ∧ pn
Exercise
Let us consider an electronic messaging network which requires that all sent
messages are certain to be received. This behaviour might be modelled as
the following specifications:
1. Messages remain in the outbound message queue until they have been
received by the recipient.
We have:
1. p → ¬q
2. ¬q → (p ∨ r)
3. q → ¬r
p q r p → ¬q ¬q → (p ∨ r) q ∧ ¬r
F F F T F F
F F T T T F
F T F T T T
F T T T T F
T F F T T F
T F T T T F
T T F F T T
T T T F T F
You meet two people, A and B. A says “B is a knight.” B says “the two of
us are different kinds of people”.
Solution
What is an equivalence? Well, the first quesiton to ask is: what is a tautology?
Definition (tautology)
Definition (contradiction)
Logically Equivalent
Two propositional formulas, say p and q, are logically equivalent if p ↔ q is a
tautology. When this is the case, we may write p ⟺ q or p ≡ q.
A simple and explicit way to determine if two expressions are logically equivalent is if
their two columns in a truth table are identical.
p q ¬p p→q ¬p ∨ q
F F T T T
F T T T T
T F F F F
T T F T T
There are several logical equivalences which would be good to memorize. They are
similar to many laws of arithmetic. For example, we know x × 0 = 0 regardless of the
value of x.
Complementation Laws p ∧ ¬p ≡ F p ∨ ¬p ≡ T
There are also interesting properties of logical connectives between two or more
propositional variables.
Associativity p ∧ (q ∧ r) ≡ (p ∧ q) ∧ r
Distributivity p ∧ (q ∨ r) ≡ (p ∧ q) ∨ (p ∧ r)
Absorption p ∧ (p ∨ q) ≡ p
p∨q ≡q∨p
p ∨ (q ∨ r) ≡ (p ∨ q) ∨ r
p ∨ (q ∧ r) ≡ (p ∨ q) ∧ (p ∨ r)
p ∨ (p ∧ q) ≡ p
¬(p ∨ q) ≡ ¬p ∧ ¬q
De Morgan’s Laws are very important. These laws explain how negation distributes
over a conjunction and disjunction. In particular, it turns disjunctions into
conjunctions, and vice versa.
Important
In these laws and properties, we can replace any propositional variable with
an entire propositional formula, and the law is still correct.
Variable-expression replacement
Let p := (¬a ∧ b) ∨ c.
(¬a ∧ b) ∨ c ∨ T ≡ ( (¬a ∧ b) ∨ c ) ∨ T
≡p∨T
≡T
These laws and properties can be used as building blocks to prove that certain
expressions are logically equivalent. Before we see that process, let’s see some more
interesting logical equivalences.
(p → q) ≡ ¬p ∨ q
(p → q) ∧ (p → r) ≡ p → (q ∧ r)
(p → r) ∧ (q → r) ≡ (p ∨ q) → r
p ↔ q ≡ (p → q) ∧ (q → p)
p ↔ q ≡ ¬p ↔ ¬q
p ↔ q ≡ (p ∧ q) ∨ (¬p ∧ ¬q)
Tip
Draw the truth table for some of the above examples to prove to yourself
that the two expressions are logically equivalent.
Equivalence proof
We can show two expressions, say A and B, are logically equivalent by constructing a
sequence of logically equivalent statements Ei, beginning with A and ending with B.
A ≡ E1
E1 ≡ E2
E2 ≡ E3
⋮
En ≡ B
p ∧ (¬p ∨ q) ≡ p ∧ ¬p ∨ p ∧ q distributivity
≡F ∨p∧q annihilation
≡p∧q identity
Whenever we use propositional logic, we will return to equivalence proofs and truth
tables. It is important that you really understand the manipulation and equivalency of
propositional truth tables.
Checkpoint Solution
Equivalence proof
Exercise 1.1
If a propositional formula has 5 variables, how many rows are needed in its
truth table?
32. Each variable has two choices: true of false. 5 variables means there are
2 × 2 × 2 × 2 × 2 = 25 = 32 possible combinations of truth values.
Exercise 1.2
p: It is snowing
q: I wear a jacket
r: I wear mitterns
p → (q ∧ r)
Exercise 1.3
p: I am at the beach
q: I go swimming
r: I wear a swimsuit
p∨q →r
2. “4 = 2 + 2 → 7 < √50”
3. “4 ≠ 2 + 2 → 7 < √50”
4. “4 = 2 + 2 → 7 ≥ √50”
Exercise 1.5
2. “x = ±1”
2. “x ≠ 1 and x ≠ −1”
Exercise 1.6
3. “ab = 0 → a = 0 or b = 0”.
1.
2.
3.
Converse: “a = 0 or b = 0 → ab = 0”
Contrapositive: “a ≠ 0 and b ≠ 0 → ab ≠ 0
Exercise 1.7
3. (p ∧ q ∧ ¬r) ∨ (p ∧ ¬q ∧ ¬r)
1. (p, q, r) := (T , T , F )
2. Not satisfiable
3. (p, q, r) := (T , T , F ) or (T , F , F )
Applications
Exercise 1.8
Julie and Jamie are identical twins. One of then always lies and one of them
always tells the truth. Suppose you meet one of them. What 3-word question
(with a yes/no answer) can you ask to determine which twin is in front of
you? You do not know which twin lies.
1. Suppose you meet Julie and Julie tells the turth. Julie will reply “no”.
2. Suppose you meet Julie and Julie lies. Julie will reply “no” (i.e. “no, Jamie
lies”).
3. Suppose you meet Jamie and Jamie tells the truth. Jamie will reply “yes”.
4. Suppose you meet Jamie and Jamie lies. Jamie will reply “yes” (i.e. “yes,
Julie lies”).
Exercise 1.9
2. Students can skype during the test when the prof is distracted.
3. If the classroom phone does not ring then the prof is not distracted.
4. Students cannot skype during the test unless the internet is on.
I := “internet is on”
C := “the campus server works”
D := “the professor is distracted”
S := “students can Zoom during the test”
R := “the classroom phone rings”
1. ¬I → ¬C
2. D → S
3. ¬R → ¬D
5. R → C
Logical Equivalences
Exercise 1.11
p q ¬(p ∧ q) ¬p ∨ ¬q
F F T T
F T T T
T F T T
T T F F
Exercise 1.12
Exercise 1.13
Show that the following expressions are logically equivalent. Do this by (a)
truth tables, and (b) logical equivalences.
p ↔ q ≡ (p ∧ q) ∨ (¬p ∧ ¬q)
Exercise 1.14
Let A be ¬p ∧ q.
Exercise 1.16
By Alexander Brandt
© Copyright 2022.