February 25, 2002Applied Discrete Mathematics Week 5: Mathematical Reasoning 1 Addition of Integers...

28
February 25, 2002 Applied Discrete Mathematics Week 5: Mathematical Reasoning 1 Addition of Integers Addition of Integers How do we (humans) add two integers? How do we (humans) add two integers? Example: Example: 7583 7583 + + 4932 4932 5 5 1 1 5 5 2 2 1 1 1 1 1 1 1 1 carry carry Binary expansions: Binary expansions: (1011) (1011) 2 + + (1010) (1010) 2 1 1 0 0 carry carry 1 1 1 1 0 0 1 1 1 1 ( ( ) ) 2

Transcript of February 25, 2002Applied Discrete Mathematics Week 5: Mathematical Reasoning 1 Addition of Integers...

February 25, 2002 Applied Discrete MathematicsWeek 5: Mathematical Reasoning

1

Addition of IntegersAddition of Integers

How do we (humans) add two integers?How do we (humans) add two integers?

Example: Example: 75837583 + + 49324932

5511552211

111111 carrycarry

Binary expansions: Binary expansions: (1011)(1011)22

+ + (1010)(1010)22

1100

carrycarry11

1100

11

11(( ))22

February 25, 2002 Applied Discrete MathematicsWeek 5: Mathematical Reasoning

2

Addition of IntegersAddition of Integers

Let a = (aLet a = (an-1n-1aan-2n-2…a…a11aa00))22, b = (b, b = (bn-1n-1bbn-2n-2…b…b11bb00))2.2.

How can we How can we algorithmically algorithmically add these two add these two binary numbers?binary numbers?First, add their rightmost bits:First, add their rightmost bits:

aa00 + b + b00 = c = c002 + s2 + s00,,

where swhere s00 is the is the rightmost bitrightmost bit in the binary in the binary expansion of a + b, and cexpansion of a + b, and c00 is the is the carrycarry..

Then, add the next pair of bits and the carry:Then, add the next pair of bits and the carry:

aa11 + b + b1 1 + c+ c00 = c = c112 + s2 + s11,,

where swhere s11 is the is the next bitnext bit in the binary expansion in the binary expansion of a + b, and cof a + b, and c11 is the carry. is the carry.

February 25, 2002 Applied Discrete MathematicsWeek 5: Mathematical Reasoning

3

Addition of IntegersAddition of Integers

Continue this process until you obtain cContinue this process until you obtain cn-1n-1..

The leading bit of the sum is sThe leading bit of the sum is snn = c = cn-1n-1..

The result is:The result is:

a + b = (sa + b = (snnssn-1n-1…s…s11ss00))22

February 25, 2002 Applied Discrete MathematicsWeek 5: Mathematical Reasoning

4

Addition of IntegersAddition of Integers

Example:Example:Add a = (1110)Add a = (1110)22 and b = (1011) and b = (1011)22..

aa00 + b + b00 = 0 + 1 = 0 = 0 + 1 = 02 + 1, so that c2 + 1, so that c00 = 0 and s = 0 and s00 = 1. = 1.

aa11 + b + b1 1 + c+ c00 = 1 + 1 + 0 = 1 = 1 + 1 + 0 = 12 + 0, so c2 + 0, so c11 = 1 and s = 1 and s11 = 0. = 0.

aa22 + b + b2 2 + c+ c11 = 1 + 0 + 1 = 1 = 1 + 0 + 1 = 12 + 0, so c2 + 0, so c22 = 1 and s = 1 and s22 = 0. = 0.

aa33 + b + b3 3 + c+ c22 = 1 + 1 + 1 = 1 = 1 + 1 + 1 = 12 + 1, so c2 + 1, so c33 = 1 and s = 1 and s33 = 1. = 1.

ss44 = c = c33 = 1. = 1.

Therefore, s = a + b = (11001)Therefore, s = a + b = (11001)22..

February 25, 2002 Applied Discrete MathematicsWeek 5: Mathematical Reasoning

5

Addition of IntegersAddition of Integers

procedure procedure add(a, b: positive integers)add(a, b: positive integers)c := 0c := 0for j := 0 to n-1for j := 0 to n-1beginbegin

d := d := (a(ajj + b + bjj + c)/2 + c)/2ssjj := a := ajj + b + bjj + c – 2d + c – 2dc := dc := d

endendssnn := c := c{the binary expansion of the sum is (s{the binary expansion of the sum is (snnssn-1n-1……ss11ss00))22}}

February 25, 2002 Applied Discrete MathematicsWeek 5: Mathematical Reasoning

