Documents
Resources
Learning Center
Upload
Plans & pricing Sign in
Sign Out

Discrete Mathematics Lecture 1.ppt

VIEWS: 12 PAGES: 46

									  Discrete Structures
   Chapter 1 Part A
Fundamentals of Logic
 Nurul Amelina Nasharuddin
  Multimedia Department


                             1
          Logic of Statements
•   Logical Form and Logical Equivalence
•   Conditional Statements
•   Valid and Invalid Arguments
•   Logic of Quantified Statements
•   Application: Digital Logic Circuits



                                           2
                Logical Form
• Concept of logic – argument form
• Argument is a sequence of statements aimed to
  demonstrate the truth of an assertion
• The preceding statements are called premises
• Assertion at the end of the sequence is called the
  conclusion
• Arguments are valid in the sense that if their
  premises are true, then their conclusions must also
  be true

                                                    3
                Logical Form
• To illustrate the logical form of arguments, we use
  letters of the alphabet (p, q, and r) to represent the
  statements
• Argument 1:
    “If Jane is a computer science major, then Jane
                   will take SSK3003”

  p = Jane is a computer science major
  q = Jane will take SSK3003
  The common logical form: If p, then q.
                                                       4
                  Logical Form
• Argument 2:
                “If x < -2 or x > 2, then x2 > 4.”
  p = x < -2, q = x > 2, r = x2 > 4
  The common logical form: If p or q, then r.

• Argument 3:
    “If the program syntax is faulty or if program execution
  results in division by 0, then the computer will generate an
       error message. Therefore, if the computer does not
     generate an error message, then the program syntax is
   correct and program execution does not result in division
                              by 0.”                          5
             Logical Form
p = The program syntax faulty,
q = The computer will generate an error message
r = The program execution results in division by 0

The common logical form:
        If p and q, then r.
        Therefore, if not r, then not p and not q.

                                                     6
              Logical Form
• Initial terms in logic: sentence, true, false
• Statement (proposition) is a sentence that is
  true or false BUT not both
• Compound statement is a statement built
  out of simple statements using logical
  operations: negation, conjunction,
  disjunction

                                                  7
            Logical Form
• Given two statements, p and q.
     Negation of p (NOT p)
          = symbolized by  / 
     Conjunction of p and q (p AND q)
          = symbolized by 
     Disjunction of p and q (p OR q)
          = symbolized by 
                                        8
                        Logical Form
•    Translation of English to symbolic logic statements:
    1.   The sky is blue.
            One simple (primitive) statement – assign to a letter i.e. p

    2.   The sky is blue and the grass is green.
            One compound statement
            Conjunction of two primitive statements
            Each single statement gets a letter i.e. p q
            And join with  i.e. p  q

    3.   The sky is blue or the sky is purple.
            One compound statement
            Disjunction of two primitive statements
            Each single statement gets a letter i.e. r s
            And join with  i.e. r  s


                                                                            9
                 Logical Form
• Each statement must have well-define truth values
  – they must either be true or false.
• We summarized all the possible truth values of a
  statement in truth tables.
• Truth tables for operators can be
   – Alone                p   q    pq   pq   p
   – Combined             F   F     F     F    T
   – Using 0’s or 1’s     F   T     F     T    T
                          T   F     F     T    F
                          T   T     T     T    F
                                                    10
               Logical Form
• Given two statements, p and q.
     Exclusive Or of p and q (p XOR q)
     = symbolized by 
     = when or is used in its exclusive sense, when
        the statement “p or q” means “p or q but not
        both.”
                          p   q   pq
                          F   F     F
                          F   T     T
                          T   F     T
                          T   T     F             11
                Logical Form
• Construct a truth table for the statement
  form (p  q)  r
    p   q   r    pq   r   (p  q)  r
    F   F   F     F     T        T         n = number of
    F   F   T     F     F        F         statements

    F   T   F     F     T        T
                                           How to calculate
    F   T   T     F     F        F         number of rows?
    T   F   F     F     T        T         Answer = 2n
    T   F   T     F     F        F
    T   T   F     T     T        T
    T   T   T     T     F        T
                                                       12
            Logical Equivalence
• Truth table for (~p  q)  (q  ~r)
• Two statements (P and Q) are called logically equivalent if
  and only if (iff) they have identical truth tables (P  Q)
