Attribution Non-Commercial (BY-NC)

52 views

Attribution Non-Commercial (BY-NC)

- List of Mathematical Symbols for use in social sciences
- Essay#2
- Writing skill
- Concession Paragraphs
- Describe Bar Chart
- Saharon Shelah- Very weak zero one law for random graphs with order and random binary functions
- Chapter 12
- Argumentative Essay
- PHIL2D03-EssayRubric
- s1001 Activities
- Symbols
- Se Ep01 Activity
- paper3
- cover letter outcome portfolio
- cover letter
- parents guide to student success
- persuasive essay rubric
- data analysis--answers
- egg harbor township school curriculum sample
- 1984 argumenative refelction

You are on page 1of 298

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

Because it is needed for answering the following questions: How many ways are there to choose a valid password on a computer system? Is there a link between two computers in a network? How can I identify spam e-mail messages? How can I encyrpt a message so that no unintended recipient can read it? What is the shortest path between two cities using a transportation system? How can a circuit that adds two integers be designed? How many valid Internet addresses are there? ...

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.

2 + 2 = 4. Study this subject well. x < 2. Blablabla. Do you know more examples of propositions? I know more examples of propositions

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

Jeff never sleeps in class. Jakarta has more than 10 million inhabitants.

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

Denition

Contrapositive of p q is the proposition q p. Converse of p q is the proposition q p. Inverse of p q is the proposition p q.

Propositions

Examples

Denition

Contrapositive of p q is the proposition q p. Converse of p q is the proposition q p. Inverse of p q is the proposition p q. What are the contrapositive, converse and inverse of the examples in the previous slide?

Propositions

Examples

Denition

Contrapositive of p q is the proposition q p. Converse of p q is the proposition q p. Inverse of p q is the proposition p q. What are the contrapositive, converse and inverse of the examples in the previous slide? Given a conditional statement, which one is equivalent (always has the same truth value) to it? Its contrapositive, converse or inverse?

Propositions

Examples

Denition

Contrapositive of p q is the proposition q p. Converse of p q is the proposition q p. Inverse of p q is the proposition p q. What are the contrapositive, converse and inverse of the examples in the previous slide? Given a conditional statement, which one is equivalent (always has the same truth value) to it? Its contrapositive, converse or inverse? Prove it.

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

Important!

p q is true exactly when p and q have the same truth value. p q is true when both p q and q p is true. See truth table below. p T T F F q T F T F pq T F T T qp T T F T (p q) (q p) T F F T pq T F F T

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

Operator Precedence 1 2 3 4 5

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.

The system is in multiuser state if and only if it is operating normally. If the system is operating normally, the kernel is functioning. The kernel is not functioning or the system is in interrupt mode. The system is not in interrupt mode.

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.

The system is in multiuser state if and only if it is operating normally. If the system is operating normally, the kernel is functioning. The kernel is not functioning or the system is in interrupt mode. The system is not in interrupt mode.

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

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

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

Find the bitwise AND, bitwise OR and bitwise XOR of the bit strings 1011 0011 and 1110 0001.

Propositions

Examples

Find the bitwise AND, bitwise OR and bitwise XOR of the bit strings 1011 0011 and 1110 0001.

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

Logical Equivalence

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

Interpretations I1 : p I2 : p I3 : p I4 : p

I1 I2 I3 I4

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

Construct the truth table for (p q) (p q) p T T F F q T F T F q F T F T p q T T F T pq T F F F (p q) (p q) T F T F

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

Denition

Let G be a proposition. G is valid iff G is true for every interpretation of G. In this case, G is also called a tautology. G is satisable iff there exists at least one interpretation of G for which G is true. G is falsiable iff there exists at least one interpretation of G for which G is false. G is unsatisable/contradictory iff G is false for every interpretation of G. In this case, G is also called a contradiction. Note: A proposition that is both not valid and non contradictory is also called contingency.

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

p q p q p q q p (p q) p q (p q) (p r ) p (q r ) (p r ) (q r ) (p q) r (p q) (p r ) p (q r ) (p r ) (q r ) (p q) r p q (p q) (q p) p q p q p q (p q) (p q) (p q) p q

Interpretation

Propositional Equivalence

Show that (p (p q)) and p q are equivalent

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

