CPSC 121: Models of Computation Instructor: Bob Woodham - - PowerPoint PPT Presentation

cpsc 121 models of computation
SMART_READER_LITE
LIVE PREVIEW

CPSC 121: Models of Computation Instructor: Bob Woodham - - PowerPoint PPT Presentation

CPSC 121: Models of Computation Instructor: Bob Woodham woodham@cs.ubc.ca Department of Computer Science University of British Columbia Lecture Notes 2008/2009, Section 203 CPSC 121: Models of Computation Menu January 19, 2009 Topics:


slide-1
SLIDE 1

CPSC 121: Models of Computation

Instructor: Bob Woodham woodham@cs.ubc.ca

Department of Computer Science University of British Columbia

Lecture Notes 2008/2009, Section 203

CPSC 121: Models of Computation

slide-2
SLIDE 2

Menu January 19, 2009

Topics: Proofs (in Propositional Logic) Rules of Inference Reading: Today: Epp 1.3 Next: Epp 2.1, 2.3 Reminders: On-line Quiz 5 deadline 9:00pm January 22 Assignment 1 due Friday, January 30, 17:00 READ the WebCT Vista course announcements board WebCT Vista: http://www.vista.ubc.ca www: http://www.ugrad.cs.ubc.ca/~cs121/

CPSC 121: Models of Computation

slide-3
SLIDE 3

What is a Proof?

A proof is a method to determine “truth.” There are many

  • approaches. . .

1

Justice System: Proof “beyond a reasonable doubt” (criminal) or on the “preponderance of the evidence” (civil) as determined by a jury of 12 people selected at random

2

Religion: Truth revealed by “God,” perhaps via a third party

3

Authority: Truth obtained from someone with whom it is unwise to disagree

4

Experimental Science: Truth is guessed and hypotheses are confirmed or refuted by experiment

5

Sampling: Truth by statistical analysis. For example, public

  • pinion determined by polling a representative sample

6

Democracy: Truth obtained by vote

CPSC 121: Models of Computation

slide-4
SLIDE 4

Mathematical Proof

Mathematics has a specific notion of “proof” Definition: A mathematical proof of a proposition is a chain of logical deductions leading to the proposition from a base set of axioms Definition: An axiom is a proposition that is assumed to be true

  • Definition. A set of axioms is consistent if no proposition can be

proven to be both true and false

  • Definition. A set of axioms is complete if it can be used to prove
  • r disprove every proposition

Definition: Logical deductions (aka inference rules) are used to combine axioms and true propositions to construct more true propositions.

CPSC 121: Models of Computation

slide-5
SLIDE 5

Terminology

Definition: A theorem is a proposition that has been proven to be true ASIDE: A proposition remains a conjecture if not yet proven to be true (and not yet known to be false) Definition: A lemma is a theorem that may not be too interesting in its own right but that is useful in proving another theorem Definition: A corollary is a theorem that follows easily from another theorem Definition: Logic is that branch of the study of knowledge that deals with the structure of arguments

CPSC 121: Models of Computation

slide-6
SLIDE 6

Example 1: Ethan’s Argument

Consider the following sequence of propositions: Ethan is reading The Paper Bag Princess If Ethan is reading The Paper Bag Princess then he is not practising the piano If Ethan is not practising the piano then the TV will be “broken” tomorrow If we assume that these propositions (or “premises”) are true, it is reasonable to conclude Therefore, the TV will be “broken” tomorrow The process of inferring a conclusion from a sequence of propositions (or premises) is called deductive reasoning

CPSC 121: Models of Computation

slide-7
SLIDE 7

Deductive Argument

In general, we can summarize the form of a deductive argument as P1 P2 P3 · · · Pn ∴ q where the Pi, i = 1, 2, 3, . . . , n are premises and q is the conclusion

CPSC 121: Models of Computation

slide-8
SLIDE 8

Deductive Argument (cont’d)

An argument is valid if the conclusion follows logically from the

  • premises. In other words,