• How to check two statements are logically equivalent?
• Double negation, ~(~p)  p
• De Morgan’s Laws:
   – The negation of and AND statement is logically equivalent to the
     OR statement in which component is negated, ~(p  q)  ~p  ~q
   – The negation of an OR statement is logically equivalent to the
     AND statement in which each component is negated,
     ~(p  q)  ~p  ~q
                                                                        13
           Logical Equivalence
• Applying De-Morgan’s Laws:
   – Write negation for
      • The bus was late or Tom’s watch was slow
      • -1 < x <= 4
• Tautology is a statement that is always true
  regardless of the truth values of the individual
  logical variables
• Contradiction is a statement that is always false
  regardless of the truth values of the individual
  logical variables
                                                      14
          Logical Equivalence
• Show that the statement form p  p is a tautology
  and p  p is a contradiction
                p   p   p  p   p  p
                F    T     T        F
                T    F     T        F


• A number of logical equivalences are summarized
  in Theorem 1.1.1 for future reference (pg. 14)
• The theorem can be used in a formal way to
  simplify complicated statements
                                                  15
                  THEOREM 1.1.1
                 Logical Equivalences
• Commutative laws: p  q  q  p, p  q  q  p
• Associative laws: (p  q)  r  p  (q  r), (p  q)  r  p  (q  r)
• Distributive laws: p  (q  r)  (p  q)  (p  r)
                       p  (q  r)  (p  q)  (p  r)
• Identity laws: p  t  p, p  c  p
• Negation laws: p  ~p  t, p  ~p  c
• Double negative law: ~(~p)  p
• Idempotent laws: p  p  p, p  p  p
• De Morgan’s laws: ~(p  q)  ~p  ~q, ~(p  q)  ~p  ~q
• Universal bound laws: p  t  t, p  c  c
• Absorption laws: p  (p  q)  p, p  (p  q)  p
                                                                   16
• Negation of t and c: ~t  c, ~c  t
           Logical Equivalence
• Use Theorem 1.1.1 to verify the logical
  equivalence of (p  q)  (p  q)  p
  (p  q)  (p  q)
   ((p)   q)  (p  q)   DM laws
   (p   q)  (p  q)       Double negative law
   p  ( q  q)             Distributive law
   p  (q   q)             Commutative law for 
  pc                        Negation law
  p                          Identity law
                                                  17
                  Exercises
• Write truth table for: (p  (~p  q))  ~(q  ~r)
• Simplify: ~(~p  q)  (p  q)
• Simplify: ~(p  ~q)  (~p  ~ q)  ~p




                                                18
                       Answers
• (p  (~p  q))  ~(q  ~r)
p   q   r   p   p  q   p  ( p  q)   r   (q   r)   (p  (~p  q)) 
                                                               ~(q  ~r)
F   F   F   T      T           T          T        T               T
F   F   T   T      T           T          F        T               T
F   T   F   T      T           T          T        F               F
F   T   T   T      T           T          F        T               T
T   F   F   F      F           T          T        T               T
T   F   T   F      F           T          F        T               T
T   T   F   F      T           T          T        F               F
T   T   T   F      T           T          F        T               T
                                                                       19
                     Answers
• ~(p  ~q)  (~p  ~ q)  ~p

  (p  q)  (p  q)
   (p  (q))  (p  q)   DM law
   (p  q)  (p  q)       Double negative law
   p  (q  q)              Distributive law
   p  t                     Negation law
   p                         Identity law


                                                     20
        Conditional Statements
• “If something, then something”: p  q, p is called
  the hypothesis and q is called the conclusion
• The formal definition of truth values for p  q is
  based on its everyday, intuitive meaning
• Eg: You go for an interview, and the boss promise
  you,
    “If you show up for work Monday morning,
              then you will get the job”
• Under what circumstances, the above sentence is
  false?
                                                   21
         Conditional Statements
• Ans: You do show up for work Monday morning and you
  do not get the job
• What happen when you do not show up for work Monday
  morning?
• The boss’ promise ONLY say you will get the job if a
  certain condition (showing up for work) is met
• It says nothing about what will happen if the condition is
  not met
• So if the condition is not met, you can not simply say the
  promise is false regardless of whether or not you get the
  job
                                                               22
       Conditional Statements
• The only combination of circumstances in which a
  conditional sentence is false is when the
  hypothesis is true and the conclusion is false
• A conditional statements is called vacuously true
  or true by default when its hypothesis is false
                  p   q    pq
                  F   F     T
                  F   T     T
                  T   F     F
                  T   T     T
                                                  23
        Conditional Statements
