Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
santos-discrete_math_lecture_notes_2.pdf
Скачиваний:
24
Добавлен:
16.03.2016
Размер:
691.48 Кб
Скачать

Chapter 3

Logic, Sets, and Boolean Algebra

3.1 Logic

96 Definition A boolean proposition is a statement which can be characterised as either true or false .

Whether the statement is obviously true or false does not enter in the definition. One only needs t o know that its certainty can be established.

97 Example The following are boolean propositions and their values, if known:72 = 49. ( true )

5 > 6. ( false )

If p is a prime then p is odd. ( false )

There exists infinitely many primes which are the sum of a squa re and 1. (unknown)

There is a G-d. (unknown)

There is a dog. ( true )

I am the Pope. ( false )

Every prime that leaves remainder 1 when divided by 4 is the sum of two squares. ( true )

Every even integer greater than 6 is the sum of two distinct primes. (unknown)

98 Example The following are not boolean propositions, since it is impossible to assign a true or false value to them.

Whenever I shampoo my camel.

Sit on a potato pan, Otis!

y x.

This sentence is false.

99 Definition A boolean operator is a character used on boolean propositions. Its output is either true or false

We will consider the following boolean operators in these notes. They are listed in order of operator precedence and their evaluation rules are given in Table 3.1.

¬ (not or negation),

(and or conjunction)

(or or disjunction)

= (implies)

= (equals)

¬has right-to-left associativity, all other operators listed have left-to-right associativity.

The = or is inclusive, meaning that if a b then either a is true, or b is true, or both a and b are true.

26

Logic

 

 

 

 

 

27

 

 

 

 

 

a b

a) (a b) (a b) (a = b) (a = b)

 

 

F

F

T

F

F

T

T

 

 

F

T

T

F

T

T

F

 

 

T

F

F

F

T

F

F

 

 

T

T

F

T

T

T

T

 

 

 

 

 

 

 

 

 

 

Table 3.1: Evaluation Rules

100 Example Consider the propositions:

a : I will eat my socks.

b : It is snowing.

c : I will go jogging.

The sentences below are represented by means of logical operators.

(b ¬b) = c: Whether or not it is snowing, I will go jogging.

b = ¬c: If it is snowing, I will not go jogging.

b = (a ¬c): If it is snowing, I will eat my socks, but I will not go jogging.

101 Example ¬a = a b is equivalent to a) = (a b) upon using the precedence rules.

102 Example a = b = c is equivalent to (a = b) = c upon using the associativity rules.

103 Example a ¬b = c is equivalent to (a ¬b) = c by the precedence rules.

104 Example Write a code fragment that accepts three numbers, decides whether they form the sides of a triangle.

Solution: First we must have a > 0, b > 0, c > 0. Sides of length a, b, c form a triangle if and only they satisfy the triangle inequalities::

a + b > c,

b + c > a, c + a > b.

Algorithm 3.1.1: ISITATRIANGLE((a, b, c))

if ((a > 0) and (b > 0) and (c > 0)

and ((a + b > c) and (b + c > a) and (c + a > b)) then istriangle true

else istriangle false

return (istriangle)

105 Definition A truth table is a table assigning all possible combinations of T or F to the variables in a proposition. If there are n variables, the truth table will have 2n lines.

106 Example Construct the truth table of the proposition a ¬b c.

Solution: Since there are three variables, the truth table will have 23 = 8 lines. Notice that by the precedence rules the given proposition is equivalent to a b c), since has higher precedence than . The truth table is in Table 3.2.

107 Definition Two propositions are said to be equivalent if they have the same truth table. If proposition P is equivalent to proposition Q we write P = Q.

27

28

 

 

 

 

 

 

Chapter 3

 

 

 

 

 

 

 

a b c

b)

b c)

a b c)

 

 

F

F

F

T

F

F

 

 

F

F

T

T

T

T

 

 

F

T

F

F

F

F

 

 

F

T

T

F

F

F

 

 

T

F

F

T

F

T

 

 

T

F

T

T

T

T

 

 

T

T

F

F

F

T

 

 

T

T

T

F

F

T

 

 

 

 

 

 

 

 

 

Table 3.2: Example 106.

 

 

a

a)

(¬(¬a))

 

 

 

F

T

F

 

 

 

T

F

T

 

 

 

 

 

 

 

 

Table 3.3: Theorem 108.

108

Theorem (Double Negation) ¬(¬a) = a.

 

 

 

 

Proof: From the truth table 3.3 the entries for a and ¬(¬a) produce the same output, proving the assertion.

109

Theorem (De Morgan's Rules) ¬(a b) = ¬a ¬b and ¬(a b) = ¬a ¬b.

 

Proof: Truth table 3.4 proves that ¬(a b) = ¬a ¬b and truth table 3.5 proves that ¬(a b) = ¬a ¬b.

a b

(a b)

¬(a b)

a)

b)

a ¬b)

F

F

F

T

T

T

T

F

T

T

F

T

F

F

T

F

T

F

F

T

F

T

T

T

F

F

F

F

 

 

 

 

 

 

 

a b

(a b)

¬(a b)

a)

b)

a ¬b)

F

F

F

T

T

T

T

F

T

F

T

T

F

T

T

F

F

T

F

T

T

T

T

T

F

F

F

F

 

 

 

 

 

 

 

Table 3.4: ¬(a b) = ¬a ¬b . Table 3.5: ¬(a b) = ¬a ¬b.

110 Example Negate A ¬B.