An argument is valid if and only if (P1 ∧ P2 ∧ . . . ∧ Pn) → q is a tautology

CPSC 121: Models of Computation

slide-9
SLIDE 9

Deductive Argument (cont’d)

Note: We conclude q if and only if

1

the argument is valid

2

the premises are proven true CAUTION: In order to validate an argument we often assume the premises to be true. This is not the same as having proven the premises to be true

CPSC 121: Models of Computation

slide-10
SLIDE 10

Deductive Argument (cont’d)

A valid argument does not say the conclusion is true A valid argument says that if you grant the premises then you also must grant the conclusion If one or more of the premises is false then the argument is

  • vacuous. It says nothing about the truth of the conclusion

CPSC 121: Models of Computation

slide-11
SLIDE 11

Ethan’s Argument Re-Visited

Let’s determine the validity of Ethan’s argument We translate into propositional logic. Let r: Ethan is reading The Paper Bag Princess p: Ethan is practising the piano t: the TV will work tomorrow Ethan’s argument is: r r → p p → t ∴ t

CPSC 121: Models of Computation

slide-12
SLIDE 12

Ethan’s Argument Re-Visited

Let’s validate Ethan’s argument 1. r premise 2. r → p premise 3. p modus ponens 1 2 4. p → t premise 5. ∴ t modus ponens 3 4

CPSC 121: Models of Computation

slide-13
SLIDE 13

Ethan’s Argument Re-Visited

Let’s validate Ethan’s argument another way 1. r → p premise 2. p → t premise 3. r → t hypothetical syllogism 1 2 4. r premise 5. ∴ t modus ponens 3 4

CPSC 121: Models of Computation

slide-14
SLIDE 14

Example 2:

Establish the validity of: p → q q → (r ∧ s) r ∨ (t ∨ u) p ∧ t ∴ u

CPSC 121: Models of Computation

slide-15
SLIDE 15

Example 2: (cont’d)

Here’s the deductive argument: step reason 1. p → q premise 2. q → (r ∧ s) premise 3. p → (r ∧ s) hypothetical syllogism 1 2 4. p ∧ t premise 5. p simplification 4 6. (r ∧ s) modus ponens 3 5 7. r simplification 6 8. r ∨ (t ∨ u) premise 9. t ∨ u disjunctive syllogism 7 8 10. t simplification 4 11. ∴ u disjunctive syllogism 9 10

CPSC 121: Models of Computation

slide-16
SLIDE 16

Example 3:

Establish the validity of: p p → r p → (q ∨ r) q ∨ s ∴ s

CPSC 121: Models of Computation

slide-17
SLIDE 17

Example 3: (cont’d)

Here’s the deductive argument: step reason 1. p premise 2. p → r premise 3. r modus ponens 1 2 4. p → (q ∨ r) premise 5. q ∨ r modus ponens 1 4 6. q disjunctive syllogism 3 5 7. q ∨ s premise 8. ∴ s disjunctive syllogism 6 7

CPSC 121: Models of Computation

slide-18
SLIDE 18

Example 3: (cont’d)

p p → r p → (q ∨ r) q ∨ s ∴ s Question: Can we conclude that the argument is a fallacy (i.e., invalid)?

CPSC 121: Models of Computation

slide-19
SLIDE 19

Example 3: (cont’d)

p p → r p → (q ∨ r) q ∨ s ∴ s Question: Can we conclude that the argument is a fallacy (i.e., invalid)? Answer: Not yet! A contradiction in the premises can be used to deduce any conclusion desired (and such an argument remains valid)

CPSC 121: Models of Computation

slide-20
SLIDE 20

Example 3: (cont’d)

If we suspect a fallacy, we should search for a contradiction. That is, we show that [p ∧ (p → r) ∧ (p → (q ∨ r)) ∧ (q ∨ s)] → s is not a tautology Let s = F, p = T, r = T and q = T. In this case, the conjunction of the premises is true and the conclusion is false Thus, we do not have a tautology and the original argument is therefore invalid

