28
January 30, 2002 Applied Discrete Mathematics Week 1: Logic and Sets 1 Let’s Talk About Logic Let’s Talk About Logic Logic is a system based on Logic is a system based on propositions propositions . . A proposition is a statement that is A proposition is a statement that is either either true true or or false false (not both). (not both). We say that the We say that the truth value truth value of a of a proposition is either true (T) or false proposition is either true (T) or false (F). (F). Corresponds to Corresponds to 1 1 and and 0 0 in digital circuits in digital circuits

Let’s Talk About Logic

Embed Size (px)

DESCRIPTION

Let’s Talk About Logic. Logic is a system based on propositions . A proposition is a statement that is either true or false (not both). We say that the truth value of a proposition is either true (T) or false (F). Corresponds to 1 and 0 in digital circuits. - PowerPoint PPT Presentation

Citation preview

Page 1: Let’s Talk About Logic

January 30, 2002 Applied Discrete MathematicsWeek 1: Logic and Sets

1

Let’s Talk About LogicLet’s Talk About Logic

• Logic is a system based on Logic is a system based on propositionspropositions..

• A proposition is a statement that is either A proposition is a statement that is either truetrue or or falsefalse (not both). (not both).

• We say that the We say that the truth valuetruth value of a of a proposition is either true (T) or false (F).proposition is either true (T) or false (F).

• Corresponds to Corresponds to 11 and and 00 in digital circuits in digital circuits

Page 2: Let’s Talk About Logic

January 30, 2002 Applied Discrete MathematicsWeek 1: Logic and Sets

2

Logical Operators Logical Operators (Connectives)(Connectives)

• Negation Negation (NOT)(NOT)• Conjunction Conjunction (AND)(AND)• Disjunction Disjunction (OR)(OR)• Exclusive or Exclusive or (XOR)(XOR)• Implication Implication (if – then)(if – then)• Biconditional Biconditional (if and only if)(if and only if)

Truth tables can be used to show how these Truth tables can be used to show how these operators can combine propositions to operators can combine propositions to compound propositions.compound propositions.

Page 3: Let’s Talk About Logic

January 30, 2002 Applied Discrete MathematicsWeek 1: Logic and Sets

3

Tautologies and Tautologies and ContradictionsContradictions

A tautology is a statement that is always A tautology is a statement that is always true.true.

Examples: Examples: • RR((R)R) (P(PQ)Q)((P)P)((Q)Q)

If SIf ST is a tautology, we write ST is a tautology, we write ST.T.

If SIf ST is a tautology, we write ST is a tautology, we write ST.T.

Page 4: Let’s Talk About Logic

January 30, 2002 Applied Discrete MathematicsWeek 1: Logic and Sets

4

Tautologies and Tautologies and ContradictionsContradictions

A contradiction is a statement that is alwaysA contradiction is a statement that is alwaysfalse.false.

Examples: Examples: • RR((R)R)• (((P(PQ)Q)((P)P)((Q))Q))

The negation of any tautology is a The negation of any tautology is a contradiction, and the negation of any contradiction, and the negation of any contradiction is a tautology.contradiction is a tautology.

Page 5: Let’s Talk About Logic

January 30, 2002 Applied Discrete MathematicsWeek 1: Logic and Sets

5

Propositional FunctionsPropositional Functions

Propositional function (open sentence):Propositional function (open sentence):

statement involving one or more variables,statement involving one or more variables,

e.g.: x-3 > 5.e.g.: x-3 > 5.

Let us call this propositional function P(x), Let us call this propositional function P(x), where P is the where P is the predicatepredicate and x is the and x is the variablevariable..

What is the truth value of P(2) ?What is the truth value of P(2) ? falsefalse

What is the truth value of P(8) ?What is the truth value of P(8) ?

What is the truth value of P(9) ?What is the truth value of P(9) ?

falsefalse

truetrue

Page 6: Let’s Talk About Logic

