CS0441 lecture notes (review of 1.1-1.4, continuation of 1.5)

Propositional versus Predicate Logic

Predicate calculus separates out the referring expression from the rest of the proposition so that you can reason with the two separately:  Every president of the US was powerful.  Clinton was a president of the US.  Therefore, Clinton was powerful.

·        How can you represent “Clinton was powerful” in each type of logic?

·        What else does predicate logic give you?

Hints to remember:

  • First translate a sentence using a non-trivial universe of discourse for each variable, then change the universe of discourse of "anything" and add extra stuff to the logical expression.  For instance, if the sentence is "No dogs love all types of dogfood." then you can start with ~$x"y(love(x,y)) where x is a dog and y is a type of dogfood.  Then you change the universe of discourse to "anything" and change the logical expression to ~$x"y(dog(x) ^ (dogfood-type(y) -> love(x,y))))
  • When translating a quantified noun phrase such as "all dogs," put the qualifying predicate in the antecedent of an implication: "All dogs go to heaven" becomes "x (dog(x) -> go-to-heaven(x)).
  • When translating a quantified noun phrase such as "some idiot," put the qualifying predicate inside a conjunction: "Some idiot  woke me up" becomes $x (idiot(x) ^ woke-me-up(x)).
  • Once a quantifier is combined with a predicate, it is just a proposition like any other - so it can be inside logical operators (Translate “Life is hard and everyone dies”)
  • It is also typical to combine several predicates inside a quantifier using the logical operators – what is an example?

Proofs and Rules of inference

Whenever you have a tautology of the form A-> B, then you have a rule of inference.  Given a proposition A, you can infer B. 

 

Proofs are often shown using a multi-column format, where one column is propositions and the next  two columns are the rule of inference (or its name, if it is famous enough to have one) and the line number of the propositions it is applied to.  If the proposition is given initially, then one writes “Given” or “Hypothesis” as its justification. 

 

Suppose you are given Foo and Foo->Baz and are asked to prove Foo^Baz.  Here is the proof:

 

Line

Proposition

Justification

Applied to

1

Foo

Given

 

2

Foo -> Baz

Given

 

3

Baz

[P^(P->Q)] -> Q  Modeus Ponens

1,2

4

Foo ^ Baz

P^Q -> P^Q Conjunction

1,3

 

Practice with formal “theorem proving”

You can work forwards from the givens or backwards from the to-be-proved proposition.  

 

Example: Given

  • Randy works hard
  • If Randy works hard, then he is a dull boy.
  • If Randy is a dull boy, then he will not get the job

Prove

  • Randy will not get the job

 

Let

  • P = Randy works hard
  • ?

 

 

Proposition

Justification

Applied to

1

P

Given

 

?

 

 

 

 

Direct proof refresher example

Given

  • If I work all night on this homework, then I can answer all the exercises.
  • If I answer all the exercise, I will understand the material.

Prove

  • If I work all night on the homework, then I will understand the material

 

Let

  • P = I work all night on this homework
  • ?

 

 

Proposition

Justification

Applied to

1

P

Assume

 

?

 

 

 

 

Indirect proof refresher example

Redo example above

Indirect Proof and Proof by cases

This proof uses a special technique, called proof by cases, which decomposes a proposition of the form AVB into cases A and B, and proves the same conclusion in both cases, then recombines them. 

 

Example: Given

·        If I ate spicy food, I will have strange dreams

·        If it thunders while I sleep, I will have strange dreams

Prove

·        If I do not have strange dreams, then I didn’t eat spicy food and it didn’t thunder last night.

Let

·        P=I ate spicy food

·        R=it thundered last night

·       Q=?

 

 

Proposition

Justification

Applied to

1

~(~P^~R)

Assumed

 

2

P vR

Demorgans & double negation

 

3

P

First case

2

4

P->Q

Given

 

5

Q

Modeus ponens

3,4

6

R

Second case

2

7

?

?

 

8

?

?

?

9

Q

Proof by cases

2, 5, 8

 

Informal and formal direct proof

Computer scientists usually do not write the quantifiers explicitly when writing a proof.  Nor do they use multiple columns.  However, if the proof is done correctly, we can add these details. 

 

Example: Prove that “If n is odd, then n^2 is odd.”  

 

 

Proposition

Justification

Applied to

Informal proof

1

"n (n is odd)

Assume

 

“Suppose that n is odd.”

2

"n $k (n = 2k+1) ^ k is integer

Definition of “odd”

1

“Then n = 2k+1, where k is an integer”

3

"n $k (n^2 = (2k+1)^2)

If x=y, then x^2=y^2

2

“It follows that n^2=(2k+1)^2…”

4

?

Algebraic manipulation

?

“…= 4k^2+k4+1…”

5

?

?

?

“…= 2(2k^2+2k)+1.”

6

?

Definition of “odd”

?

therefore, n^2 is odd (it is 1 more than twice an integer).”

 

Informal proof by contradiction

Proof by contradiction can be done with any proposition, P.  One assumes ~P and shows that this leads to a contradiction. 

 

For example, prove “If n is an integer and n^3+5 is odd, then n is even  We negate the proposition, obtaining the first line below.

 

 

Proposition

Justification

Applied to

1

~(if n^3+5 is odd, then n is even)

Assume

 

2

n^3+5 is odd, and ~(n is even)

~(P->Q) ó P^~Q

1

3

n is odd

An integer is either even or odd

2

4

n^2 is odd

An earlier theorem: if n is odd, then n^2 is odd

3

5

n*n^2 is odd

An earlier theorem: if a and b are odd, then ab is odd

4

6

n^3 is odd

Algebraic manipulation

5

7

(n^3+5) – n^3 is even

Thm: if a and b are odd, then a-b is even

6

8

5 is even

Algebraic manipulation

7

9

5 is odd

Fact

 

10

Contradiction

 

8, 9

11

if n^3+5 is odd, then n is even

Proof by contradiction

1, 10

 

Existence proofs: Constructive

If the proposition to be proved has an existential quantifier in it, then its proof is called an existence proof.  One way to prove such a proposition is to construct a constant that satisfies the proposition when it is substituted for the existentially quantified variable. 

 

Example: Prove “For every n, there is an integer divisible by more than n different prime numbers.”  That is, "n $k (k is divisible by more than n different prime numbers)

 

 

Proposition

Justification

Applied to

1

Let {3, 5, 7, …, pn+1) be the first n+1 prime numbers.

There are infinitely many prime numbers

 

2

Let k = 3*5*…*pn+1

You can multiply any number of numbers together

1

3

k is divisible by pi for all i between 1 and n+1

Because pi is a factor of k

2

4

k is divisible by n+1 different prime numbers

counting

3

Existence proofs: Non-constructive

If an existence proof does not actually construct the constant that makes the proposition true, then the proof is called a non-constructive existence proof.