6

MatricesMatricesA A matrixmatrix is a rectangular array of numbers. is a rectangular array of numbers.A matrix with m rows and n columns is called A matrix with m rows and n columns is called ananmmn matrix.n matrix.

Example:Example:

083.05.2

11A is a 3is a 32 matrix.2 matrix.

A matrix with the same number of rows and A matrix with the same number of rows and columns is called columns is called squaresquare..

Two matrices are Two matrices are equalequal if they have the same if they have the same number of rows and columns and the number of rows and columns and the corresponding entries in every position are corresponding entries in every position are equal. equal.

February 25, 2002 Applied Discrete MathematicsWeek 5: Mathematical Reasoning

7

MatricesMatricesA general description of an mA general description of an mn matrix A = [an matrix A = [aijij]: ]:

mnmm

n

n

aaa

aaaaaa

A

............

...

...

21

22221

11211

inii aaa ...,,, 21

mj

j

j

a

aa

.

.

.2

1

i-th row of Ai-th row of A

j-th column j-th column

of A of A

February 25, 2002 Applied Discrete MathematicsWeek 5: Mathematical Reasoning

8

Matrix AdditionMatrix Addition

Let A = [aLet A = [aijij] and B = [b] and B = [bijij] be m] be mn matrices.n matrices.The sum of A and B, denoted by A+B, is the mThe sum of A and B, denoted by A+B, is the mnnmatrix that has amatrix that has aijij + b + bijij as its (i, j)th element. as its (i, j)th element.In other words, A+B = [aIn other words, A+B = [aijij + b + bijij]. ].

Example:Example:

17141103

146395

038412

February 25, 2002 Applied Discrete MathematicsWeek 5: Mathematical Reasoning

9

Matrix MultiplicationMatrix Multiplication

Let A be an mLet A be an mk matrix and B be a kk matrix and B be a kn matrix.n matrix.The The productproduct of A and B, denoted by AB, is the of A and B, denoted by AB, is the mmnnmatrix with (i, j)th entry equal to the sum of matrix with (i, j)th entry equal to the sum of the products of the corresponding elements the products of the corresponding elements from the i-th row of A and the j-th column of B.from the i-th row of A and the j-th column of B.

In other words, if AB = [cIn other words, if AB = [cijij], then], then

tj

k

titkjikjijiij babababac

1

2211 ...

February 25, 2002 Applied Discrete MathematicsWeek 5: Mathematical Reasoning

10

Matrix MultiplicationMatrix MultiplicationA more intuitive description of calculating C = AB: A more intuitive description of calculating C = AB:

011500412103

A

4310

12B

- Take the first column of B - Take the first column of B - Turn it counterclockwise by 90Turn it counterclockwise by 90 and and superimpose superimpose it on the first row of A it on the first row of A - Multiply corresponding entries in A and B andMultiply corresponding entries in A and B and add the products: 3 add the products: 32 + 02 + 00 + 10 + 13 = 9 3 = 9 - Enter the result in the upper-left corner of C Enter the result in the upper-left corner of C

February 25, 2002 Applied Discrete MathematicsWeek 5: Mathematical Reasoning

11

Matrix MultiplicationMatrix Multiplication

- Now superimpose the first column of B on the Now superimpose the first column of B on the second, third, …, m-th row of A to obtain the second, third, …, m-th row of A to obtain the entries in the first column of C (same order). entries in the first column of C (same order).

- Then repeat this procedure with the second, Then repeat this procedure with the second, third, …, n-th column of B, to obtain to obtain third, …, n-th column of B, to obtain to obtain the remaining columns in C (same order). the remaining columns in C (same order).

- After completing this algorithm, the new matrixAfter completing this algorithm, the new matrix C contains the product AB. C contains the product AB.

February 25, 2002 Applied Discrete MathematicsWeek 5: Mathematical Reasoning

12

Matrix MultiplicationMatrix Multiplication

Let us calculate the complete matrix C: Let us calculate the complete matrix C:

011500412103

A

4310

12B

C9988

1515-2-2

7715152020-2-2

February 25, 2002 Applied Discrete MathematicsWeek 5: Mathematical Reasoning

13

Identity MatricesIdentity MatricesThe The identity matrix of order nidentity matrix of order n is the n is the nn matrix n matrix IInn = [ = [ijij], where ], where ij ij = 1 if i = j and = 1 if i = j and ij ij = 0 if i = 0 if i j: j:

1...00.........0...100...01

A

Multiplying an mMultiplying an mn matrix A by an identity n matrix A by an identity matrix of appropriate size does not change this matrix of appropriate size does not change this matrix:matrix:

AIAInn = I = ImmA = AA = A

February 25, 2002 Applied Discrete MathematicsWeek 5: Mathematical Reasoning

14

Powers and Transposes of Powers and Transposes of MatricesMatrices

The The power functionpower function can be defined for can be defined for squaresquare matrices. If A is an nmatrices. If A is an nn matrix, we have:n matrix, we have:

AA00 = I = Inn,,AArr = AAA…A = AAA…A (r times the letter A)(r times the letter A)

The The transpose transpose of an mof an mn matrix A = [an matrix A = [aijij], ], denoted by Adenoted by Att, is the n, is the nm matrix obtained by m matrix obtained by interchanging the rows and columns of A.interchanging the rows and columns of A.

In other words, if AIn other words, if Att = [b = [bijij], the b], the bijij = a = ajiji for for i = 1, 2, …, n and j = 1, 2, …, m.i = 1, 2, …, n and j = 1, 2, …, m.

February 25, 2002 Applied Discrete MathematicsWeek 5: Mathematical Reasoning

15

Powers and Transposes of Powers and Transposes of MatricesMatrices

Example:Example:

411302tA

4310

12A

A square matrix A is called A square matrix A is called symmetricsymmetric if A = if A = AAtt..Thus A = [aThus A = [aijij] is symmetric if a] is symmetric if aij ij = a= ajiji for all for alli = 1, 2, …, n and j = 1, 2, …, m.i = 1, 2, …, n and j = 1, 2, …, m.

493921

315A

131131131

B

A is symmetric, B is not.A is symmetric, B is not.

February 25, 2002 Applied Discrete MathematicsWeek 5: Mathematical Reasoning

16

Zero-One MatricesZero-One MatricesA matrix with entries that are either 0 or 1 is A matrix with entries that are either 0 or 1 is called a called a zero-one matrixzero-one matrix. Zero-one matrices . Zero-one matrices are often used like a “table” to represent are often used like a “table” to represent discrete structures.discrete structures.

We can define Boolean operations on the We can define Boolean operations on the entries in zero-one matrices:entries in zero-one matrices:

aa bb aabb

00 00 00

00 11 00

11 00 00

11 11 11

aa bb aabb

00 00 00

00 11 11

11 00 11

11 11 11

February 25, 2002 Applied Discrete MathematicsWeek 5: Mathematical Reasoning

17

Zero-One MatricesZero-One Matrices

Let A = [aLet A = [aijij] and B = [b] and B = [bijij] be m] be mn zero-one n zero-one matrices.matrices.

Then the Then the joinjoin of A and B is the zero-one matrix of A and B is the zero-one matrix with (i, j)th entry awith (i, j)th entry aijij b bijij. The join of A and B is . The join of A and B is denoted by A denoted by A B. B.

The The meetmeet of A and B is the zero-one matrix of A and B is the zero-one matrix with (i, j)th entry awith (i, j)th entry aijij b bijij. The meet of A and B is . The meet of A and B is denoted by A denoted by A B. B.

February 25, 2002 Applied Discrete MathematicsWeek 5: Mathematical Reasoning

18

Zero-One MatricesZero-One Matrices

Example:Example:

011011

A

001110

B

Join:Join:

011111

000111101101

BA

Meet:Meet:

001010

000111101101

BA

February 25, 2002 Applied Discrete MathematicsWeek 5: Mathematical Reasoning

19

Zero-One MatricesZero-One MatricesLet A = [aLet A = [aijij] be an m] be an mk zero-one matrix and k zero-one matrix and B = [bB = [bijij] be a k] be a kn zero-one matrix.n zero-one matrix.

Then the Then the Boolean productBoolean product of A and B, of A and B, denoted by Adenoted by AB, is the mB, is the mn matrix with (i, j)th n matrix with (i, j)th entry [centry [cijij], where], where

cij = (acij = (ai1i1 b b1j1j) ) (a (ai2i2 b b2i2i) ) … … (a (aikik b bkjkj). ).

Note that the actual Boolean product symbol Note that the actual Boolean product symbol has a dot in its center.has a dot in its center.

Basically, Boolean multiplication works like the Basically, Boolean multiplication works like the multiplication of matrices, but with computing multiplication of matrices, but with computing instead of the product and instead of the product and instead of the sum. instead of the sum.

February 25, 2002 Applied Discrete MathematicsWeek 5: Mathematical Reasoning

20

Zero-One MatricesZero-One Matrices

Example:Example:

11

01A

10

10B

10

