Snick  snack CPSC 121: Models of Computation 2011 Winter Term 1 Proof Techniques (Part A) Steve Wolfman, based on notes by Patrice Belleville and others.

Slides:



Advertisements
Similar presentations
CPSC 121: Models of Computation Unit 6 Rewriting Predicate Logic Statements Based on slides by Patrice Belleville and Steve Wolfman.
Advertisements

Inference and Reasoning. Basic Idea Given a set of statements, does a new statement logically follow from this. For example If an animal has wings and.
CPSC 121: Models of Computation
Truth Trees Intermediate Logic.
Snick  snack CPSC 121: Models of Computation 2010 Winter Term 2 Introduction to Induction Steve Wolfman 1.
CPSC 121: Models of Computation
Snick  snack CPSC 121: Models of Computation 2009 Winter Term 1 Revisiting Induction Steve Wolfman, based on work by Patrice Belleville and others 1.
Snick  snack CPSC 121: Models of Computation 2009 Winter Term 1 Introduction & Motivation Steve Wolfman, based on notes by Patrice Belleville and others.
Snick  snack CPSC 121: Models of Computation 2008/9 Winter Term 2 Proof Techniques Steve Wolfman, based on notes by Patrice Belleville and others 1.
Snick  snack CPSC 121: Models of Computation 2009 Winter Term 1 Rewriting Predicate Logic Statements Steve Wolfman, based on notes by Patrice Belleville.
Snick  snack CPSC 121: Models of Computation 2009 Winter Term 1 Introduction to Induction Steve Wolfman 1.
Snick  snack CPSC 121: Models of Computation 2009 Winter Term 1 DFAs in Depth Steve Wolfman, based on notes by Patrice Belleville and others.
Snick  snack CPSC 121: Models of Computation 2008/9 Winter Term 2 Propositional Logic: Conditionals and Logical Equivalence Steve Wolfman, based on notes.
1 Introduction to Computability Theory Lecture15: Reductions Prof. Amos Israeli.
1 Introduction to Computability Theory Lecture12: Reductions Prof. Amos Israeli.
Proof Points Key ideas when proving mathematical ideas.
CPSC 411, Fall 2008: Set 12 1 CPSC 411 Design and Analysis of Algorithms Set 12: Undecidability Prof. Jennifer Welch Fall 2008.
1 Undecidability Andreas Klappenecker [based on slides by Prof. Welch]
Snick  snack A Working Computer Slides based on work by Bob Woodham and others.
Snick  snack CPSC 121: Models of Computation 2011 Winter Term 1 Revisiting Induction Steve Wolfman, based on work by Patrice Belleville and others 1.
Snick  snack CPSC 121: Models of Computation 2011 Winter Term 1 Introduction & Motivation Steve Wolfman, based on notes by Patrice Belleville and others.
Snick  snack CPSC 121: Models of Computation 2008/9 Winter Term 2 Functions Steve Wolfman, based on notes by Patrice Belleville and others.
Snick  snack CPSC 121: Models of Computation 2010 Winter Term 2 Revisiting Induction Steve Wolfman, based on work by Patrice Belleville and others 1.
Snick  snack CPSC 121: Models of Computation 2008/9 Winter Term 2 Proof Techniques Steve Wolfman, based on notes by Patrice Belleville and others.
Snick  snack CPSC 121: Models of Computation 2008/9 Winter Term 2 Rewriting Predicate Logic Statements Steve Wolfman, based on notes by Patrice Belleville.
Snick  snack CPSC 121: Models of Computation 2010/11 Winter Term 2 Propositional Logic: A First Model of Computation Steve Wolfman, based on notes by.
Snick  snack CPSC 121: Models of Computation 2010 Winter Term 2 Proof Techniques Steve Wolfman, based on notes by Patrice Belleville and others 1.
Snick  snack CPSC 121: Models of Computation 2010 Winter Term 2 DFAs in Depth Benjamin Israel Notes heavily borrowed from Steve Wolfman’s,
Snick  snack CPSC 121: Models of Computation 2010 Winter Term 2 Rewriting Predicate Logic Statements Steve Wolfman, based on notes by Patrice Belleville.
Snick  snack CPSC 121: Models of Computation 2010 Winter Term 2 DFAs in Depth Steve Wolfman, based on notes by Patrice Belleville and others.
Snick  snack CPSC 121: Models of Computation 2011 Winter Term 1 Proof Techniques (Part B) Steve Wolfman, based on notes by Patrice Belleville and others.
Proofs, Recursion and Analysis of Algorithms Mathematical Structures for Computer Science Chapter 2.1 Copyright © 2006 W.H. Freeman & Co.MSCS SlidesProofs,
CPSC 121: Models of Computation Unit 7: Proof Techniques Based on slides by Patrice Belleville and Steve Wolfman.
Proof by Deduction. Deductions and Formal Proofs A deduction is a sequence of logic statements, each of which is known or assumed to be true A formal.
Snick  snack CPSC 121: Models of Computation 2010/11 Winter Term 2 Introduction & Motivation Steve Wolfman, based on notes by Patrice Belleville and others.
Snick  snack CPSC 121: Models of Computation 2008/9 Winter Term 2 Proof (First Visit) Steve Wolfman, based on notes by Patrice Belleville, Meghan Allen.
Algebra Problems… Solutions
Introduction to Computer Science. A Quick Puzzle Well-Formed Formula  any formula that is structurally correct  may be meaningless Axiom  A statement.
Based on slides by Patrice Belleville and Steve Wolfman CPSC 121: Models of Computation Unit 9b: Mathematical Induction - part 2.
Introduction to Proofs
MATH 224 – Discrete Mathematics
Snick  snack CPSC 121: Models of Computation 2008/9 Winter Term 2 Describing the World with Predicate Logic Steve Wolfman, based on notes by Patrice Belleville.
Section 3.1: Proof Strategy Now that we have a fair amount of experience with proofs, we will start to prove more difficult theorems. Our experience so.
Snick  snack CPSC 121: Models of Computation 2012 Summer Term 2 Rewriting Predicate Logic Statements Steve Wolfman, based on notes by Patrice Belleville.
1 Section 1.1 A Proof Primer A proof is a demonstration that some statement is true. We normally demonstrate proofs by writing English sentences mixed.
Snick  snack CPSC 121: Models of Computation 2013W2 Introduction to Induction Steve Wolfman 1.
1 Sections 1.5 & 3.1 Methods of Proof / Proof Strategy.
Mathematical Induction I Lecture 4: Sep 16. This Lecture Last time we have discussed different proof techniques. This time we will focus on probably the.
Snick  snack CPSC 121: Models of Computation 2011 Winter Term 1 Introduction to Induction Steve Wolfman 1.
Automated Reasoning Early AI explored how to automated several reasoning tasks – these were solved by what we might call weak problem solving methods as.
Snick  snack Supplement: Worked Set Proofs Based on work by Meghan Allen.
Based on slides by Patrice Belleville and Steve Wolfman CPSC 121: Models of Computation Unit 11: Sets.
Year 9 Proof Dr J Frost Last modified: 19 th February 2015 Objectives: Understand what is meant by a proof, and examples.
Based on slides by Patrice Belleville and Steve Wolfman CPSC 121: Models of Computation Unit 11: Sets.
Snick  snack CPSC 121: Models of Computation 2008/9 Winter Term 2 Introduction & Motivation Steve Wolfman, based on notes by Patrice Belleville and others.
Week 4 - Friday.  What did we talk about last time?  Floor and ceiling  Proof by contradiction.
Direct Proof and Counterexample I Lecture 11 Section 3.1 Fri, Jan 28, 2005.
CPSC 121: Models of Computation REVIEW. Course Learning Outcomes You should be able to: – model important problems so that they are easier to discuss,
Proof And Strategies Chapter 2. Lecturer: Amani Mahajoub Omer Department of Computer Science and Software Engineering Discrete Structures Definition Discrete.
Chapter 1 Logic and Proof.
CPSC 121: Models of Computation 2008/9 Winter Term 2
CPSC 121: Models of Computation 2012 Summer Term 2
CPSC 121: Models of Computation 2016W2
CPSC 121: Models of Computation 2013W2
CPSC 121: Models of Computation 2016W2
CPSC 121: Models of Computation
CPSC 121: Models of Computation
CPSC 121: Models of Computation
Presentation transcript:

