0% found this document useful (0 votes)
6 views

Chapter 1 CSC510

Uploaded by

2023239336
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Chapter 1 CSC510

Uploaded by

2023239336
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 29

Nm/shahalam

CHAPTER 1
PROPOSITIONAL AND PREDICATE LOGIC
1. INTRODUCTION
Every day we deal with problem statements either in mathematical or sentence
form. Several rules of logic need to be used to determine whether the problem
statement is valid or invalid. Greek philosopher Aristotle was the pioneer of
logical reasoning.
This chapter aims to expose students to how to deal with problem statements,
how to produce mathematical statements and subsequently model problems
into mathematical statements.
These knowledge are important to introduce students to the basics of logical
thinking to understand mathematical reasoning which is widely used in various
fields of computer science.
These rules form the basis of computer circuit design, programming design,
verification of the program correctness, artificial intelligence, and many other
ways.

2. NOTATION AND TERMINOLOGIES

2.1 Propositional Logic

Basic building blocks of logic is called propositions. A proposition is a declarative


sentence or statement that is either true or false; it must be one or the other,
and it cannot be both.

The Truth Value of a proposition is True (denoted as T) if it is a true statement,


and False (denoted as F) if it is a false statement.

The following sentences are example of propositions:


1. Shah Alam is located in Selangor.
2. 5 + 3 = 8.
3. Rabbits are a kind of insect.

Propositions 1 and 2 are True, whereas proposition 3 is False.

1
Nm/shahalam

2.2 Proposition or Not Proposition?

Some sentences cannot be defined as proposition as they do not have neither


true nor false value.

The following sentences are not proposition:


1. How are you?
2. x + 5 = 8.
3. Answer all questions.

Sentence 1 is not proposition because it is a question where we cannot evaluate


the truth value of that sentence.
Sentence 2 is not proposition because x is a variable, so we cannot define
whether It is true or false since x is undefined.
Sentence 3 is not proposition because it is an instruction that has no truth value
in it.

3. LOGICAL CONNECTIVES

3.1 Simple or Compound Statement


Propositions constructed using two or more propositions are called compound
propositions. The propositions are combined using Logical
Connectives or Logical Operators.

Now let us see several connectives which will allow us to build up compound
propositions. The most common logical connectives are:

● Negation/ NOT (¬)


● OR (∨)
● AND (∧)
● Implication / if-then (→)
● If and only if (↔)
● Exclusive Or (⊕)

2
Nm/shahalam

Negation

Definition: Let p be a proposition. The statement "It is not the case that p." is
another proposition, called the negation of p. The negation of p is denoted by
¬ p and read as "not p."

Examples:
1. It is not the case that Shah Alam is located in Selangor
2. 5 + 3 ≠ 8.
3. 10 is not a prime number.
4. It is not the case that buses stop running at 9:00pm.

Conjunction

Definition: Let p and q be propositions. The proposition "p and q" denoted by p
∧ q, is true when both p and q are true and is false otherwise. The proposition p
∧ q is called the conjunction of p and q.

Examples:
1. Shah Alam is located in Selangor and 5 + 2 = 8
2. It is raining today and 2 is a prime number.
3. 2 is a prime number and 5 + 2 ≠ 8.
4. 13 is a perfect square and 9 is a prime.

Disjunction

Definition: Let p and q be propositions. The proposition "p or q" denoted by p


∨ q, is false when both p and q are false and is true otherwise. The proposition
p ∨ q is called the disjunction of p and q.

Examples:
1. Shah Alam is located in Selangor or 5 + 2 = 8.
2. It is raining today or 2 is a prime number.
3. 2 is a prime number or 5 + 2 ≠ 8.
4. 13 is a perfect square or 9 is a prime.

3
Nm/shahalam

Implication

Definition: Let p and q be propositions. The proposition "p implies q" denoted
by p → q is called implication. It is false when p is true and q is false and is true
otherwise.
In p → q, p is called the hypothesis and q is called the conclusion.

Implication p 🡪 q is read in a variety equivalent ways:

● p → q is read in a variety of equivalent ways:


• if p then q
• p only if q
• p is sufficient for q
• q whenever p

Examples:

1. if the moon is made of green cheese then 2 is a prime.


•T
2. if today is friday then 2 * 3 = 8.
•F

Biconditional

Definition: Let p and q be propositions. The biconditional p ↔ q (read p if and


only if q), is true when p and q have the same truth values and is false otherwise.
Examples:
Both statements are true.

• If I eat lunch, then my mood will improve. (true)


• If my mood improves, then I will eat lunch. (true)

Biconditional statements:

4
Nm/shahalam

1. I will eat lunch if and only if my mood improves.


2. My mood will improve if and only if I eat lunch.

Exclusive Or

Definition: Let p and q be propositions. The proposition "p exclusive or q"


denoted by p ⊕ q, is true when exactly one of p and q is true and is false
otherwise.
Examples:

A disjunction for which either statement may be true but not both.

For example, the use of the word or in "This morning I can go to school or I can
stay home" is exclusive. Either option may be true but not both.

5
Nm/shahalam

3.2 Truth Table

The truth value of a compound statement is determined by the truth value of


its component.
we need to consider all the possible combinations of the propositions which are
joined together by Logical Connectives to form the given compound
proposition. This compilation of all possible scenarios in a tabular format is
called a truth table.

Negation (¬) : The negation of a proposition p (written as ¬p) is false when p is


true and is true when p is false.
The truth table is as follows:

p ¬p

1 0

0 1

OR (∨) : The OR operation of two propositions p and q (written as p ∨ q) is true


if at least any of the propositional variable p or q is true.
The truth table is as follows:

p q p∨q

1 1 1

1 0 1

0 1 1

0 0 0

6
Nm/shahalam

AND (∧) : The AND operation of two propositions p and q (written as p ∧ q) is


true if both the propositional variable p and q is true.
The truth table is as follows:

p q p∧q

1 1 1

1 0 0

0 1 0

0 0 0

Implication / if-then (→) : An implication p→q is the proposition “if p, then q”.
It is false if p is true and q is false. The rest cases are true.
The truth table is as follows:

p q p→q

1 1 1

1 0 0

0 1 1

0 0 1

Biconditional/ If and only if (↔) : p↔ q is biconditional logical connective


which is true when p and q are same, i.e. both are false or both are true.
The truth table is as follows:

p q p↔q

1 1 1

1 0 0

0 1 0

0 0 1

7
Nm/shahalam

Exclusive Or : The proposition "p exclusive or q" denoted by p ⊕ q, is true


when exactly one of p and q is true and is false otherwise.
The truth table is as follows:

p q p⊕ q

1 1 0

1 0 1

0 1 1

0 0 0

Rules to
construct Truth
Table
Step 1. Number of
possibilities can be
calculated using 2^n.
Where n is number.
of variables involved
Formula: 2^n

Step 2. Follow
sequence order of
the variable at the
column.

Step 3. Arrange the


combination of
possibilities in
ascending or
descending order.

8
Nm/shahalam

EXERCISES 1

QUESTION 1
Determine whether each of these sentences is proposition.
a) 8 – 3 = 5.
b) Answer all questions.
c) This statement is not true.

QUESTION 2

State whether the following statement is simple or compound statement.

a) Today is raining but windy.

b) Aisyah likes wearing blouse bought by her sister.

QUESTION 3
Negate the following propositions:
a) It is raining today.

b) 2 is a prime number.

c) There are other life forms on other planets in the universe.

d) If I am sleepy, I will go to bed early tonight.

e) The blue bag is not mine.

QUESTION 4

Let p, q and r be the propositions


p: Today is Friday.

9
Nm/shahalam

q: It is raining.
r: It is hot.

Represent each of these propositions using p, q, r and logical connectives.

a) Today is Friday but it is raining.

b) Either today is Friday or it is raining, but it is not hot if it is raining.

c) It is not the case that today is Friday or it is raining if and only if it is hot.

QUESTION 5
Let p, q and r be the propositions
p: You have registered for the course.
q: You miss the deadline to submit application.
r: You are allowed to sit for exam.

Express each of these propositions as an English sentence.


a) (¬p → ¬ r) v (q → ¬ r)

b) (¬p v q) → ¬r

10
Nm/shahalam

