Title: Word power
1Word power
- Bercita-cita tanpa usaha
- bukan cita-cita
- tapi angan-angan
2CHAPTER 1 LOGIC
- Fundamental Discrete Structure
- DCT 1073
3CONTENT
- 1.1 Propositions
- 1.2 Logical Connectives
- 1.3 Logical Equivalences
- 1.4 Predicates
- 1.5 Quantifiers
- 1.6 Valid and Invalid Arguments
- (Modus Ponens and Modus Tollens)
4OBJECTIVES
- At the end of this chapter you should be able to
- Identify whether a statement is a proposition or
not. - Solve problems involving logical connectives,
determine truth value and construct a truth
table. - Verify that the proposition (s) is a tautology,
contradiction, contingency or logically
equivalents. - Find the truth values of a predicate.
- Find the truth and falsity of universal and
existential statements. - Determine whether an argument is valid apply
modus ponens and modus tollens in solving
problems.
5Introduction
- Logic ? basis of all mathematical reasoning
automated reasoning - Rules of logic
- specify the meaning of mathematical statements
- Used to distinguish between valid and invalid
mathematical arguments - How to understand and how to construct
mathematical arguments?
Logic - a particular way of thinking, especially
one which is reasonable and based on good
judgment Logic - a formal scientific method of
examining or thinking about ideas By Cambridge
Advanced Learners Dictionary
6Applications in Computer Science
- Design of computer circuits
- The construction of computer programs
- The verification of the correctness of programs
- Design of computing machines
- System specifications
- Programming languages
- Artificial intelligence
- Computer programming
71.1 PROPORTIONS
Lesson outcome Identify whether a statement is
a proposition or not.
8Propositions
- Basic building blocks of logic
- A proposition is a declarative sentence
(statement or sentence that declare a fact)
that is either true of false, but not both.
But not both
or
9Example
- Which of the following are propositions?
(a) The earth is round.
This is a proposition
(b)
This is a proposition
(c) Do you speak English?
This is not a proposition
(d)
This is not a proposition
(e) Take two tables.
This is not a proposition
10Exercise 1.1
- Which of the following are propositions?
- The earth is flat.
- 29 is an odd number.
- What time is it?
- Read this carefully.
- 2 2 3
- x 1 2
- x y z
- Where do you come from?
- Please sit down.
11Propositional Variables
- In logic, the letters p, q, r, s, denote
propositional variables (statement variables)
that is, variables that can be replaced by
statements. - Example
- p The earth is round.
- q Today is Monday
A proposition consisting of only a single
propositional constant is called an atomic
proposition.
12Truth Value Truth Table
The truth of falsity of a proposition is called
its truth value. T - true, F -
false. T and F are also called propositional
constants
Example p The earth is round (
p T ) q Today is Monday ( q
F )
A truth table displays the relationships between
the truth values of propositions.
13Exercise 1.1
- Assign the logical constants T or F to the
following propositions. - 12 is even.
- 8 is prime.
- Kuantan is a village
- Ahmad is a name
141.2 LOGICAL CONNECTIVES
Lesson outcome Solve problems involving logical
connectives, determine truth value and construct
a truth table.
15Compound Propositions
- How to produce a new propositions from those we
already have? - Many mathematical statements are constructed by
combining one or more propositions - Logical connectives (operator) are use to combine
propositions to form new propositions. - New propositions, called compound propositions
are formed from existing propositions using
logical operators not, or and. -
- These new propositions are compound propositions
because they consist of several components.
All nonatomic propositions are called compound
propositions. All compound propositions contain
at least one logical connective (operator).
16Exercise 1.2
- Which of the following statements are atomic
propositions and which are compound propositions? - Every cat has seven lives
- Lim is tall, and so is David
- Lim and David is tall
- The car involved in the accident was green or blue
17Logical connectives - Not, Or And
And
? ? ?
? ? ?
Not
Or
- Let p The sun is shining today.
- q It is cold.
- (not p) - The sun is not shining today.
- (p or q) - The sun is shining today or it is
cold. - (p and q) - The sun is shining today and it is
cold.
Example 1
18Logical connectives - Not, Or And
- Let p Logic is fun
- q Today is Friday
- Express each of the following compound
propositions - in symbolic form.
- (a) Logic is not fun and today is Friday.
- ? (not p) and q
-
- (b) Today is not Friday, nor is logic fun.
- ? (not q) and (not p)
-
- (c) Either logic is fun or it is Friday.
- ? p or q
-
Example 2
Not
And
Or
19Exercise 1.2
- Using the statements R and H for Mark is rich
and Mark is happy, respectively, write the
following statements in symbolic form. - Mark is not rich
- Mark is rich and happy
- Mark is rich or happy
- Let p Today is Monday
- q the grass is wet
- r the dish ran away with the spoon
-
- write the following statements in terms of p, q,
r and logical connectives. - Today is Monday and the dish ran away with the
spoon - Either the grass is wet or Today is Monday
- The dish ran away with the spoon but the grass is
wet - Today is not Monday and the grass is wet
20Types of Logical Connectives
- 1.2.1 Negation
- 1.2.2 Conjunction
- 1.2.3 Disjunction
- 1.2.4 Implication
- 1.2.5 Biconditional
211.2.1 Negation
TRUTH TABLE
Symbol
or
T - true
Read as Not p _at_ opposite of p
F - false
Example
Give the negation of the following
statements. (a) p It is cold. (b) q 2 3 gt
1
(a) p It is not cold. (b) q 2 3 is not
greater than 1. That is q 2 3 1.
221.2.2 Conjunction
TRUTH TABLE
Symbol
Read as p and q
The proposition is TRUE only when p and q are
both true
Example
Find the conjunction of the propositions p and q
where (a) p Today is Monday (b) q It is
raining today.
Today is Monday and it is raining today.
23Exercise 1.2
- Form the conjunction of p and q for each of the
following - p It is snowing q I am cold
- p 2 lt 3 q - 5 gt - 8
- p It is snowing q 3 lt 5
241.2.3 Disjunction
TRUTH TABLE
Symbol
Read as p or q
The proposition is FALSE only when p and q are
both false
Example
Find the disjunction of the propositions p and q
where (a) p Today is Monday (b) q It is
raining today.
Today is Monday or it is raining today.
25Exercise 1.2
- Form the disjunction of p and q for each of the
following - p 2 is positive integer q 2 3 6
- p the computer program has a bug
- q the input is erroneous
- p I drove to work q I took the train to work
261.2.4 Implication / Conditional
TRUTH TABLE
Symbol
Read as if p then q
p is called hypothesis and q is called the
conclusion.
The proposition is TRUE only when p and q are
both true and p is false (no matter what truth
value q has)
Example If you get 100 on the examination,
then you will get an A.
271.2.4 Implication / Conditional
also can be read as
- If p, then q
- If p, q
- p is sufficient for q
- q if p
- q when p
- a necessary condition for p is q
- q unless p
- p implies q
- p only if q
- a sufficient condition for q is p
- q whenever p
- q is necessary for p
- q follows from p
28Example 1 Implication
- The meaning of this statement
- If you get 100 on the examination, then you will
get an A. - Is the same as below statements
- If you manage to get 100 on the final, then you
would expect to receive an A. - If you do not get 100 you may or may not receive
and A depending on other factors. - If you do get 100, but the professor does not
give you an A, you will feel cheated.
29Example 2 Implication
- Let p Maria learns discrete mathematics
- q Maria will find a good job
-
- Express the statement as a statement in
English. - Solution
- If Maria learns discrete mathematics, then she
will find a good job. - Maria will find a good job when she learns
discrete mathematics. - For Maria to get a good job, it is sufficient
for her to learn discrete mathematics. - Maria will find a good job unless she does not
learn discrete mathematics.
30Converse, Contrapositive, Inverse
- There are some related implications that can be
formed from p ? q which are converse,
contrapositive and inverse. - Let p ? q ,
- converse q ? p
- contrapositive q ? p
- inverse p ? q
31Example 3 Implication
- What are the converse, the contrapositive and the
inverse of the implication -
- If it is raining, then the home team wins.
- Solution
- Let p It is raining q The home team
wins. - converse q ? p
-
- If the home team wins, then it is
raining. - contrapositive q ? p
-
- If the home team does not win, then it is
not raining. - inverse p ? q
-
32Exercise 1.2
- Write the implication p ? q for each of the
following - p I am hungry. q I will eat.
- p It is hot q 3 5 8
- Give the converse, contrapositive and inverse of
the implication - If today is holiday, then class is cancel.
331.2.5 Biconditional
TRUTH TABLE
Symbol
Read as p if and only if q
The proposition is TRUE when p and q have the
same truth values.
- In other words
- p is necessary and sufficient condition for q
- If p then q, and conversely
- p iff q
34Example
-
- You can take the flight if and only if you buy a
ticket. - Let p You can take the flight
- q You buy a ticket
- This statement is TRUE if p and q are either both
true or both false. - That is,
- if you buy a ticket and can take the flight or
- if you do not buy a ticket and you cannot take
the flight. - It is FALSE when p and q have opposite truth
values - That is,
- when you do not buy a ticket, but you can take
the flight (such as when you get a free trip) and
- when you buy a ticket and cannot take the flight
(such as when the airline bumps you) .
35Exercise 1.2
- Write each of the following propositions in the
form of p if and only if q. - For you to get A in this course, it is necessary
and sufficient that you learn how to solve
discrete structure problems. - If you read the newspaper everyday, you will be
informed, and conversely. - Is the following statement TRUE?
- 3 gt 2 if and only if 0 lt 3 2
36Truth Tables for Compound Preposition
- We can use negations, conjunctions, disjunctions,
implications, and biconditionals to build up a
complicated compound propositions involving any
number of propositional variables. - The truth tables is use to determine the truth
values of each compound propositions. - Separate column is use to find the truth value of
each compound expression. - The truth values of the compound proposition for
each combination of truth values of the
propositional variables in it is found in the
final column of the table.
37Precedence of Logical Operators
- To correctly interpret the resulting expression,
precedence rules are used - We will use parentheses when the order of
conditional operator and biconditional operator
is at issue, although the conditional operator
has precedence over the biconditional operator.
38Example
- Construct the truth table of the compound
proposition - Solution
TIPS The number of possible assignments in a
truth table is given by where n is the
number of propositional variables.
39Example
- Construct the truth table of the compound
proposition - Solution
40Exercise 1.2
- Construct the truth table of the following
compound proposition -
-
-
41Exercise 1.2 EXTRA
- Let p Logic is fun
- q Today is Friday
- Express each of the following compound
propositions in symbolic form. - Logic is not fun and today is Friday.
- Today is not Friday, nor is logic fun.
- Either logic is fun or it is Friday.
- What is the truth value of the compound
proposition -
- Either the moon is made of green cheese and
Kuala Lumpur is the capital of Malaysia or it is
not true that 3 is a prime number
42Exercise 1.2 EXTRA
- Using the statements p and q for Danial is rich
and Danial is happy, respectively, write the
following statements in symbolic form - Danial is not rich.
- Danial is rich and happy.
- Danial is rich or happy.
- If Danial is rich, then he is happy.
- Danial is happy only if he is rich.
43Exercise 1.2 EXTRA
- Identify all propositions in the following
sentences, and abbreviate them with symbols such
as p, q, or r. Then convert the sentences into
propositional calculus. - If Siti is in the car, then Ana must be in the
car as well. - The shoe was red or brown.
- The news is not good.
- You will be on time only if you hurry.
- He will come if he is free.
- If she was there, then she must have heard it.
44Exercise 1.2 EXTRA
- Construct a truth table for each of these
compound propositions -
-
-
-
- Give the truth tables for
-
-
451.3 LOGICAL EQUIVALENCES
Lesson outcome Verify that the proposition (s)
is a tautology, contradiction, contingency or
logically equivalents.
46Tautology, Contradiction, Contingency
Tautology a compound proposition that is always
true.
Contradiction a compound proposition that is
always false.
Contingency - a proposition that is neither a
tautology nor a
contradiction
Example
Tautology
Contradiction
47Example
Determine whether
is a tautology.
Solution
This is a tautology.
48Logical Equivalences
Logical equivalent - Compound propositions
that have the same truth values.
The compound propositions p and q are called
logically equivalent if p ? q is a tautology.
The notation p q denotes that p and q are
logically equivalent
Truth table is use to determine whether two
compound propositions are equivalent.
49Example 1 Logical Equivalent
Show that and
are logically equivalent.
Solution
From 4th and 7th columns, it follows that these
propositions are logically equivalent.
50Example 2 Logical Equivalent
Show that
Solution
From 5th and 8th columns, it follows that these
propositions are logically equivalent.
51Exercise 1.3
- Determine whether
is a contingency. - Determine whether
is a contradiction. - Show that the propositions and
are logically equivalent. - Show that is logically
equivalent to . - Show that and
are logically equivalent. - Show that
521.4 PREDICATES
Lesson outcome Find the truth values of a
predicate.
53Introduction
- Propositional logic cannot adequately express the
meaning of statements in mathematics and in
natural language. - For example, suppose that we know that
- Every computer connected to the university
network is functioning properly. - No rules of propositional logic allow us to
conclude the truth of the statement - MATH3 is functioning properly.
- where MATH3 is one of the computers connected to
the university network.
54Introduction
- Likewise, we cannot use the rules of
propositional logic to conclude from the
statement -
- CS2 is under attack by an intruder.
-
- where CS2 is a computer on the university
network, to conclude the truth of -
- There is a computer on the university network
that is under attack by an intruder.
55Introduction
- In this section, we will
- introduce a more powerful type of logic called
predicate logic. - see how predicate logic can be used to express
the meaning of a wide range of statements in
mathematics and computer science, in ways that
permit us to reason and explore relationships
between objects. - To understand predicate logic,
- First We need to introduce the concept of a
predicate. - Afterward We will introduce the notion of
quantifiers, which enable us reason with
statements that assert that a certain property
holds for all objects of a certain type and with
statements that assert the existence of an object
with a particular property. -
56A Predicate
predicate refers to the part of a sentence that
gives information about the subject
Subject
Predicate
IN GRAMMAR
Jeffri is a student at UMP
IN LOGIC
variable
Predicate
x is a student at UMP
predicate can be obtained by removing some of all
of the nouns from a statement
57A Predicate
- Predicate - a sentence that contains a finite
number of variables and becomes a statement when
specific values are substituted for the
variables. - Domain - the set of all values that may be
substituted in place of the variable.
58Propositional Function
- We can denote a statement by P (x)
- The statement P (x) is said to be the value of
the propositional function P at x. - Once a value has been assigned to the variable x,
the statement P (x) becomes a proposition and has
a truth values. - Example
- Let P (x) denotes the statement x is greater
than 3 - Thus P denotes the predicate is greater than 3
and x is the variable
59Finding the Truth Values a Predicate
- Example 1
- Let P (x) denote the statement x gt 3 with the
domain is the set R of all real numbers. - What are the truth values of P (4) and P (2) ?
Solution
P (4) True P (2) False
60Finding the Truth Values a Predicate
Example 2 Let Q (x, y) denote the statement
x y 3. What are the truth values of the
propositions Q (1, 2) and Q (3, 0) ?
Solution
Q (1, 2) 1 2 3 ? False Q (3, 0) 3 0 3
? True
61Finding the Truth Values a Predicate
Example 3 Let R (x, y, z) denote the
statement x y z. What are the truth
values of the propositions R (1, 2, 3) and R (0,
0, 1)?
Solution
R(1, 2, 3) 1 2 3 ? True R(0, 0, 1) 0 0
1 ? False
62Finding the Truth Values a Predicate
- Consider the statement
-
- if x gt 0 then x x 1.
- When this statement is encountered in a program,
the value of the variable x at that point in the
execution of the program is inserted into P (x),
which is x gt 0. - If P (x) is true for this value of x, the
assignment statement x x 1 is executed, so
the value of x is increased by 1. - If P (x) is false for this value of x, the
assignment statement is not executed, so the
value of is not changed.
63Preconditions Postconditions
- Predicates are also used in the verification that
computer program always produce the desired
output when given valid input. - The statements that describe valid input are
known as precondition. - The conditions that the output should satisfy
when the program has run are known as
postconditions.
64Preconditions Postconditions
- Example
- Consider the following program, designed to
interchange the values of two variables and. - temp x
- x y
- y temp
- Find predicates that we can use as the
precondition and the postcondition to verify the
correctness of this program. - Then explain how to use them to verify that for
all valid input the program does what is intended.
65Preconditions Postconditions
66The Truth Set of P (x)
Definition If P (x) is a predicate and x has
domain D, the truth set of P (x) is the set of
all elements of D that make P (x) true when they
are substituted for x. The truth set of P (x)
is denoted by
such that
The set of all x
Read the set of all x in D such that P(x)
67The Truth Set of P (x)
Example Let Q (n) be the predicate n is
factor of 8. Find the truth set of Q (n)
if (a) the domain of n is the set Z of all
positive integers (b) the domain of n is the set
Z of all integers.
Solution
(a) The truth set is 1, 2, 4, 8because these
are exactly the positive integers that
divides 8 evenly. (b) The truth set is 1, 2, 4,
8, -1, -2, -4, -8 because the negative integers
-1, -2, -4, and -8 also divide into 8 without
leaving a remainder.
68Exercise 1.4
- Let P (x) denote the statement x 4.
- What are these truth values?
- P(0)
- P(4)
- P(6)
- Let be the statement the word contains the
letter. - What are these truth values?
- P(orange)
- P(lemon)
- P(true)
- P(false)
69Exercise 1.4
- What is the value of the variable x after the
statement - If 2 2 4 then x x 1
- if x 0 before this statement is encountered?
- (The symbol x x 1 stands for assignment.
The statement x x 1 means the
assignment of the value of x 1 to x ) - State the value of x after the statement if P (x)
then x 1 is executed, where P (x) is the
statement x gt 1 , if the value of x when this
statement is reached is - x 0
- x 1
- x 2
-
701.5 QUANTIFIERS
Lesson outcome Find the truth and falsity of
universal and existential statements.
71Types of Quantification
- Quantification - Another way to create a
proposition from - a propositional
function.
Quantification
Universal
Existential
A predicate is TRUE for every element under
consideration
There is one or more element under consideration
for which the predicate is TRUE
72Quantifiers
- words that refer to quantities
- such as some, many, none, few, or all
- tell for how many elements a given predicate is
true. - 2 types universal and existential
The area of logic that deals with predicates and
quantifiers is called the predicate calculus
73Universal Quantifier
- Symbol
- means for all
- or for every, for arbitrary, for any, for
each, given any
74Universal Quantification of Q (x)
- The universal quantification of Q (x) is the
statement - Q (x) for all values of x in the domain (D)
-
or - True iff every x in D is true
- False iff Q (x) is false for at least one x in D
- Counterexample - A value x for which Q (x) is
false
75Example 1 Universal Quantifier
Let D 1, 2, 3, 4, 5, and consider the
statement. Show that this statement is true.
76Example 2 Universal Quantifier
Consider the statement Find a
counterexample to show that this statement is
false.
77Existential Quantifier
- Symbol
- Means there exists
- Or there is a, we can find a, there is at
least one, for some, and for at least one.
78Existential Quantification of Q (x)
- The existential quantification of Q (x) is the
proposition - There exists an element x in the domain (D)
such that Q (x) -
or
- True iff Q(x) is true for at least one x in D
- False iff Q(x) is false for all x in D
79Example 1 Existential Quantifier
Consider the statement Show that this
statement is true.
80Example 2 Existential Quantifier
Let E 5, 6, 7, 8, 9, 10 and consider the
statement Show that this statement is false.
81Combining Quantifiers
For every x , there is a y, so that x y 0
In symbols
This is a true statement. Why?
This sentence makes a claim about an arbitrary
integer x. It says that no matter what x is,
something is true, namely, we can find an integer
y so that x y 0.
82Example Combining Quantifiers
Please label each of the following sentences
about integers as either true of false.
True ?? False ??
83Exercise 1.5
- Determine the truth value of each of the
following statements (where R is the universal
set) - c.
- d.
- Find a counterexample for each statement where
3,5,7,9 is the universal set - c. is prime
- is odd d.
- Let the universe of domain be the set of real
numbers. Determine the truth value for the
statement. - b.
841.6 VALID AND INVALID ARGUMENTS
Lesson outcome Determine whether an argument is
valid apply modus ponens and modus tollens in
solving problems.
85Valid and Invalid Argument
- How to determine whether an argument is valid?
- Does the conclusion follows necessarily from the
preceding statements? - The determination depends only on the form of an
argument, not on its content.
86Valid and Invalid Argument
- An argument is a sequence of propositions written
Premises (Hypothesis)
conclusion
An argument is valid if all the premises are
true, then the conclusion must be true
87Example of an Argument
If Sarah is a doctor, then Sarah is
married. Sarah is a doctor. Sarah
is married.
therefore
If p then q p q
Has the abstract form
88Testing an Argument Form for Validity
- Identify the premises and conclusion of the
argument form. - Construct a truth table showing the truth values
of all the premises and the conclusion. - If the truth table contains a row in which all
the premises are true and the conclusion is
false, then it is possible for an argument of the
given form to have true premises and a false
conclusion, and so the argument form is invalid.
Otherwise, in every case where all premises are
true, the conclusion is also true, and so the
argument form is valid.
89Valid and Invalid Argument
- Example 1
- Show that the following argument form is invalid.
Construct a truth table
90Valid and Invalid Argument
Solution
premises
conclusion
Hence, this form of argument is invalid.
91TIPS
- If you are in a hurry to check the validity of
an argument, you need not fill in truth values
for the conclusion except in the rows where all
premises are true. - We call these the critical rows. The truth
values in the other rows are irrelevant to the
validity or invalidity of the argument.
92Valid and Invalid Argument
- Example 2
- Show that the following argument form is invalid.
Construct a truth table
93Valid and Invalid Argument
Solution
premises
conclusion
Critical rows
In each situation where the premises are both
true, the conclusion is also true, so the
argument form is valid.
94Syllogism
- syllogism - an argument form consisting of two
premises and a conclusion - The first and second premises are called the
major and minor premises, respectively
Modus Ponens
Modus Tollens
95Modus Ponens
method of affirming (the conclusion is an
affirmation)
General form
Example
If p then q p q
If 2 3, then I bite my finger 2 3 I
bite my finger
We construct a truth table for the premises and
conclusion.
Hence, the argument form is valid.
96Modus Tollens
method of denying (the conclusion is a denial
)
General form
Example
If p then q q p
If 2 3, then I bite my finger I dont bite my
finger 2 ? 3
We construct a truth table for the premises and
conclusion.
Hence, the argument form is valid.
97Modus Ponens or Modus Tollens
Example Use modus ponens or modus tollens to
fill in the blanks of the following arguments so
that they become valid inferences. (a) If
there are more pigeons than there are
pigeonholes, then two pigeons roost in the same
hole. There are more pigeons than there are
pigeonholes.
Two pigeons roost in the same hole. (by modus
ponens)
98Modus Ponens or Modus Tollens
Example Use modus ponens or modus tollens to
fill in the blanks of the following arguments so
that they become valid inferences. (b) If
870,232 is divisible by 6, then it is divisible
by 3. 870,232 is not divisible by 3.
870,232 is not divisible by 6. (by modus tollens)
99Exercise 1.6
-
- Formulate the following arguments symbolically
and determine whether each is valid. Let -
- p I study hard, q I get As, r I get
rich. - If I study hard, then I get As.
- I study hard.
- I get As
- If I study hard or I get rich, then I get As.
- I get As.
- If I dont study hard, then I get rich.
100Thank You
Alangkah sempitnya hidup kalau bukan kerana
luasnya cita-cita