snick  snack CPSC 121: Models of Computation 2011 Winter Term 1 Proof Techniques (Part A) Steve Wolfman, based on notes by Patrice Belleville and others 1

Outline Learning Goals, Quiz Notes, and Big Picture Problems and Discussion: Generally Faster? –Breaking Down Big Proofs –Witness Proofs, also known as Proofs of Existence –Without loss of generality (WLOG), also known as Generalizing from the Generic Particular –Antecedent Assumption –Proving Inequality (and equivalences/equality) –Breaking Down Big Proofs, Revisited Coming Soon: More –Steve’s rebuilding to make this work better! 2

Learning Goals: “Pre-Class” Be able for each proof strategy below to: –Identify the form of statement the strategy can prove. –Sketch the structure of a proof that uses the strategy. Strategies: constructive/non-constructive proofs of existence ("witness"), disproof by counterexample, exhaustive proof, generalizing from the generic particular ("WLOG"), direct proof ("antecedent assumption"), proof by contradiction, and proof by cases. Alternate names are listed for some techniques. 3

Learning Goals: In-Class By the end of this unit, you should be able to: –Devise and attempt multiple different, appropriate proof strategies—including all those listed in the “pre-class” learning goals plus use of logical equivalences, rules of inference, universal modus ponens/tollens, and predicate logic premises—for a given theorem. –For theorems requiring only simple insights beyond strategic choices or for which the insight is given/hinted, additionally prove the theorem. 4

