Presentation is loading. Please wait.

Presentation is loading. Please wait.

Logic - Elementary Discrete Math1 Discrete Mathematics Jim Skon Mount Vernon Nazarene College Chapter 1.

Similar presentations


Presentation on theme: "Logic - Elementary Discrete Math1 Discrete Mathematics Jim Skon Mount Vernon Nazarene College Chapter 1."— Presentation transcript:

1

2 Logic - Elementary Discrete Math1 Discrete Mathematics Jim Skon Mount Vernon Nazarene College Chapter 1

3 Logic - Elementary Discrete Math2 Discrete Mathematics §Discrete - "Consisting of unconnected parts" §Discrete/Continuous Math l pieces of ice vs. liquid water l Letter grade vs. gpa

4 Logic - Elementary Discrete Math3 Discrete Mathematics  Applications of discrete mathematics: Formal Languages (computer languages) Compiler Design Data Structures Computability Automata Theory Algorithm Design Relational Database Theory Complexity Theory (counting)

5 Logic - Elementary Discrete Math4 Discrete Mathematics  Example (counting): The Traveling Salesman Problem Important in circuit design many other CS problems

6 Logic - Elementary Discrete Math5 The Traveling Salesman Problem  Given: n cities c 1, c 2,..., c n distance between city i and j, d ij  Find the shortest tour. a c b d 3 5 4 7 2 d ab = 3

7 Logic - Elementary Discrete Math6 The Traveling Salesman Problem  Assume a very fast PC:  1 flop = 1 nanosecond = 10 -9 sec. = 1,000,000,000 ops/sec = 1 GHz.

8 Logic - Elementary Discrete Math7 The Traveling Salesman Problem  A tour requires n-1 additions. How many different tours? Choose the first city n ways, the second city n-1 ways, the third city n-2 ways, etc. a c b d 3 5 4 7 2

9 Logic - Elementary Discrete Math8 The Traveling Salesman Problem  Total number of tours n (n-1) (n-2)....(2) (1) = n! (Combinations)  Total number of additions (n-1) n! (Rule of Product)

10 Logic - Elementary Discrete Math9 The Traveling Salesman Problem  If n = 8, T(n) = 7  8! = 282,240 flops < 1/3 second.  HOWEVER

11 Logic - Elementary Discrete Math10 The Traveling Salesman Problem  If n=50, T(n) = 49  50! = 1.48  10 66 = 1.49  10 57 seconds = 2.48  10 55 minutes = 4.13  10 53 hours = 1.72  10 52 days = 2.46  10 51 weeks = 4.73  10 49 years.

12 Logic - Elementary Discrete Math11 The Traveling Salesman Problem ...a long time. You’ll be an old person before it’s finished.  There are some problems for which we do not know if efficient algorithms exist to solve them!

13 Logic - Elementary Discrete Math12 Propositions § An assertion which is either true (or 1) or false (or 0). l Today is Wednesday. l Some dogs each fish. l 4 + 2 = 5 l There exists a person who can run 100 mph. l The number of hairs on Bill Clinton’s head is 5,543,234,123. l Every natural number can be written as the sum of the squares of four natural numbers. l The equation x n + y n = z n where n > 2 and x, y, and z are positive integers has no solutions. (Fermat’s last Theorem) l Every even number greater then 4 can be written as the sum of two prime numbers.

14 Logic - Elementary Discrete Math13 Propositions §Now consider: a. Give me my book. (Imperative) b. What is my test score? (Interrogative) c. Four score and seven years ago (Clause)

15 Logic - Elementary Discrete Math14 Logical Connectives §Consider l I like rock and I like classical. l I’ll either eat at Jody’s or I will go to class. l I did not do my homework today. l I will either ride will Bill or I will walk tomorrow, but not both.

16 Logic - Elementary Discrete Math15 Logical Connectives §Proposition - Any sentence with a truth value §Simple Proposition - No connectives §Compound Proposition - made up of one or more simple Propositions linked together by connectives.