January 30, 2002 Applied Discrete MathematicsWeek 1: Logic and Sets

6

Propositional FunctionsPropositional Functions

Let us consider the propositional function Let us consider the propositional function Q(x, y, z) defined as: Q(x, y, z) defined as:

x + y = z.x + y = z.

Here, Q is the Here, Q is the predicatepredicate and x, y, and z are and x, y, and z are the the variablesvariables..

What is the truth value of Q(2, 3, 5) What is the truth value of Q(2, 3, 5) ??

truetrue

What is the truth value of Q(0, 1, What is the truth value of Q(0, 1, 2) ?2) ?What is the truth value of Q(9, -9, 0) ?What is the truth value of Q(9, -9, 0) ?

falsefalse

truetrue

Page 7: Let’s Talk About Logic

January 30, 2002 Applied Discrete MathematicsWeek 1: Logic and Sets

7

Universal QuantificationUniversal Quantification

Let P(x) be a propositional function.Let P(x) be a propositional function.

Universally quantified sentenceUniversally quantified sentence::

For all x in the universe of discourse P(x) is For all x in the universe of discourse P(x) is true.true.

Using the universal quantifier Using the universal quantifier ::

x P(x) x P(x) “for all x P(x)” or “for every x P(x)”“for all x P(x)” or “for every x P(x)”

(Note: (Note: x P(x) is either true or false, so it is a x P(x) is either true or false, so it is a proposition, not a propositional function.)proposition, not a propositional function.)

Page 8: Let’s Talk About Logic

January 30, 2002 Applied Discrete MathematicsWeek 1: Logic and Sets

8

Universal QuantificationUniversal Quantification

Example: Example:

S(x): x is a UMB student.S(x): x is a UMB student.

G(x): x is a genius.G(x): x is a genius.

What does What does x (S(x) x (S(x) G(x)) G(x)) mean ? mean ?

““If x is a UMB student, then x is a genius.”If x is a UMB student, then x is a genius.”

oror

““All UMB students are geniuses.”All UMB students are geniuses.”

Page 9: Let’s Talk About Logic

January 30, 2002 Applied Discrete MathematicsWeek 1: Logic and Sets

9

Existential QuantificationExistential Quantification

Existentially quantified sentenceExistentially quantified sentence::There exists an x in the universe of discourse There exists an x in the universe of discourse for which P(x) is true.for which P(x) is true.

Using the existential quantifier Using the existential quantifier ::x P(x) x P(x) “There is an x such that P(x).”“There is an x such that P(x).”

“ “There is at least one x such that There is at least one x such that P(x).”P(x).”

(Note: (Note: x P(x) is either true or false, so it is a x P(x) is either true or false, so it is a proposition, but no propositional function.)proposition, but no propositional function.)

Page 10: Let’s Talk About Logic

January 30, 2002 Applied Discrete MathematicsWeek 1: Logic and Sets

10

Existential QuantificationExistential Quantification

Example: Example: P(x): x is a UMB professor.P(x): x is a UMB professor.G(x): x is a genius.G(x): x is a genius.

What does What does x (P(x) x (P(x) G(x)) G(x)) mean ? mean ?

““There is an x such that x is a UMB professor There is an x such that x is a UMB professor and x is a genius.”and x is a genius.”oror““At least one UMB professor is a genius.”At least one UMB professor is a genius.”

Page 11: Let’s Talk About Logic

January 30, 2002 Applied Discrete MathematicsWeek 1: Logic and Sets

11

QuantificationQuantification

Another example:Another example:

Let the universe of discourse be the real numbers.Let the universe of discourse be the real numbers.

What does What does xxy (x + y = 320)y (x + y = 320) mean ? mean ?

““For every x there exists a y so that x + y = 320.”For every x there exists a y so that x + y = 320.”

Is it true?Is it true?

Is it true for the natural Is it true for the natural numbers?numbers?

yesyes

nono

Page 12: Let’s Talk About Logic