Quiz 7 Results NO QUIZ 7 THIS TERM 5

Where We Are in The Big Stories Theory How do we model computational systems? Now: With our powerful modelling language (pred logic), we can begin to express interesting questions (like whether one algorithm is faster than another “in general”). Hardware How do we build devices to compute? Now: We’ve been mostly on the theoretical side for a while, and we’ll stay there for another few days. Never fear, though, we’ll return! 6

Outline Learning Goals, Quiz Notes, and Big Picture Problems and Discussion: Generally Faster? –Breaking Down Big Proofs –Witness Proofs, also known as Proofs of Existence –Without loss of generality (WLOG), also known as Generalizing from the Generic Particular –Antecedent Assumption –Proving Inequality (and equivalences/equality) –Breaking Down Big Proofs, Revisited Coming Soon: More –Steve’s rebuilding to make this work better! 7

Our “GenerallyFaster” GenerallyFaster(a1, a2)   i  Z +,  n  Z +, n  i  Faster(a1, a2, n). 8 Alg A Alg B problem size time

Our Algorithms (a) Ask each student for the list of their MUG-mates’ classes, and check for each class whether it is CPSC 121. If the answer is ever yes, include the student in my count. (b) For each student s 1 in the class, ask the student for each other student s 2 in the class whether s 2 is a MUG-mate. If the answer is ever yes, include s 1 in my count. 9 Alg A Alg B problem size time

Our Algorithms At Particular Sizes (a) For 10 students: 10 minutes For 100 students: 100 minutes For 400 students: 400 minutes (b) For 10 students: ~10*10 seconds For 100 students: ~100*100 seconds For 400 students: ~400*400 seconds 10 Alg A Alg B problem size time

Proving “GenerallyFaster” GenerallyFaster(a1, a2)   i  Z +,  n  Z +, n  i  Faster(a1, a2, n). Can we prove algA is generally faster than algB? GenerallyFaster(algA, algB)   i  Z +,  n  Z +, n  i  Faster(algA, algB, n).   i  Z +,  n  Z +, n  i  60n < n Alg A Alg B problem size time (The last line is what we really mean in this case.)