17 Logic - Elementary Discrete Math16 Logical Connectives §Examples: l I like pop music and I like classical music. l I got an A in English or I got an B in Philosophy. l You did not bring me what I wanted. l If you see my mother, then tell her where I am.

18 Logic - Elementary Discrete Math17 Logical Connectives §4 basic connectives ConnectiveNotationName of Connective not  negation and  conjunction or  disjunction if..then..  conditional, implication

19 Logic - Elementary Discrete Math18 Logical Connectives §Sentence form statements may be translated to symbolic form: If today is Wednesday and the time is 10:30 am then we should all be in chapel. P: today is Wednesday Q: time is 10:30 am R: We should all be in chapel (P  Q)  R

20 Logic - Elementary Discrete Math19 Logical Connectives §It is false that roses are red and violets are blue. l P: roses are red l Q: violets are blue  (p  q)

21 Logic - Elementary Discrete Math20 Truth Tables: Negation pppp T F F T  Negation ‘not’ Symbol:   Example: P: I am going to town  P: I am not going to town; It is not the case that I am going to town; I ain’t goin’.

22 Logic - Elementary Discrete Math21 Truth Tables: Disjunction pqp  q TT T TF T FT T FF F  Disjunction inclusive ‘or’ Symbol:   Example: P - ‘I am going to town’ Q - ‘It is going to rain’ P  Q: ‘I am going to town or it is going to rain.’

23 Logic - Elementary Discrete Math22 Truth Tables:  Conjunction ‘and’ Symbol:   Example: P - ‘I am going to town’ Q - ‘It is going to rain’ P  Q: ‘I am going to town and it is going to rain.’ Conjunction pqp  q TT T TF F FT F FF F

24 Logic - Elementary Discrete Math23 Truth Tables:  Exclusive OR Symbol:   Example: P - ‘I am going to town’ Q - ‘It is going to rain’ P  Q: ‘Either I am going to town or it is going to rain.’ Exclusive Or pqp  q TT F TF T FT T FF F

25 Logic - Elementary Discrete Math24 Truth Tables:  Implication ‘If...then...’ Symbol:   Example: P - ‘I am going to town’ Q - ‘It is going to rain’ P  Q: ‘If I am going to town then it is going to rain.’ Implication pqp  q TT T TF F FT T FF T

26 Logic - Elementary Discrete Math25 Implication  Equivalent forms: If P, then Q P implies Q If P, Q P only if Q P is a sufficient condition for Q Q if P Q whenever P Q is a necessary condition for P  Note: The implication is false only when P is true and Q is false! Implication pqp  q TT T TF F FT T FF T

27 Logic - Elementary Discrete Math26 Implication §The implication p  q is the proposition that is false when p is true and q is false and true otherwise. §p is called the hypothesis (or antecedent or premise) §q is called the conclusion (or consequence) Conditional pqp  q TT T TF F FT T FF T

28 Logic - Elementary Discrete Math27 Implication §Consider l If it is sunny, class will meet in the grove l If today is Saturday, then we will all play leap frog. l If x is even then x 2 is even If the moon is made of green cheese then I have more money than Bill Gates If the moon is made of green cheese then I’m on welfare If 1+1=3 then your grandma wears combat boots

29 Logic - Elementary Discrete Math28 Implication  implication P  Q  converse Q  P  inverse  P   Q  contrapositive  Q   P Q  P is the CONVERSE of P  Q  Q  P is the CONTRAPOSITIVE of P  Q

30 Logic - Elementary Discrete Math29 Implication implication P  Q converse Q  P inverse  P   Q contrapositive  Q   P §If it's after 10:00, then I will go to bed. §If I go to bed, then it is after 10:00. §If it's not after 10:00 then I will not go to bed. §If I do not go to bed, then it is not after 10:00.

31 Logic - Elementary Discrete Math30 Implication  Find the converse and contrapositive of the following statement: R: ‘Raining tomorrow is a sufficient condition for my not going to town.’

32 Logic - Elementary Discrete Math31 Implication Step 1: Assign propositional variables to component propositions P: It will rain tomorrow Q: I will not go to town

