1 / 80

Quick Review

Quick Review. Get paper and pencil out. Not graded just for review. Questions. Write a derivation tree for pred(succ(zero)) int. S. Z. P. X int. X int. succ( X ) int. zero int. pred( X ) int. Is the rule below derivable, admissible, or neither?. S. Z. P. R0. X int. X int.

hugh
Download Presentation

Quick Review

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Quick Review Get paper and pencil out. Not graded just for review.

  2. Questions

  3. Write a derivation tree for pred(succ(zero))int S Z P Xint Xint succ(X)int zeroint pred(X)int

  4. Is the rule below derivable, admissible, or neither? S Z P R0 Xint Xint Xint succ(X)int zeroint pred(X)int eq(pred(succ(X)),X)

  5. Is the rule below derivable, admissible, or neither? S Z P R1 Xint Xint pred(X)int succ(X)int zeroint pred(X)int succ(X)int

  6. Is the rule below derivable, admissible, or neither? S Z P R2 Xint Xint Xint succ(X)int zeroint pred(X)int succ(pred(X))int

  7. Is the rule below derivable, admissible, or neither? S Z P R3 Xint Xint pred(X)int succ(X)int zeroint pred(X)int pred(succ(X))int

  8. Is the rule below derivable, admissible, or neither? S Z P R4 Xint Xint succ(X)int succ(X)int zeroint pred(X)int pred(succ(X))int

  9. Prove the following IfXnatthenXint (just sketch out the structure) S Z P Xint Xint succ(X)int zeroint pred(X)int

  10. What is the principle of rule induction look like for the rules above? S Z P Xint Xint succ(X)int zeroint pred(X)int

  11. Answers

  12. S Z P P S Z Xint Xint succ(zero)int zeroint succ(X)int zeroint pred(X)int Write a derivation tree for pred(succ(zero))int

  13. Is the rule below derivable, admissible, or neither? S Z P R0 Xint Xint Xint succ(X)int zeroint pred(X)int eq(pred(succ(X)),X)

  14. Is the rule below is neither derivable or admissible. S Z P R0 Xint Xint Xint succ(X)int zeroint pred(X)int eq(pred(succ(X)),X)

  15. Is the rule below derivable, admissible, or neither? S Z P R1 Xint Xint pred(X)int succ(X)int zeroint pred(X)int succ(X)int

  16. The rule below is admissible. S Z P R1 Xint Xint pred(X)int succ(X)int zeroint pred(X)int succ(X)int

  17. Is the rule below derivable, admissible, or neither? S Z P R2 Xint Xint Xint succ(X)int zeroint pred(X)int succ(pred(X))int

  18. The rule below is derivable. S Z P R2 Xint Xint Xint succ(X)int zeroint pred(X)int succ(pred(X))int

  19. Is the rule below derivable, admissible, or neither? S Z P R3 Xint Xint pred(X)int succ(X)int zeroint pred(X)int pred(succ(X))int

  20. The rule below is admissible. S Z P R3 Xint Xint pred(X)int succ(X)int zeroint pred(X)int pred(succ(X))int

  21. Is the rule below derivable, admissible, or neither? S Z P R4 Xint Xint succ(X)int succ(X)int zeroint pred(X)int pred(succ(X))int

  22. The rule below is derivable. S Z P R4 Xint Xint succ(X)int succ(X)int zeroint pred(X)int pred(succ(X))int

  23. Prove the following IfXnatthenXint (just sketch out the structure, i.e.) S Z P Xint Xint succ(X)int zeroint pred(X)int

  24. Proof Sketch By induction on X nat IH(x) = If x natthen x int Subgoal1: IH(zero) Subgoal2: IfIH(X’) thenIH(succ(X’))

  25. What is the principle of rule induction look like for the rules above? S Z P Xint Xint succ(X)int zeroint pred(X)int

  26. Rule Induction Principle If Xint, P(zero), if P(X’) then P(succ(X’)), and if P(Y’) then P(pred(Y’)) then P(X)

  27. Did You Ace The Quiz? • If so great! • If not go through the notes and the slides from lecture 1 • Still stuck talk to me or the TA • Did the entire class ace the quiz? • Probably not you are not the only one who is is confused!

  28. Inductively Defined Functions and Standard ML COS 441 Princeton University Fall 2004

  29. Assignment 1 • Handout today due back next Wednesday • Requires ML programming an a few simple proofs • Make sure you’re all set up to use your CS account and program in ML • Details and updates available through the course web

  30. Relations Review • A relation is set of tuples Odd = {1, 3, 5, … } Line = { (0.0, 0.0), (1.5,1.5), (x, x) , …} Circle = { (x, y) | x2 + y2 = 1.0 } • Odd is a predicate on natural numbers • Line, Circle, and Sphere are relations on real numbers • Line is a function

  31. Functions and Their Graphs • The graphof a function f(x) is the unique relation {(x,y) | f(x) = y } • We can uniquely specify a function by defining its graph as a relation • Not all relations specify valid functions!

  32. Some “graphs” of Relations • Below are some plotted graphs of the relations Circle and Line • For a relation to be a valid graph of a function each unique input has a unique output Line Circle

  33. Defining the Function add • We want to define a function add(m,n) • To do this first specify a relation that defines its graph A(m,n,p) inductively • Next show that our for any unique pair of m and n there is a unique p such that A(m,n,p)

  34. A-Z A-S X nat A(X,Y,Z) A(X,zero,X) A(X,succ(Y),succ(Z)) Defining the Graph of add

  35. A-Z A-S X nat Y nat Z nat A(X,Y,Z) X nat A(X,succ(Y),succ(Z)) A(X,zero,X) Avoiding Clutter Alternative definition that is equivalent to our previous one but its more cluttered since we have redundant premises Why are the all those extra premises not needed?

  36. A-Z-nat A-Y-nat A-X-nat A-Z A-S X nat A(X,Y,Z) A(X,Y,Z) A(X,Y,Z) A(X,Y,Z) A(X,succ(Y),succ(Z)) Ynat A(X,zero,X) Znat Xnat Defining the Graph of add The definition above immediately entails the following rules Why?

  37. A-Z-nat A-Y-nat A-X-nat A-Z A-S X nat A(X,Y,Z) A(X,Y,Z) A(X,Y,Z) A(X,Y,Z) A(X,succ(Y),succ(Z)) Ynat A(X,zero,X) Znat Xnat Defining the Graph of add The definition above immediately entails the following rules They can be shown to be admissible with the principle of rule induction for derivations of A and the rules Z and S

  38. Proving A is a Function Graph IfA(X,Y,Z), Xunique, and Yuniquethen Zisunique. Proof: By ??

  39. Proving A is a Function Graph IfA(X,Y,Z), Xunique, and Yuniquethen Zisunique. Proof: By rule induction for A(X,Y,Z)

  40. Proving A is a Function Graph IfA(X,Y,Z), Xunique, and Yuniquethen Zisunique. Proof: By rule induction for A(X,Y,Z) If A(X,Y,Z), IfX’ nat thenP(X’,zero,X’), and IfP(X’,Y’,Z’) then P(X’,succ(Y’),succ(Z’)) then P(X,Y,Z).

  41. Proving A is a Function Graph If A(X,Y,Z), case A-Z: IfX’ nat then IH(X’,zero,X’), case A-S: IfIH(X’,Y’,Z’) then IH(X’,succ(Y’),succ(Z’)) then IH(X,Y,Z).

  42. Proving A is a Function Graph If A(X,Y,Z), case A-Z: IfX’ nat then IH(X’,zero,X’), case A-S: IfIH(X’,Y’,Z’) then IH(X’,succ(Y’),succ(Z’)) then IH(X,Y,Z). IH(x,y,z) = ??

  43. Proving A is a Function Graph If A(X,Y,Z), case A-Z: IfX’ nat then IH(X’,zero,X’), case A-S: IfIH(X’,Y’,Z’) then IH(X’,succ(Y’),succ(Z’)) then IH(X,Y,Z). IH(x,y,z) = IfA(x,y,z), x unique, and y uniquethen z isunique.

  44. Proving A is a Function Graph case A-Z: IfX’ nat thenIH(X’,zero,X’) IH(x,y,z) = IfA(x,y,z), x unique, and y uniquethen z isunique.

  45. Proving A is a Function Graph case A-Z: IfX’ nat thenifA(X’,zero,X’), X’unique, and zerounique thenX’isunique.

  46. Proving A is a Function Graph case A-Z: … thenifA(X’,zero,X’), X’unique, and zerounique thenX’isunique. • X’ nat by assumption

  47. Proving A is a Function Graph case A-Z: …thenX’isunique. • X’ nat by assumption • A(X’,zero,X’), X’unique, and zerounique by assumption

  48. Proving A is a Function Graph case A-Z: • X’ nat by assumption • A(X’,zero,X’), X’unique, and zerounique by assumption • X’unique by (2)

  49. Proving A is a Function Graph case A-S: IfIH(X’,Y’,Z’) then IH(X’,succ(Y’),succ(Z’)) IH(x,y,z) = IfA(x,y,z), x unique, and y uniquethen z isunique.

  50. Proving A is a Function Graph case A-S: …then ifA(X’,succ(Y’),succ(Z’)), X’unique, and succ(Y’)unique thensucc(Z’)isunique • IH(X’,Y’,Z’) by assumption IH(x,y,z) = IfA(x,y,z), x unique, and y uniquethen z isunique.

More Related