Propositional Logic
Adila A. Krisnadhi
Faculty of Computer Science, University of Indonesia
General Introduction
Propositions
Examples
Propositional Logic
Outline
1 2
General Introduction Propositions The Basics Compound propositions Examples Translating English sentences System specications Boolean searches Logic puzzles Logic and bit operations
General Introduction
Propositions
Examples
General Introduction
Propositions
Examples
discrete: consisting of distinct or unconnected elements; opposite of continuous discrete mathematics: mathematics of discrete objects typical topics: logic, arithmetics, algorithms, number theory, counting, set theory, graph theory, etc.
General Introduction
Propositions
Examples
General Introduction
Propositions
Examples
General Introduction
Propositions
Examples
Logic: propositional, rst order Sets, functions, sequences and summations Number theory Mathematical induction
General Introduction
Propositions
Examples
Logic: propositional, rst order Sets, functions, sequences and summations Number theory Mathematical induction
Important emphasis
problem solving skills, especially on reasoning and constructing mathematical proofs.
Propositions
Examples
Propositions
Denition
proposition: a declarative sentence that has a denite truth value (either true or false, but not both)
Propositions
Examples
Propositions
Denition
proposition: a declarative sentence that has a denite truth value (either true or false, but not both) Propositions are typically represented using letters: p, q, r , s, p1 , p2 . . . , q1 , q2 , . . .
Propositions
Examples
Propositions
Denition
proposition: a declarative sentence that has a denite truth value (either true or false, but not both) Propositions are typically represented using letters: p, q, r , s, p1 , p2 . . . , q1 , q2 , . . . Possible truth values for propositions: true and false (you can use T and F ; or 1 and 0, etc.)
Propositions
Examples
Propositions
Denition
proposition: a declarative sentence that has a denite truth value (either true or false, but not both) Propositions are typically represented using letters: p, q, r , s, p1 , p2 . . . , q1 , q2 , . . . Possible truth values for propositions: true and false (you can use T and F ; or 1 and 0, etc.) An interpretation (truth assignment): mapping that maps propositional variables to their truth values.
Propositions
Examples
Propositions
Denition
proposition: a declarative sentence that has a denite truth value (either true or false, but not both) Propositions are typically represented using letters: p, q, r , s, p1 , p2 . . . , q1 , q2 , . . . Possible truth values for propositions: true and false (you can use T and F ; or 1 and 0, etc.) An interpretation (truth assignment): mapping that maps propositional variables to their truth values. Example notation: pI = T means p is interpreted as true. Similarly, pI = F means p is false.
Propositions
Examples
Propositions: examples
Example
Jakarta is the capital of Indonesia. There are 19 new students of this class. The students are on time for todays class.
Propositions
Examples
Propositions: examples
Example
Jakarta is the capital of Indonesia. There are 19 new students of this class. The students are on time for todays class.
Propositions
Examples
Logical connectives
Propositions that you have encountered up to now is called atomic proposition. If you have one or two propositions, you can form a new proposition using a logical connective or logical operator. Such a proposition is called compound proposition.
Propositions
Examples
Logical connectives
Propositions that you have encountered up to now is called atomic proposition. If you have one or two propositions, you can form a new proposition using a logical connective or logical operator. Such a proposition is called compound proposition. There are two kinds of logical operator:
unary operator (needs only one operand): negation () binary operator (needs two operands):
conjunction () disjunction () exclusive-or () implication/conditional () biconditional ().
Propositions
Examples
Negation
Denition
Let p be a proposition. Then p is also a proposition. p is called the negation of p and read as not p.
Propositions
Examples
Negation
Denition
Let p be a proposition. Then p is also a proposition. p is called the negation of p and read as not p.
Important!
p has always the opposite meaning of p. This can be described using the following truth table: p T F p F T
Propositions
Examples
Negation: examples
Example
p: Jakarta is the capital of Indonesia p: Jakarta is not the capital of Indonesia; or It is not the case that Jakarta is the capital of Indonesia q: Today is Friday q: Today is not Friday or It is not the case that today is Friday
Propositions
Examples
Negation: examples
Example
p: Jakarta is the capital of Indonesia p: Jakarta is not the capital of Indonesia; or It is not the case that Jakarta is the capital of Indonesia q: Today is Friday q: Today is not Friday or It is not the case that today is Friday
Propositions
Examples
Conjunction
Denition
Let p and q be propositions. Then p q is also a proposition. p q is called the conjunction of p and q, read as p and q.
Propositions
Examples
Conjunction
Denition
Let p and q be propositions. Then p q is also a proposition. p q is called the conjunction of p and q, read as p and q.
Important!
p q is true whenever both p and q are true. Otherwise, it is false. p T T F F q T F T F pq T F F F
Propositions
Examples
Conjunction: examples
Example
p: Today is Friday. q: It is raining today. p q: Today is Friday and it is raining today. p: This class is interesting. q: Class participation is lacking. p q: This class is interesting, but class participation is lacking.
Propositions
Examples
Disjunction
Denition
Let p and q be propositions. Then p q is also a proposition. p q is called the disjunction of p and q, read as p or q.
Propositions
Examples
Disjunction
Denition
Let p and q be propositions. Then p q is also a proposition. p q is called the disjunction of p and q, read as p or q.
Important!
p q is true whenever at least one among p and q is true, otherwise it is false. p T T F F q T F T F pq T T T F
Propositions
Examples
Disjunction: examples
Example
p: Today is Friday. q: It is raining today. p q: Today is Friday or it is raining today. p: This job requires experience in web design. q: This job requires experience in web programming. p q: This job requires experience in web design or web programming.
Propositions
Examples
Disjunction: examples
Example
p: Today is Friday. q: It is raining today. p q: Today is Friday or it is raining today. p: This job requires experience in web design. q: This job requires experience in web programming. p q: This job requires experience in web design or web programming.
Important!
The use of or in disjunction is inclusive, i.e., p q is still true whenever both p and q are true. For the exclusive or, see next slide.
Propositions
Examples
Exclusive Or
Denition
Let p and q be propositions. Then p q is also a proposition. p q is called the exclusive or of p and q, read as p xor q.
Propositions
Examples
Exclusive Or
Denition
Let p and q be propositions. Then p q is also a proposition. p q is called the exclusive or of p and q, read as p xor q.
Important!
p q is true whenever exactly one among p and q is true, otherwise it is false. p T T F F q T F T F pq F T T F
Propositions
Examples
Example
p: I pass this course. q: I fail this course. p q: (Either) I pass this course or I fail it. p: You can choose computer science. q: You can choose information systems. p q: You can choose (either) computer science or information systems, (but not both).
Propositions
Examples
Implication/Conditional
Denition
Let p and q be propositions. Then p q is also a proposition, called implication or conditional statement. p is called the hypothesis/antecedent/premise; and q is called the conclusion/consequence.
Propositions
Examples
Implication/Conditional
Denition
Let p and q be propositions. Then p q is also a proposition, called implication or conditional statement. p is called the hypothesis/antecedent/premise; and q is called the conclusion/consequence.
p q is read as:
if p, (then) q p is sufcient for q q if p q when p a necessary condition for p is q q unless p p implies q a sufcient condition for q is p p only if q q whenever p q is necessary for p q follows from p
Propositions
Examples
Implication/Conditional
Important!
p q is true whenever both p and q are true; or when p is false. Thus, p q is only false when p is true and q is false. p T T F F q T F T F pq T F T T
Propositions
Examples
Implication: examples
Example
p: Jeff gets seasick. q: Jeff is on a boat. p q: If Jeff gets seasick, then Jeff is on a boat. p: Tuesday is a holiday. q: 2 + 3 = 5. p q: Tuesday is a holiday implies 2 + 3 = 5. Try restate these examples using patterns in the previous slide. When do these implications become true?
Propositions
Examples
Propositions
Examples
Propositions
Examples
Propositions
Examples
Propositions
Examples
contrapositive
converse
inverse
p T T F F
q T F T F
p F F T T
q F T F T
pq T F T T
q p T F T T
qp T T F T
p q T T F T
Propositions
Examples
Biconditional/bi-implication/equivalence
Denition
Let p and q be propositions. Then p q is also a proposition, called bi-implication or biconditional statement.
Propositions
Examples
Biconditional/bi-implication/equivalence
Denition
Let p and q be propositions. Then p q is also a proposition, called bi-implication or biconditional statement.
p q is read as:
p if and only if q if p then q, and conversely. p is equivalent with q p iff q p is necessary and sufcient for q. p and q are equivalent
Propositions
Examples
Propositions
Examples
Biconditional: examples
Example
p: You can take the ight. q: You buy a ticket. p q: You can take the ight if and only if you buy a ticket. p: For you to win the contest. q: You have the only winning ticket. p q: For you to win the contest, it is necessary and sufcient that you have the only winning ticket.
Propositions
Examples
negation
conjunction
disjunction
exclusive or
implication
bi-implication
NOT
AND
OR
XOR
IMPLIES
IFF
p T T F F
q T F T F
p F F T T
pq T F F F
pq T T T F
pq F T T F
pq T F T T
pq T F F T
Propositions
Examples
Example
p q r means (p q) r p q means (p) q p q r means (p q) r
Propositions
Examples
Translate the following sentence into logical expression: You cannot ride the roller coaster if you are under 130 cm tall unless you are older than 16 years old.
Propositions
Examples
Translate the following sentence into logical expression: You cannot ride the roller coaster if you are under 130 cm tall unless you are older than 16 years old.
Answer
Let p: You can ride the roller coaster, q: You are under 130 cm tall, and r : You are older than 16 years old. Then the sentence can be translated into (q r ) p
Propositions
Examples
System specications are expected to be consistent, i.e., they should not contain conicting requirements that can be used to derive a contradiction.
Propositions
Examples
System specications are expected to be consistent, i.e., they should not contain conicting requirements that can be used to derive a contradiction.
Propositions
Examples
System specications are expected to be consistent, i.e., they should not contain conicting requirements that can be used to derive a contradiction.
Answer
Suppose p: The system is in multiuser state, q: The system is operating normally, r : The kernel is functioning and s: The system is in interrupt mode. Thus the specications can be written as: p q, q r , r s, s. We want to nd a truth assignment for p, q, r , s that makes all statements true. First, s must be false to make s true. Thus, to make r s true, r must be false. This means, q must also be false in order to make q r true. Finally, p should be false to make p q true. Hence, the specications are consistent because they are all true when p, q, r , s are all false. (Check this using truth table).
Propositions
Examples
Boolean searches
Logical connectives are used for searching in large collections of information. E.g., in search engine. AND: match records containing both two search terms OR: match records containing at least one of the two search terms NOT: exclude records containing the search term.
Example
We can search pages that contains the term universitas, either the term Indonesia or Bogor, but does not contain the term Semarang. search term: UNIVERSITAS AND (INDONESIA OR BOGOR) AND NOT SEMARANG in Google: universitas indonesia OR bogor -semarang
Propositions
Examples
Inhabitants of an island can be divided into the knights and the knaves. Knights always tell the truth and knaves always lie. Suppose you meet two inhabitants of this island, say A and B. A says At least one of us is a knave and B says nothing. Can you tell whos the knight and/or whos the knave?
Propositions
Examples
Inhabitants of an island can be divided into the knights and the knaves. Knights always tell the truth and knaves always lie. Suppose you meet two inhabitants of this island, say A and B. A says At least one of us is a knave and B says nothing. Can you tell whos the knight and/or whos the knave?
Answer
Let p: A is a knight and q: B is a knight, so that p means A is a knave and q means B is a knave. We can thus express As statement as p q.
Propositions
Examples
Inhabitants of an island can be divided into the knights and the knaves. Knights always tell the truth and knaves always lie. Suppose you meet two inhabitants of this island, say A and B. A says At least one of us is a knave and B says nothing. Can you tell whos the knight and/or whos the knave?
Answer
Let p: A is a knight and q: B is a knight, so that p means A is a knave and q means B is a knave. We can thus express As statement as p q. First suppose p is true, i.e., A is a knight. Then As statement, i.e., p q is true. It follows that q must be true, i.e., B is a knave.
Propositions
Examples
Inhabitants of an island can be divided into the knights and the knaves. Knights always tell the truth and knaves always lie. Suppose you meet two inhabitants of this island, say A and B. A says At least one of us is a knave and B says nothing. Can you tell whos the knight and/or whos the knave?
Answer
Let p: A is a knight and q: B is a knight, so that p means A is a knave and q means B is a knave. We can thus express As statement as p q. First suppose p is true, i.e., A is a knight. Then As statement, i.e., p q is true. It follows that q must be true, i.e., B is a knave. To ensure that this is the only answer, lets take a look what happen if we assume p as false. If p is false, then p is true, i.e., A must be a knave. This means As statement, p q must be false. But to make p q false, we require p to be false too which is impossible since we already have that p is true.
Propositions
Examples
Inhabitants of an island can be divided into the knights and the knaves. Knights always tell the truth and knaves always lie. Suppose you meet two inhabitants of this island, say A and B. A says At least one of us is a knave and B says nothing. Can you tell whos the knight and/or whos the knave?
Answer
Let p: A is a knight and q: B is a knight, so that p means A is a knave and q means B is a knave. We can thus express As statement as p q. First suppose p is true, i.e., A is a knight. Then As statement, i.e., p q is true. It follows that q must be true, i.e., B is a knave. To ensure that this is the only answer, lets take a look what happen if we assume p as false. If p is false, then p is true, i.e., A must be a knave. This means As statement, p q must be false. But to make p q false, we require p to be false too which is impossible since we already have that p is true. Hence, we conclude that A is a knight and B is a knave.
Propositions
Examples
Bit operation
Bit (Binary digit): a symbol with two possible values (0 and 1). Computers represent information using bits. Bit can be used to represent truth value: 1 represents true and 0 represents false. Bit operations: analogous to operations using logical connectives (AND, OR, XOR). Bit string: sequence of zero or more bits. Its length is the number of bits in the string. Example: 101010011 is a bit string of length nine.
Propositions
Examples
Propositions
Examples
Answer
1011 0011 1110 0001 1010 0001 b i t w i s e AND 1111 0011 b i t w i s e OR 0101 0010 b i t w i s e XOR
Adila A. Krisnadhi
Faculty of Computer Science, University of Indonesia
Interpretation
Propositional Equivalence
Logical Equivalence
Outline
Interpretation
Propositional Equivalence
Interpretation
Propositional Equivalence
Interpretation
Denition
Interpretation is a truth assignment to a (possibly compound) proposition. Interpretation can be described simply by truth assignments of all propositional variables of the proposition. Truth assignment of a compound proposition can then be computed from truth assignments of its propositional variables. Each row of the truth table of a proposition corresponds to a particular interpretation of the proposition.
Interpretation
Propositional Equivalence
q F T F T
p q T T F T
pq T F F F
(p q) (p q) T F T F
= T, q = T, q = F, q = F, q
I1 I2 I3 I4
=T =F =T =F
Interpretation
Propositional Equivalence
The compound proposition above used 2 variables. Its truth table contains 4 rows. How many rows are there in the truth table of a compound proposition that uses 3 variables? 4 variables? n variables?
Interpretation
Propositional Equivalence
Interpretation
Propositional Equivalence
Equivalence
Denition
Let p and q be two propositions. p is equivalent with q iff the proposition p q is a tautology. In other words, p and q are equivalent iff p and q have the same truth value on every row of their truth tables. Instead of using , we often use to denote equivalence.
Interpretation
Propositional Equivalence
Proving equivalence
If you are given two propositions p and q, how can you show that they are equivalent? There are two ways of proving two propositions equivalent:
using truth tables; using laws of equivalence.
Interpretation
Propositional Equivalence
Note: we dene G := p q (p q)
Interpretation
Propositional Equivalence
Since p q and p q have the same truth values on each row of the truth table, both of them are equivalent.
Interpretation
Propositional Equivalence
Identity laws Domination laws Idempotent laws Double negation laws Commutative laws
Interpretation
Propositional Equivalence
(p q) r p (q r ) (p q) r p (q r ) p (q r ) (p q) (p r ) p (q r ) (p q) (p r ) (p q) p q (p q) p q p (p q) p p (p q) p p p T p p F
Associative laws Distributive laws De Morgans laws Absorption laws Negation laws
Interpretation
Propositional Equivalence
Interpretation
Propositional Equivalence
Answer
(p (p q)) p (p q) p ((p) q) p (p q) by De Morgan laws by De Morgan laws by double negation law (p p) (p q) by distributivity F (p q) (p q) F p q because p p F by commutativity of disjunction by identity law for F
Interpretation
Propositional Equivalence
Answer
We show that the statement is equivalent to T. (p q) (p q) (p q) (p q) since p q p q (p q) (p q) by De Morgan laws (p p) (q q) by associativity and
commutativity of
TT T
Adila A. Krisnadhi
Faculty of Computer Science, University of Indonesia
Answer
To show that the statement is valid, we assume that there exists an interpretation making it false, and derive a contradiction. Assume that (p q) (p q) is false. It must be the case that (p q) is true and (p q) is false. Since (p q) is false, p q must be true. Since p q is true, we have both p and q are true. p that p and q are true implies that both p and q are false. Since p and q are false, (p q) must be false. Since we already have that (p q) is true, we obtain a contradiction. Therefore, our assumption that (p q) (p q) is false is incorrect, i.e., (p q) (p q) is always true.
More examples
Determine whether the following statements are valid, or contradictory or neither. (p q) (p q) (p q) (p q) p (p q) q ((p q) (q r )) (p r ) (p q) (p q)
Predicates
Quantiers
Predicates
Predicates
Quantiers
Predicates
The statement x > 3 or x is greater than 3 consists of two parts:
variable x whose possible values are taken from a certain set D predicate is greater than 3
The set D is called the domain or the universe of discourse. We can denote such statement as P(x) where P denotes the predicate and x is the variable. P(x) has no truth value until x is assigned to a certain element from D. A predicate is always associated to a certain arity: the number of variables associated to P An n-ary predicate is a predicate with arity n.
Predicates
Quantiers
Let P(x) be the statement x > 3. What are the truth values of P(5) and P(1)?
P(5) is obtained by setting x = 5 in the statement. Hence, P(5) is true since 5 > 3 is true. P(1) is false since 1 > 3 is false. P is a unary predicate, i.e., a predicate with arity 1.
Let A(c, n) be Computer c is connected to network n where c represents a computer and n represents a network.
A(c, n) is true whenever c is a computer that is connected to the network n, otherwise it is false. A is a binary predicate, i.e., its arity is 2.
Let R(x, y , z) be x + y = z.
R is a ternary predicate, i.e., its arity is 3. R(1, 2, 3) is true whereas R(0, 0, 1) is false.
Predicates
Quantiers
Variable Binding
Variable x in P(x) is bound if x is replaced with an element of the domain D or bound by a quantier. Otherwise it is a free variable. Two mainly used quantiers are universal quantiers and existential quantier.
Quantiers
Universal quantier
Denition
The universal quantication of P(x) (xP(x)) is the proposition P(x) is true for all (every) values of x in the domain D is the universal quantier and read for all, for every, for each, for any, for arbitrary, all of, given any, etc. An element for which P(x) is false is called counterexample of xP(x) xP(x) is true when P(x) is true for every x xP(x) is false when there is an x for which P(x) is false. In xP(x, y ), x is a bound variable whereas y is a free variable.
Quantiers
Let P(x) be x + 1 > x. What is the truth value of xP(x) with R as the domain ? Let Q(x) be x < 2. What is the truth value of xQ(x) with R as the domain? What is the truth value of xP(x), where P(x) denotes x 2 < 10 and the domain consists of positive integers not exceeding 4? Note: for a nite domain where x1 , . . . , xn are its elements, xP(x) is equivalent with P(x1 ) P(x2 ) P(xn )
Quantiers
Quantiers
Quantiers
Second alternative:
Take as the domain: D := {x | x is a student} Q(x) := x is in this class. P(x) := x attends the course of Foundations of Programming Then the statement can be written as x(Q(x) P(x))
Quantiers
Existential quantier
Denition
The existential quantication of P(x) (xP(x)) is the proposition P(x) is true for some values of x in the domain D is the existential quantier and read: for some, there exists, there is, at least one, etc. xP(x) is true when there is at least one element x of D for which P(x) is true. xP(x) is false when P(x) is false for every x, i.e., no element xof D for which P(x) is true. In xP(x, y ), x is a bound variable whereas y is a free variable.
Quantiers
Let P(x) be x > 34. What is the truth value of xP(x) with R as the domain? Let Q(x) be x = x + 1. What is the truth value of xQ(x) with R as the domain? What is the truth value of xP(x), where P(x) denotes x 2 < 10 and the domain consists of positive integers not exceeding 4? Note: for a nite domain where x1 , . . . , xn are its elements, xP(x) is equivalent with P(x1 ) P(x2 ) P(xn )
Quantiers
More examples
Everyone has a close friend
Quantiers
More examples
Everyone has a close friend Because friendship is a relation between two person, we need two variables: x and y
Quantiers
More examples
Everyone has a close friend Because friendship is a relation between two person, we need two variables: x and y Take D := {x | x is a person} as the domain of both variables x and y .
Quantiers
More examples
Everyone has a close friend Because friendship is a relation between two person, we need two variables: x and y Take D := {x | x is a person} as the domain of both variables x and y . Take a predicate A(x, y ) := y is a close friend of x
Quantiers
More examples
Everyone has a close friend Because friendship is a relation between two person, we need two variables: x and y Take D := {x | x is a person} as the domain of both variables x and y . Take a predicate A(x, y ) := y is a close friend of x The sentence becomes: x D(y DA(x, y )) or x(yA(x, y )) or xyA(x, y )
Quantiers
More examples
Everyone has a close friend Because friendship is a relation between two person, we need two variables: x and y Take D := {x | x is a person} as the domain of both variables x and y . Take a predicate A(x, y ) := y is a close friend of x The sentence becomes: x D(y DA(x, y )) or x(yA(x, y )) or xyA(x, y ) The scope for y is A(x, y ) in which x is still a free variable. The scope for x is yA(x, y ) in which x is no longer a free variable.
Quantiers
More examples
Change the following sentences into expressions in predicate logic. Jackie has exactly one close friend. Everyone has exactly one close friend. If someone is a woman and has a child, then she is a mother.
Quantiers
Summary
xP(x) :
is true iff P(x) is true for every x D; is false iff P(x) is false for some x D.
xP(x):
is true iff P(x) is true for some x D; is false iff P(x) is false for every x D.
xyP(x, y ):
is true iff P(x, y ) is true for every pair x Dx and y Dy is false iff P(x, y ) is false for some pair x Dx and y Dy
y xP(x, y ):
is true iff P(x, y ) is true for every pair y Dy and x Dx is false iff P(x, y ) is false for some pair y Dy and x Dx
Quantiers
Summary (2)
xyP(x, y ):
is true iff for every x Dx , there is one y Dy for which P(x, y ) is true; is false iff there is one x Dx such that P(x, y ) is false for every y Dy .
xyP(x, y ):
is true iff there is one x Dx such that P(x, y ) is true for every y Dy ; is false iff for every x Dx , there is one y Dy for which P(x, y ) is false.
Quantiers
Summary (3)
xyP(x, y ):
is true iff there is (at least) one pair x Dx and y Dy such that P(x, y ) is true; is false iff for every pair x Dx and y Dy , P(x, y ) is false.
y xP(x, y ):
is true iff there is (at least) one pair y Dx and x Dy such that P(x, y ) is true; is false iff for every pair y Dx and x Dy , P(x, y ) is false.
Quantiers
More examples
Here the domain of all variables are real numbers. Let Q(x, y ) be the relation x + y = y + x. What is the truth value of xyQ(x, y )? Let Q(x, y ) be the relation x + y = 0. What is the truth value of xyQ(x, y ) and y xQ(x, y )? Let Q(x, y , z) be the relation x + y = z. What is the truth value of xy zQ(x, y , z) and zxyQ(x, y , z)?
Quantiers
Some remarks
xyP(x, y ) y xP(x, y ) xyP(x, y ) y xP(x, y ) xP(x) xP(x) (De Morgans) xP(x) xP(x) (De Morgans) xyP(x, y ) is not equivalent with y xP(x, y ) If the domain for x is empty, the statement:
xP(x) is true, because we cannot nd any counterexample for P(x) (that makes P(x) false); xP(x) is false, because we cannot nd any x in the domain that makes P(x) true.
Valid arguments
Fallacies
Rules of Inference
Outline
8
Valid arguments Modus Ponens Modus tollens Syllogisms Other rules of inference Resolution Examples Fallacies Rules of inference for quantied statements Rules on universal quantiers Rules on existential quantiers Examples Universal modus ponens & modus tollens
9 10
Valid arguments
Fallacies
Argument in Logic
Denition
Argument: a sequence of propositions All but the nal proposition is called premises, whereas the nal proposition is the conclusion. An argument is valid if the truth of all its premises implies that the conclusion is true.
Fallacies
Modus ponens
p pq q
Fallacies
Modus ponens
p pq q
I f you do a l l t h e e x e r c i s e s , then you w i l l suceed i n exams . You do a l l t h e e x e r c i s e s . You w i l l succeed i n exams .
Fallacies
Modus Tollens
Modus tollens
q pq p
Fallacies
Modus Tollens
Modus tollens
q pq p
I f you do a l l t h e e x e r c i s e s , then you w i l l suceed i n exams . You d i d n o t succeed i n exams . You d i d n o t do a l l t h e e x e r c i s e s .
Fallacies
Syllogisms
Hypothetical syllogism
pq qr pr
Fallacies
Syllogisms
Hypothetical syllogism
pq qr pr
Disjunctive syllogism
pq p q
Fallacies
Other rules
Addition
p pq
Fallacies
Other rules
Addition
p pq
Simplication
pq p
Fallacies
Other rules
Addition
p pq
Simplication
pq p
Conjunction
p q pq
Fallacies
Resolution
pq p r qr
Fallacies
Resolution
pq p r qr Resolution is the rule of inference for computer to do an automatic reasoning. In the above denition, q r is called the resolvent. In using resolution, hypotheses and conclusion must be expressed as clauses. Clause: disjunction of variables or negations of variables.
Fallacies
Fallacies
Answer
3 Let p be the proposition 2 > 2 and q be the proposition 2 > 3 . The premises of the argument are p q and p, 2 whereas the conclusion is q. Thus, the argument is valid because it is constructed by using modus ponens, a valid argument form.
Fallacies
Answer
3 Let p be the proposition 2 > 2 and q be the proposition 2 > 3 . The premises of the argument are p q and p, 2 whereas the conclusion is q. Thus, the argument is valid because it is constructed by using modus ponens, a valid argument form. However, one of its premises, 2 > 3 , is false. Consequently, 2 we cannot conclude that the conclusion is true. Moreover, note that the conclusion itself is false, because 2 < 9 4
Fallacies
Show that the hypotheses If you send me an e-mail, then I will nish writing the program, If you do not send me an e-mail, then I will go to sleep early, and If I go to sleep early, then I will wake up feeling refreshed lead to the conclusion If I do not nish writing the program, then I will wake up feeling refreshed.
Fallacies
Show that the hypotheses If you send me an e-mail, then I will nish writing the program, If you do not send me an e-mail, then I will go to sleep early, and If I go to sleep early, then I will wake up feeling refreshed lead to the conclusion If I do not nish writing the program, then I will wake up feeling refreshed.
Solution
Let p be the proposition You send me an e-mail q, the proposition I will nish writing the program r , the proposition I will go to sleep early s, the proposition I will wake up feeling refreshed
Fallacies
Show that the hypotheses If you send me an e-mail, then I will nish writing the program, If you do not send me an e-mail, then I will go to sleep early, and If I go to sleep early, then I will wake up feeling refreshed lead to the conclusion If I do not nish writing the program, then I will wake up feeling refreshed.
Solution
Let p be the proposition You send me an e-mail q, the proposition I will nish writing the program r , the proposition I will go to sleep early s, the proposition I will wake up feeling refreshed The hypotheses are p q, p r , r s. The desired conclusion is q s
Fallacies
Show that the hypotheses If you send me an e-mail, then I will nish writing the program, If you do not send me an e-mail, then I will go to sleep early, and If I go to sleep early, then I will wake up feeling refreshed lead to the conclusion If I do not nish writing the program, then I will wake up feeling refreshed.
Solution
Let p be the proposition You send me an e-mail q, the proposition I will nish writing the program r , the proposition I will go to sleep early s, the proposition I will wake up feeling refreshed The hypotheses are p q, p r , r s. The desired conclusion is q s
1
pq
Hypothesis
p r
Hypothesis
5 6
r s q s
Hypothesis
Fallacies
Show that the hypotheses If you send me an e-mail, then I will nish writing the program, If you do not send me an e-mail, then I will go to sleep early, and If I go to sleep early, then I will wake up feeling refreshed lead to the conclusion If I do not nish writing the program, then I will wake up feeling refreshed.
Solution
Let p be the proposition You send me an e-mail q, the proposition I will nish writing the program r , the proposition I will go to sleep early s, the proposition I will wake up feeling refreshed The hypotheses are p q, p r , r s. The desired conclusion is q s
1 2 3
pq q p p r
5 6
r s q s
Hypothesis
Fallacies
Show that the hypotheses If you send me an e-mail, then I will nish writing the program, If you do not send me an e-mail, then I will go to sleep early, and If I go to sleep early, then I will wake up feeling refreshed lead to the conclusion If I do not nish writing the program, then I will wake up feeling refreshed.
Solution
Let p be the proposition You send me an e-mail q, the proposition I will nish writing the program r , the proposition I will go to sleep early s, the proposition I will wake up feeling refreshed The hypotheses are p q, p r , r s. The desired conclusion is q s
1 2 3 4 5 6
pq q p p r q r r s q s
Hypothesis Contrapositive of (1) Hypothesis Hypothetical syllogism using (2) and (3) Hypothesis
Fallacies
Show that the hypotheses If you send me an e-mail, then I will nish writing the program, If you do not send me an e-mail, then I will go to sleep early, and If I go to sleep early, then I will wake up feeling refreshed lead to the conclusion If I do not nish writing the program, then I will wake up feeling refreshed.
Solution
Let p be the proposition You send me an e-mail q, the proposition I will nish writing the program r , the proposition I will go to sleep early s, the proposition I will wake up feeling refreshed The hypotheses are p q, p r , r s. The desired conclusion is q s
1 2 3 4 5 6
pq q p p r q r r s q s
Hypothesis Contrapositive of (1) Hypothesis Hypothetical syllogism using (2) and (3) Hypothesis Hypothetical syllogism using (4) and (5)
Fallacies
Fallacies
Solution
(p q) r can be rewritten as two clauses, p r and q r . r s can also be rewritten as r s. Using resolution on the two clauses, p r and r s, we can obtain the conclusion p s.
Valid arguments
Fallacies
Valid arguments
Fallacies
Valid arguments
Fallacies
Valid arguments
Fallacies
Fallacies
Universal instantiation
Universal instantiation
x.P(x) P(c)
Fallacies
Universal instantiation
Universal instantiation
x.P(x) P(c) c is a particular member of the domain, given the premise x.P(x) Example: from the statement All women are wise, we can conclude Lisa is wise, provided that Lisa is a member of the domain of all women.
Fallacies
Universal generalization
Universal generalization
P(c) for an arbitrary c x.P(x)
Fallacies
Universal generalization
Universal generalization
P(c) for an arbitrary c x.P(x) Universal generalization is used when we show that x.P(x) is true by taking an arbitrary element c from the domain, and showing that P(c) is true. Arbitrary means that we have no control over c and cannot make any assumptions about c other than it comes from the domain. This rule is often used implicitly in mathematics. Also often used incorrectly, due to making unwarranted assumptions about the arbitrary element c.
Fallacies
Existential instantiation
Existential instantiation
x.P(x) P(c) for some element c
Fallacies
Existential instantiation
Existential instantiation
x.P(x) P(c) for some element c This rule allows us to conclude that there is an element c in the domain for which P(c) is true, if we know that x.P(x) is true. c is NOT arbitrary, but rather it must the c for which P(c) is true. Usually we have no knowledge over c, other that it exists. Because it exists, we may give it a name (c) and continue our argument.
Fallacies
Existential generalization
Existential generalization
P(c) for some element c x.P(x)
Fallacies
Existential generalization
Existential generalization
P(c) for some element c x.P(x) This rule is used to conclude that x.P(x) is true when we know a particular element c with P(c) true.
Fallacies
Show that the premises Everyone in this discrete mathematics class also takes a course in foundations of programming, and Eva is a student is this class imply the conclusion Eva takes a course in foundations of programming.
Fallacies
Show that the premises Everyone in this discrete mathematics class also takes a course in foundations of programming, and Eva is a student is this class imply the conclusion Eva takes a course in foundations of programming.
Solution
Let D(x) denote x is in this discrete mathematics class, and C(x) denote x takes a course in foundations of programming.
Fallacies
Show that the premises Everyone in this discrete mathematics class also takes a course in foundations of programming, and Eva is a student is this class imply the conclusion Eva takes a course in foundations of programming.
Solution
Let D(x) denote x is in this discrete mathematics class, and C(x) denote x takes a course in foundations of programming. The hypotheses are x.(D(x) C(x)) and D(Eva). The desired conclusion is C(Eva)
Fallacies
Show that the premises Everyone in this discrete mathematics class also takes a course in foundations of programming, and Eva is a student is this class imply the conclusion Eva takes a course in foundations of programming.
Solution
Let D(x) denote x is in this discrete mathematics class, and C(x) denote x takes a course in foundations of programming. The hypotheses are x.(D(x) C(x)) and D(Eva). The desired conclusion is C(Eva)
1
x.(D(x) C(x))
Premise
Fallacies
Show that the premises Everyone in this discrete mathematics class also takes a course in foundations of programming, and Eva is a student is this class imply the conclusion Eva takes a course in foundations of programming.
Solution
Let D(x) denote x is in this discrete mathematics class, and C(x) denote x takes a course in foundations of programming. The hypotheses are x.(D(x) C(x)) and D(Eva). The desired conclusion is C(Eva)
1 2
Fallacies
Show that the premises Everyone in this discrete mathematics class also takes a course in foundations of programming, and Eva is a student is this class imply the conclusion Eva takes a course in foundations of programming.
Solution
Let D(x) denote x is in this discrete mathematics class, and C(x) denote x takes a course in foundations of programming. The hypotheses are x.(D(x) C(x)) and D(Eva). The desired conclusion is C(Eva)
1 2 3
Fallacies
Show that the premises Everyone in this discrete mathematics class also takes a course in foundations of programming, and Eva is a student is this class imply the conclusion Eva takes a course in foundations of programming.
Solution
Let D(x) denote x is in this discrete mathematics class, and C(x) denote x takes a course in foundations of programming. The hypotheses are x.(D(x) C(x)) and D(Eva). The desired conclusion is C(Eva)
1 2 3 4
Premise Universal instantiation from (1) Premise Modus ponens from (2) and (3)
Fallacies
Fallacies
Example
Assume that For all positive integers n, if n is greater than 4, then n2 is less than 2n is true. Show that 1002 < 2100 .
Fallacies
Example
Assume that For all positive integers n, if n is greater than 4, then n2 is less than 2n is true. Show that 1002 < 2100 .
Solution
Let P(n) denote n > 4 and Q(n) denote n2 < 2n . The premise can be represented by n.(P(n) Q(n)), where the domain consists of all positive integers. Note P(100) is true because 100 > 4. It follows by universal modus ponens that Q(n) is true, namely 1002 < 2100
Proof methods
Proofs
Outline
11
12
Proof methods
Proof methods
Answer
Superman does not prevent evil. By Modus Tollens, we obtain that Superman is either unable or unwilling to prevent evil. If Superman is unable to prevent evil, then he is impotent; similarly, if Superman is unwilling to prevent evil, then he is malevolent. Thus, by Modus Ponens, we have that Superman is either impotent or malevolent. Since if Superman exists, he is neither impotent nor malevolent, by Modus Tollens, we conclude that Superman does not exist. Since the conclusion is derived by always using valid rules of inference, we know that the argument is valid.
Proof methods
Basic Terminology I
Theorem, proposition, lemma: a statement that can be shown to be true. Theorem is usually reserved for a statement that is considered somewhat important; sometimes it is refered as fact or result. Propositions are typically less important than theorems; lemma are typically less important than propositions. Proof: a valid argument that establishes the truth of a theorem/proposition/lemma. Statements used in a proof can include:
axioms (postulates): statements assumed to be true; premise(s) of the theorem/proposition/lemma that we want to prove; previously proven theorem/proposition/lemma.
Proof methods
Basic Terminology II
Lemma (small theorem) are usually used to help proving other results (not as itself); complicated proofs are usually easier to understand when they are proved using series of lemmas. Corollary: a theorem that can be established directly/straightforwardly from a theorem that has been proved. Conjencture: a statement that is being proposed to be a true statement; its truth is unknown until somebody gives it a valid proof.
Proof methods
Theorem statement
Many (though not all) theorems assert that a property holds for all elements in a domain. In such cases, a universal quantier is usually omitted, although it is formally needed for a precise statement. In proving theorems, universal instantiation is often used implicitly.
Proof methods
Theorem statement
Many (though not all) theorems assert that a property holds for all elements in a domain. In such cases, a universal quantier is usually omitted, although it is formally needed for a precise statement. In proving theorems, universal instantiation is often used implicitly. The theorem: If x > y , where x and y are positive real numbers, then x 2 > y 2
Proof methods
Theorem statement
Many (though not all) theorems assert that a property holds for all elements in a domain. In such cases, a universal quantier is usually omitted, although it is formally needed for a precise statement. In proving theorems, universal instantiation is often used implicitly. The theorem: If x > y , where x and y are positive real numbers, then x 2 > y 2 actually means
Proof methods
Theorem statement
Many (though not all) theorems assert that a property holds for all elements in a domain. In such cases, a universal quantier is usually omitted, although it is formally needed for a precise statement. In proving theorems, universal instantiation is often used implicitly. The theorem: If x > y , where x and y are positive real numbers, then x 2 > y 2 actually means For all positive real numbers x and y , if x > y , then x 2 > y 2
Proof methods
Direct proof
Proof methods
Direct proof
Proof methods
Direct proof
Proof methods
Direct proof
Proof methods
Direct proof
In intermediate steps, we are also allowed to use axioms, denitions and previously proven theorems.
Proof methods
Direct proof
In intermediate steps, we are also allowed to use axioms, denitions and previously proven theorems. A direct proof of a statement x(P(x) Q(x)) is constructed by showing that P(c) Q(c) is true, where c is an arbitrary element of the domain (and then applying universal generalization).
Proof methods
Denition
An integer n is even if there exists an integer k such that n = 2k ; and n is odd if there exists an integer k such that n = 2k + 1.
Theorem
If n is an odd integer then n2 is odd.
Proof methods
Theorem
If m and n are both perfect squares, then then nm is also perfect square, where an integer a is a perfect square if there is an integer b such that a = b2 .
Theorem
The sum of two odd integers is even. The square of an even number is an even number.
Theorem
If m + n and n + p are even integers, where m, n, and p are integers, then m + p is even.
Proof methods
Denition
A real number r is rational if there exists integers p and q with p q = 0 such that r = q ; otherwise it is called irrational.
Theorem
The sum of two rational numbers is rational.
Proof methods
Proof by contraposition
Proof methods
Proof by contraposition
Proof methods
Proof by contraposition
Proof methods
Proof by contraposition
Proof methods
Theorem
If n is an integer and 3n + 2 is odd, then n is odd.
Theorem
If n = ab, where a and b are positive integers, then a b n.
n or
Theorem
If n is an integer and n2 is odd, then n is odd.
Theorem
If x is irrational, then 1/x is irrational.
Adila A. Krisnadhi
Faculty of Computer Science, University of Indonesia
Mistakes in Proof
Proofs (2)
Outline
13
Proof Methods (2) Vacuous and Trivial Proofs Proof by Contradiction Proofs of equivalence Counterexamples Mistakes in Proof Proof methods (3) Exhaustive proof Proof by cases
14 15
Mistakes in Proof
Vacuous proof
We can quickly prove that a conditional statement p q is true when we know that p is false. Why?
Mistakes in Proof
Vacuous proof
We can quickly prove that a conditional statement p q is true when we know that p is false. Why? Because p q must be true whenever p is false.
Mistakes in Proof
Vacuous proof
We can quickly prove that a conditional statement p q is true when we know that p is false. Why? Because p q must be true whenever p is false. Show that the proposition P(0) is true, where P(n) is If n > 1, then n2 > n and the domain consists of all integers.
Mistakes in Proof
Vacuous proof
We can quickly prove that a conditional statement p q is true when we know that p is false. Why? Because p q must be true whenever p is false. Show that the proposition P(0) is true, where P(n) is If n > 1, then n2 > n and the domain consists of all integers.
Vacuous proof
Note that P(0) is If 0 > 1, then 02 > 0. Then P(0) is true because the hypothesis 0 > 1 is false.
Mistakes in Proof
Trivial proof
We can quickly prove that a conditional statement p q is true when we know that q is true. Why?
Mistakes in Proof
Trivial proof
We can quickly prove that a conditional statement p q is true when we know that q is true. Why? Because p q must be true whenever q is true (regardless of the hypothesis p).
Mistakes in Proof
Trivial proof
We can quickly prove that a conditional statement p q is true when we know that q is true. Why? Because p q must be true whenever q is true (regardless of the hypothesis p). Let P(n) be If a and b are positive integers with a b, then an bn where the domain consists of all integers. Show that P(0) is true.
Mistakes in Proof
Trivial proof
We can quickly prove that a conditional statement p q is true when we know that q is true. Why? Because p q must be true whenever q is true (regardless of the hypothesis p). Let P(n) be If a and b are positive integers with a b, then an bn where the domain consists of all integers. Show that P(0) is true.
Trivial proof
Note that P(0) is If a b, then a0 b0 . Because a0 = b0 = 1, the conclusion of the statement P(0) is true. Hence, P(0) itself is trivially true. Note that the hypothesis a b was not needed in this proof.
Mistakes in Proof
Mistakes in Proof
Mistakes in Proof
Mistakes in Proof
Mistakes in Proof
Mistakes in Proof
Suppose that p is a proposition that we want to prove. A proof by contradiction of p is constructed as follows: First, assume that p is true.
Mistakes in Proof
Suppose that p is a proposition that we want to prove. A proof by contradiction of p is constructed as follows: First, assume that p is true. Derive statements which are true as consequences of this assumption until ...
Mistakes in Proof
Suppose that p is a proposition that we want to prove. A proof by contradiction of p is constructed as follows: First, assume that p is true. Derive statements which are true as consequences of this assumption until ... we obtain a statement that contradicts previously-derived statements, i.e., a statement r whose negation r is already derived previously.
Mistakes in Proof
Theorem
At least four of any 22 days must fall on the same day.
Theorem
2 is irrational
Theorem
If 3n + 2 is odd, then n is odd.
Mistakes in Proof
Proof of equivalence
In order to show that a biconditional statement p q is true, we show that p q and q p are both true.
Mistakes in Proof
Proof of equivalence
In order to show that a biconditional statement p q is true, we show that p q and q p are both true. This approach is valid because it is based on the tautology (p q) [(p q) (q p)].
Mistakes in Proof
Theorem
If n is a positive integer, then n is odd iff n2 is odd.
Theorem
If n is a positive integer, then n is odd if and only if 5n + 6 is odd.
Mistakes in Proof
Mistakes in Proof
Counterexamples
In order to show that a statement of the form xP(x), we need only nd a counterexample, i.e., an example x for which P(x) is false.
Using counterexample
Disprove the statement Every positive integer is the sum of the squares of two integers.
Mistakes in Proof
Counterexamples
In order to show that a statement of the form xP(x), we need only nd a counterexample, i.e., an example x for which P(x) is false.
Using counterexample
Disprove the statement Every positive integer is the sum of the squares of two integers.
Answer
To disprove the universally quantied statement above, we look for a counterexample which is a particular integer that is NOT the sum of the squares of two integers. For this statement, a counterexample is easy to nd. One such counterexample is 3. To show that this is the case, not that the only two perfect squares not exceeding 3 are 02 = 0 and 12 = 1. It is easy to see that there is no way to get 3 as the sum of two terms each of which is 0 or 1. Thus 3 is a counterexample of the statement above.
Mistakes in Proof
Supposed Proof
Suppose that n2 is positive. Because the statement If n is positive, then n2 is positive is true, we can conclude that n is positive.
Mistakes in Proof
Supposed Proof
Suppose that n2 is positive. Because the statement If n is positive, then n2 is positive is true, we can conclude that n is positive. This proof is wrong. Let P(n) be n is positive and Q(n) be n2 is positive. Then the statement that we want to prove is n(Q(n) P(n)). Take Q(n) is the hypothesis. In the supposed proof, we make use of the statement n(P(n) Q(n)). But from Q(n) as the hypothesis and the statement n(P(n) Q(n)), we cannot conclude P(n), since there is no valid rule inference that is usable here.
Mistakes in Proof
Supposed proof
Suppose that n2 is even. Then n2 = 2k for some integer k . Let n = 2 for some integer . This shows that n is even.
Mistakes in Proof
Supposed proof
Suppose that n2 is even. Then n2 = 2k for some integer k . Let n = 2 for some integer . This shows that n is even. The proof is wrong, because the statement let n = 2 for some integer occurs in the proof. No argument has been given to show that n can indeed be written as 2 for some integer . This is circular reasoning because this statement is equivalent to the statement being proved, i.e., n is even. Note that the theorem itself is actually correct (can you give a valid proof of it?), but the method of proof is wrong.
Mistakes in Proof
Some statement can be proved by examining ALL possible example. Such proofs is called exhaustive proof. This method is suitable only when the number of examples are relatively small.
Mistakes in Proof
Some statement can be proved by examining ALL possible example. Such proofs is called exhaustive proof. This method is suitable only when the number of examples are relatively small.
Mistakes in Proof
Proof by cases
see the whiteboard for details; take notes if necessary!
A proof by cases must cover ALL possible cases that arise in a theorem. This method works since the statement (p1 p2 . . . pn ) q is equivalent to (p1 q) (p2 q) . . . (pn q).
Theorem
If n is an integer, then n2 n.
Theorem
For every real numbers x and y , |xy | = |x||y |, where |a| = a if a 0 and |a| = a if a < 0.
Set: basics
Set operations
Set
Outline
16
Set: basics
17
Set operations
Set: basics
Set operations
Set: denition
Denition
A set is an unordered collection of distinct objects.
Denition
Objects in a set are called elements or members of the set. Here, the set is said to contain its elements.
Set: basics
Set operations
Set: notation
Sets are usually denoted by large capitals: A, B, X , Y , . . . ; if necessary with index. Elements of a set are usually denoted by small letters: a, b, x, y , . . . ; if necessary with index. x A denotes that x is an element of A, i.e., A contains x as one of its element. x A denotes that x is not an element of A. / denotes the empty set.
Set: basics
Set operations
Set: representation
using description (set builder notation) where P is a predicate over elements of the set:
{x : P(x)} or {x | P(x)} {x S : P(x)} or {x S | P(x)} where S is another set in the context of the discussion, restricting the elements of the denoted set (sometimes called a universal set).
Set: basics
Set operations
Set: examples
The set of natural numbers N = {0, 1, 2, 3, . . . } (Note: sometimes people dene natural numbers starting from 1, not 0) The set of integers Z = {0, 1, 1, 2, 2, . . . } = {. . . , 2, 1, 0, 1, 2, . . . } The set of positive integers Z+ = {1, 2, 3, . . . } The set of rational numbers Q = {p/q | p Z, q Z, and q = 0} The set of real numbers R A = {x N | x 2 3x + 2 = 0}, set of natural numbers x such that x 2 3x + 2 = 0. A can also be written as {1, 2}. The set of positive even numbers is written as {2x | x N} or {x | x = 2y , y N} or {x N | x = 2y , y N}. The set B = {x N | 6 < x < 9} can also be written as B = {7, 8} The set B = {7, 8} can also be written as {x N | 40 < x 2 < 80} or {x N | x 2 15x + 56 = 0} or {7 + x N | x = 0 or x = 1}
Set: basics
Set operations
Denition
The set A is a subset of B (written A B) iff every element of A is also an element of B. Here, we also say that B is a superset of A (written B A) A B iff x(x A x B) is true.
Denition
The set A is a proper subset of B iff A B and A = B
Set: basics
Set operations
Set: basics
Set operations
Set: basics
Set operations
Theorem
If a set S has n elements then its power set P(S) has 2n elements.
Set: basics
Set operations
Ordered tuple
Sets are unordered; we need different structure to represent ordered collection.
Denition
The (ordered) n-tuple (a1 , a2 , . . . , an ) is the ordered collection with a1 as its rst element, a2 as its second element, ..., and an as its nth element. 2-tuples are usually called ordered pairs Two n-tuples (a1 , a2 , . . . , an ) and (b1 , b2 , . . . , bn ) are equal iff ai = bi for i = 1, 2, . . . , n (i.e., each corresponding pair of their elements are equal). In particular, two ordered pairs (a, b) and (c, d) are equal iff a = c and b = d.
Set: basics
Set operations
Cartesian products
We can use Cartesian product to form a set of ordered pairs from two sets.
Denition
Let A and B be sets. The Cartesian product of A and B (denoted by A B), is the set of all ordered pairs (a, b) where a A and b B. In other words A B = {(a, b) | a A b B}
If A = {1, 2, 3} and B = {2, 3}, then A B = {(1, 2), (1, 3), (2, 2), (2, 3), (3, 2), (3, 3)} If A = {x | 2 x 3} and B = {x | 1 x 2 or 3 x 4}, then A B = {(x, y ) | 2 x 3 and 1 y 2 or 3 y 4} A B = B A unless A = B or A = or B =
Set: basics
Set operations
Relation
Denition
A relation R from a set A to a set B is a set of ordered pairs (a, b) such that a is some element of a and b is some element B. In other words, R A B. Let A = {1, 2, 3} and B = {2, 3}. R = {(1, 3), (3, 3)} is a relation from A to B. Let A = {1, 2, 3} and B = {a, b, c}. R = {(1, a), (1, b), (1, c)} is a relation from A to B.
Set: basics
Set operations
Denition
The Cartesian product of the sets A1 , A2 , . . . , An , (denoted by A1 A2 An ) is the set of ordered n-tuples (a1 , a2 , . . . , an ), where ai Ai for i = 1, 2, . . . , n. In other words, A1 A2 An = {(a1 , a2 , . . . , an ) | ai Ai for i = 1, 2, . . . , n}
Let A = {0, 1}, B = {1, 2} and C = {0, 1, 2}. A B C = {(0, 1, 0), (0, 1, 1), (0, 1, 2), (0, 2, 0), (0, 2, 1), (0, 2, 2), (1, 1, 0), (1, 1, 1), (1, 1, 2), (1, 2, 0), (1, 2, 1), (1, 2, 2)}
Set: basics
Set operations
Venn diagram
Let V = {a, e, i, o, u} be the set of all vowels. A Venn diagram for V is:
Set: basics
Set operations
Set: basics
Set operations
Set: basics
Set operations
Let A = {1, 3, 5} and B = {1, 2, 4} A B = {1, 3, 5, 2, 4} A B = {1} A \ B = {3, 5} B \ A = {2, 4} A and B are NOT disjoint. But A and {2, 4} are disjoint. If the universal set U = {x N | 1 x 10}, then A = {2, 4, 6, 7, 8, 9, 10}
Set: basics
Set operations
Set identities
Proofs of them are left as exercises
Identity laws: A = A and A U = A for a universal set U Domination laws: A U = U for a universal set U and A = Idempotent laws: A A = A and A A = A. Complementation law: A = A. Complement laws: A A = U for a universal set U, and A A = Commutative laws: A B = B A and A B = B A. Associative laws: A (B C) = (A B) C and A (B C) = (A B) C. Distributive laws: A (B C) = (A B) (A C) and A (B C) = (A B) (A C). De Morgans laws: A B = A B and A B = A B Absorption laws: A (A B) = A and A (A B) = A.
Set: basics
Set operations
Ai =
i=1
{Ai , i = 1, 2, . . . , n} = A1 A2 . . . An
Ai =
i=1
{Ai , i = 1, 2, . . . , n} = A1 A2 . . . An
Adila A. Krisnadhi
Faculty of Computer Science, University of Indonesia
Functions
18
19
20
Functions
Function: denitions
Denition
Let A and B be nonempty sets. A function f from A to B (written f : A B) is an assignment of each element of A to exactly one element of B. Functions are also called mappings or transformations We write f (a) = b if a A is assigned to a unique b B A function can also be viewed as a relation from A to B that contains one and only one ordered pair (a, b) for evey element a A.
Functions
The range of f is the set of all images of elements of A. The range of f is always a subset of the codomain of f If f is a function from A to B, we say that f maps A to B. Two functions are equal if they have the same domain, the same codomain and map elements of their common domain to the same elements in their common codomain. Equality of functions can also be seen as equality of sets (recall the denition of function as relation).
Functions
Let f be a function from A to B and S A. The image of S under f is the subset of B that consists of the images of elements of S, i.e., {t | s S(t = f (s))} Note: we can also use a shorthand for this set: {f (s) | s S}
Functions
Lemma
Let f : A B be a function. If f is strictly increasing, then f is increasing. If f is strictly decreasing, then f is decreasing.
Functions
Let f : A B be a function. f is surjective (onto) iff it satises y B.x A : f (x) = y f is injective (one-to-one) iff it satises x1 x2 (f (x1 ) = f (x2 ) x1 = x2 ) f is bijective (one-to-one correspondence) iff f is both surjective and injective.
Theorem
Let f : A B be a function. If f is either strictly increasing or strictly decreasing, then f is a one-to-one function.
Functions
Examples
Let f be a function from {a, b, c, d} to {1, 2, 3, 4, 5} with f (a) = 4, f (b) = 5, f (c) = 1 and f (d) = 3. Then f is one-to-one, but not onto. Let f : Z Z be a function such that f (x) = x 2 . Then
f is not one-to-one, because e.g., f (1) = f (1) = 1, but 1 = 1; f is not onto, because there is no x Z such that f (x) = 1 f is not increasing and not decreasing. Why?
Functions
Inverse function
Denition
Let f : A B be a bijective function. The inverse function of f is the function f 1 : B A dened such that if f (x) = y then f 1 (y ) = x. Do not confuse f 1 with the function 1/f . They are NOT the same. Inverse function of f only exists (is well-dened) if f is bijective. Why? If f is bijective, then f has an inverse function, i.e., f is invertible.
Functions
Examples
Let f be the function from {a, b, c} to {1, 2, 3} such that f (a) = 2, f (b) = 3 and f (c) = 1. Then f is invertible (why?) and the inverse of f is the function f 1 from {1, 2, 3} to {a, b, c} such that f 1 (1) = c, f 1 (2) = a, and f 1 (3) = b. Let f : Z Z be such that f (x) = x + 1. Then f is invertible (why?) and its inverse is the function f 1 : Z Z such that f 1 (x) = x 1. Let f : R R be such that f (x) = x 2 . Is f invertible? If it is, what is its inverse? Let f : R+ {0} R+ {0} be such that f (x) = x 2 . Is f invertible? If it is, what is its inverse?
Functions
Function composition
Denition
Let f : B C and g : A B be functions. The composition of f and g is the function f g : A C dened as (f g)(x) = f (g(x)) To nd (f g)(a), we rst apply g to a obtaining g(a) and then we apply f to g(a) to obtain (f g)(a). For the function f g to be well-dened, the range of g must be a subset of the domain of f . Why?
Functions
Examples
Let g be the function from {a, b, c} to itself such that g(a) = b, g(b) = c and g(c) = a. Let f be the function from {a, b, c} to {1, 2, 3} such that f (a) = 3, f (b) = 2 and f (c) = 1. Then
(f g) is the function from {a, b, c} to {1, 2, 3} such that (f g)(a) = f (g(a)) = 2, (f g)(b) = f (g(b)) = 1 and (f g)(c) = f (g(c)) = 3 Is g f well-dened? If it is, give the denition of g f .
Functions
Functions Sequences
Sequences
Denition (Informal denition)
A sequence is an ordered list of terms.
Functions Sequences
Examples
The sequence {an } where an = 1/n for n = 1, 2, . . . is the sequence 1, 1 , 1 , 1 , . . . . 2 3 4 A geometric progression is the sequence of the form a, ar , ar 2 , . . . , ar n , . . . with the initial term a and the ratio r are real numbers. For example:
1, 2, 4, 8, . . . . 1 1, 2 , 1 , 1 , . . . . 4 8 1, 1, 1, 1, 1, . . . .
An arithmetic progression is the sequence of the form a, a + d, a + 2d, . . . , a + nd, . . . where the initial term a and the common difference r are real numbers. For example:
1, 3, 7, 11, . . . . 7, 4, 1, 2, . . . .
Functions Sequences
Functions Sequences
Examples
Guess a simple formula for an if the rst 10 terms of the sequence {an } are 1, 7, 25, 79, 241, 727, 2185, 6559, 19681, 59047.
Functions Summations
Summation
We are usually interested in summing a given sequence. Here, we use the summation notation, namely the sigma notation. Given the terms am , am+1 , . . . , an from the sequence {an }, we use the notation
n
aj ,
j=m
n j=m
aj ,
or
n mjn
aj
to represent am + am+1 + + an In the notation, j is the index of summation, and we could also use any other letter such as i or k . Also, m is the lower limit and n is the upper limit of the summation.
Functions Summations
Example
The sum of the rst 100 terms of the sequences {an } where an = 1/n for n = 1, 2, 3, . . . is 100 1 . j=1 j Calculate Calculate
5 2 j=1 j . 8 k k =4 (1) .
Index of summation can be shifted, e.g., 5 4 2 2 j=1 j = k =0 (k + 1) Prove this result: if a and r ar real numbers, and r = 0, then n ar n+1 a if r = 1 r 1 ar j = (n + 1)a if r = 1 j=0
Functions Summations
ij =
i=1 j=1 i=1 4
(i + 2i + 3i)
=
i=1
6i
= 6 + 12 + 18 + 24 = 60
Functions Summations
ij =
i=1 j=1 i=1 4
(i + 2i + 3i)
=
i=1
6i
= 6 + 12 + 18 + 24 = 60 Given a set S, we can sum the values f (s) for all members of S. E.g.: s2 = 02 + 22 + 42 = 20
s{0,2,4}
Functions Summations
Provided r = 0:
k =0
ar k =
ar n+1 a r 1
(n + 1)a
if r = 1 if r = 1
(a + kd) = (n + 1)a +
k =0 n
dn(n + 1) 2
k=
k =1 n
k2 =
k =1 n
k3 =
k =1
Functions
Recall that, cardinality of a set is dened as the number of elements in the set. Two nite sets A and B are of the same cardinality if the number of elements in A is the same as the number of elements in B (which can be counted). What if the set is innite? Can we extend the notion of cardinality to innite sets?
Functions
Denition
The sets A and B have the same cardinality iff there exists a bijection from A to B. A set is countable iff it is either nite or has the same cardinality with the set of positive integers (Z+ ). A set is uncountable iff it is not countable. When an innite set S is countable, we denote the cardinality of S (i.e., |S|) by 0 (read as aleph null)
Functions
Examples
Is the set of odd positive integers is countable? Explain. Is the set {5, 4, . . . , 9, 10} countable? Explain. Is the set of all integers (Z) is countable? Explain. Is the set of positive rational numbers is countable? Explain. Is the set of real numbers is countable? Explain.
Functions
More examples
Is a subset of a countable set also countable? Suppose A and B are sets, A is uncountable, and A B. Is B countable or uncountable? Prove it. Suppose A is an uncountable set and B is a countable set. Is A \ B countable or uncountable? Prove it.
Adila A. Krisnadhi
Faculty of Computer Science, University of Indonesia
Integers
Outline
21
The Integers Division Division The Division Algorithm Modular Arithmetic Primes and Greatest Common Divisor Primes Greatest Common Divisor and Least Common Multiples
22
Division
From your previous experiences, you should already know some properties of integers: on addition, multiplication, etc. We are going to look at an operation on integers in more details, namely the division. When an integer is divided by another, nonzero integer, the result (i.e., quotient) may or may not be an integer. E.g., 12/4 = 3, whereas 11/4 = 2.75. So, if we require the division operation on integers always to give an integer, we need the following denition
Division
Denition
Let a and b be integers with a = 0. Then we say, a divides b (written as a | b) if there is an integer c such that b = ac. If a | b, we say that a is a factor of b and b is a multiple of a. If a does NOT divide b, we write a b.
Theorem
If a,b and c are integers such that a | b and a | c, then a | mb + nc for every integers m and n.
Proof.
Left as exercise. (Hint: use the rst part of the previous theorem).
Example
What are the quotient and remainder when 101 is divided by 11? What are the quotient and remainder when -11 is divided by 3.
Example
What are the quotient and remainder when 101 is divided by 11? What are the quotient and remainder when -11 is divided by 3. By the previous denition, remainder cannot be negative.
Example
What are the quotient and remainder when 101 is divided by 11? What are the quotient and remainder when -11 is divided by 3. By the previous denition, remainder cannot be negative.
Theorem
An integer a is divisible (i.e., can be divided) by an integer d if and only if a mod d = 0
Modular arithmetic
Denition
Let a and b be integers, and m a positive integer. Then a is congruent to b modulo m written as a b ( mod m) iff m |ab If a and b are not congruent modulo m, we write a b ( mod m)
Modular arithmetic
Denition
Let a and b be integers, and m a positive integer. Then a is congruent to b modulo m written as a b ( mod m) iff m |ab If a and b are not congruent modulo m, we write a b ( mod m)
Theorem
Let a and b be integers and m a positive integer. Then a b ( mod m) iff a mod m = b mod m Proof of this theorem is left as an exercise.
Example
Determine whether 17 is congruent to 5 modulo 6. Determine whether 24 and 14 are congruent modulo 6.
Proof.
If a b ( mod m), then m | (a b). Hence, there is an integer k such that a b = km. This means a = b + km. Conversely, if there is an integer k such that a = b + km, then km = a b. This implies that m divides a b, which means that a b ( mod m). Note: the set of all integers congruent to an integer a modulo m is called the congruence class of a modulo m.
Proof.
Because a b ( mod m) and c d ( mod m), there are integers s and t such that b = a + sm, and d = c + tm. Hence, b + d = (a + sm) + (c + tm) = (a + c) + (s + t)m bd = (a + sm)(c + tm) = ac + atm + csm + stm2 = ac + m(at + cs + stm) Hence, a + c b + d ( mod m) and ac bd ( mod m)
Applications of Congruences
Read Rosens book page 205 208 for more details. Hashing functions: storing records in memory so that retrieval can be done quickly. Pseudorandom numbers: random numbers generated by computers. Cryptology: encryption and decryption of messages, e.g. with Caesar cipher, shift cipher, etc.
Primes
Denition
A positive integer p > 1 is called prime if the only positive factor of p are 1 and p. A p A positive integer that is greater than 1 and is not prime is called composite Remark: an integer n is composite iff there exists an integer a such that a | n and 1 < a < n. List all primes less than 100
Theorem
If n is a composite integer, then n has a prime divisor less than or equal n
Theorem
If n is a composite integer, then n has a prime divisor less than or equal n Proof: look at Rosens book page 211. Show that 101 is prime. Find the prime factorization of 7007.
Innitude of primes
Theorem
There are innitely many primes. Proof: Rosens book page 212. Mersenne primes: a prime that has a special form 2p 1 where p is also a prime.
Distribution of primes
The Integers Division Greatest Common Divisor and Least Common Multiples
Denition
Let a and b be integers, not both zero. The largest integer d such that d | a and d | b is called the greatest common divisor of a and b (written as gcd(a, b)). What is gcd(24, 36)? What is gcd(17, 22)?
The Integers Division Greatest Common Divisor and Least Common Multiples
Relatively primes
Denition
The integers a and b are relatively prime if gcd(a, b) = 1.
The Integers Division Greatest Common Divisor and Least Common Multiples
Relatively primes
Denition
The integers a and b are relatively prime if gcd(a, b) = 1.
Denition
The integers a1 , a2 , . . . , an are pairwise relatively prime if gcd(ai , aj ) = 1 for every 1 i < j n. Determine whether 10, 17 and 21 are pairwise relatively prime. Determine whether 10, 19 and 24 are pairwise relatively prime.
The Integers Division Greatest Common Divisor and Least Common Multiples
Denition
The least common multiple of positive integers a and b (written lcm(a, b)) is the smallest positive integer that is divisible by both a and b. What is lcm(23 35 72 , 24 33 )?
Theorem
Let a and b be positive integers. Then ab = gcd(a, b) lcm(a, b)
Adila A. Krisnadhi
Faculty of Computer Science, University of Indonesia
Representation of Integers
Euclidean Algorithm
23
Representation of Integers
24
Euclidean Algorithm
Representation of Integers
Euclidean Algorithm
Representation of Integers
Euclidean Algorithm
(101011111)2 = 1 28 + 0 27 + 1 26 + 0 25 + 1 24 + 1 23 + 1 22 + 1 21 + +1 20 = (351)10 (2AE0B)16 = 2164 +10163 +14162 +016+11 = (175627)10 (3071)8 = 3 83 + 0 82 + 7 8 + 1 = (1593)10
Representation of Integers
Euclidean Algorithm
Representation of Integers
Euclidean Algorithm
Representation of Integers
Euclidean Algorithm
Representation of Integers
Euclidean Algorithm
Representation of Integers
Euclidean Algorithm
Euclidean algorithm
Representation of Integers
Euclidean Algorithm
Theorem
Let a = bq + r , where a, b, q, and r are integers. Then gcd(a, b) = gcd(b, r ). For example, in the previous slide, it holds that: gcd(91, 287) = gcd(91, 14) = gcd(14, 7) = gcd(7, 0) = 7.