33 Logic - Elementary Discrete Math32 Implication Step 2: Symbolize the assertion R: P  Q Step 3: Symbolize the converse Q  P

34 Logic - Elementary Discrete Math33 Implication Step 4: Convert the symbols back into words ‘If I don’t go to town then it will rain tomorrow’ or ‘Raining tomorrow is a necessary condition for my not going to town.’ or ‘My not going to town is a sufficient condition for it raining tomorrow.’

35 Logic - Elementary Discrete Math34 Implication implication converse inverse contrapositive pq  p  qp  q q  p  p   q  q   p TTFF TTTT TFFT FTTF FTTF TFFT FFTT TTTT §Therefore: p  q  q   p,implication  contrapositive q  p   p   q, converse  inverse

36 Logic - Elementary Discrete Math35 Examples § Make a truth table for: p     q (p    q)   (p   q)    r (p   q)   ( r   q ) l p   q

37 Logic - Elementary Discrete Math36 Logical Connectives §Put in symbolic form: l I am not a mathematician. l I am not a mathematician and 2 + 2 = 5. l If I am not a mathematician then 2 + 2 = 5. l If it is raining, then I will not go to the store, and if it is not raining, then I will go to the store. l Either Frank love Mary, or Mary loves Frank, but not both.

38 Logic - Elementary Discrete Math37 Examples 1. MVNC is in Mt. Vernon or Mt. Vernon is in Russia. 2. MVNC is in Ohio and Lake Erie is in Florida. 3. If MVNC is in Ohio then Mt. Vernon is in Ohio. 4. If MVNC is in Ohio then Mt. Vernon is made of cheese. 5. If MVNC is a military school then Mt. Vernon is in Ohio. 6. If MVNC is a military school then Mt. Vernon is made of cheese.

39 Logic - Elementary Discrete Math38 Examples § Let p = True, q = False, r = True. p     q (  p    q)   (p   q)   (   p   q)  (p   q)  (r     p)

40 Logic - Elementary Discrete Math39 Logical Equivalence §How about: l If x = 2, then x 2 = 4 l If x is positive and x 2 = 4, then x = 2 l If n 2 is odd, then n is odd

41 Logic - Elementary Discrete Math40 Implication  p  q may be stated as: §"if p then q" §"p only if q" §"p is a sufficient condition for q" §"q is a necessary condition for p" §"a necessary condition for p is q" §"a sufficient condition for q is p" §"q if p" §"q follows from p" §"q is a logical consequence of p" §"q whenever p"

42 Logic - Elementary Discrete Math41 Translating English Sentences §You cannot take CS II if you have not taken CS or have not passed a c proficiency exam §Try 1.1:problem 5

43 Logic - Elementary Discrete Math42 Propositional Variables §A proposition can also be represented as a variable. Use lower case for numeric variables. Use upper case for propositional variables. Example: –Let p be “Today is Wednesday.” –Let p be “I like to eat in the MVNC cafeteria.” –Let p be “1 = 3”

44 Logic - Elementary Discrete Math43 Biconditional §Let p and q be propositions. §The biconditional p  q is the proposition that is true when p and q have the same truth values, and false otherwise. §It is BOTH the implication AND its converse § Ex: “I will eat in the cafeteria if and only if they have pizza.” biconditional pqp  q TT T TF F FT F FF T

45 Logic - Elementary Discrete Math44 Translating to English sentences §p: you like eating candy §q: you lose your teeth p  q  p  q (p  q)  p   q

46 Logic - Elementary Discrete Math45 Logic and Bit Operations §bit - two values: 0 or 1 §bit can be used to store truth values l 0 = false l 1 = true §Thus logic operators can apply

47 Logic - Elementary Discrete Math46 Bit operation Truth Tables: Negation pppp 1 0 0 1 Disjunction pqp  q 11 1 10 1 01 1 00 0 Conjunction pqp  q 11 1 10 0 01 0 00 0 Exclusive OR pqp  q 11 0 10 1 01 1 00 0