Show that (p q) (p q) is a tautology.

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

Logical Equivalence: continued

Adila A. Krisnadhi

Faculty of Computer Science, University of Indonesia

Outline

Show that (p q) (p q) is a tautology.

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)

valid if the proposition is true on each row of the truth table; straightforward; difcult if there are too many variables (2n rows for n variables)

Assume that the proposition is false Derive a contradictory truth assignment for the variables/subpropositions Due to contradiction, the initial assumption is incorrect, i.e., the proposition is always true.

Predicates and Quantiers Adila A. Krisnadhi

Faculty of Computer Science, University of Indonesia

Predicates

Quantiers

Outline

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

Every student in this class attends the course of Foundations of Programming

Quantiers

Every student in this class attends the course of Foundations of Programming First alternative:

Take D := {x | x is a student in this class} P(x) := x attends the course of Foundations of Programming Then the statement can be written as xP(x)

Quantiers

Every student in this class attends the course of Foundations of Programming First alternative:

Take D := {x | x is a student in this class} P(x) := x attends the course of Foundations of Programming Then the statement can be written as xP(x)

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.

Rules of Inference Adila A. Krisnadhi

Faculty of Computer Science, University of Indonesia

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

Is the following argument valid?

3 If 2 > 3 , then ( 2)2 > ( 3 )2 . We know that 2 > 2 . 2 2 2 Consequently, ( 2) = 2 > ( 3 )2 = 9 . 2 4

Fallacies

Is the following argument valid?

3 If 2 > 3 , then ( 2)2 > ( 3 )2 . We know that 2 > 2 . 2 2 2 Consequently, ( 2) = 2 > ( 3 )2 = 9 . 2 4

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

Is the following argument valid?

3 If 2 > 3 , then ( 2)2 > ( 3 )2 . We know that 2 > 2 . 2 2 2 Consequently, ( 2) = 2 > ( 3 )2 = 9 . 2 4

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

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

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

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

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

If you do every problem in this book, then you will learn discrete mathematics. You learned discrete mathematics. Therefore, you did every problem in this book.

Valid arguments

Fallacies

If you do every problem in this book, then you will learn discrete mathematics. You learned discrete mathematics. Therefore, you did every problem in this book. This argument is not valid because the proposition [(p q) q] p is NOT a tautology.

Valid arguments

Fallacies

If you do every problem in this book, then you will learn discrete mathematics. You did not do every problem in this book. Therefore, you did not learn discrete mathematics.

Valid arguments

Fallacies

If you do every problem in this book, then you will learn discrete mathematics. You did not do every problem in this book. Therefore, you did not learn discrete mathematics. This argument is not valid because the proposition [(p q) p] q is NOT a tautology.

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

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

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

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

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

x.(P(x) Q(x)) P(a), where a is a particular element in the domain Q(a)

x.(P(x) Q(x)) Q(a), where a is a particular element in the domain P(a)

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

Proofs Adila A. Krisnadhi

Faculty of Computer Science, University of Indonesia

Proof methods

Proofs

Outline

11

12

Proof methods

Is the following argument valid?

If Superman were able and willing to prevent evil, he would do so. If Superman were unable to prevent evil, he would be impotent; if he were unwilling to prevent evil, he would be malevolent. Superman does not prevent evil. If Superman exists, he is neither impotent nor malevolent. Therefore, Superman does not exist.

Proof methods

Is the following argument valid?

If Superman were able and willing to prevent evil, he would do so. If Superman were unable to prevent evil, he would be impotent; if he were unwilling to prevent evil, he would be malevolent. Superman does not prevent evil. If Superman exists, he is neither impotent nor malevolent. Therefore, Superman does not exist.

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

rst, assume that p is true;

Proof methods

Direct proof

rst, assume that p is true; construct subsequent steps using rules of inference until ...

Proof methods

Direct proof

rst, assume that p is true; construct subsequent steps using rules of inference until ... q is obtained as true as the nal step.

Proof methods

Direct proof

rst, assume that p is true; construct subsequent steps using rules of inference until ... q is obtained as true as the nal step.

In intermediate steps, we are also allowed to use axioms, denitions and previously proven theorems.

Proof methods

Direct proof

rst, assume that p is true; construct subsequent steps using rules of inference until ... q is obtained as true as the nal step.

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

