Beruflich Dokumente
Kultur Dokumente
1. INTRODUCTION TO LOGIC
Example 1:
p : I am going to town
1
BACS 1253 Mathematics for computer science 1(linear algebra)
Faculty of Information and Communications & Technology
____________________________________________________________________________________________________________
Truth Table:
p ¬p
T F
F T
Example 2:
p : ‘I am going to town’
q : ‘It is going to rain’
p ∧ q : ‘I am going to town and it is going to rain.’
Truth Table:
p q p∧q
F F F
F T F
T F F
T T T
Note: Both p and q must be true!!!!!
Example 3:
p : ‘I am going to town’
q : ‘It is going to rain’
p ∨ q : ‘I am going to town or it is going to rain.’
2
BACS 1253 Mathematics for computer science 1(linear algebra)
Faculty of Information and Communications & Technology
____________________________________________________________________________________________________________
Truth Table:
p q p∨q
F F F
F T T
T F T
T T T
Note: Only one of p, q need be true.
Example 4:
p : ‘I am going to town’
q : ‘It is going to rain’
p ⊕ q : ‘Either I am going to town or it is going to rain.’
Truth Table:
p q p⊕q
F F F
F T T
T F T
T T F
Note: Only one of p and q must be true.
Example 5:
p : ‘I am going to town’
q : ‘It is going to rain’
p → q : ‘If I am going to town then it is going to rain.’
3
BACS 1253 Mathematics for computer science 1(linear algebra)
Faculty of Information and Communications & Technology
____________________________________________________________________________________________________________
Truth Table:
p q p→q
F F T
F T T
T F F
T T T
Note: The implication is false only when p is true and q is false!
Terminology:
p = premise, hypothesis, antecedent
q = conclusion, consequence
More terminology:
q → p is the CONVERSE of p → q
¬q → ¬p is the CONTRAPOSITIVE of p → q
Example 6:
4
BACS 1253 Mathematics for computer science 1(linear algebra)
Faculty of Information and Communications & Technology
____________________________________________________________________________________________________________
Example 7:
p : ‘I am going to town’
q : ‘It is going to rain’
p ↔ q : ‘I am going to town if and only if it is going to rain.’
Truth Table:
p q p↔q
F F T
F T F
T F F
T T T
Note: Both P and Q must have the same truth value.
Example 8:
Solution
p : I go to UTeM
q : I go to the hostel
r : I will go shopping
If......p......or.....q.....then....not.....r
(p ∨ q) → ¬r
5
BACS 1253 Mathematics for computer science 1(linear algebra)
Faculty of Information and Communications & Technology
____________________________________________________________________________________________________________
2. PROPOSITIONAL EQUIVALENCES
Example 9:
Solution
p ¬p p ∨ ¬p
T F T
F T T
Note that p ∨ ¬p is always true (no matter what proposition is
substituted for p) and is therefore a tautology.
6
BACS 1253 Mathematics for computer science 1(linear algebra)
Faculty of Information and Communications & Technology
____________________________________________________________________________________________________________
Example 10:
Solution
We draw up the truth table for ¬p ∨ ¬q and also for ¬(p ∧ q).
p q ¬p ¬q ¬p ∨ ¬q p∧q ¬(p ∧ q)
T T F F F T F
T F F T T F T
F T T F T F T
F F T T T F T
7
BACS 1253 Mathematics for computer science 1(linear algebra)
Faculty of Information and Communications & Technology
____________________________________________________________________________________________________________
Example 11:
Solution
(a) P(−3), P(−2), and P(−1) are all true because the numbers
−3,−2,−1 are negative but their absolute values are positive.
Therefore, ∀x P( x) is true.
(b) The predicate x < |x| is false for every nonnegative number.
For example, P(1) is false because 1 = |1|. Having one value of
x that makes the predicate false is enough to guarantee that
∀x P( x) is false.
Example 12:
8
BACS 1253 Mathematics for computer science 1(linear algebra)
Faculty of Information and Communications & Technology
____________________________________________________________________________________________________________
Solution
(a) P(1), P(2), and P(3) are all false because in each case x = |x|.
Therefore, ∃x P( x) is false for this universe.
Notation:
x is an element of set S: x ∈ S.
x is not an element of set S: x ∉ S.
9
BACS 1253 Mathematics for computer science 1(linear algebra)
Faculty of Information and Communications & Technology
____________________________________________________________________________________________________________
For a large set, especially an infinite set, we cannot write down all
the elements and so formally we write
S = {x : P(x)}
to denote the set of objects x for which the predicate P(x) is true.
For example,
Subsets
10
BACS 1253 Mathematics for computer science 1(linear algebra)
Faculty of Information and Communications & Technology
____________________________________________________________________________________________________________
Example 13:
Example 14:
A = {a, b},
|{a, b}| = 2 and |P({a, b})| = 4.
Example 15:
A = {a,b}, B = {1, 2, 3}
AxB = {(a, 1), (a, 2), (a, 3), (b, 1), (b, 2), (b, 3)}
11
BACS 1253 Mathematics for computer science 1(linear algebra)
Faculty of Information and Communications & Technology
____________________________________________________________________________________________________________
Set Operations
Definitions:
• The union of A and B, denoted A ∪ B, is the set of all elements
which belong to A or to B or to both. {x | x∈A ∨ x∈B}
12
BACS 1253 Mathematics for computer science 1(linear algebra)
Faculty of Information and Communications & Technology
____________________________________________________________________________________________________________
Example 16:
• A ∪ B = {1, 2, 3, 4, 5, 6, 7, 8}
• A ∩ B = {4, 5}
• A = {0, 6, 7, 8, 9, 10}
• B = {0, 1, 2, 3, 9, 10}
• A - B = {1, 2, 3}
• B - A = {6, 7, 8}
5. FUNCTIONS
13
BACS 1253 Mathematics for computer science 1(linear algebra)
Faculty of Information and Communications & Technology
____________________________________________________________________________________________________________
If f (a) = b
• b is called the image of a under f
• a is called a pre-image of b
(note there may be more than one pre-image of b but there is only
one image of a).
Example 17:
• f (a) = Z
• the image of d is Z
• the domain of f is A = {a, b, c, d}
• the codomain is B = {X, Y, Z}
• the range of f is {Y, Z}
• the preimage of Y is b
• the preimages of Z are a, c and d
14
BACS 1253 Mathematics for computer science 1(linear algebra)
Faculty of Information and Communications & Technology
____________________________________________________________________________________________________________
Example 18:
15
BACS 1253 Mathematics for computer science 1(linear algebra)
Faculty of Information and Communications & Technology
____________________________________________________________________________________________________________
Example 19:
Solution
Let
f ( x) = f ( y )
3x − 7 = 3 y − 7
3x = 3 y
x= y
so f is injective.
Inverse Functions
Example 20:
16
BACS 1253 Mathematics for computer science 1(linear algebra)
Faculty of Information and Communications & Technology
____________________________________________________________________________________________________________
Composition Functions
Example 21:
Solution
f o g ( x) = f ( g ( x) ) g o f ( x) = g ( f ( x) )
2
= ( g ( x) ) and = 2 ( f ( x) ) + 1
= (2 x +1)2 = 2 x2 +1
17