4. TYPES OF PROPOSITIONS

4.1 Tautology, Contradiction or Contingency

Tautology

A Tautology is a formula which is always true for every value of its propositional
variables.
Example : Prove [(p→q)∧p]→q is a tautology.

The truth table is as follows:

p q p→q (p → q) ∧ p [( p → q ) ∧ p] → q

1 1 1 1 1

1 0 0 0 1

0 1 1 0 1

0 0 1 0 1

As we can see every value of [(p→q)∧p]→q is "True", it is a tautology.

11
Nm/shahalam

Contradiction

A Contradiction is a formula which is always false for every value of its


propositional variables.

Example : Prove (p∨q)∧[(¬p)∧(¬q)] is a contradiction.

The truth table is as follows :

p q ¬p ¬q p∨q (¬ p) ∧ ( ¬ q) (p ∨ q) ∧ [( ¬
p) ∧ (¬ q)]

1 1 0 0 1 0 0

1 0 0 1 1 0 0

0 1 1 0 1 0 0

0 0 1 1 0 1 0

As we can see every value of (p∨q)∧[(¬p)∧(¬q)] is “False”, it is a contradiction.

12
Nm/shahalam

Contingency

A Contingency is a formula which has both some true and some false values for
every value of its propositional variables.

Example : Prove (p∨q)∧(¬p) is a contingency.

The truth table is as follows :

p q ¬p p∨q (p ∨ q) ∧ (¬ p)

1 1 0 1 0

1 0 0 1 0

0 1 1 1 1

0 0 1 0 0

As we can see every value of (p∨q)∧(¬p) has both “True” and “False”, it is a
contingency.

13
Nm/shahalam

Translation

Logic helps us to define the meaning of statements: Mathematical or English


statements.

How to translate an English sentence to the logic?

• Assume a sentence:
– If you are older than 13 or you are with your parents then you can attend a
PG-13 movie.

Parse:
• If ( you are older than 13 or you are with your parents ) then ( you can
attend a PG-13 movie)
A= you are older than 13
B= you are with your parents
C=you can attend a PG-13 movie

Translation: A ∨ B → C

General rule for


translation
Look for patterns
corresponding to
logical connectives
in the sentence
and use them to
define elementary
propositions

14
Nm/shahalam

Examples:

Assume two elementary statements:


p: you drive over 65 mph
q: you get a speeding ticket

Translate each of these sentences to logic:


1. you do not drive over 65 mph. (¬p)
2. you drive over 65 mph, but you don't get a speeding ticket. (p ∧ ¬q)
3. you will get a speeding ticket if you drive over 65 mph. (p → q)
4. if you do not drive over 65 mph then you will not get a speeding ticket.(¬p
→ ¬q)
5. driving over 65 mph is sufficient for getting a speeding ticket. (p → q)
6. you get a speeding ticket, but you do not drive over 65 mph. (q ∧ ¬p)

4.2 Variants of Conditional Statement


Implication / if-then (→) is also called a conditional statement. It has two parts:

Hypothesis, p

● Conclusion, q

As mentioned earlier, it is denoted as p→q

Inverse, Converse, and Contra-positive

● • The converse of p → q is q → p.
1.The contrapositive of p → q is ¬q → ¬p
2. The converse of p → q is q → p
3. The inverse of .p → q is ¬p → ¬q

Statement If p , then q .

Converse If q , then p .

Inverse If not p , then not q


.

15
Nm/shahalam

Contrapositive If not q , then not


p

Examples:

• If it snows, the traffic moves slowly.


• p: it snows q: traffic moves slowly.

•p→q

The converse - The converse of the conditional statement is computed by


interchanging the hypothesis and the conclusion.

If the traffic moves slowly then it snows.


•q→p

The contrapositive − The contra-positive of the conditional is computed by


interchanging the hypothesis and the conclusion of the inverse statement.
If the traffic does not move slowly then it does not snow.
• ¬q → ¬p

The inverse − An inverse of the conditional statement is the negation of both


the hypothesis and the conclusion
If does not snow the traffic moves quickly.
• ¬p → ¬q

16
Nm/shahalam

Tips on how to
answer question on
converse, inverse,
contrapositive.