• Among , , ~ and  operations,  has the
  lowest priority
• Show that (p  q)  r  (p  r)  (q  r) by
  using truth table
• Representation of : p  q  ~p  q
• Re-write using if-then: Either you get in class on
  time, or you risk missing some material


                                                       24
       Conditional Statements
• Ans: ~p  q, Let ~p be you get in class on
  time and q be you risk missing some
  material
• So, the equivalent if-then version, p  q is
  If you do not get in class on time, then you
           risk missing some material

• Negation of : ~(p  q)  p  ~q
                                                 25
       Conditional Statements
• Contrapositive of the statement p  q is another
  conditional statement, ~q  ~p
• A conditional statement is equivalent to its
  contrapositive
• Write in contrapositive form: If today is Easter,
  then tomorrow is Monday.
• Ans: If tomorrow is not Monday, then today is not
  Easter.
                                   Easter is a Christian celebration
                                   celebrated on Sunday


                                                               26
         Conditional Statements
• The converse of p  q is q  p
• The inverse of p  q is ~p  ~q
• Conditional statement and its converse are NOT equivalent
• Conditional statement and its inverse are NOT equivalent
• The converse and inverse of a statement are logically
  equivalent to each other
• Write the converse and inverse: If today is Easter, then
  tomorrow is Monday
   – Converse: If tomorrow is Monday, then today is Easter
   – Inverse: If today is not Easter, then tomorrow is not
     Monday
                                                          27
                        Exercises
• Write contrapositive, converse and inverse
  statements for:
   –   If P is a square, then P is a rectangle
   –   If n is prime, then n is odd or n is 2
   –   If x is nonnegative, then x is positive or x is 0
   –   If n is divisible by 6, then n is divisible by 2 and n is
       divisible by 3




                                                                   28
                  Answers
• If P is a square, then P is a rectangle
  Contrapositive: If P is not a rectangle, then
  P is not a square
  Converse: If P is a rectangle, then P is a
  square
  Inverse: If P is not a square, then P is not a
  rectangle

                                                   29
       Conditional Statements
• Biconditional of p and q means “p if and
  only if q” (iff) and is denoted as p  q
• True when both statement have the same
  truth values
                p   q   pq
                F   F    T
                F   T    F
                T   F    F
                T   T    T
                                             30
        Conditional Statements
• “p only if q” means p occurs only if q also occurs
• Means ~q  ~p, or p  q
• Re-write using if-then: You will get an A only if
  you get 80 marks.
• Ans 1: If you do not get 80 marks, then you will
  not get an A.
• Ans 2: If you get an A, then you will have to get
  80 marks.

                                                       31
       Conditional Statements
• p  q  (p  q)  (q  p)
• r is a sufficient condition for s means “if r
  then s”
• r is a necessary condition for s means “if not
  r then not s” and “if s then r”
• r is a necessary and sufficient condition for
  s means “r if and only if s”

                                              32
   Order of Operations for Logical
             Operators
1.       Evaluate negation first
2. ,    Evaluate  and  second. When both are present, parentheses
          may be needed
3. ,    Evaluate  and  third. When both are present, parentheses
          may be needed




                                                                        33
                    Arguments
• An argument is a sequence of statements. All statements
  except the final one are called premises (or assumptions or
  hypotheses). The final statement is called the conclusion
               If Ali is a man, then Ali is mortal.
               Ali is a man.
               Ali is mortal.
• An argument is considered valid if from the truth of all
  premises, the conclusion must also be true.
• The conclusion is said to be inferred or deduced from the
  truth of the premises
                    Arguments
• Test to determine the validity of the argument:
   – Identify the premises and conclusion of the argument
   – Construct the truth table for all premises and the
     conclusion
   – Find critical rows in which all the premises are true
   – If the conclusion is true in all critical rows then the
     argument is valid, otherwise it is invalid
                Invalid Argument
• Example of invalid argument form:
  – Premises: p  q  ~r and q  p  r, conclusion: p  r
   p  q  r   qpr     pr
       T          T        T
       T          F        F
                                       This row shows it is possible for
       F          T        T           this argument to have true
       T          T        F           premises and false conclusion.
                                       Hence this form of argument is
       T          F        T
                                       invalid
       T          F        T
       T          T        T
       T          T        T
                                                               36
              Valid Argument
