Está en la página 1de 33

1

CHAPTER 1
LOGIC
2
Learning outcomes
At the end of this topic, students should be able to:
identify a proposition.
tell the name of the logical connectives
construct truth table.
combine the propositions by using the logical
connectives.
to show that a proposition is tautology /
contradiction / equivalent.
identify law of logic.
3
History
Greek philosopher.
Known as the father of logic.
his works contain the earliest known
formal study of logic, which were
incorporated in the late nineteenth
century into modern formal logic.
Born on Nov. 2, 1815 in Lincoln, England.
Died on Dec. 8, 1864 in Ballintemple,
Ireland at 49 yrs old.
In 1854, he established the rules of
symbolic logic in his book The Laws of
Thought.
George Boole
Aristotle Aristotle
4
LOGIC
.is study of reasoning, specifically concerned with whether reasoning
is correct or not.
.is widely used in the disciplines of philosophy, mathematics and
computer science.
.is part of critical thinking.
.is a tool for distinguishing between the true and the false. (Averroes)
.has been called the calculus of computer science (CS) since it
plays a fundamental role in CS similar to that played by Calculus in
the physical sciences and engineering disciplines.
5
Logic & Computer science
Some applications of logic:
- Data base theory formalize the
definitions of queries.
- Software engineering design of
electronic computers including the design
of networks or circuits.
- Programming languages to prove a
program to be correct can use logic-based
notions such as loop invariants.
6
1.1 Propositional Logic
A proposition is a statement that is either true or false (not both).
Logic is a system based on propositions, which truth value is either true
or false.
Some applications in computer science:
i. design of digital electronic circuits
ii. Expressing conditions in programs
iii. Queries to databases & search engines.
7
The Statement/Proposition Game
Earth is the only planet in the universe that
contains life.
Is this a statement? Is this a statement? yes yes
Is this a proposition? Is this a proposition? yes yes
What is the truth value What is the truth value
of the proposition? of the proposition?
true true
8
The Statement/Proposition Game
3 + 4 = 8
Is this a statement? Is this a statement? yes yes
Is this a proposition? Is this a proposition? yes yes
What is the truth value What is the truth value
of the proposition? of the proposition?
false false
9
The Statement/Proposition Game
y > 5
Is this a statement? Is this a statement? yes yes
Is this a proposition? Is this a proposition? no no
Its truth value depends on the value of y and Its truth value depends on the value of y and
x, but this value is not specified. x, but this value is not specified.
10
The Statement/Proposition Game
x + y > 10
Is this a statement? Is this a statement? yes yes
Is this a proposition? Is this a proposition? no no
What is the truth value What is the truth value
of the proposition? of the proposition?
No truth value No truth value
11
The Statement/Proposition Game
Is it raining?
Is this a statement? Is this a statement? no no
Is this a proposition? Is this a proposition? no no
** It has no truth value. ** It has no truth value.
(Its a question.) (Its a question.)
12
The Statement/Proposition Game
If the world is round, then Columbus was right.
Is this a statement? Is this a statement? yes yes
Is this a proposition? Is this a proposition? yes yes
What is the truth value What is the truth value
of the proposition? of the proposition?
probably true probably true
13
The Statement/Proposition Game
x < y if and only if y > x.
Is this a statement? Is this a statement? yes yes
Is this a proposition? Is this a proposition? yes yes
What is the truth value What is the truth value
of the proposition? of the proposition?
true true
( because its truth value does not depend on ( because its truth value does not depend on
specific values of x and y.) specific values of x and y.)
14
Test your understanding on
proposition.
Which of the following sentences are
proposition ?
i. The sun is shining.
ii. n is a prime number.
iii. Take an umbrella with you.
iv. Lets go to the restaurant.
v. Come to class!!
vi. The sum of two prime numbers are even.
15
1.2 Logical Operators (Connectives)
We formalize this by denoting propositions with letters
such as p, q, r, s, and introducing several logical
operators.
We will examine the following logical operators:
i) Negation (NOT)
ii) Conjunction (AND)
iii) Disjunction (OR)
iv) Exclusive Or (XOR)
v) Implication (if then)
vi) Biconditional (if and only if)
Truth tables can be used to show how these operators
can combine propositions to compound propositions.
16
Negation (NOT)
Unary Operator, Symbol:
P P
true false
false true
e.g.
P = I am a Malaysian.
P = I am not a Malaysian
17
Conjunction (AND)
Binary Operator, Symbol:
P Q P Q
true true true
true false false
false true false
false false false
e.g.
P = I will have salad for lunch
Q = I will have fried mee for dinner .
P Q = I will have salad for lunch
and fried mee for
dinner
18
Disjunction (OR)
Binary Operator, Symbol: v
P Q P v Q
true true true
true false true
false true true
false false false
e.g.
P= ladybugs are purple
Q = ladybugs are green
P v v Q= ladybugs are purple or
ladybugs are green.
19
Exclusive Or (XOR)
Binary Operator, Symbol:
(p or q but not both)
P Q PQ
true true false
true false true
false true true
false false false
e.g.
P = I will order Fried rice for
dinner
Q = I will order Chicken chop for
dinner
P Q = I will either order Fried
rice or Chicken chop for
dinner
20
Implication (if - then)
Binary Operator, Symbol:
P Q PQ
true true true
true False false
false True true
false False true
e.g
P= you study hard
Q= you will get good grade
P Q= If you study hard then
you will get good
grade
21
Biconditional (if and only if)
Binary Operator, Symbol:
P Q PQ
true true true
true false false
false true false
false false true
e.g
P = You can take the flight
Q = You buy a ticket
P Q = you can take the flight if
and only if you buy a ticket
P if Q and Q if P P if Q and Q if P
22
Which is the correct truth table
for p v q ?
p q
T T T
T F T
F T T
F F F
p q
T T T
T F T
F T F
F F T
p q
T T T
T F F
F T T
F F T
p q
T T F
T F T
F T T
F F T
1. 2. 3. 4.
Hint: Look at the values of p and q that make p v q false
23
1.3 Compound Proposition
One or more propositions can be combined to form a single
compound proposition.
For example:
Single propositions:
m : Fatimah is a pretty girl.
n : Fatimah is a kind girl.
Compound proposition:
m n : Fatimah is a pretty and kind girl.
24
Example
1. Show that the statement forms (p q) and
p q are not logically equivalent.
2. Construct the truth table for the statement
form (p v q) (p q).
3. Write the following sentences symbolically,
letting h = It is hot
s = It is sunny
a) It is not hot and it is sunny.
b) It is either hot or sunny.
25
Example:
4. If P = It is raining and
Q= I am indoor
Use the symbols of logical connectives to
represent the following sentences:
i. It is raining and I am indoor.
ii. If it is raining then I am indoor.
iii. It is raining if I am indoor.
iv. It is raining if and only if I am indoor.
v. It is not raining.
26
1.4 Tautologies and Contradictions
Tautology is a statement form which is true
for all values of statement variables.
Contradiction is a statement form which is false
for all values of statement variables.
Other than tautology & contradiction, the
propositions are called contigency.
27
1.5 The Laws of Logic
1.
Law of Double Negation
2. De Morgans Laws
3. Commutative Laws
4. Associative Laws
5. Idempotent Laws
6. Identity Laws
7. Absorption Laws
8. Negation Laws
9. Distributive Laws
p p
) ) q p q p q p q p v v
p q q p p q q p v v
) ( ) ( ) ( ) ( r q p r q p r q p r q p v v v v
p p p p p p v
c q q t p p v
p t p p c p v
) ) p q p p p q p p v v
) ( ) ( ) (
) ( ) ( ) (
r p q p r q p
r p q p r q p
v v v
v v
28
Simplify the following statement:
Solution
) ( ) ( q p q p v
law Identity p
law Negation c p
law e Commutativ q q p
law ve Distributi q q p
law negative Double q p q p
laws s Morgan De q p q p q p q p

v
v
v
v v
v v v
) (
) (
) ( ) (
' ) ( ) ) ( ( ) ( ) (
29
Rules of Inference:
1. Modus ponens
p q
If p, q.
e.g.
If password correct, then login permitted
__________________
Password is correct
Login is permitted
2. Modus Tollen
p q
If q, p.
e.g.
If password correct, then login permitted
______________
Login not permitted
Password incorrect
.
3. Eliminition
P v v q
p, p, q
e.g.
Either Amin is in the library or he is
in the cafe .
_____________________
Amin is not in the library.
So he must be in the cafe.
4. Transitivity
p p q
q q r p p r e.g. r e.g.
If tomorrow is not a holiday then I have to go
to work.
If I have to go to work then I have to take
the train.
_____________________
* If tomorrow is not a holiday then I have to
take the train.
If p is true then q is true.
// p is truetherefore q is true
If p is true then q is true.
// q is not truetherefore p is
not true
Either p or q is true.
// p is not true, therefore q is
true
30
Example
1. Recognizing modus Ponens and Modus Tollen
i) If Socrates is a man, then Socrates is mortal
Socrates is a man