see the whiteboard for details; take notes if necessary!

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

see the whiteboard for details; take notes if necessary!

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

see the whiteboard for details; take notes if necessary!

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

assume that q is true;

Proof methods

Proof by contraposition

assume that q is true; construct subsequent steps using rules of inference until ...

Proof methods

Proof by contraposition

assume that q is true; construct subsequent steps using rules of inference until ... p is obtained as true as the nal step.

Proof methods

see the whiteboard for details; take notes if necessary!

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.

Proofs (2)

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

The idea of proof by contradiction: Suppose we want to prove that a statement p is true.

Mistakes in Proof

The idea of proof by contradiction: Suppose we want to prove that a statement p is true. Moreover, suppose we can show that there is a statement q such that p q is true AND q is a contradictory statement.

Mistakes in Proof

The idea of proof by contradiction: Suppose we want to prove that a statement p is true. Moreover, suppose we can show that there is a statement q such that p q is true AND q is a contradictory statement. Then, we can conclude that p is false, which means that p is true.

Mistakes in Proof

The idea of proof by contradiction: Suppose we want to prove that a statement p is true. Moreover, suppose we can show that there is a statement q such that p q is true AND q is a contradictory statement. Then, we can conclude that p is false, which means that p is true. How can we nd such a contradiction q that might help us prove that p is true in this way?

Mistakes in Proof

The idea of proof by contradiction: Suppose we want to prove that a statement p is true. Moreover, suppose we can show that there is a statement q such that p q is true AND q is a contradictory statement. Then, we can conclude that p is false, which means that p is true. How can we nd such a contradiction q that might help us prove that p is true in this way? Because the statement r r is always a contradiction whenever r is a proposition, we can prove that p is true if we can show that p (r r ) is true for some proposition r .

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

see the whiteboard for details; take notes if necessary!

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

see the whiteboard for details; take notes if necessary!

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

In order to show that the propositions p1 , p2 , . . . , pn are equivalent, we show that p1 p2 . . . pn is true. One way to show this, is by showing that all conditional statements p1 p2 , p2 p3 , . . . , pn p1 are true. The idea is so that we can establish any chain of conditional statements from any one of the proposition to any other propositions.

1 2 3

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

Can you nd what is wrong in the following proof of the statement If n2 is positive, then n is positive?

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

Can you nd what is wrong in the following proof of the statement If n2 is positive, then n is positive?

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

Can you nd what is wrong with the following proof of the theorem n2 is an even integer implies n is an even integer?

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

Can you nd what is wrong with the following proof of the theorem n2 is an even integer implies n is an even integer?

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.

The only consecutive positive integers not exceeding 100 that are perfect powers are 8 and 9. (An integer n is a perfect power if there exists two integers m and k > 1 such that n = mk ).

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.

The only consecutive positive integers not exceeding 100 that are perfect powers are 8 and 9. (An integer n is a perfect power if there exists two integers m and k > 1 such that n = mk ). An exhaustive proof of this statement can be done by constructing a table consisting all possible example of numbers not exceeding 100 and of the form mk . This method is suitable only because the size of the table is relatively small. If you must prove the result for integers not exceeding 1000, this method would be too difcult and tedious.

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 Adila A. Krisnadhi

Faculty of Computer Science, University of Indonesia

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

{x1 , x2 , x3 . . . , xn } for sets with nite number of elements {x1 , x2 , x3 . . . } for sets with innite number of elements

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

Two sets A and B are equal (written A = B) iff A and B have the same elements. Otherwise, they are not equal and written as A = B. A = B iff x(x A x B) is true.

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

{1, 3, 5} = {3, 5, 1} (the order is not important) {1, 3, 5} {3, 5, 1} {1, 3, 5} N {1, 3, 5} {3, 1} and {1, 3, 5} {x N | x is even}

For every set S S SS

For every two sets A and B, A = B iff A B and B A

Set: basics

Set operations

Denition

Let S be a set. S is a nite set iff it has exactly n elements where n is nonnegative integer. Here, n is called the cardinality of S. The cardinality of S is denoted by |S| S is innite iff it is not nite. Let A be the set of odd positive integer less than 10. Then A is nite (its cardinality |A| is 5). || = 0. The set of positive integers is innite.

