CSCI 2824: Lecture 5 Notes

Today's lecture:

  • Quantifiers, Truth of Quantified Formulas and Negation of Quantified Formulas (Section 1.4 of the book).

  • Implication (Section 1.5 of the book)

Quantifiers

We have already seen two types of quantifiers in the previous lecture:

  • The forall (for-all or universal ) quantifier, and

  • The exists (exists or existential) quantifier.

Truth and Quantifiers

The rule for determining the truth of a quantified statement is really simple.

  • Statement is of the form (exists x in S) psi:

    • Present a value x in S. We will plugin this value for x and tackle the remainder of psi.

    • If psi[x] is true, then (exists x in S) psi is also true.

    • On the other hand, if all your choices for x in S do not make psi[x] true, then the formula exists x in S psi is false.

Pseudo Code For Checking Exists-Formulae

   /* Checking (Exists x IN S) P */
   for each x IN set S,  {
          result := CHECK P[x];
          if ( result is TRUE)
          then return TRUE;
    }
   /* We have gone through all values in S and they all do not satisfy P */
   return FALSE;
  • Statement is of the form (forall x in S) psi:

    • Go through each and every value of x in S and verify that psi[x] is true.

    • If for some value x, psi[x] is false, then the original formula (forall x in S) psi is false.

    • Otherwise, if we have successfully verified all values, then (forall x in S) psi is true.

Pseudo Code For Checking Forall-Formulae

   /* Checking (Forall x IN S) P */
   for each x IN set S,  {
          result := CHECK P[x];
          if ( result is FALSE)
          then return FALSE;
    }
   /* We have gone through all values in S and all  satisfy P */
   return TRUE;

Formulas with Multiple Quantifiers

Formulas with multiple quantifiers can be often tricky and the order of quantification matters .

Let D = { -5,-4,ldots,4,5 } be a fixed set.

We ask whether the following formula is true:

 psi_1: (forall m in D) ( (exists n in D) (n = m) ) ,.

Let us run our checking algorithm. The outermost quantifier is a forall. Therefore, we plugin each value of m and check the inner formula:

  • m = -5: (exists n in D) (-5 = n). Is this TRUE?

  • m = -4: (exists n in D) (-4 = n). Is this TRUE?

  • vdots

  • m = 5: (exists n in D) (5 = n). Is this TRUE?

Has the inner formula ( (exists n in D) (n = m) ) been verified for all m in D?

Now let us try this formula:

 psi_2: (exists n in D) (forall m in D) (n = m)

This is the same formula but with the quantifiers reversed. Does it mean the same as psi_1? Perhaps, if you paraphrase these formulae in plain language, the difference should be clear.

Once again, we run our checking algorithm. The outermost quantifier is an exists.

  • n = -5: (forall m in D) (m = -5), Is this TRUE?

  • vdots

  • n = 5: (forall m in D) (m = 5), Is this TRUE?

Is there indeed a value of n that makes the formula (forall m in D) (n = m) true?

Negating Formulas

Let us start by negating formulas without quantifiers.

Example

What is the negation of ( x leq 0  mbox{OR}  y > 10)?

Answer: We start by writing mbox{NOT}  ( x leq 0  mbox{OR}  y > 10). The idea is to get rid of the mbox{NOT} sign as much as we can. First apply De Morgan's law:

 mbox{NOT}  (p  mbox{OR}  q) equiv (mbox{NOT}  p  mbox{AND}  mbox{NOT}  q)

Therefore, we get

 mbox{NOT}  ( x leq 0  mbox{OR}  y > 10) equiv  ( mbox{NOT}  (x leq 10)   mbox{AND}  mbox{NOT}  (y > 10) ) equiv ( x > 10  mbox{AND}  y leq 10)

The answer is therefore  ( x > 10   mbox{AND}  y leq 10 ).

Note the following table of negations for arithmetic predicates:

Predicate Negation
leq  >
geq  <
 =  not=

Negation with Quantifiers