• Example of valid argument form:
  – Premises: p  (q  r) and ~r, conclusion: p  q
            p  (q  r)   r        pr
                T          F          T
                T          T          T
                T          F          T
                T          T          T
                T          F          T
                T          T          T
                T          F          F
                F          T          F
                                                      37
            Rules of Inference
• An argument consisting of two premises and a
  conclusion is called a syllogism
• A rule of inference is a form of argument that is
  valid
• Modus ponens (method of affirming): Has the
  form If p then q.
          p.                  pq         p           q
          q                    T         T           T
                                F         T           F
                                T         F           T
                                T         F           F
               Rules of Inference
• Modus tollens (method of denying): Has the form
                        If p then q.
                        q.
                        p

• Use ponens or tollens to make arguments valid:
   – If 5 is divisible by 6, the it is divisible by 3.
     5 is not divisible by 3.
     _________________________________
   – If this is a while loop, then the body of the loop may never be
     executed.
     ______________________
     The body of the loop may never be executed
         Rules        Related logical implication                           Name of rule

pq                [(p  q)  p]  q                   Modus Ponens (Rule of Detachment)
p
q
pq                [(p  q)  q]  p                 Modus Tollens
q
 p
p           q      ppq                               Generalization
pq        pq   qpq                               (Disjunctive Amplification)
pq         pq    pqp                               Specialization
p          q     pqq                               (Conjunctive Simplification)
p                                                      Conjunction
q
pq
pq         pq    [(p  q)  q]  p                  Elimination (Disjunctive Syllogism)
q          p
p          q     [(p  q)  p]  q
pq                [(p  q)  (q  r)]  (p  r)       Transitivity (Law of the Syllogism)
qr
pr
pq                [(p  q)  (p  r)  (q  r)]  r   Proof by Division into Cases
pr
qr
r
p  c             (p  c)  p                        Contradiction Rule
p
       Complex Deduction (1)
• Premises:
  a) Rita is baking a cake.
  b) If Rita is baking a cake, then she is not
     practicing her flute.
  c) If Rita is not practicing her flute, then her
     father will not buy her a car.
  d) Therefore Rita’s father will not buy her a car.
• Consider and validate
                                                   41
                        Answer
• Let p = Rita is baking a cake
        q = She is practicing her flute
        r = Her father will not buy her a car
• Translate question into premises:
  (a) p                (b) p  q             (c) q  r

• The following deductions can be made:
1. p         by (a)          2.  q           by the conclusion of

   p  q by (d)                 q  r     by (c)

   q       by modus ponens     r         by modus ponens

                                                                     42
         Complex Deduction (2)
• Premises:
   a) If my glasses are on the kitchen table, then I saw them at
      breakfast
   b) I was reading the newspaper in the living room or I was reading
      the newspaper in the kitchen
   c) If I was reading the newspaper in the living room, then my
      glasses are on the coffee table
   d) I did not see my glasses at breakfast
   e) If I was reading my book in bed, then my glasses are on the bed
      table
   f) If I was reading the newspaper in the kitchen, then my glasses are
      on the kitchen table
• Where are the glasses?
                       Answer
• Let p = My glasses are on the kitchen table
       q = I saw them at breakfast
       r = I was reading the newspaper in the living room
       s = I was reading the newspaper in the kitchen
       t = My glasses are on the coffee table
       u = I was reading my book in bed
       v = My glasses are on the bed table
• Translate question into premises:
  (a) p  q           (b) r  s               (c) r  t
  (d) q              (e) u  v               (f) s  p
                                                            44
                        Answer
• The following deductions can be made:
1. p  q   by (a)                   4. r  t       by (c)

    q     by (d)                       r          by the conclusion of 3

   p     by modus tollens            t          by modus ponens

2. s  p   by (f)
                                    Hence t is true and the glasses are
    p     by the conclusion of 1
                                    on the coffee table.
   s     by modus tollens

3. r  s   by (b)

    s     by the conclusion of 2

   r      by elimination
                                                                   45
                     Fallacies
• A fallacy is an error in reasoning that results in an
  invalid argument
• Three common fallacies:
   – Vague or ambiguous premises
   – Begging the question (assuming what is to be proved)
   – Jumping to conclusions without adequate grounds
• Converse Error:
   – Premises: p  q and q, conclusion: p
• Inverse Error:
   – Premises: p  q and ~p, conclusion: ~q

								
To top