.
ii) If the sum of the digits of 371,487 is divisible by 3, then
371,487 is divisible by 3.

371,487 is divisible by 3.
iii) .
870,232 is not divisible by 3.
870,232 is not divisible by 6.
31
2. Identify the rules of inference for each of the following:
i) If Anisahs father is Ahmad then Anisah could be my sister.
**Anisah is not my sister, therefore her father is not Ahmad.
ii) If you get an A for this subject then I will buy you ice cream.
** You scored A for this subject. Therefore I will buy you ice
cream.
iii) x 3 = 0 or x + 2 = 0.
** x + 2 0
x 3 = 0
iv) If you invest in the stock market, then you will get rich.
v) If you get rich, then you will be happy.
** If you invest in the stock market, then you will be happy.
32
Websites:
http://www.authorstream.com/Presentation/Silvia-46066-cs201-prop-logic-
Data-Structures-Discrete-Mathematics-Propositional-logi-Education-ppt-
powerpoint/ (date accessed: 3
rd
June 2009)
http://www.mathgoodies.com/lessons/toc_vol9.html (date accessed: 4th
June 2009)
http://www.mathwarehouse.com/math-statements/logic-and-truth-
values.php (date accessed: 30th July 2009)
http://www.facstaff.bucknell.edu/mastascu/eLessonsHtml/Logic/Logic1.html
(date accessed: 5th Jan 2010)
http://www.jgsee.kmutt.ac.th/exell/Logic/Logic11.htm ( 12
th
Jan 2010)
(+ exercise recommended)
33
THE END

También podría gustarte