CPSC 121: Models of Computation

slide-21
SLIDE 21

Rules of Inference

Rule Tautology Name p ∴ p ∨ q p → (p ∨ q) Addition p ∧ q ∴ p (p ∧ q) → p Simplification p q ∴ p ∧ q ((p) ∧ (q)) → p ∧ q Conjunction p p → q ∴ q (p ∧ (p → q)) → q Modus ponens ¬q p → q ∴ ¬p (¬q ∧ (p → q)) → ¬p Modus tollens

CPSC 121: Models of Computation

slide-22
SLIDE 22

Rules of Inference

Rule Tautology Name p → q q → r ∴ p → r ((p → q) ∧ (q → r)) → (p → r) Hypothetical syllogism p ∨ q ¬p ∴ q ((p ∨ q) ∧ ¬p) → q Disjunctive syllogism p ∨ q ¬p ∨ r ∴ (q ∨ r) ((p ∨ q) ∧ (¬p ∨ r)) → (q ∨ r) Resolution p → r q → r ∴ (p ∨ q) → r ((p → r) ∧ (q → r)) → ((p ∨ q) → r) Proof by cases

CPSC 121: Models of Computation

slide-23
SLIDE 23

Digression: Logic Programming

Logic programming uses proof as the framework for computing A logic program consists of a set of rules (including simple facts) together with input (consisting of additional facts and a desired conclusion) Evaluation consists of a demonstration that the desired conclusion does (or does not) follow from the given rules and facts

CPSC 121: Models of Computation

slide-24
SLIDE 24

Digression: Logic Programming

One can build an evaluator for logic programming based on a specific proof method Consider two proof methods (and hence two evaluators):

1

Forward chaining starts with the original facts and rules and works towards the desired conclusion. At each step, new facts are derived. We stop when the conclusion is known to be a fact (or when no new facts can be derived)

2

Backward chaining starts with the conclusion and works backwards to try to find facts and rules that derive it

CPSC 121: Models of Computation

slide-25
SLIDE 25

Example 4:

I want to be happy if I had $1M then I would be happy if I had a good job then I could earn $1M if I had a B.Sc in CPSC then I could get a good job if I pass CPSC 121 then I can get a B.Sc in CPSC

Question: Is this example forward chaining or backward chaining?

CPSC 121: Models of Computation

slide-26
SLIDE 26

Example 4:

I want to be happy if I had $1M then I would be happy if I had a good job then I could earn $1M if I had a B.Sc in CPSC then I could get a good job if I pass CPSC 121 then I can get a B.Sc in CPSC

Question: Is this example forward chaining or backward chaining? Answer: It is backward chaining. We reason backwards from a conclusion “to be happy” finding facts and rules that derive it

CPSC 121: Models of Computation

slide-27
SLIDE 27

(Humourous) Example 5:

I pass CPSC 121 I get degree in BIOL I apply to medical school if not accepted I lose! if accepted I get good job I earn $1M I am happy I get degree in CHEM I get no job I buy lottery ticket I lose! I get degree in CPSC I get good job I earn $1M I am happy I get degree in MATH I get no job I buy lottery ticket I lose! I get degree in PHYS I get no job I buy lottery ticket I lose!

CPSC 121: Models of Computation

slide-28
SLIDE 28

Digression: Logic Programming (concluded)

Question: What are the relative merits of forward and backward chaining?

CPSC 121: Models of Computation

slide-29
SLIDE 29

Digression: Logic Programming (concluded)

Question: What are the relative merits of forward and backward chaining? Answer: Backward chaining typically is faster and therefore is more useful in practice. It is somewhat more difficult to implement and to explain. Forward chaining is a naive approach that is not useful in practice. It is, however, easiest to implement and to explain. Forward chaining can find multiple derivations, if they exist. In the above examples, backward chaining found the “get a degree in CPSC” solution. Forward chaining found this solution but it found the “go to medical school” solution too.

CPSC 121: Models of Computation