48 Logic - Elementary Discrete Math47 Bit Strings §A bit string is a sequence of zero or more 0’s and 1’s §Example l 0100010010 l 00111011 l 1111111111111 l 00100100000010101 l 0

49 Logic - Elementary Discrete Math48 Bit Strings §Bit operations can be extended to bit strings §example: 01000101 00111101 00000101 bitwise and 01111101 bitwise or 01111000 bitwise xor

50 Logic - Elementary Discrete Math49 Propositional Equivalences §Tautology - true for any values assigned to it's variables §Contradiction - never true, irregardless of values of variables. §Consider l I will either get a new car, or I won’t get a new car. l I will come tomorrow and I won’t come tomorrow

51 Logic - Elementary Discrete Math50 Propositional Equivalences §Examples p  pp   pp   p F T T F T F TautologyContradiction

52 Logic - Elementary Discrete Math51 Propositional Equivalences § Tautologies are logically true. § Contradictions are logically false. § Such statements are true or false because of it's structure rather then because of it's variables truth values.

53 Logic - Elementary Discrete Math52 Propositional Equivalences §Consider: p  (q  p) (p  q)    (p  q)

54 Logic - Elementary Discrete Math53 Logical Equivalence §Two compound statements are logically equivalent if they always have the same truth value. §Two compound statements are logically equivalent if they have the same truth tables.  If p and q are logically equivalent, then: p  q

55 Logic - Elementary Discrete Math54 Logical Equivalence  C onsider:   (p   q)  (  p    q)

56 Logic - Elementary Discrete Math55 Logical Equivalence §Logical Identities l Useful properties of logic l Similar to the properties of Algebra

57 Logic - Elementary Discrete Math56 Logical Equivalence §Properties of Identity and Dominance: p  F  p, p  T  p p  T  T, p  F  F §The idempotent properties: p  p  p, p  p  p

58 Logic - Elementary Discrete Math57 Logical Equivalence §The commutative properties: p  q  q  p p  q  q  p §The associative properties: p  (q  r)  (p  q)  r p  (q  r)  (p  q)  r

59 Logic - Elementary Discrete Math58 Logical Equivalence §The distributive properties: p  (q  r)  (p  q)  (p  r) p  (q  r)  (p  q)  (p  r)

60 Logic - Elementary Discrete Math59 Logical Equivalence §properties of Complement:  T  F,  F  T p   p  T, p   p  F  (  p)  p

61 Logic - Elementary Discrete Math60 Logical Equivalence §Demorgan's laws:  (p   q)   p   q  (p   q)   p   q

62 Logic - Elementary Discrete Math61 Logical Equivalence §Implication p  q   p  q §Negation of Implication  (p  q)  p   q

63 Logic - Elementary Discrete Math62 Logical Equivalence §If and only if p  q  (p  q)  (q  p)

64 Logic - Elementary Discrete Math63 Logical Equivalence §By Demorgan's law the negation of l I don’t like to eat apples and I don’t like to walk. §becomes l It's not true that I like to eat apples or I don't like to walk.

65 Logic - Elementary Discrete Math64 Logical Equivalence §Examples: l Try 1.2: 7, 9, 11, 13, 15, 17, 19

66 Logic - Elementary Discrete Math65 Logical Equivalence §Notice that: p  q  (p  q)  (q  p)  In order to prove a biconditional statement P  Q, we must only prove the statement p  q, and it's converse q  p. (Or perhaps by proving the inverse and the contrapositive).

67 Logic - Elementary Discrete Math66 Propositions §Free Variables l A proposition may contain variable - values not yet assigned. l Variables must be assigned values before the truth value can be assessed. § Examples l x + y = 11 l Car m the faster then car n. l There are x people in this room. l I have h hairs on my head.

68 Logic - Elementary Discrete Math67 Propositions as Functions §A proposition with variables can be written as a function: l x 2 > 4P(x) l x + 3y 2 + 8 = y + 2x 2 - 15Q(x, y) l x is the mother of yM(x, y) l Student a is in the b class S(a, b, c) and lives in apartment c. §How would we write: l 3 2 > 4 l Sally is Bill's mother l 3 + 3(2) 2 + 8 = 5 + 2(3) 2 - 15