Proving “GenerallyFaster” Theorem:  i  Z +,  n  Z +, n  i  60n < n 2. Which of these is the best overall description of this statement? a.It’s a big “AND”. b.It’s a big “OR”. c.It’s a conditional. d.It’s an inequality. 12 Alg A Alg B problem size time

Proving “GenerallyFaster” with “Helper Predicates” Theorem:  i  Z +,  n  Z +, n  i  60n < n 2. That’s the same as: Helper(i)   n  Z +, n  i  60n < n 2.  i  Z +, Helper(i). So to get started, we can think about how to prove an existential… 13 Alg A Alg B problem size time

Outline Learning Goals, Quiz Notes, and Big Picture Problems and Discussion: Generally Faster? –Breaking Down Big Proofs –Witness Proofs, also known as Proofs of Existence –Without loss of generality (WLOG), also known as Generalizing from the Generic Particular –Antecedent Assumption –Proving Inequality (and equivalences/equality) –Breaking Down Big Proofs, Revisited Coming Soon: More –Steve’s rebuilding to make this work better! 14

Proof of Existence or “witness proofs” Pattern to prove  x  D, R(x). Prove R(x) for any one x in D. Pick the one that makes your job easiest! The x you use for your proof is the “witness” to the existential… it “testifies” that your existential is true. 15 proving 

Why Does This Work? Pattern to prove  x  D, R(x). Prove R(x) for any one x in D. Pick the one that makes your job easiest! This is a big “OR”. To prove it, we must prove (at least) one of the “disjuncts”. Does this proof prove at least one of the disjuncts true? 16

Witness Proof Example: A Touch of Brevity Theorem: There’s a valid Racket program shorter than this (45-character) Java program: class A{public static void main(String[]a){}} Problem: prove the theorem. 17 Where “valid” means “runnable using the java / racket commands with no flags.

Proving “GenerallyFaster” Our Strategy So Far Theorem:  i  Z +,  n  Z +, n  i  60n < n 2. We pick i = ??. Then, we prove:  n  Z +, n  i  60n < n Alg A Alg B problem size time

Form of Our “TODO Item” Partial Theorem:  n  Z +, n  i  60n < n 2. Which of these is the best overall description of this statement? a.It’s a big “AND”. b.It’s a big “OR”. c.It’s a conditional. d.It’s an inequality. 19 Alg A Alg B problem size time

Proving “GenerallyFaster” Our Strategy So Far Theorem:  i  Z +,  n  Z +, n  i  60n < n 2. We pick i = ??. Then, we prove:  n  Z +, n  i  60n < n 2. That’s the same as: Helper2(i)  n  i  60n < n 2.  n  Z +, Helper2(i). 20 Alg A Alg B problem size time So, how do we prove a universal?

Outline Learning Goals, Quiz Notes, and Big Picture Problems and Discussion: Generally Faster? –Breaking Down Big Proofs –Witness Proofs, also known as Proofs of Existence –Without loss of generality (WLOG), also known as Generalizing from the Generic Particular –Antecedent Assumption –Proving Inequality (and equivalences/equality) –Breaking Down Big Proofs, Revisited Coming Soon: More –Steve’s rebuilding to make this work better! 21

Generalizing from the Generic Particular / Without Loss of Generality (WLOG) Pattern to prove  x  D, R(x). Pick some arbitrary x, but assume nothing about which x it is except that it’s drawn from D Then prove R(x). That is: pick x “without loss of generality”! 22 proving 

Why Does This Work? Pattern to prove  x  D, R(x). Pick some arbitrary x, but assume nothing about which x it is except that it’s drawn from D. Then prove R(x). This is a big “AND”. To prove it, we must prove each “conjunct”. Can we generate each individual proof from this one generic proof? 23

WLOG Example: My Machine Speaks Racket Theorem: Any valid Racket program can be represented in my computer’s machine language. Problem: prove the theorem. 24