Step 1: Label each P, Q


CORRECTLY.

Step 2: Memorise the


formula of inverse,
converse,
contrapositive. DON’T
MIX UP.
Step 3: rewrite
statement in full
sentence using the
converse, or inverse or
contrapositive
respectively

17
Nm/shahalam

EXERCISES 2

QUESTION 1
Construct the truth table for the logical expression p V (¬ q ᴧ ¬ r )→
p. Determine whether it is a tautology, contradiction or contingent.

QUESTION 2
Show that the expression (P ∧ Q) → (P V Q) is a tautology.

QUESTION 3
Determine whether (¬q ∧ (p → q)) → ¬ p is a tautology by using rule of
inference.

QUESTION 4
State the converse, contrapositive, and inverse of the following conditional
statement:
Salina will go to university only if she receives a scholarship.

QUESTION 5

Consider this statement:

You get promoted whenever you are elected as senior staff.

Write the following statement in the form of inverse, converse and


contrapositive.

QUESTION 6
Determine the converse, inverse and contrapositive for the following
statement: If I don’t play with fire then I will not get burnt.

18
Nm/shahalam

5. PREDICATES AND QUANTIFIERS

5.1 Predicate Logic

A predicate is an expression of one or more variables defined on some specific


domain. A predicate with variables can be made a proposition by either
assigning a value to the variable or by quantifying the variable. A predicate P(x)
assigns a value true or false to each x depending on whether the property holds
or not for x.

“Ali is a UiTM student.”


Ali a UiTM student

object property
Basic building blocks of the predicate logic:
i. Constant –models a specific object
Examples: “Ali”, “Selangor”, “7”
ii. Variable – represents object of specific type (defined by the universe of
discourse)
Examples: x, y
(universe of discourse can be people, students, numbers)
iii. Predicate - over one, two or many variables or constants.
– Represents properties or relations among objects
Examples: Red(car23), student(x), married(John,Ann)

The following are some examples of predicates:

1. Let S(x) denote "x is a student"


2. Let T(y ) denote "y is a teacher"

19
Nm/shahalam

Predicate can also be used to represent a relation involving 2 different objects.

The following are some examples of relation predicates:

1. Let M(x, y) denote "x is married to y"


2. Let P(x,y) denote "x is parent to y"

5.2 Quantifiers
The variable of predicates is quantified by quantifiers.
There are two types of quantifier in predicate logic −
Universal Quantifier and Existential Quantifier.
Universal Quantifier
Universal quantifier states that the statements within its scope are true for every
value of the specific variable. It is denoted by the symbol ∀
∀xP(x) is read as for every value of x, P(x) is true.

Example 1: "Man is mortal" can be transformed into the propositional


form ∀xP(x) where P(x) is the predicate which denotes x is mortal and the
universe of discourse is all men.

Example 2:

• Let P(x) denote x > x - 1.

• What is the truth value of ∀x P(x)?

• Assume the universe of discourse of x is all real numbers.

• Answer: Since every number x is greater than itself minus 1.

Therefore, ∀x P(x) is true.

20
Nm/shahalam

Example 3:

• Let T(x) denote x > 5.

• What is the truth value of ∀x T(x)?

• Assume the universe of discourse of x is all real numbers.

• Answer: Since 3 > 5 is false. So, T(x) is not true for all values of x.

Therefore, it is false that ∀x T(x).

Existential Quantifier
Existential quantifier states that the statements within its scope are true for some
values of the specific variable. It is denoted by the symbol ∃
∃xP(x) is read as for some values of x, P(x) is true.

Example 1: "Some people are dishonest" can be transformed into the


propositional form ∃xP(x) where P(x) is the predicate which denotes x is
dishonest and the universe of discourse is some people.

Example 2:
• Let T(x) denote x > 5 and x is from Real numbers.
• What is the truth value of ∃x T(x)?
• Answer:
• Since 10 > 5 is true. Therefore, it is true that ∃x T(x).

Example 3:
• Let Q(x) denote x = x + 2 where x is real numbers
• What is the truth value of ∃x Q(x)?
• Answer: Since no real number is 2 larger than itself, the truth value of
∃x Q(x) is false.

