Logic-Session 1-3 New
Logic-Session 1-3 New
Logic-Session 1-3 New
Logic
Session 1-3
Acknowledgement
Chapter 1&12
2
Learning Objectives
LO1:
LO1:
Evaluate the logic of compound,
Evaluate the logic of compound,
quantified statements and method
quantified statements and method
of proof related to discrete
of proof related to discrete
problems
problems
Sub Topics
• Propositional Logic
1
• Propositional Equivalences
2
• Rules of Inference
3
4
Propositional Logic
Propositions
Example :
1. Washington, D.C., is the capital of the
United States of America. (T)
2. Toronto is the capital of Canada. (F)
3. 1 + 1 = 2. (T)
4. 2 + 2 = 3. (F)
Propositions
Negation
Conjunction
Definition 2:
Let p and q be propositions. The conjunction of p
and q, denoted by p ∧ q, is the proposition “p and
q.” The conjunction p ∧ q is true when both p and
q are true and is false otherwise.
Disjunction
Definition 3:
Let p and q be propositions. The disjunction of p
and q, denoted by p ∨ q, is the proposition “p or
q.” The disjunction p ∨ q is false when both p and
q are false and is true otherwise.
Exclusive Or
Definition 4:
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 : Let
p : “A student can have a salad with dinner” and
q : “A student can have soup with dinner,”
What is p ⊕ q, the exclusive or of p and q?
Solution :
“A student can have soup or a salad with dinner,” (but not both)
Conditional Statements
Conditional Statements
Definition 5:
Let p and q be propositions. The conditional statement p → q is the
proposition “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).
Example : Let
p : “Maria learns discrete mathematics” and
q : “Maria will find a good job.”
Then
p → q : “If Maria learns discrete mathematics, then she will find a good
job.”
Example :
Find the contrapositive, the converse, and the inverse of the conditional
statement
“The home team wins whenever it is raining.”
Solution :
p → q : “If it is raining, then the home team wins.”
1. Contrapositive : “If the home team does not win, then it is not raining.”
2. Converse : “If the home team wins, then it is raining.”
3. Inverse : “If it is not raining, then the home team does not win.”
Biconditional Statements
Definition 6 :
Let p and q be propositions. The biconditional statement p ↔ q is the
proposition “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.
Definition 6 :
Let p and q be propositions. The biconditional statement p ↔ q is the
proposition “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.
Example : Let
p : “You can take the flight,” and
q : “You buy a ticket.”
Then
p ↔ q: “You can take the flight if and only if you buy a ticket.”
Example :
p ∨ q ∧ r means p ∨ (q ∧ r)
p ∧ q ∨ r means (p ∧ q) ∨ r
p → q ∨ r means p → (q ∨ r)
p ∨ q → r means (p ∨ q) → r
Logic and Bit Operations
Definition 7 :
A bit string is a sequence of zero or more bits. The length of this string is the
number of bits in the string.
The bitwise OR, bitwise AND, and bitwise XOR of two strings of the
same length to be the strings that have as their bits the OR, AND, and
XOR of the corresponding bits in the two strings, respectively.
The symbols ∨, ∧, and ⊕ to represent the bitwise OR, bitwise AND, and
bitwise XOR operations
Logic and Bit Operations
Example :
Find the bitwise OR, bitwise AND, and bitwise XOR of the bit strings
01 1011 0110 and 11 0001 1101.
Solution:
01 1011 0110
11 0001 1101
11 1011 1111 bitwise OR
01 0001 0100 bitwise AND
10 1010 1011 bitwise XOR
Propositional Equivalences
Compound proposition
Definisi 1.
A compound proposition that is always true, no matter what the truth
values of the propositional variables that occur in it, is called a tautology.
A compound proposition that is always false is called a contradiction. A
compound proposition that is neither a tautology nor a contradiction is
called a contingency.
Example Tautology Contradiction
:
Logical Equivalences
Definisi 2.
The compound propositions p and q are called logically equivalent if p ↔ q
is a tautology. The notation p ≡ q (p ⇔ q) denotes that p and q are logically
equivalent.
Example : (p ∨ q) and p ∧ q are logically equivalent.
Logical Equivalences
Logical Equivalences Identities
Constructing New Logical
Equivalences
Solution :
(p ∨ (p ∧ q) )≡ p ∧ (p ∧ q) by the second De Morgan law
≡ p ∧ [(p) ∨ q] by the first De Morgan law
≡ p ∧ (p ∨ q) by the double negation law
≡ (p ∧ p) ∨ (p ∧ q) by the second distributive law
≡ F ∨ (p ∧ q) because p ∧ p ≡ F
≡ (p ∧ q) ∨ F by the commutative law for disjunction
≡p∧q by the identity law for F
Consequently (p ∨ (p ∧ q)) and p ∧ q are logically equivalent.
Rules of Inference
Rules of Inference
Definition :
An argument in propositional logic is a sequence of propositions. All but
the final proposition in the argument are called premises and the final
proposition is called the conclusion. An argument is valid if the truth of all
its premises implies that the conclusion is true. An argument form in
propositional logic is a sequence of compound propositions involving
propositional variables. An argument form is valid if no matter which
particular propositions are substituted for the propositional variables in
its premises, the conclusion is true if the premises are all true.
Remark: From the definition of a valid argument form we see that the
argument form with premises p1, p2,…, pn and conclusion q is valid
exactly when (p1 ∧ p2 ∧⋯∧ pn) → q is a tautology.
Rules of Inference
Rules of Inference
Using Rules of Inference to
Build Arguments
Example :
Show that the premises :
“It is not sunny this afternoon and it is colder than yesterday,”
“We will go swimming only if it is sunny,”
“If we do not go swimming, then we will take a canoe trip,” and
“If we take a canoe trip, then we will be home by sunset”
lead to the conclusion :
“We will be home by sunset.”
Solution:
Let p : “It is sunny this afternoon,”
q : “It is colder than yesterday,”
r : “We will go swimming,”
s : “We will take a canoe trip,” and
t : “We will be home by sunset.”
∴ The conclusion is simply t.
Using Rules of Inference
to Build Arguments
Construct an argument :
Step Reason
1. p ∧ q Premise
2. p Simplification using (1)
3. r → p Premise
4. r Modus tollens using (2) and (3)
5. r → s Premise
6. s Modus ponens using (4) and (5)
7. s → t Premise
8. t Modus ponens using (6) and (7)
• Many of computer programs make use of a rule of inference known as
resolution. This rule of inference is based on the tautology,
((p ∨ q) ∧ (p ∨ r)) → (q ∨ r).
The final disjunction in the resolution rule, q ∨ r, is called the resolvent.
When we let q = r in this tautology, we obtain (p ∨ q) ∧ (p ∨ q) → q.
Furthermore, when we let r = F, we obtain (p ∨ q) ∧ (p) → q (because q ∨
F ≡ q), which is the tautology on which the rule of disjunctive syllogism is
based.
Example :
Use resolution to show that the hypotheses :
“Jasmine is skiing or it is not snowing” and
“It is snowing or Bart is playing hockey”
imply that
“Jasmine is skiing or Bart is playing hockey.”
Resolution
•
Solution :
Let p : “It is snowing,”
q : “Jasmine is skiing,” and
r : “Bart is playing hockey.”
We can represent the hypotheses
“Jasmine is skiing or it is not snowing” (p ∨ q )
“It is snowing or Bart is playing hockey” (p ∨ r )
Using resolution, the proposition :
q ∨ r, (“Jasmine is skiing or Bart is playing hockey,”)
follows.
Fallacies
•2. Fallacy of denying the hypothesis
The proposition ((p → q) ∧ p) → q is not a tautology, because it is false
when p is false and q is true. Many incorrect arguments use this incorrectly
as a rule of inference.
Example :
Is it correct to assume that you did not learn discrete mathematics if you
did not do every problem in the book, assuming that if you do every
problem in this book, then you will learn discrete mathematics?
Solution : p→q
Let p : “You did every problem in this book.” p
q?
q : “You learned discrete mathematics.”
It is possible that you learned discrete mathematics even if you did not do
every problem in this book.
This is incorrect reasoning called the Fallacy of denying the hypothesis
Applications of Propositional Logic
Applications of Propositional
Logic
“You can access the Internet from campus only if you are a
computer science major or you are not a freshman.”
Solution :
let
a : “You can access the Internet from campus”
c : “You are a computer science major”
f : “You are a freshman”
this sentence can be represented as
a → (c ∨ f )
Applications of Propositional Logic
•2. System Specifications
Example:
Express the specification
“The automated reply cannot be sent when the file system is full”
using logical connectives.
Solution :
let p : “The automated reply can be sent” and
q : “The file system is full.”
p : “It is not the case that the automated reply canbe sent,”
3. Boolean Searches
Example:
Web Page Searching : using Boolean searching to find Web pages about
universities in New Mexico.
we can look for pages matching at search engines :
- NEW AND MEXICO AND UNIVERSITIES
- “NEW MEXICO” AND UNIVERSITIES.
Applications of Propositional
Logic
4. Logic Puzzles
Example :
As a reward for saving his daughter from pirates, the
King has given you the opportunity to win a treasure
hidden inside one of three trunks. The two trunks that
do not hold the treasure are empty. To win, you must
select the correct trunk :
- Trunks 1 and 2 are each inscribed with the message
“This trunk is empty,” and
- Trunk 3 is inscribed with the message “The treasure
is in Trunk 2.”
The Queen, who never lies, tells you that only one of
these inscriptions is true, while the other two are
wrong. Which trunk should you select to win?
Logic Puzzles
Solution :
Let pi be the proposition that the treasure is in Trunk i, for i = 1, 2, 3. To
translate into propositional logic the Queen’s statement that exactly one
of the inscriptions is true, we observe that the inscriptions on Trunk 1,
Trunk 2, and Trunk 3, are ¬ p1, ¬ p2, and p2, respectively. So, her
statement can be translated to
5. Logic Circuits
A logic circuit (or digital circuit) receives input signals p1, p2,…, pn,
each a bit [either 0 (off) or 1 (on)], and produces output signals s1, s2,
…, sn, each a bit.
Complicated digital circuits can be constructed from three basic
circuits, called gates, that is NOT gate, OR gate, and AND gate.
Logic Circuits
Example 1 : (p ∧ ¬ q) ∨ ¬ r
A combinatorial circuit.
Example 2 :
(p∨ ¬ r) ∧ ( ¬ p ∨ (q∨ ¬ r))
Boolean Algebra
Boolean expressions
•Example
The values of the Boolean function represented by F(x, y, z) = xy +
Identities of Boolean Algebra
Identities of Boolean Algebra
Example 1 :
Show that the distributive law x(y + z) = xy + xz is valid.
Solution :
The identity holds because the last two columns of the table agree.
Identities of Boolean Algebra
Example 2 :
Prove the absorption law x(x + y) = x using the other identities of Boolean
algebra
Solution:
Solution :
F(x, y,z) = xz
G(x,
y, z) = xy + y
Representing Boolean Functions
Solution :
F(x, y, z) = (x + y)
=x +y Distributive law
= x1 + 1y Identity law
= x(y + ) + (x + )y Unit property
= xy + x + xy + y Distributive law
= xy + x + y Idempotent law
Representing Boolean Functions
Solution :
b. By determining the values of F for all possible values of the variables x,
y, and z
This gives :
F(x, y, z) = xy + x + y
Representing Boolean Functions
Representing Boolean Functions
Example
Construct circuits that produce the following outputs:
(a) (x + y)
(b) and
(c) (x +y + z)( ).
Solution :
Combinations of Gates
Examples of Circuits
Solution :
Let
x = 1 if the first individual
votes yes,
y = 1 if the second individual
votes yes,
z = 1 if the third individual
votes yes,
Examples of Circuits
Solution :
Adders
The circuit that has two output is called the half adder, namely, s and c,
where s is the sum bit and c is the carry bit .
Example
67
Karnaugh Map in
Two Variables
68
Karnaugh Map in
Two Variables
Example :
Find the K-maps for Boolean expression E that equal to :
Solution :
E=y E= E=
69
Karnaugh Map in three variables
70
Blocks in K-maps in three variables.
Karnaugh Map in three variables
Example :
Use K-maps to minimize these sum-of-products expansions
Karnaugh Map in three variables
Solution :
A K-map in four variables
74
Blocks in K-maps in four variables
A K-map in four variables
Example :
Use K-maps to simplify these sum-of-products expansions.
A K-map in four variables
Solution :
Reference