January 30, 2002 Applied Discrete MathematicsWeek 1: Logic and Sets

12

Disproof by CounterexampleDisproof by Counterexample

A counterexample to A counterexample to x P(x) is an object c x P(x) is an object c so that P(c) is false. so that P(c) is false.

Statements such as Statements such as x (P(x) x (P(x) Q(x)) can be Q(x)) can be disproved by simply providing a disproved by simply providing a counterexample.counterexample.

Statement: “All birds can fly.”Statement: “All birds can fly.”Disproved by counterexample: Penguin.Disproved by counterexample: Penguin.

Page 13: Let’s Talk About Logic

January 30, 2002 Applied Discrete MathematicsWeek 1: Logic and Sets

13

NegationNegation

((x P(x)) is logically equivalent to x P(x)) is logically equivalent to x (x (P(x)).P(x)).

((x P(x)) is logically equivalent to x P(x)) is logically equivalent to x (x (P(x)).P(x)).

See Table 3 in Section 1.3.See Table 3 in Section 1.3.

I recommend exercises 5 and 9 in Section 1.3.I recommend exercises 5 and 9 in Section 1.3.

Page 14: Let’s Talk About Logic

January 30, 2002 Applied Discrete MathematicsWeek 1: Logic and Sets

14

… … and now for something and now for something completely different…completely different…

Set TheorySet TheoryActually, you will see that logic Actually, you will see that logic and set theory are very closely and set theory are very closely

related.related.

Page 15: Let’s Talk About Logic

January 30, 2002 Applied Discrete MathematicsWeek 1: Logic and Sets

15

Set TheorySet Theory

• Set: Collection of objects (“elements”)Set: Collection of objects (“elements”)

• aaAA “a is an element of A” “a is an element of A” “a is a member of A” “a is a member of A”

• aaAA “a is not an element of A” “a is not an element of A”

• A = {aA = {a11, a, a22, …, a, …, ann} } “A contains…”“A contains…”

• Order of elements is meaninglessOrder of elements is meaningless

• It does not matter how often the same It does not matter how often the same element is listed.element is listed.

Page 16: Let’s Talk About Logic

January 30, 2002 Applied Discrete MathematicsWeek 1: Logic and Sets

16

Set EqualitySet Equality

Sets A and B are equal if and only if they Sets A and B are equal if and only if they contain exactly the same elements.contain exactly the same elements.

Examples:Examples:

• A = {9, 2, 7, -3}, B = {7, 9, -3, A = {9, 2, 7, -3}, B = {7, 9, -3, 2} :2} :

A = BA = B

• A = {dog, cat, horse}, A = {dog, cat, horse}, B = {cat, horse, squirrel, dog} B = {cat, horse, squirrel, dog} ::

A A B B

• A = {dog, cat, horse}, A = {dog, cat, horse}, B = {cat, horse, dog, dog} : B = {cat, horse, dog, dog} : A = BA = B

Page 17: Let’s Talk About Logic

January 30, 2002 Applied Discrete MathematicsWeek 1: Logic and Sets

17

Examples for SetsExamples for Sets

““Standard” Sets:Standard” Sets:

• Natural numbers Natural numbers NN = {0, 1, 2, 3, …} = {0, 1, 2, 3, …}

• Integers Integers ZZ = {…, -2, -1, 0, 1, 2, …} = {…, -2, -1, 0, 1, 2, …}

• Positive Integers Positive Integers ZZ++ = {1, 2, 3, 4, …} = {1, 2, 3, 4, …}

• Real Numbers Real Numbers RR = {47.3, -12, = {47.3, -12, , …}, …}

• Rational Numbers Rational Numbers QQ = {1.5, 2.6, -3.8, 15, = {1.5, 2.6, -3.8, 15, …}…}(correct definition will follow)(correct definition will follow)

Page 18: Let’s Talk About Logic

January 30, 2002 Applied Discrete MathematicsWeek 1: Logic and Sets

18

Examples for SetsExamples for Sets

