Midterm Review Session Wednesday, June 13 from 56pm in ORCH 3074 - - PDF document

midterm review session
SMART_READER_LITE
LIVE PREVIEW

Midterm Review Session Wednesday, June 13 from 56pm in ORCH 3074 - - PDF document

Midterm Review Session Wednesday, June 13 from 56pm in ORCH 3074 CPSC 121: Models of Computation the TAs will stay until 6:30pm if there are still 2018S questions Proof Techniques (Part A) Meghan Allen based on notes by Steve


slide-1
SLIDE 1

1

CPSC 121: Models of Computation 2018S

Proof Techniques (Part A) Meghan Allen based on notes by Steve Wolfman, Patrice Belleville and others

1

Midterm Review Session

  • Wednesday, June 13 from 5‐6pm in ORCH

3074

– the TAs will stay until 6:30pm if there are still questions

2

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: The Rest

3

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.

4

Alternate names are listed for some techniques.

slide-2
SLIDE 2

2

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.

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

  • ne 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 a little while longer. 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: The Rest

7

Our “GenerallyFaster”

GenerallyFaster(a1, a2) = i  Z+, n  Z+, n  i  Faster(a1, a2, n).

8

Alg A Alg B problem size time

slide-3
SLIDE 3

3

Our Algorithms

(a) Ask each student for the list of their groupmates’ 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 s1 in the class, ask the student for each other student s2 in the class whether s2 is a groupmate. If the answer is ever yes, include s1 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 < n2.

11

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 < n2.

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

slide-4
SLIDE 4

4

Proving “GenerallyFaster”

Theorem: i  Z+, n  Z+, n  i  60n < n2.

We can always pick out the “outermost” operator:

i  Z+, P(i), where… P(i) = n  Z+, n  i  60n < n2

13

Alg A Alg B problem size time

Proving “GenerallyFaster”

Theorem: i  Z+, n  Z+, n  i  60n < n2.

We can always pick out the “outermost” operator:

i  Z+, P(i), where… P(i) = n  Z+, Q(i,n), Q(i,n) = n  i  60n < n2

14

Alg A Alg B problem size time

Proving “GenerallyFaster”

Theorem: i  Z+, n  Z+, n  i  60n < n2.

We can always pick out the “outermost” operator:

i  Z+, P(i), where… P(i) = n  Z+, Q(i,n), Q(i,n) = R(i,n)  S(n), R(i,n)= n  i, S(n) = 60n < n2

15

Alg A Alg B problem size time

Proving “GenerallyFaster”

Theorem: i  Z+, n  Z+, n  i  60n < n2.

We can always pick out the “outermost” operator:

i  Z+, P(i), where… P(i) = n  Z+, Q(i,n), Q(i,n) = R(i,n)  S(n), R(i,n)= n  i, S(n) = 60n < n2

So to get started, we can think about how to prove an existential…

16

Alg A Alg B problem size time

slide-5
SLIDE 5

5

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: The Rest

17

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.

(We’re proving one of the disjuncts of a big “OR”.)

18

proving 

Witness Proof Example: A Touch of Brevity

Theorem: There’s a valid BSL program shorter than this (45‐character) Java program: class A{public static void main(String[]a){}} Problem: prove the theorem.

19

Proving “GenerallyFaster” Our Strategy So Far

Theorem: i  Z+, n  Z+, n  i  60n < n2.

We pick i = ??. Then, we prove: n  Z+, n  i  60n < n2.

20

Alg A Alg B problem size time

LEAVE this blank until you know what to pick. Take notes as you learn more about i.

slide-6
SLIDE 6

6

Form of Our “TODO Item”

Partial Theorem: n  Z+, n  i  60n < n2.

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.

21

Alg A Alg B problem size time

Proving “GenerallyFaster” Our Strategy So Far

Theorem: i  Z+, n  Z+, n  i  60n < n2.

We pick i = ??. Then, we prove: n  Z+, n  i  60n < n2. That’s the same as: Q(i,n) = n  i  60n < n2. n  Z+, Q(i,n).

22

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: The Rest

23

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”!

24

proving 

slide-7
SLIDE 7

7

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

  • ne generic proof?

25

WLOG Example: My Machine Speaks BSL

Theorem: Any valid BSL program can be represented in my computer’s machine language. Problem: prove the theorem.

26

WLOG Example: My Machine Speaks BSL

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

27

Proving “GenerallyFaster” Our Strategy So Far

Theorem: i  Z+, n  Z+, n  i  60n < n2.

We pick i = ??. Without loss of generality, let n be an arbitrary positive integer. Then, we prove: n  i  60n < n2.