Set: basics

Set operations

Denition

Let S be a set. The power set of S is the set of all subsets of S. The power set of S is denoted by P(S) or sometimes 2S . The power set of the set {0, 1, 2} is P({0, 1, 2}) = {, {0}, {1}, {2}, {0, 1}, {0, 2}, {1, 2}, {0, 1, 2}} The power set of the empty set is P() = {}. The power set of the set {} is P({}) = {, {}}

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

Denition

The union of the sets A and B is A B = {x | x A x B}. The intersection of the sets A and B is A B = {x | x A x B}. Two sets A and B are disjoint iff A B = . The difference of the sets A and B is A B = A \ B = {x | x A x B}. / A \ B is also called the complement of B with respect to A. Assuming that we have a universal set S, the complement of a set A is AC = A = S \ A = {x | x A}. /

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

Due to associativity, A (B C) or (A B) C can be written as A B C. Similarly, A (B C) and (A B) C can be written as A B C. For n 3 sets A1 , A2 , . . . , An , their intersection can be written as

n

Ai =

i=1

{Ai , i = 1, 2, . . . , n} = A1 A2 . . . An

n

Ai =

i=1

{Ai , i = 1, 2, . . . , n} = A1 A2 . . . An

Functions, Sequences and Summations

Adila A. Krisnadhi

Faculty of Computer Science, University of Indonesia

Functions

Outline

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

If f is a function from A to B, we say that

A is the domain of f B is the codomain of f

b is the image of a a is the preimage of b

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 f1 and f2 be functions from A to R. Then

f1 + f2 is a function from A to R dened by (f1 + f2 )(x) = f1 (x) + f2 (x) f1 f2 is a function from A to R dened by (f1 f2 )(x) = f1 (x)f2 (x)

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

Let f : A B be a function. f is increasing iff x, y A : x < y f (x) f (y ) f is strictly increasing iff x, y A : x < y f (x) < f (y ) f is decreasing iff x, y A : x < y f (x) f (y ) f is strictly decreasing iff x, y A : x < y f (x) > f (y )

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?

f is one-to-one, because for every x1 , x2 Z, x1 + 1 = x2 + 1 implies x1 = x2 . f is onto, because for every y Z, there is an x Z such that f (x) = y by taking x = y 1. f is bijective. Why? f is strictly increasing. 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

f f 1 = idA where id : A A is the identity function on A, i.e., id(x) = x; f 1 f = idB where id : B B is the identity function on A, i.e., id(x) = x; If A = B, then f f 1 = f 1 f = idA (f 1 )1 = f .

Functions Sequences

Sequences

Denition (Informal denition)

A sequence is an ordered list of terms.

A sequence is a function from a subset of the set of integers (typically the set {0, 1, 2, . . . } or {1, 2, 3, . . . }) to a set S. We use the notation {an } to denote a sequence (DO NOT confuse it with sets) where we can either describe the form of an and/or list the terms of the sequence in order of increasing subscripts.

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

When you want to deduce a formula for the terms of a sequence, try to answer the following questions: Are there runs of the same value? I.e., does the same value occur many times in a row? Are terms obtained from previous terms by adding the same amount or an amount that depends on the position in the sequence? Are terms obtained from previous terms by multiplying by a particular amount? Are terms obtained by combining previous terms in a certain way? Are there cycles among the terms?

Functions Sequences

Examples

1, 1/2, 1/4, 1/8, . . . . 1, 3, 5, 7, 9, . . . . 1, 1, 1, 1, . . . .

1, 2, 2, 3, 3, 3, 4, 4, 4, 4, . . . . 5, 11, 17, 23, 29, 35, 41, 47, 53, 59, . . . .

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

Summations can be nested. E.g.:

4 3 4

ij =

i=1 j=1 i=1 4

(i + 2i + 3i)

=

i=1

6i

= 6 + 12 + 18 + 24 = 60

Functions Summations

Summations can be nested. E.g.:

4 3 4

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

n

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.

Integers

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

Let a, b and c are integers. Then if (a | b) and a | c, then a | (b + c) if a | b, then a | bc, for all integers c if a | b and b | c, then a | c.

