Fundamentals of Logic Notes
Fundamentals of Logic Notes
Fundamentals of Logic
1.1 Propositional Logic
1.1.1 Introduction
The rules of logic give precise meaning to mathematical statements. These rules are used to
distinguish between valid and invalid mathematical arguments. Besides the importance of
logic in understanding mathematical reasoning, logic has numerous applications to computer
science. These rules are used in the design of computer circuits, the construction of computer
programs, the verification of the correctness of programs, and in many other ways.
Furthermore, software systems have been developed for constructing some, but not all, types
of proofs automatically.
1.1.2 Propositions(statement)
A proposition is a declarative sentence (that is, a sentence that declares a fact) that is either
true or false, but not both.
Sentences 1 and 2 are not propositions because they are not declarative sentences. Sentences 3
and 4 are not propositions because they are neither true nor false. Note that each of sentences
3 and 4 can be turned into a proposition if we assign values to the variables.
1.1.3 Important terms
Propositional variables (or sentential variables): These are the variables that represent
propositions, just as letters are used to denote numerical variables. The conventional letters
used for propositional variables are p, q, r, s,… .
Truth value: The truth value of a proposition is true, denoted by T, if it is a true proposition,
and the truth value of a proposition is false, denoted by F, if it is a false proposition.
Atomic propositions.: these are the propositions without any connectives such as or, and but
etc.
example1: Today is Friday
example 2: 3+2=9
Propositional calculus or propositional logic: The area of logic that deals with propositions
is called the propositional calculus or propositional logic. It was first developed
systematically by the Greek philosopher Aristotle more than 2300 years ago.
Compound propositions, many mathematical statements are constructed by combining one
or more atomic propositions. These new propositions are called as compound propositions,
are formed from existing propositions using logical operators.
Example 1: Today is Sunday and it is holiday
Example 2 : If it is raining then road becomes wet
Example 3: Students who have taken either Discrete maths or Use of computer packages will
get a software job.
1.1.4 Logical Operators. (Connectives)
Negation:
Conjunction(And Connective)
definition :
Let p and q be propositions. The conjunction of p and q, denoted by p ∧ q, which is read as
“p and q.” The conjunction p ∧ q is true when both p and q are true and is false otherwise.
Example 1:
Find the conjunction of the propositions p and q where
p : “Rebecca’s PC has more than 16 GB free hard disk space”
q : “The processor in Rebecca’s PC runs faster than 1 GHz.”
Solution: The conjunction of these propositions, p ∧ q, is the proposition “Rebecca’s PC has
more than 16 GB free hard disk space, and the processor in Rebecca’s PC runs faster than
1 GHz.”
This conjunction can be expressed more simply as “Rebecca’s PC has more than
16 GB free hard disk space, and its processor runs faster than 1 GHz.”
For this conjunction to be true, both conditions given must be true. It is false when one or both
of these conditions are false.
Example 2:
Find the conjunction of the propositions p and q where
p: John has taken Discrete mathematics course
q: John has taken M S Office corse
p q p∧q
0 0 0
0 1 0
1 0 0
1 1 1
disjuction(or connective)
Let p and q be propositions. The disjunction of p and q, denoted by p ∨ q, is read as “ p or q “.
The disjunction p ∨ q is false when both p and q are false and is true otherwise.
The use of the connective or in a disjunction corresponds to one of the two ways the word
or is used in English, namely, as an inclusive or. A disjunction is true when at least one of the
two propositions is true. That is, p ∨ q is true when both p and q are true or when exactly one
of p and q is true.
Example 1:
Find the disjunction of the propositions P and Q where
P: “A student who has taken calculus can take this class”
Q: “A student who has taken introductory computer science can take this class.”
𝑝⋁𝑞: 𝐴 𝑠𝑡𝑢𝑑𝑒𝑛𝑡 𝑤ℎ𝑜 ℎ𝑎𝑠 𝑡𝑎𝑘𝑒𝑛 𝑐𝑎𝑙𝑐𝑢𝑙𝑢𝑠 𝑎𝑛𝑑 𝑖𝑛𝑡𝑟𝑜𝑑𝑢𝑐𝑡𝑜𝑟𝑦 𝑐𝑜𝑚𝑝𝑢𝑡𝑒𝑟 𝑠𝑐𝑖𝑒𝑛𝑐𝑒 𝑐𝑎𝑛 𝑡𝑎𝑘𝑒 𝑡ℎ𝑖𝑠 𝑐𝑙𝑎𝑠𝑠
Example 2:
Find the disjunction of the propositions p and q where
p : “Rebecca’s PC has more than 16 GB free hard disk space”
q : “The processor in Rebecca’s PC runs faster than 1 GHz.”
𝑝⋁𝑞: 𝑅𝑒𝑏𝑒𝑐𝑐𝑎′ 𝑠 𝑃𝐶 ℎ𝑎𝑠 𝑚𝑜𝑟𝑒 𝑡ℎ𝑎𝑛 16𝐺𝐵 𝑓𝑟𝑒𝑒 ℎ𝑎𝑟𝑑 𝑑𝑖𝑠𝑘 𝑠𝑝𝑎𝑐𝑒 𝑜𝑡 𝑝𝑟𝑜𝑐𝑒𝑠𝑠𝑜𝑟 𝑜𝑛 ℎ𝑒𝑟 𝑃𝐶 𝑟𝑢𝑛𝑠
𝑓𝑎𝑠𝑡𝑒𝑟 𝑡ℎ𝑎𝑛1 𝐺𝐻𝑍
TRUTH TABLE:
p q p∨q
0 0 0
0 1 1
1 0 1
1 1 1
Exclusive OR (XOR)
Let p and q be propositions. The exclusive or of p and q, denoted by p ⊕ q (or pXOR q), is
the proposition that is true when exactly one of p and q is true and is false otherwise.
Example 1:
Find the exclusive or of the propositions P and Q where
P: A student can have a salad with dinner”
Q: A student can have soup with dinner,
p ⊕ q: A student can have either salad or soup with dinner but not both
Example 2:
Find the exclusive or of the propositions P and Q where
P: “I will use all my savings to travel to Europe
Q: I will use all my savings to buy an electric car.”
p ⊕ q: I will use all my savings either to travel to Europe or to buy an electric car but not both
TRUTH TABLE:
p q p⊕q
0 0 0
0 1 1
1 0 1
1 1 0
Conditional Statements
Let p and q be propositions. The conditional statement p → q is read as, “if p, then
q.” The conditional statement p → q is false when p is true and q is false, and true otherwise.
In the conditional statement p → q, p is called the hypothesis (or antecedent or premise) and
q is called the conclusion (or consequence).
Because conditional statements play such an essential role in mathematical reasoning, a variety
of terminology is used to express p → q. the following ways are used to express this conditional
statement:
p → q. not equals to q → p
p:It is raining
q: road becomes wet
“if p, then q” “p implies q”
“if p, q” “p only if q”
“p is sufficient for q” “a sufficient condition for q is p”
“q if p” “q whenever p”
“q when p” “q is necessary for p”
“a necessary condition for p is q” “q follows from p”
“q unless ¬𝒑” “q provided that p”
Example 1:
Find the conditional statements of the propositions P and Q where
P: I am elected as President of Zambia
Q: I will lower taxes
p → q: if I am elected as President of Zambia then I will lower the taxes
Example 2:
Find the conditional statements of the propositions P and Q where
P: you get 100% on the final exam
Q: you will get an A grade
p → q: if you get 100% on the final exam the you will get an A grade
Example 3:
“You can receive an A in the course only if your score on the final is at least 90%.” Is it a
conditional statement?
Answer : Yes ,It is. It Is in the form of Q only if P
Example 4:
Let p be the statement “Maria learns discrete mathematics” and q the statement “Maria will
find a good job.” Express the statement p → q as a statement in English.
SOLUTION: If I Maria learns discrete mathematics then she will find a good job.
TRUTH TABLE:
p q p→q
0 0 1
0 1 1
1 0 0
1 1 1
BICONDITIONALS
Let p and q be propositions. The biconditional statement p ↔ q is read as “p if and
only if q.” The biconditional statement p ↔ q is true when p and q have the same truth values,
and is false otherwise. Biconditional statements are also called bi-implications.
(p→ 𝑞 ) ∧ (𝑞 → 𝑝)
There are some other common ways to express p ↔ q:
“p is necessary and sufficient for q”
“if p then q, and if q then p”
“p iff q.” “p exactly when q.”
Example 1: Let p be the statement “You can take the flight,” and let q be the statement “You
buy a ticket.”
Then find the p ↔ q the statement
You can take the flight if and only if you buy a ticket
TRUTH TABLE:
p q p↔q
0 0 1
0 1 0
1 0 0
1 1 1
Truth Tables Of Logical Operators
Exercises
1) Let p and q be the propositions
p: I bought a lottery ticket this week.
q: I won the million-dollar jackpot.
Express each of these propositions as an English sentence.
2) Let p and q be the propositions “The election is decided” and “The votes have been
counted,” respectively. Express each of these compound propositions as an English
sentence.
9) For each of these sentences, determine whether an inclusive or, or an exclusive or, is
intended. Explain your answer.
a) Experience with C++ or Java is required.
b) Lunch includes soup or salad.
c) To enter the country, you need a passport or a voter registration card.
d) Publish or perish.
10) For each of these sentences, state what the sentence means if the logical connective or
is an inclusive or (that is, a disjunction) versus an exclusive or. Which of these meanings
of or do you think is intended?
a) To take discrete mathematics, you must have taken calculus or a course in computer
science.
b) When you buy a new car from Acme Motor Company, you get $2000 back in cash or
a 2% car loan.
c) Dinner for two includes two items from column A or three items from column B.
d) School is closed if more than two feet of snow falls or if the wind chill is below −100
◦F.
Example 1:
Construct the truth table of the compound proposition 𝑝 ∧ ¬𝑝
Solution: Since the compound proposition has 1 variable , we have 2n = 21= 2 possible
combinations of inputs. Then the truth table is written as follows,
p ¬𝑝 𝑝 ∧ ¬𝑝
0 1 0
1 0 0
Example 2:
Construct the truth table of the compound proposition (𝑝 ∨ ¬𝑞) ∧ (𝑞 ∨ ¬𝑝)
Solution: Since the compound proposition has 2 variables, we have 2n = 22= 4 possible
combinations of inputs (4 rows). Then the truth table is written as follows,
p q ¬𝑞 (𝑝 ∨ ¬𝑞) ¬𝑝 (𝑞 ∨ ¬𝑝) (𝑝 ∨ ¬𝑞) ∧ (𝑞 ∨ ¬𝑝)
0 0 1 1 1 1 1
0 1 0 0 1 1 0
1 0 1 1 0 0 0
1 1 0 1 0 1 1
Example 3:
Construct the truth table of the compound proposition (𝑝 → 𝑞) ↔ (¬𝑞 → ¬𝑝 )
Solution: Since the compound proposition has 2 variables, we have 2n = 22= 4 possible
combinations of inputs(4 rows). Then the truth table is written as follows,
p q (𝑝 → 𝑞) ¬𝑞 ¬𝑝 (¬𝑞 → ¬𝑝) (𝑝 → 𝑞) ↔ (¬𝑞 → ¬𝑝 )
0 0 1 1 1 1 1
0 1 1 0 1 1 1
1 0 0 1 0 0 1
1 1 1 0 0 1 1
Example 4:
Exercise:
4) How many rows appear in a truth table for each of these compound propositions?
5) How many rows appear in a truth table for each of these compound propositions?
Example 1: 𝑝 ∨ ¬𝑝 is a tautology.
Example 2: : (𝑝 ∨ 𝑞) → (𝑞 ∨ 𝑝) is a tautology.
Contradiction: A compound proposition that is always false, for all possible combinations of
inputs is called a contradiction.
Example 1: 𝑝 ∧ ¬𝑝 is a contradiction.
Example 2: : (𝑝 ∧ 𝑞) ∧ ¬(𝑝 ∨ 𝑞) is a contradiction.
Worked examples:
Q1) Show that whether the following compound proposition is tautology or not?
[¬𝑝 ∧ (𝑝 → 𝑞)] → ¬q
Conclusion: Since the last column contains combinations of both 0’s and 1’s . It is not
tautology
Q2: Show that whether the following compound proposition is tautology or not?
[¬𝑞 ∧ (𝑝 → 𝑞)] → ¬p
p q ¬q (𝑝 → 𝑞) [¬𝑞 ∧ (𝑝 → 𝑞)] ¬p [¬𝑞 ∧ (𝑝 → 𝑞)] → ¬p
0 0 1 1 1 1 1
0 1 0 1 0 1 1
1 0 1 0 0 0 1
1 1 0 1 0 0 1
Conclusion : Since all the truth values of last column are only 1’s. It is a tautology
p q r (p → q) (q → r) p → r) (p → q) ∧ (q → r) (p → q) ∧ (q → r) →
(p → r)
0 0 0 1 1 1 1 1
0 0 1 1 1 1 1 1
0 1 0 1 0 1 0 1
0 1 1 1 1 1 1 1
1 0 0 0 1 0 0 1
1 0 1 0 1 1 0 1
1 1 0 1 0 0 0 1
1 1 1 1 1 1 1 1
Conclusion : Since all the truth values of last column are only 1’s. It is a tautology
Q4: show that (𝑝 ∨ 𝑞) ∧ (¬p ∨ r) → (q ∨ r) is a tautology?
Logical Equivalences
The compound propositions p and q are called logically equivalent if all the truth values of p
is equals to all the truth values of q The notation p ≡ q denotes that p and q are logically
equivalent. The symbol ⇔ is sometimes used instead of ≡ to denote logical equivalence.
One way to determine whether two compound propositions are equivalent is to use a truth table.
In particular, the compound propositions p and q are equivalent if and only if the columns
giving their truth values agree. Example 1 illustrates this method to establish an extremely
important and useful logical equivalence, namely, that of ¬(𝑝 ∨ 𝑞) ≡ ¬𝑝 ∧ ¬𝑞
Example 1: Show that ¬(𝑝 ∨ 𝑞) 𝑎𝑛𝑑¬𝑝 ∧ ¬𝑞 are logically equivalent.
Solution:
The truth tables for these compound propositions are displayed below. Because the truth values
of the compound propositions ¬(𝑝 ∨ 𝑞) 𝑎𝑛𝑑¬𝑝 ∧ ¬𝑞 agree for all possible combinations of
the truth values of p and q, it follows that ¬(𝑝 ∨ 𝑞) 𝑎𝑛𝑑¬𝑝 ∧ ¬𝑞 compound propositions are
logically equivalent.
p q (𝑝 ∨ 𝑞) ¬(𝑝 ∨ 𝑞) ¬𝑝 ¬𝑞 ¬𝑝 ∧ ¬𝑞
0 0 0 1 1 1 1
0 1 1 0 1 0 0
1 0 1 0 0 1 0
1 1 1 0 0 0 0
Since the truth values of 4th column and 7th column are same, we can say that
¬(𝑝 ∨ 𝑞) 𝑎𝑛𝑑¬𝑝 ∧ ¬𝑞 are logically equivalent. That is
¬(𝑝 ∨ 𝑞) ≡ ¬𝑝 ∧ ¬𝑞
Example 2:
Show that (𝑝 → 𝑞) ∧ (p → r) and [𝑝 → ( 𝑞 ∧ r)] are logically equivalent
p q r (p → q) (p → r) (p → q) ∧ ( 𝑞 ∧ r) [𝑝 → ( 𝑞 ∧ r)]
(p → r)
0 0 0 1 1 1 0 1
0 0 1 1 1 1 0 1
0 1 0 1 1 1 0 1
0 1 1 1 1 1 1 1
1 0 0 0 0 0 0 0
1 0 1 0 1 0 0 0
1 1 0 1 0 0 0 0
1 1 1 1 1 1 1 1
Since all the truth values of 6th and 8th Columns are same ,
(𝑝 → 𝑞) ∧ (p → r) ≡ [𝑝 → ( 𝑞 ∧ r)]
Exercises:
1) Show that each of these conditional statements is a tautology by using truth tables.
2) Show that each of these conditional statements is a tautology by using truth tables.
The dual of a compound proposition that contains only the logical operators ∨, ∧, and ¬ is the
compound proposition obtained by replacing each ∨ by ∧, each ∧ by ∨, each T by F, and each
F by T. The dual of s is denoted by s∗.
Example1 : Write the duals of
(a) (𝑝 ∨ ¬𝑞 ) ∧ 𝑟 (b) (𝑝 ∨ ¬𝑟) ∧ (𝑞 ∧ 𝑝) (c) )(𝑝 ∨ 𝑞) ∧ (¬𝑝 ∧ ¬𝑞)
Solution: The duals are
(a) (𝑝 ∧ ¬𝑞 ) ∨ 𝑟 ∨ r (b) (𝑝 ∧ ¬𝑟) ∨ (𝑞 ∨ 𝑝) (c) )(𝑝 ∧ 𝑞) ∨ (¬𝑝 ∨ ¬𝑞)
1) Find the dual of each of these compound propositions.
a) 𝑝 ∨ ¬𝑞 = 𝑝 ∧ ¬𝑞
𝒃) 𝑝 ∧ (𝑞 ∨ (𝑟 ∧ 𝑻)) = 𝑝 ∨ (𝑞 ∧ (𝑟 ∨ 𝑭))
𝒄) (𝑝 ∧ ¬𝑞) ∨ (𝑞 ∧ 𝑭) =(𝑝 ∨ ¬𝑞) ∧ (𝑞 ∨ 𝑻)
2) Find the dual of each of these compound propositions.
𝒂) 𝑝 ∧ ¬𝑞 ∧ ¬𝑟
𝒃) (𝑝 ∧ 𝑞 ∧ 𝑟) ∨ 𝑠
𝒄) (𝑝 ∨ 𝑭) ∧ (𝑞 ∨ 𝑻)
Laws of Logic
Example 1:
Using laws of logic Show 𝑡ℎ𝑎𝑡 ¬ (𝑝 → 𝑞) 𝑎𝑛𝑑 𝑝 ∧ ¬𝑞 are logically equivalent.
Example 2:
Using laws of logic Show that ¬ [p ∨ (¬ p ∧ q)] and ¬ p ∧ ¬ q are logically equivalent by
developing a series of logical equivalences.
Example 3:
Using laws of logic Show that (𝑝 ∧ 𝑞) → (𝑝 ∨ 𝑞) is a tautology.