• A = A = “empty set/null set”“empty set/null set”

• A = {z}A = {z} Note: zNote: zA, but z A, but z {z}{z}

• A = {{b, c}, {c, x, d}}A = {{b, c}, {c, x, d}}

• A = {{x, y}} A = {{x, y}} Note: {x, y} Note: {x, y} A, but {x, y} A, but {x, y} {{x, y}} {{x, y}}

• A = {x | P(x)}A = {x | P(x)}“set of all x such that P(x)”“set of all x such that P(x)”

• A = {x | xA = {x | xNN x > 7} = {8, 9, 10, …}x > 7} = {8, 9, 10, …}“set builder notation”“set builder notation”

Page 19: Let’s Talk About Logic

January 30, 2002 Applied Discrete MathematicsWeek 1: Logic and Sets

19

Examples for SetsExamples for Sets

We are now able to define the set of rational We are now able to define the set of rational numbers Q:numbers Q:

QQ = {a/b | a = {a/b | aZZ bbZZ++} }

or or

QQ = {a/b | a = {a/b | aZZ bbZ Z bb0} 0}

And how about the set of real numbers R?And how about the set of real numbers R?

RR = {r | r is a real number} = {r | r is a real number}

That is the best we can do.That is the best we can do.

Page 20: Let’s Talk About Logic

January 30, 2002 Applied Discrete MathematicsWeek 1: Logic and Sets

20

SubsetsSubsetsA A B B “A is a subset of B” “A is a subset of B”A A B if and only if every element of A is also B if and only if every element of A is also an element of B. an element of B.We can completely formalize this:We can completely formalize this:A A B B x (xx (xA A x xB)B)

Examples:Examples:

A = {3, 9}, B = {5, 9, 1, 3}, A A = {3, 9}, B = {5, 9, 1, 3}, A B ? B ?

truetrue

A = {3, 3, 3, 9}, B = {5, 9, 1, 3}, A A = {3, 3, 3, 9}, B = {5, 9, 1, 3}, A B ? B ?

falsefalse

truetrue

A = {1, 2, 3}, B = {2, 3, 4}, A A = {1, 2, 3}, B = {2, 3, 4}, A B ? B ?

Page 21: Let’s Talk About Logic

January 30, 2002 Applied Discrete MathematicsWeek 1: Logic and Sets

21

SubsetsSubsetsUseful rules:Useful rules:• A = B A = B (A (A B) B) (B (B A) A) • (A (A B) B) (B (B C) C) A A C C (see Venn Diagram)(see Venn Diagram)

UU

AABB

CC

Page 22: Let’s Talk About Logic

January 30, 2002 Applied Discrete MathematicsWeek 1: Logic and Sets

22

SubsetsSubsets

Useful rules:Useful rules: A for any set A A for any set A • AA A for any set A A for any set A

Proper subsets:Proper subsets:

A A B B “A is a proper subset of B”“A is a proper subset of B”

A A B B x (xx (xA A x xB) B) x (xx (xB B x xA)A)

oror

A A B B x (xx (xA A x xB) B) x (xx (xB B x xA) A)

Page 23: Let’s Talk About Logic

January 30, 2002 Applied Discrete MathematicsWeek 1: Logic and Sets

23

Cardinality of SetsCardinality of Sets

If a set S contains n distinct elements, nIf a set S contains n distinct elements, nNN,,we call S a we call S a finite setfinite set with with cardinality ncardinality n..

Examples:Examples:

A = {Mercedes, BMW, Porsche}, |A| = 3A = {Mercedes, BMW, Porsche}, |A| = 3

B = {1, {2, 3}, {4, 5}, 6}B = {1, {2, 3}, {4, 5}, 6} |B| = |B| = 44C = C = |C| = 0|C| = 0

D = { xD = { xN N | x | x 7000 } 7000 } |D| = 7001|D| = 7001

E = { xE = { xN N | x | x 7000 } 7000 } E is infinite!E is infinite!