Suppose a | b and a | c. Then, by denition of division, there are integers s and t such that b = as and c = at. Hence, b + c = as + at = a(s + t) Therefore, a divides b + c, i.e., a | (b + c).

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).

Theorem

Let a be an integer and d a positive integer. Then there are unique integers q and r , with 0 r < d such that a = dq + r . The proof of this theorem uses the so-called well-ordering property of nonnegative integers (optional part of this course). In the above theorem, d is called the divisor, a is called the dividend, q is called the quotient, and r is called the remainder. The notation used to express the quotient and remainder: q = a div d, r = a mod d

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.

Theorem

Let m be a positive integer. The integers a and b are congruent modulo m iff there is an integer k such that a = b + km

Theorem

Let m be a positive integer. The integers a and b are congruent modulo m iff there is an integer k such that a = b + km

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.

Theorem (Addition and multiplication with congruences)

Let m be a positive integer. If a b ( mod m) and c d ( mod m), then a + c b + d ( mod m) and ac bd ( mod m)

Theorem (Addition and multiplication with congruences)

Let m be a positive integer. If a b ( mod m) and c d ( mod m), then a + c b + d ( mod m) and ac bd ( mod 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)

Corollary

Let m be a positive integers and let a and b be integers. Then (a + b) mod m = ((a mod m) + (b mod m)) mod m and ab mod m = ((a mod m)(b mod m)) mod m For the proof, read Rosens book page 205. Note: although the we can do addition and multiplication with congruences, some properties are NOT valid:

if ac bc( mod m), the congruence a b( mod m) may be FALSE. if a b( mod m) and c d( mod m), the congruence ac bd ( mod m) may be FALSE.

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

Every positive integer greater than 1 can be written uniquely as a prime or the product of two or more primes where the prime factors are written in order of nondecreasing size.

Every positive integer greater than 1 can be written uniquely as a prime or the product of two or more primes where the prime factors are written in order of nondecreasing size. The prime factorization of 100, 641, 999, 1024 are:

Every positive integer greater than 1 can be written uniquely as a prime or the product of two or more primes where the prime factors are written in order of nondecreasing size. The prime factorization of 100, 641, 999, 1024 are: 100 = 2 2 5 5 = 22 52 .

Every positive integer greater than 1 can be written uniquely as a prime or the product of two or more primes where the prime factors are written in order of nondecreasing size. The prime factorization of 100, 641, 999, 1024 are: 100 = 2 2 5 5 = 22 52 . 641 = 641

Every positive integer greater than 1 can be written uniquely as a prime or the product of two or more primes where the prime factors are written in order of nondecreasing size. The prime factorization of 100, 641, 999, 1024 are: 100 = 2 2 5 5 = 22 52 . 641 = 641 999 = 3 3 3 37 = 33 37

Every positive integer greater than 1 can be written uniquely as a prime or the product of two or more primes where the prime factors are written in order of nondecreasing size. The prime factorization of 100, 641, 999, 1024 are: 100 = 2 2 5 5 = 22 52 . 641 = 641 999 = 3 3 3 37 = 33 37 1024 = 2 2 2 2 2 2 2 2 2 2 = 210

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 ratio of number of primes not exceeding x and x/ ln x approaches 1 as x grows without bound, where ln x is the natural logarithm of x.

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)

Integers and Algorithms

Adila A. Krisnadhi

Faculty of Computer Science, University of Indonesia

Representation of Integers

Euclidean Algorithm

Outline

23

Representation of Integers

24

Euclidean Algorithm

Representation of Integers

Euclidean Algorithm

Let b be a positive integer greater than 1. Then if n is a positive integer, it can be expressed uniquely in the form n = ak bk + ak 1 bk 1 + + a1 b + a0

The base b expansion of n is denoted by (ak ak 1 . . . a1 a0 )b , e.g., (245)8 represents 2 82 + 4 8 + 5 = 165. The base 10 expansion of integers is called decimal expansion. The base 2 expansion of integers is called binary expansion. The base 8 expansion of integers is called octal expansion. The base 16 expansion of integers is called hexadecimal expansion (using 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E, and F as digits where A through F correspond to numbers 10 through 15 in decimal).

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

Find octal expansion of 12345

Representation of Integers

Euclidean Algorithm