10)11()11()01()01()10()11()00()01(

BA

February 25, 2002 Applied Discrete MathematicsWeek 5: Mathematical Reasoning

21

Zero-One MatricesZero-One Matrices

Let A be a square zero-one matrix and r be a Let A be a square zero-one matrix and r be a positive integer.positive integer.

The The r-th Boolean powerr-th Boolean power of A is the Boolean of A is the Boolean product of r factors of A. The r-th Boolean product of r factors of A. The r-th Boolean power of A is denoted by Apower of A is denoted by A[r][r]..

AA[0][0] = I = Inn,,AA[r][r] = A = AAA……A A (r times the letter A)(r times the letter A)

February 25, 2002 Applied Discrete MathematicsWeek 5: Mathematical Reasoning

22

Let’s proceed to…Let’s proceed to…

Mathematical Mathematical ReasoningReasoning

February 25, 2002 Applied Discrete MathematicsWeek 5: Mathematical Reasoning

23

Mathematical ReasoningMathematical Reasoning

We need We need mathematical reasoningmathematical reasoning to to

• determine whether a mathematical determine whether a mathematical argument is argument is correct or incorrect and correct or incorrect and• construct mathematical arguments.construct mathematical arguments.

Mathematical reasoning is not only important Mathematical reasoning is not only important for conducting for conducting proofsproofs and and program program verificationverification, but also for , but also for artificial artificial intelligenceintelligence systems (drawing inferences). systems (drawing inferences).

February 25, 2002 Applied Discrete MathematicsWeek 5: Mathematical Reasoning

24

TerminologyTerminology

An An axiomaxiom is a basic assumption about is a basic assumption about mathematical structured that needs no proof.mathematical structured that needs no proof.

We can use a We can use a proofproof to demonstrate that a to demonstrate that a particular statement is true. A proof consists of a particular statement is true. A proof consists of a sequence of statements that form an argument.sequence of statements that form an argument.

The steps that connect the statements in such a The steps that connect the statements in such a sequence are the sequence are the rules of inferencerules of inference..

Cases of incorrect reasoning are called Cases of incorrect reasoning are called fallaciesfallacies..

A A theoremtheorem is a statement that can be shown to is a statement that can be shown to be true. be true.

February 25, 2002 Applied Discrete MathematicsWeek 5: Mathematical Reasoning

25

TerminologyTerminology

A A lemmalemma is a simple theorem used as an is a simple theorem used as an intermediate result in the proof of another intermediate result in the proof of another theorem.theorem.

A A corollarycorollary is a proposition that follows is a proposition that follows directly from a theorem that has been proved.directly from a theorem that has been proved.

A A conjectureconjecture is a statement whose truth is a statement whose truth value is unknown. Once it is proven, it value is unknown. Once it is proven, it becomes a theorem.becomes a theorem.

February 25, 2002 Applied Discrete MathematicsWeek 5: Mathematical Reasoning

26

Rules of InferenceRules of Inference

Rules of inferenceRules of inference provide the justification of provide the justification of the steps used in a proof.the steps used in a proof.

One important rule is called One important rule is called modus ponensmodus ponens or the or the law of detachmentlaw of detachment. It is based on the . It is based on the tautology tautology (p(p(p(pq)) q)) q. We write it in the following way: q. We write it in the following way:

ppp p q q________ qq

The two The two hypotheseshypotheses p and p p and p q are q are

written in a column, and the written in a column, and the conclusionconclusionbelow a bar, where below a bar, where means means “therefore”.“therefore”.

February 25, 2002 Applied Discrete MathematicsWeek 5: Mathematical Reasoning

27

Rules of InferenceRules of Inference

The general form of a rule of inference is:The general form of a rule of inference is:

pp11

pp22 .. .. .. ppnn________ qq

The rule states that if pThe rule states that if p11 andand p p22 andand … … andand p pnn are all true, then q is true as are all true, then q is true as well.well.

These rules of inference can be used These rules of inference can be used in any mathematical argument and do in any mathematical argument and do not not require any proof.require any proof.

February 25, 2002 Applied Discrete MathematicsWeek 5: Mathematical Reasoning

28

Rules of InferenceRules of Inference

pp__________ ppqq AdditionAddition

ppqq__________ pp SimplificatioSimplificatio

nn

pp qq__________ ppqq

ConjunctionConjunction

qq ppq q __________ pp

Modus Modus tollenstollens

ppqq qqr r __________ ppr r

Hypothetical Hypothetical syllogismsyllogism

ppqq pp__________ q q

Disjunctive Disjunctive syllogismsyllogism