WLOG Example: My Machine Speaks Racket Theorem: Any valid Racket program can be represented in my computer’s machine language. Proof: Without loss of generality, consider a valid Racket program p. Since it is valid, my Racket interpreter (DrRacket) can interpret it on my computer. However, all commands that my computer runs are expressed in its machine language. Therefore, the program can be expressed (as the combination of the compiled interpreter and the input program) in my computer’s machine language. QED 25

Proving “GenerallyFaster” Our Strategy So Far Theorem:  i  Z +,  n  Z +, n  i  60n < n 2. We pick i = ??. Without loss of generality, let n be a positive integer. Then, we prove: n  i  60n < n Alg A Alg B problem size time So, how do we prove a universal?

Form of Our “TODO Item” Partial Theorem: n  i  60n < n 2. Which of these is the best overall description of this statement? a.It’s a big “AND”. b.It’s a big “OR”. c.It’s a conditional. d.It’s an inequality. 27 Alg A Alg B problem size time

Proving “GenerallyFaster” Our Strategy So Far Theorem:  i  Z +,  n  Z +, n  i  60n < n 2. We pick i = ??. Without loss of generality, let n be a positive integer. Then, we prove: n  i  60n < n 2. With appropriate helpers, that’s just: H3(i,n)  H4(i,n) 28 Alg A Alg B problem size time So, how do we prove a conditional?

Outline Learning Goals, Quiz Notes, and Big Picture Problems and Discussion: Generally Faster? –Breaking Down Big Proofs –Witness Proofs, also known as Proofs of Existence –Without loss of generality (WLOG), also known as Generalizing from the Generic Particular –Antecedent Assumption –Proving Inequality (and equivalences/equality) –Breaking Down Big Proofs, Revisited Coming Soon: More –Steve’s rebuilding to make this work better! 29

A New Proof Strategy “Antecedent Assumption” To prove p  q: Assume p. Prove q. You have then shown that q follows from p, that is, that p  q, and you’re done. But this is a prop logic technique? Can we use those for pred logic? 30 proving 

Why Does This Work? To prove p  q: Assume p. Prove q. p  q is “really” an OR like ~p  q. If our assumption is wrong, is the OR true? If our assumption is right, is the OR true? 31

Partly Worked Problem: Universality of NOR Gates Theorem: If a circuit can be built from NOT gates and two-input AND, OR and XOR gates, then it can be built from NOR gates alone. Problem: prove the theorem. 32

Partly Worked Problem: Universality of NOR Gates Opening steps: (1) Without loss of generality, consider an arbitrary circuit. (2) [Assume the antecedent.] Assume the circuit can be built from NOT gates and two-input AND, OR and XOR gates. 33

Partly Worked Problem: Universality of NOR Gates Insight: We can “rewrite” each of the gates in this circuit as a NOR gate. How? AND OR XOR NOT Once you’ve shown this rewriting, you’ve proven the theorem. 34

Partly Worked Problem: Universality of NOR Gates Which of these NOR gate configurations is equivalent to ~p? e. None of these 35 p p T p F p q a. b. c. d.

Partly Worked Problem: Universality of NOR Gates Insight: Now that we can build NOT, can we rewrite the rest in terms of NOR and NOT? AND OR XOR 36

Proving “GenerallyFaster” Our Strategy So Far Theorem:  i  Z +,  n  Z +, n  i  60n < n 2. We pick i = ??. Without loss of generality, let n be a positive integer. Assume n  i. Then, we prove: 60n < n Alg A Alg B problem size time So, how do we prove an inequality?

Outline Learning Goals, Quiz Notes, and Big Picture Problems and Discussion: Generally Faster? –Breaking Down Big Proofs –Witness Proofs, also known as Proofs of Existence –Without loss of generality (WLOG), also known as Generalizing from the Generic Particular –Antecedent Assumption –Proving Inequality (and equivalences/equality) –Breaking Down Big Proofs, Revisited Coming Soon: More –Steve’s rebuilding to make this work better! 38

“Rules” for Inequalities Proving an inequality is a lot like proving equivalence. First, do your scratch work (often solving for a variable). Then, rewrite formally: Start from one side. Work step-by-step to the other. Never move “opposite” to your inequality (so, to prove “<”, never make the quantity smaller). Strict inequalities ( ): have at least one strict inequality step. 39