Page 24: Let’s Talk About Logic

January 30, 2002 Applied Discrete MathematicsWeek 1: Logic and Sets

24

The Power SetThe Power Set

22AA oror P(A) P(A) “power set of A”“power set of A”

22AA = {B | B = {B | B A} A} (contains all subsets of A)(contains all subsets of A)

Examples:Examples:

A = {x, y, z}A = {x, y, z}

22A A = {= {, {x}, {y}, {z}, {x, y}, {x, z}, {y, z}, , {x}, {y}, {z}, {x, y}, {x, z}, {y, z}, {x, y, z}}{x, y, z}}

A = A = 22AA = { = {}}

Note: |A| = 0, |2Note: |A| = 0, |2AA| = 1| = 1

Page 25: Let’s Talk About Logic

January 30, 2002 Applied Discrete MathematicsWeek 1: Logic and Sets

25

The Power SetThe Power SetCardinality of power sets:Cardinality of power sets:

| 2| 2AA | = 2 | = 2|A||A|

• Imagine each element in A has an “Imagine each element in A has an “onon//offoff” switch” switch• Each possible switch configuration in A Each possible switch configuration in A

corresponds to one element in 2corresponds to one element in 2AA

AA 11 22 33 44 55 66 77 88

xx xx xx xx xx xx xx xx xx

yy yy yy yy yy yy yy yy yy

zz zz zz zz zz zz zz zz zz

• For 3 elements in A, there are For 3 elements in A, there are 22222 = 8 elements in 22 = 8 elements in 2AA

Page 26: Let’s Talk About Logic

January 30, 2002 Applied Discrete MathematicsWeek 1: Logic and Sets

26

Cartesian ProductCartesian ProductThe The ordered n-tupleordered n-tuple (a (a11, a, a22, a, a33, …, a, …, ann) is an ) is an

ordered collectionordered collection of objects. of objects.

Two ordered n-tuples (aTwo ordered n-tuples (a11, a, a22, a, a33, …, a, …, ann) and ) and

(b(b11, b, b22, b, b33, …, b, …, bnn) are equal if and only if they ) are equal if and only if they

contain exactly the same elements contain exactly the same elements in the same in the same orderorder, i.e. a, i.e. aii = b = bii for 1 for 1 i i n. n.

The The Cartesian productCartesian product of two sets is defined as: of two sets is defined as:

AAB = {(a, b) | aB = {(a, b) | aA A b bB}B}

Example:Example: A = {x, y}, B = {a, b, c} A = {x, y}, B = {a, b, c}AAB = {(x, a), (x, b), (x, c), (y, a), (y, b), (y, c)}B = {(x, a), (x, b), (x, c), (y, a), (y, b), (y, c)}

Page 27: Let’s Talk About Logic

January 30, 2002 Applied Discrete MathematicsWeek 1: Logic and Sets

27

Cartesian ProductCartesian Product

Note that:Note that:

• AA = = • A = A = • For non-empty sets A and B: AFor non-empty sets A and B: AB B A AB B B BAA

• |A|AB| = |A|B| = |A||B||B|

The Cartesian product of The Cartesian product of two or more setstwo or more sets is is defined as:defined as:

AA11AA22……AAnn = {(a = {(a11, a, a22, …, a, …, ann) | a) | aiiA for 1 A for 1 i i

n}n}

Page 28: Let’s Talk About Logic

January 30, 2002 Applied Discrete MathematicsWeek 1: Logic and Sets

28

Set OperationsSet Operations

Union: AUnion: AB = {x | xB = {x | xA A x xB}B}

Example:Example: A = {a, b}, B = {b, c, d} A = {a, b}, B = {b, c, d}

AAB = {a, b, c, d} B = {a, b, c, d}

Intersection: AIntersection: AB = {x | xB = {x | xA A x xB}B}

Example:Example: A = {a, b}, B = {b, c, d} A = {a, b}, B = {b, c, d}

AAB = {b}B = {b}