21
Nm/shahalam

5.3 Compound statements


Compound statements are obtained via logical connectives
Examples:
i. Student(Ani) ∧ Student(Zainab)
Translation: “Both Ani and Zainab are students”

ii. Country(Sienna) ∨ River(Sienna)


Translation: “Sienna is a country or a river”

iii. CS-major(x) → Student(x)


Translation: “if x is a CS-major then x is a student”

5.4 Quantified Statement


Predicate logic lets us make statements about groups of objects.
i. Universally quantified statement
• CS-major(x) → Student(x)
– Translation: “if x is a CS-major then x is a student”
• ∀x CS-major(x) → Student(x)
– Translation: “(For all people it holds that) if a person is a CS- Major
then she is a student.”

ii. Existentially quantified statement


• CS- UiTM -graduate (x) ∧ Honor-student(x)
– Translation: “x is a CS- UiTM -graduate and x is an honor student”
• ∃ x CS- UiTM -graduate (x) ∧ Honor-student(x)
– Translation: “There is a person who is a CS- UiTM -graduate and who is
also an honor student.”

22
Nm/shahalam

Statement When true? When false?

∀x P(x) P(x) true for all x There is an x


where P(x) is false

∃x P(x) There is some x for which P(x) is false for all x


P(x) is true)

Tips: When ∀x P(x) and ∃x P(x) are true and false?

5.5 Nested Quantifiers


If we use a quantifier that appears within the scope of another quantifier, it is
called nested quantifier.
● ∀a∃b P(x,y) where P(a,b)P(a,b) denotes a+b=0a+b=0
● ∀a∀b∀cP(a,b,c) where P(a,b)P(a,b) denotes a+(b+c)=(a+b)+ca+(b+c)=(a
+b)+c

Note − ∀a∃bP(x,y) ≠ ∃a∀bP(x,y)

More than one quantifier may be necessary to capture the meaning of a


statement in the predicate logic.

Example1:
• Every real number has its corresponding negative.
Assume:
• a real number is denoted as x and its negative as y
• A predicate P(x,y) denotes: “x + y =0”
• Then we can write: ∀x ∃ y P(x,y)

Example2:
• There is a person who loves everybody.
Assume:
• Variables x and y denote people
• A predicate L(x,y) denotes: “x loves y”

23
Nm/shahalam

• Then we can write in the predicate logic: ∃ x ∀y L(x,y)

5.6 Different scope of domain


i. Universal
Sentence: All UiTM students are smart.

scenario 1: Assume: the domain of discourse of x are UiTM students


• ∀x Smart(x)

scenario 2: Assume: the universe of discourse are students (all students):


• ∀x at(x,UiTM) → Smart(x)

scenario 3: Assume: the universe of discourse are people:


• ∀x student(x) ∧ at(x,UiTM) → Smart(x)

ii. Existential
Sentence: Someone at MSU is smart.

scenario 1: Assume: the domain of discourse is all MSU students


• ∃ x Smart(x)

scenario 2: Assume: the universe of discourse are students:


• ∃ x at(x,MSU) ∧ Smart(x)

scenario 3: Assume: the universe of discourse are people:


• ∃ x student(x) ∧ at(x,MSU) ∧ Smart(x)

Assume two predicates S(x) and P(x)

Universal statements typically tie with implications


• All S(x) is P(x)
∀x ( S(x) → P(x) )
• No S(x) is P(x)
∀x( S(x) → ¬P(x) )

Existential statements typically tie with conjunction


• Some S(x) is P(x)
∃x (S(x) ∧ P(x) )

24
Nm/shahalam

• Some S(x) is not P(x)


∃x (S(x) ∧ ¬P(x) )

5.7 Order of Quantifiers: Does it matters?


The order of nested quantifiers matters if quantifiers are of different type.
• ∀x∃y L(x,y) is not the same as ∃y∀x L(x,y)

Example:
• Assume L(x,y) denotes “x loves y”
• Then: ∀x∃y L(x,y)
• Translates to: Everybody loves somebody.
• And: ∃y ∀x L(x,y)
• Translates to: There is someone who is loved by everyone.
The meaning of the two is different.