69 Logic - Elementary Discrete Math68 Existential Quantification §Consider the proposition: l There is a person in this class with a January birthday.  Existentially quantified expression:  x : (x is in this class and x has a January birthday)

70 Logic - Elementary Discrete Math69 Existential Quantification §Consider again: l There is a person in this class with a January birthday. §Existentially quantified expression:  x : ( C(x)  JBD(x) ) §Read "There exists an x such that C(x) and JBD(x) are true.

71 Logic - Elementary Discrete Math70 Existential Quantification   - existential quantifier   x : - x is a bound variable   x : P - existentially quantified proposition

72 Logic - Elementary Discrete Math71 Existential Quantification  To show that an existentially quantified proposition  x : P is true, you must only find a single example of x which makes P true.  To show that an existentially quantified proposition  x : P is false, you must show that x possible values of x makes P false.

73 Logic - Elementary Discrete Math72 Universal Quantification §Consider the proposition: l Every student eating in the MVNC cafeteria must either have a meal ticket, or have paid at the door. §Universal quantified expression:  s : if s is eating in the cafeteria s has a meal ticket or s paid at the door.

74 Logic - Elementary Discrete Math73 Universal Quantification §Consider again: l Every student eating in the MVNC cafeteria must either have a meal ticket, or have paid at the door. §Functions: l s eating in the cafeteria C(s) l s has a meal ticketMT(s) l s paid at the doorPAID(s) §Existentially quantified expression  s : (C(s)  MT(s)  PAID(s) ) )

75 Logic - Elementary Discrete Math74 Universal Quantification §Every student eating in the MVNC cafeteria must either have a meal ticket, or have paid at the door. §Universally quantified expression  s : (C(s)  MT(s)  PAID(s) ) ) §Read "For every student s, if s is eating in the cafeteria then s has a meal ticket or s has paid at the door.

76 Logic - Elementary Discrete Math75 Universal Quantification   - universal quantifier   x : - x is a bound variable   x : P(x) - universally quantified proposition

77 Logic - Elementary Discrete Math76 Universal Quantification  To show that an universally quantified proposition  x : P is true, you must show that P holds for all values of x.  To show that an universally quantified proposition  x : P is false, you must only show at least one x for which P is false (a counter example)

78 Logic - Elementary Discrete Math77 Quantification §Consider: l For every x, x 2 > 4 if and only if x > 2 or x < -2. l There exists a number that equals it own square l For every number x > 1, there exists a number y where x < y < 2x. l There exists a number x such that for every y, y 2 > x. l Everybody has a mother and a father. l Tom and Harry have the same mother. l Nobody is their own mother. l Peter has no children.

79 Logic - Elementary Discrete Math78 Universal Quantification §The following ranger over the real numbers:  x:  y: x + y = y.  x:  y: x + y = y.  x:  y: x + y = y.  x:  y: x + y = y.

80 Logic - Elementary Discrete Math79 Universal Quantification §The following range over the integers:  x:  y: (x 2 = y 2  x = -y).  x:  y: (x = y  x > y).  x:  y: (x = y  x > y).

81 Logic - Elementary Discrete Math80 Negations of Quantified Propositions § Let P be a proposition. Then:  x:P   x:  P  x:P   x:  P

82 Logic - Elementary Discrete Math81 Negations of Quantified Propositions §Consider: l There is a student in this class with a January birthday.  x: JB(x) l It is not true that there is a a student in this class with a January birthday.  x: JB(x)   x:  JB(x)

83 Logic - Elementary Discrete Math82 Negations of Quantified Propositions l Expand domain to include all students:  x: CL(x)  JB(x)  x:  CL(x)  JB(x) )  x:  CL(x)  JB(x)

84 Logic - Elementary Discrete Math83   


Download ppt "Logic - Elementary Discrete Math1 Discrete Mathematics Jim Skon Mount Vernon Nazarene College Chapter 1."

Similar presentations


Ads by Google