Proving “GenerallyFaster” Our Strategy So Far Theorem:  i  Z +,  n  Z +, n  i  60n < n 2. We pick i = ??. Without loss of generality, let n be a positive integer. Assume n  i. Then, we prove: 60n < n Alg A Alg B problem size time Scratch work: We need to pick an i so that 60n < n 2.

Scratch Work Partial Theorem: 60n < n 2. We need to pick an i so that 60n < n Alg A Alg B problem size time

Polished Work Partial Theorem: 60n < n 2. With i = ____ : 42 Alg A Alg B problem size time

Outline Learning Goals, Quiz Notes, and Big Picture Problems and Discussion: Generally Faster? –Breaking Down Big Proofs –Witness Proofs, also known as Proofs of Existence –Without loss of generality (WLOG), also known as Generalizing from the Generic Particular –Antecedent Assumption –Proving Inequality (and equivalences/equality) –Breaking Down Big Proofs, Revisited Coming Soon: More –Steve’s rebuilding to make this work better! 43

Finishing the Proof Theorem:  i  Z +,  n  Z +, n  i  60n < n 2. We pick i = 61. Without loss of generality, let n be a positive integer. Assume n  i. We note that: 60n < 61n = i*n  n*n(since n  i) = n 2 44 Alg A Alg B problem size time QED!

Notation note… Remember that this: 60n < 61n = i*n  n*n = n 2 Actually means this: 60n < 61n 61n= i*n i*n  n*n n*n= n 2 Since 60n is less than 61n, and 61n is equal to i*n, 60n is less than i*n. And, since i*n is less than or equal to n*n, 60n is less than n*n. And so on… 45 Alg A Alg B problem size time

How Did We Build the Proof? Theorem:  i  Z +,  n  Z +, n  i  60n < n 2. We pick i = 61. Without loss of generality, let n be a positive integer. Assume n  i. We note that: 60n < 61n = i*n  n*n(since n  i) = n 2 46 Alg A Alg B problem size time QED!

Strategies So Far  x  D, P(x).with WLOG  x  D, P(x).with a witness p  qby assuming the LHS p  qby proving each part p  qby proving either part 47 Those last two are prop logic strategies, and we can still use the rest of those as well!

Prop Logic Proof Strategies Work backwards from the end Play with alternate forms of premises Identify and eliminate irrelevant information Identify and focus on critical information Alter statements’ forms so they’re easier to work with “Step back” from the problem frequently to think about assumptions you might have wrong or other approaches you could take And, if you don’t know that what you’re trying to prove follows... switch from proving to disproving and back now and then. 48

More Practice: Always a Bigger Number Prove that for any integer, there’s a larger integer. Note: our proofs will frequently be purely in words now. Use predicate logic as you need it to clarify your thinking! In pred logic, this is  x  Z,  y  Z, y > x. The order of the quantifiers is important!! 49

More Practice: Always a Bigger Number Prove that for any integer, there’s a larger integer. Which strategy or strategies should we use? a.Witness proof alone b.WLOG with a witness proof inside c.Without loss of generality, twice. d.Witness proof, twice. e.None of these 50

Worked Problem: Always a Bigger Number Prove that for any integer, there’s a larger integer. Proof: Without loss of generality, let the first number x be an integer. Let the second number y be x + 1. Then, y = x + 1 > x. QED The proof uses WLOG then witness. 51 And… the predicate logic version makes that order obvious! WLOG outside for  x  Z, witness inside for  y  Z.

Outline Learning Goals, Quiz Notes, and Big Picture Problems and Discussion: Generally Faster? –Breaking Down Big Proofs –Witness Proofs, also known as Proofs of Existence –Without loss of generality (WLOG), also known as Generalizing from the Generic Particular –Antecedent Assumption –Proving Inequality (and equivalences/equality) –Breaking Down Big Proofs, Revisited Coming Soon: More –Steve’s rebuilding to make this work better! 52