Graph and Trees Application
Graph and Trees Application
2.1.1 Proposition
Example of preposition:
p ¬p
T F
F T
Example of negation:
p q pɅq
T T T
T F F
F T F
F F F
*Note that in logic the word “but” sometimes is used instead of “and” in a conjunction. For
example, the statement: “The sun is shining but it is raining” is another way instead of saying
“the sun is shining and it is raining”
Example of Conjunction:
p q pvq
T T T
T F T
F T T
F F F
Example of Disjunction:
*This proposition is true either when Nadia’s phone has 5Gb free space or when Nadia’s
phone IOS system is working efficiently and when both conditions are true.
Students who have taken introductory statistic can join this class
Students who have taken fundamental mathematics can join this class
Disjunction: Students who have taken Introductory statistics or fundamental
mathematics can join this class
*This proposition is true (can join the class) either if the students have taken introductory
statistics or fundamental mathematics and when the students have taken both.
2.1.5 Exclusive Or
p q pꚚq
T T F
T F T
F T T
F F F
*Note that the proposition only true when only one of the statements is true
2.1.6 Conditional Statement (Implication)
Let p and q be propositions. The conditional statement p → q is the proposition “if p, the q.”
The conditional statement p → q is F when p is T and q is F, 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).
p q p→q
T T T
T F F
F T T
F F T
*Note that the statement p → q is true when both p and q are true and when p is false (no
matter what truth value q has)
Solution
a) T
b) T
How can this sentence be translated into logical expression?
If you can break into the computer database then you are a professional hacker or you are a
science computer graduate.
Solution
Let
p → (q v ¬ r)
2.1.6 Converse, Contrapositive and Inverse
Converse of p → q is q → p
Inverse of p → q is ¬p → ¬q
Contrapositive of p → q is the proposition ¬q → ¬p
What are the converse, inverse and contrapositive for conditional statement “If it is afternoon
then the students are sleepy”
Solution
Let p = it is afternoon
What are the converse, inverse and contrapositive, of the conditional statement “if you work
hard, you will succeed”
p q p↔q
T T T
T F F
F T F
F F T
Let p be the statement “You will be cured,” and let q be the statement “You take the
medicine.” Then p ↔ q is the statement: You will be cured if and only if you take the
medicine.
2.1.7 Precedence of Logical Operators
Operator Precedence
¬ 1
Ʌ 2
V 3
→ 4
↔ 5
2.1.8 Bit Operator
Computers represent information in bits. A bit has two possible values, namely 0 and 1. 0 bit
represents F and 1 bit represents T.
Example
Find the bitwise Ʌ, V and Ꚛ of the bit strings 101010101010 and 111010100110
Solution
101010101010
111010100110
Bitwise Ʌ 101010100010
Bitwise V 111010101110
Bitwise Ꚛ 010000001100
2.1.8 Truth Table
Example
p q pɅq qɅp
T T T T
T F F F
F T F F
F F F F
Hence, it is a commutative law
2.2.1 Predicates
The statement “x is greater than 10” has two parts. The first part, the variable x, is the subject
of the statement. The second part, the predicate,”is greater than 10” refers to a property that
the subject of the statement can have.
We can denote the statement “x is greater than 10” by P(x) where P denotes the predicate “is
greater than 10” and x is the variable.
The statement P(x) is also 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 value.
Example of predicates
Example
Let P (x) denote the statement x>4. What are the truth values of P(5) and P(3)?
Solution
Quantification express the extent to which a predicate is true over a range of elements. In
English, the word all, some, many, none, and few are used in quantifications.
We will focus on two types of quantification here: universal quantification, which tell use
that the predicate is true for every element under consideration, and existential quantification,
which tells us that there is one or more element under consideration for which the predicate is
true.
The universal quantification of P (x) is the statement “P(x) for all value of x in the domain.”
The notation ∀ xP (x) denotes the universal quantification of P(x). Here ∀ is called the
universal quantifier. We read ∀xP (x) as “for all xP(x)” or “for every xP(x).” An element for
which P (x) is false is called a counterexample of ∀ xP(x).
Besides “for all” and “for every”, universal quantification can be expressed in many other
ways, including “all of,” ”for each,” “given any,” ”for arbitrary,” “for each,” and “for any.”
A statement ∀xP(x) is false, where P(x) is a propositional function, if and only if P(x) is not
always true when x is in the domain. One way to show that P(x) is not always true when x is
in the domain is to find a counterexample to the statement ∀xP(x). Note that a single
counterexample is all we need to establish that ∀ x P(x) is false.
Example
Let P(x) be the statement x+5>x. what is the truth value of the quantification ∀xP(x) where
the domain consists of all real numbers?
Solution
Because P(x) is true for all real numbers x, the quantification ∀xP(x) ia T.
Example
Let P(x) be the statement x< 4. What is the truth value of the quantification ∀xP(x) where the
domain consists of all real numbers?
Solution
By counterexample, when x=5. P(5) is F. Thus ∀xP(x) is F.
2.2.2.2 Existential Quantification
The existential quantification of P(x) is the proposition. There exist an element x in the
domain such that P(x). We use the notation ∃xP(x) for the existential quantification of P(x).
Here ∃ is called the existential quantifier.
A domain must always be specified when a statement ∃xP(x) is used. Furthermore the
meaning of ∃xP(x) changes when the domain changes. Without specifying the domain, the
statement ∃xP(x) has no meaning.
Besides the phrase “there exist,” we can also express existential quantification in many other
ways, such as by using the words “for some,” “for at least one,” or “there is.” The existential
quantification ∃xP(x) is read as
Or
Observe that the statement ∃xP(x) is false if and only if there is no element x in the domain
for which P(x) is true. That is, ∃xP(x) is false if and only if P(x) is false for every element of
the domain.
TABLE 1 Quantifiers
Statement When True? When False?
∀xP (x) P(x) is true for every x There is an x for which P (x) is false
∃xP (x) There is an x for which P (x) is P (x) is false for every x
true
Example
Let Q(x) denote the statement x=x+2. What is the truth value of the quantification ∃xQ(x)
where the domain consist of all real numbers?
Solution
Because Q(x) is F for every real number x, ∃xQ(x) is F.Type equation here.
What is the truth value of ∀xP(x) and ∃xP(x) where P(x) is the statement x3 < 10 and the
domain consists of positive integers not exceeding 3?
Solution
∀xP(x) is F ∃xP(x) is T
Precedence of Quantifiers
The quantifiers ∀ and ∃ have higher precedence than all logical operators from propositional
calculus. For example, ∀xP(x) V Q(x) is the disjunction of ∀xP(x) and Q(x). In other words,
it means (∀xP(x))VQ(x) rather than ∀x(P(x)VQ(x)).
Example
What are the negations of the statements “There is a good dug addicter” and “All Malaysians
eat Nasi Lemak”?
Solution
Let P denote “x is good” then the statement “There is a good druf addicter” is represented by
∃xP(x) where the domain consist of all drug addicters.
The negation of this statement is ¬∃xP(x) which is equivalent to ∀xP(x). This negation can be
expressed as “Every drug addicters are bad.”
Let P(x) denote “x eats Nasi Lemak.” Then the statement “All Malaysians eat Nasi Lemak” is
represented by ∀ xP(x) where the domain consist of all Malaysians. The negation of this
statement is ¬∀xP(x) which is equivalent to ∃x¬P(x) this negation can be expressed in “there
is a Malaysians that does not eat Nasi Lemak”