28

Alg A Alg B problem size time

slide-8
SLIDE 8

8

Form of Our “TODO Item”

Partial Theorem: n  i  60n < n2.

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.

29

Alg A Alg B problem size time

Proving “GenerallyFaster” Our Strategy So Far

Theorem: i  Z+, n  Z+, n  i  60n < n2.

We pick i = ??. Without loss of generality, let n be an arbitrary positive integer. Then, we prove: n  i  60n < n2. With appropriate helpers, that’s just: R(i,n)  S(n)

30

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: The Rest

31

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.

32

But this is a prop logic technique. Can we use those for pred logic? proving 

slide-9
SLIDE 9

9

Why Does This Work?

To prove p  q: Assume p. Prove q. p  q is “really” an OR like ~p  q. Our assumption must be true or false… If our assumption is false, is the OR true? If our assumption is true, is the OR true?

33

Partly Worked Problem: Universality

  • f 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. Step 1: rewrite in predicate logic

34

Partly Worked Problem: Universality

  • f 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.

35

Partly Worked Problem: Universality

  • f NOR Gates

Insight: We can “rewrite” each of the gates in this circuit as a NOR gate. How?

36

AND OR XOR

NOT

Once you’ve shown this rewriting, you’ve proven the theorem.

slide-10
SLIDE 10

10 Partly Worked Problem: Universality

  • f NOR Gates

Which of these NOR gate configurations is equivalent to ~p?

37

  • e. None of these

p p T p F p q a. b. c. d.

Partly Worked Problem: Universality

  • f NOR Gates

Insight: Now that we can build NOT, can we rewrite the rest in terms of NOR and NOT?

38

AND OR XOR

Proving “GenerallyFaster” Our Strategy So Far

Theorem: i  Z+, n  Z+, n  i  60n < n2.

We pick i = ??. Without loss of generality, let n be an arbitrary positive integer. Assume n  i. Then, we prove: 60n < n2.

39

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: The Rest

40

slide-11
SLIDE 11

11

“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 (< and >): have

at least one strict inequality step.

41

Proving “GenerallyFaster” Our Strategy So Far

Theorem: i  Z+, n  Z+, n  i  60n < n2.

We pick i = ??. Without loss of generality, let n be an arbitrary positive integer. Assume n  i. Then, we prove: 60n < n2.

42

Alg A Alg B problem size time

Scratch work: We need to pick an i so that 60n < n2.

Scratch Work

Partial Theorem: 60n < n2.

We need to pick an i so that 60n < n2. Let’s try solving for n in our scratch work!

43

Alg A Alg B problem size time

Polished Work

Partial Theorem: 60n < n2.

With i = _61___:

44

Alg A Alg B problem size time

slide-12
SLIDE 12

12

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: The Rest

45

Finishing the Proof

Theorem: i  Z+, n  Z+, n  i  60n < n2.

We pick i = 61. Without loss of generality, let n be an arbitrary positive integer. Assume n  i. Observe that:

60n < 61n = i*n  n*n (since n  i) = n2

46

Alg A Alg B problem size time

QED!

Notation note…

Remember that this: 60n < 61n = i*n  n*n = n2 Actually means this: 60n < 61n 61n = i*n i*n  n*n n*n = n2

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…

47

Alg A Alg B problem size time

How Did We Build the Proof?

Theorem: i  Z+, n  Z+, n  i  60n < n2.

We pick i = 61. Without loss of generality, let n be an arbitrary positive integer. Assume n  i. Observe that:

60n < 61n = i*n  n*n (since n  i) = n2

48

Alg A Alg B problem size time

QED!

slide-13
SLIDE 13

13

Strategies So Far

x  D, P(x). with WLOG x  D, P(x). with a witness p  q by assuming the LHS p  q by proving each part p  q by proving either part p  q by assuming ~p and showing q (same strategy as for p  q!!)

49

We can still use all our propositional logic strategies!

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

  • ther approaches you could take

50

And, if you don’t know that what you’re trying to prove follows... switch from proving to disproving and back now and then.

More Practice: Always a Bigger Number

Prove that for any integer, there’s a larger integer.

51

Note: our proofs will frequently be purely in words now. BUT, translate the theorem into predicate logic so you can structure your proof! This is x  Z, y  Z, y > x.

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

52

x  Z, y  Z, y > x

slide-14
SLIDE 14

14 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.

53

And… the predicate logic version makes that order obvious! WLOG outside for x  Z, witness inside for y  Z. x  Z, y  Z, y > x.

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: The Rest

54