Now we consider negation with quantifier. Proposition 1 in Page 45 of the book is the key rule here.

  • Negation of (forall x in D), psi is given by  (exists x in D), mbox{NOT}  psi.

  • Negation of (exists x in D), varphi is given by  (forall x in D), mbox{NOT}  varphi.

Let us try some examples.

Example

Negate the formula:  (forall x in D) ( (x leq 2)  mbox{AND}  (x > 3) ).

Let us do it step by step:

 begin{array}{rcl} mbox{NOT}  (forall x in D) ( (x leq 2)  mbox{AND}  (x > 3) ) & equiv & (exists x in D), mbox{NOT}  (x leq 2  mbox{AND}  x > 3)  & equiv & (exists x in D),  ( mbox{NOT}  x leq 2)   mbox{OR}  (mbox{NOT}  x > 3)  & equiv & (exists x in D), ( x > 2  mbox{OR}  x leq 3)  end{array}

Is the negation true for the set D = { -5, ldots, 5 }?

Yes, there is indeed x = -1 that satisifies the formula (x > 2  mbox{OR}  x leq 3).

Now let us try a formula with existential quantifier:  (exists x in D) (x not= 3) .

 begin{array}{rcl} mbox{NOT}  (exists x in D) ( x not= 3) & equiv & (forall x in D), mbox{NOT}  (x not= 3)  & equiv & (forall x in D), x = 3  end{array}

Implications

Implications are a very important concept that needs to be understood thoroughly to move forward in this course. What is an implication? Simply answer is any if.. then.. statement.

  • If I were a rich person then I would stop selling gadgets.

  • If x is a prime number greater than 2 then x is odd.

  • If a real number x satisfies x^2 > 4 then x > 2.

We write implications as

 p Rightarrow q

p is called the premise, hypothesis or the antecedent of the implication.

q is called the conclusion.

Example:

  • (x > 2) Rightarrow ( x > 3).

  • (x > x) Rightarrow ( x = 0).

Practice Problem 1 in page 54 talks about writing down statements as implications.

Example: If a triangle has three sides then it has three equal angles.

We recast it as: for all triangles t, if t has three equal sides then t has three angles.

 (forall t in mbox{Triangles}) ThreeEqualSides(t) Rightarrow ThreeEqualAngles(t) ,.

Example: If an integer is its own square then it is either 0 or 1.

Recast it as: For all integers n, If n=n^2 then  n= 0 or n = 1.

 (forall n in mathbb{Z}) n = n^2  Rightarrow (n= 0  mbox{OR}  n= 1)

Logic of Implications

Truth Table for Implication: We noted earlier that p Rightarrow q was a place holder for  mbox{NOT}  p   mbox{OR}  q. But that barely begins to address the entire story!

p q p Rightarrow q
T T T
T F F
F T T
F F T

Note: An implication p Rightarrow q is false (or fails to hold true) only in one scenario: p, the hypothesis is true but q the conclusion is false.

Example

The law says: If you are drinking alcoholic beverages, then you must be over 21 years of age.

Let us analyze the various scenarios:

Drinking alc. bev. Over 21 Years Breaking Law?
T T T
F T T
F F T
T F F

In other words, the implication is true no matter what if q (over 21 years of age?) is true OR p (drinking alcoholic beverates) is false.

Example

Consider the statement: For every integer n, if n is odd then n^2-1 is divisible by 4. Is it true?

The statement is of the form (forall n in mathbb{Z}) underset{P(n)}{underbrace{(n mbox{mod} 2 = 1)}} Rightarrow  underset{Q(n)}{underbrace{( (n^2 -1 ) mbox{mod} 4 = 0 )}} .

n P(n) n^2 -1 Q(n) P(n) Rightarrow Q(n)?
3 T 8 T Yes
6 F 35 F Yes
0-5 T 24 T Yes

As you try a lot of choices, you see that it is NEVER the case where P(n) is true and Q(n) is false. Of course, there are infinitely many cases to try so this will never convince us of the truth of the statement, since we will never have checked all n this way.