The order of nested quantifiers does not matter if quantifiers are of the same
type.
Example:
• For all x and y, if x is a parent of y then y is a child of x
• Assume:
Parent(x,y) denotes “x is a parent of y”
Child(x,y) denotes “x is a child of y”
• Two equivalent ways to represent the statement:
∀x ∀y Parent(x,y) → Child(y,x)
∀y ∀x Parent(x,y) → Child(y,x)

25
Nm/shahalam

5.8 Negation of Quantifiers


Example 1: English statement:
• Nothing is perfect.
• Translation: ¬ ∃x Perfect(x)
Another way to express the same meaning:
• Everything is imperfect.
• Translation: ∀x ¬ Perfect(x)
Conclusion: ¬ ∃x P (x) is equivalent to ∀x ¬ P(x)

Example 2: English statement:


• It is not the case that all cats are fleabags.
• Translation: ¬ ∀x Cat(x) → Fleabag(x)
Another way to express the same meaning:
• There is a cat that is not a fleabag.
• Translation: ∃x Cat(x) ∧ ¬ Fleabag(x)
• Logically equivalent to ∃x ¬ ( Cat(x) → Fleabag(x) )
Conclusion: ¬ ∀x P (x) is equivalent to ∃x ¬ P(x)

Tips on Negation Equivalent

Negation Equivalent

¬∃x P(x) ∀x ¬P(x)

¬∀x P(x) ∃x ¬P(x)

26
Nm/shahalam

Exercises:
EXERCISES 3

QUESTION 1
Suppose: Variables x,y denote people
L(x,y) denotes “x loves y”.
Translate each of following predicates:
a) Everybody loves Ramli.
b) Everybody loves somebody.
c) There is somebody whom everybody loves.
d) There is somebody who Ramli does not love.
e) There is somebody whom no one loves.
QUESTION 2

Let P(x) be the statement “ x + 1 > 2x”. If the domain consists of all integers, what
is the truth value?

a) ∀x P(x).
b) ∃x ¬P(x).
c) ∀ x ¬P(x).
d) ¬∃x P(x)

QUESTION 3
Translate each of these nested quantifications into an English statement that
expresses a mathematical fact. The domain in each case consists of all real
numbers.

a) ∃x∃y(((x > 0) ∧ (y> 0)) ∧ (x + y > 0))


b) ∀x∀y((x = 0) ∧ (y ≠ 0) → (xy = 0)

QUESTION 4
Translate each of the following statements into logical expression using
predicates, quantifiers, and logical connectives.

C(x): x is an ART student


L(X): x like the drawing class very much
27
Nm/shahalam

Universe of discourse for the variable x is all students

a) Every student like the drawing class very much.


b) No student like the drawing class.
c) Some students like the drawing class very much.
d) Every ART student likes the subject very much.
e) Some ART students like the subject very much.
f) No ART student like the drawing class.

QUESTION 5
Translate each of the following statements into logical expression using
predicates, quantifiers, and logical connectives.

C(x) : x is a CS230 student


E(X): x enjoy studying CSC510
Universe of discourse for the variable x is all students.

a) Every student enjoys studying CSC510.


b) No student enjoys studying CSC510.
c) Some students enjoy studying CSC510.
d) Every CS230 student enjoys studying CSC510.
e) Some CS230 students enjoy studying CSC510.

QUESTION 6

Express the statement “ every first year student in primary school takes
Pendidikan Jasmani“ using suitable predicate symbols for each of the following
universe of discourse:

a) All first-year students in primary school.


b) All students in primary school.
c) All students.

28
Nm/shahalam

SUMMARY
1. Proposition or not proposition?
- what are differences
-how to recognise not proposition

2. Logical Connectives
- symbol each of logical connective
- how to write negation

3. Truth table (TT)


- tips on constructing TT
- output column

4. Tautology, Contradiction or Contingency


- how to read in output column

5. Translation
- from sentence to expression
- from expression to sentence

6. Inverse, Converse, and Contrapositive


- formula of each
- tips how to read from original statement and rewrite in appropriate sentence

7. Predicate logic
- building blocks of the predicate logic
- Quantifier
- Nested quantifier
- Different scope of domain
- Negation of Quantifiers

29

You might also like