Solution: Using the De Morgan Rules and double negation: ¬(A ¬B) = ¬A ¬(¬B) = ¬A B.

111 Example Let p and q be propositions. Translate into symbols: either p or q is true, but not both simultaneously.

Solution: By the conditions of the problem, if p is true then q must be false, which we represent as p ¬q. Similarly if q is true, p must be false and we must have ¬p q. The required expression is thus

( p ¬q) (¬p q).

112 Definition A predicate is a sentence containing variables, whose truth or falsity depends on the values assigned to the variables.

113 Definition (Existential Quantifier) We use the symbol to mean “there exists.”

114 Definition (Universal Quantifier) We use the symbol to mean “for all.”

28

Sets

29

Observe that ¬ = and ¬ = .

115 Example Write the negation of ( n N)( x ]0; +[)(nx < 1).

Solution: Since ¬( n N) = ( n N), ¬( x ]0; +[) = ( x ]0; +[) and ¬(nx < 1) = (nx 1), the required statement is

( n N)( x ]0; +[)(nx 1).

3.2 Sets

We will consider a set naively as a collection of objects called elements. We use the boldface letters N to denote the natural numbers (nonnegative integers) and Z to denote the integers. The boldface letters R and C shall respectively denote the real numbers and the complex numbers.

If S is a set and the element x is in the set, then we say that x belongs to S and we write this as x S. If x does not belong to S we write x 6 S. For example if S = {n N : n is the square of an integer }, then 4 S but 2 6 S. We denote by card (A) the cardinality of A, that is, the number of elements that A has.

If a set A is totally contained in another set B, then we say that A is a subset of B and we write this as A B (some authors use the notation A B). For example, if S = {squares of integers}, then A = {1, 4, 9, 16} is a subset of S. If x A such that x 6 B, then A is not a subset of B, which we write as A 6 B. Two sets A and B are equal if A B and B A.

116 Example Find all the subsets of {a, b, c}.

Solution: They are

S1

=

 

S2

=

{a}

S3

=

{b}

S4

=

{c}

S5

= {a, b}

S6

= {b, c}

S7

= {c, a}

S8

=

{a, b, c}

117 Example Find all the subsets of {a, b, c, d}.

Solution: The idea is the following. We use the result of example 116. Now, a subset of {a, b, c, d} either contains d or it does not. Since the subsets of {a, b, c} do not contain d, we simply list all the subsets of {a, b, c} and then to each one of them we add d. This gives

S1

=

S9

= {d}

S2

= {a}

S10

= {a, d}

S3

= {b}

S11

= {b, d}

S4

= {c}

S12

= {c, d}

S5

= {a, b}

S13

= {a, b, d}

S6

= {b, c}

S14

= {b, c, d}

S7

= {c, a}

S15

= {c, a, d}

S8

= {a, b, c}

S16

= {a, b, c, d}

118 Theorem A finite n-element set has 2n subsets.

Proof: We use induction and the idea of example 117. Clearly a set A with n = 1 elements has 21 = 2 subsets: and A itself. Assume every set with n 1 elements has 2n1 subsets. Let B be a set with n elements. If x B then B \{x} is a set with n 1 elements and so by the induction hypothesis it has 2n1 subsets. For each subset S B \{x} we form the new subset S {x}. This is a subset of B. There are 2n1 such new subsets, and so B has a total of 2n1 + 2n1 = 2n subsets.

119 Definition The union of two sets A and B, is the set

A B = {x : (x A) (x B)}.

29

30

Chapter 3

This is read “ A union B.” See figure

3.1. The intersection of two sets A and B, is

A B = {x : (x A) (x B)}.

This is read “ A intersection B.” See figure 3.2. The difference of two sets A and B, is

A \B = {x : (x A) (x 6B)}.

This is read “ A set minus B.” See figure 3.3.

 

 

 

{A

 

 

 

A

A B

A B

A B

 

Figure 3.1: A B

Figure 3.2: A B

Figure 3.3: A \B

Figure 3.4: {A

120 Definition Let A X . The complement of A with respect to X is {A = X \A.

Observe that {A is all that which is outside A. Usually we assume that A is a subset of some universal set U which is tacitly understood. The complement {A represents the event that A does not occur. We represent {A pictorially as in figure 3.4.

121 Example Let U = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9} be the universal set of the decimal digits and let A = {0, 2, 4, 6, 8} U be the set of even digits. Then {A = {1, 3, 5, 7, 9} is the set of odd digits.

Observe that

 

{A A = .

(3.1)

We also have the De Morgan Laws: if A and B share the same universal set, we have

 

{(A B) = {A ∩{B,

(3.2)

{(A B) = {A {B.

(3.3)

We will now prove one of the De Morgan's Rules.

 

122 Example Prove that {(A B) = {A ∩{B.

Solution: Let x {(A B). Then x 6A B. Thus x 6A x 6B, that is, x {A x {B. This is the same as x {A ∩ {B. Therefore

{(A B) {A ∩{B.

Now, let x {A ∩{B. Then x {A x {B. This means that x 6A x 6B or what is the same x 6A B. But this last statement asserts that x {(A B). Hence {A ∩{B {(A B).

Since we have shown that the two sets contain each other, it must be the case that they are equal.

123 Example Prove that A \(B C) = (A \B) ∩(A \C).

Solution: We have

x A \(B C) x A x 6(B C)

(x A) ((x 6B) (x 6C))

(x A x 6B) (x A x 6C)(x A \B) (x A \C)

x (A \B) ∩(A \C)

30

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]