Find octal expansion of 12345 Take the remainders of the following divisions: 12345 = 8 1543 + 1 1543 = 8 192 + 7 192 = 8 24 + 0 24 = 8 3 + 0 3=80+3 Hence, (12345)10 = (30071)8 Find hexadecimal expansion of (177130)10 . Find binary expansion of (241)10 .

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.

- List of Mathematical Symbols for use in social sciencesUploaded byAnish S.Menon
- Essay#2Uploaded byMelba O. Cruz
- Writing skillUploaded byLingChiann玲倩
- Concession ParagraphsUploaded bySoumyabrata Barik
- Describe Bar ChartUploaded bysrem_cantik
- Saharon Shelah- Very weak zero one law for random graphs with order and random binary functionsUploaded byJgfm2
- Chapter 12Uploaded byBayerischeMotorenWer
- Argumentative EssayUploaded byJeremy Ender
- PHIL2D03-EssayRubricUploaded byfabrajl
- s1001 ActivitiesUploaded byMilton Moto
- SymbolsUploaded byArnold Dimaano
- Se Ep01 ActivityUploaded bySofia Bulgaru
- paper3Uploaded byAhmed Gouda
- cover letter outcome portfolioUploaded byapi-242803924
- cover letterUploaded byapi-242812851
- parents guide to student successUploaded byapi-243270471
- persuasive essay rubricUploaded byapi-288279463
- data analysis--answersUploaded byapi-286974387
- egg harbor township school curriculum sampleUploaded byapi-315987964
- 1984 argumenative refelctionUploaded byapi-318701980
- Essay Proposal Template and GuidelinesUploaded byS
- reflection 5 1Uploaded byapi-353102329
- Discrete BookUploaded byGvantsa
- Essay WritingUploaded byhh
- Overall Written ProductionUploaded byretno wulandari
- DSCS_RL_2.1Uploaded byAdil Rashid
- reflection essayUploaded byapi-384774722
- Academic writing ppt.Uploaded byMagdalena
- Lecture 2Uploaded byMaricar Balmes
- writing and readin examUploaded byapi-479346813

- Checkpoint Mar Apr11Uploaded byDan Romuald
- UT Dallas Syllabus for eedg6375.501.11s taught by William Swartz (wps100020)Uploaded byUT Dallas Provost's Technology Group
- Application FormUploaded bySherif M. Dabour
- Effect of particle size and temperature on rheological, thermal, and structural properties of pumpkin flour dispersion 2014.pdfUploaded byDiana Maria Amaya Cruz
- AMCP 706-181 Explosions in Air Pt 1 [Opt-Linked]Uploaded bySam Larter
- Ethics Case Digests 1Uploaded byKim Salazar
- taxa de jurosUploaded byCarolina Oliveira
- Code of Civil Procedure With CaselawUploaded bySmart
- Teng v SECUploaded byAnonChie
- Parseval's TheoremUploaded byLucas Gallindo
- Lovett 2015 Cost and Delay of Railroad Timber and ConcreteUploaded byStefanBelibou
- Case StudyUploaded byMahfuzul Islam Shopan
- Program Pecutan2Uploaded byAdyfairos Nayah
- Windows Kernel Internals Virtual Memory Manager.pdfUploaded bytamthientai
- iec62539 = enUploaded byBrisner Acosta Valencia
- Respuestas - Step 2 Thinking AheadUploaded byRaul Aviña
- Escano v OrtigasUploaded byTooMUCHcandy
- ITR 2Q13Uploaded byKlabin_RI
- 73982767Uploaded byDali Wu
- natrescase1Uploaded byPeperonii
- 27844v2a learners guideUploaded byapi-324415177
- How to Setup a Freight Charge Modifier for Application at the Line LevelUploaded byMegha Vijay
- Service Marketing Unit 2Uploaded byRam Vasu
- Measurement of Refractive IndexUploaded byKarl Roderno
- Why Modeling Averages is Not Good EnoughUploaded byquentin3
- Saadi ShiraziUploaded byJatinder Bhatia
- The State of PastoralismUploaded byOxfam
- Grammar TerminologyUploaded byil_memo
- Status of Portfolio Implementation and Teachers’ Belief of Its Contributions to their Professional Development and Students’ LearningUploaded byAlexander Decker
- Can Women PreachUploaded byPat Ruth Holliday