1 / 53

Room Change!!!!

Room Change!!!!. Starting Wednesday Room 302. Inductive Definitions. COS 441 Princeton University Fall 2004. Reminder. If you are not on the official class list send me email. Relations. A relation is set of tuples Odd = {1, 3, 5, … } Line = { (0.0, 0.0), (1.5,1.5), (x, x) , …}

lamis
Download Presentation

Room Change!!!!

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. Room Change!!!! Starting Wednesday Room 302

  2. Inductive Definitions COS 441 Princeton University Fall 2004

  3. Reminder If you are not on the official class list send me email

  4. Relations • 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

  5. Judgments • Given a relation Ron objects x1,…,xn we say R(x1,…,xn) or (x1,…,xn) R to mean (x1,…,xn) 2R • The assertion R(x1,…,xn) or (x1,…,xn)Ris a judgment • The tuple (x1,…,xn) is an instance of the judgment formR

  6. Example Judgments • Valid judgments: Odd(7), Line(,), Circle(0.0,1.0), Sphere(1.0,0.0,0.0) • Invalid judgments: Odd(2), Line(0.0,0.5) • How do we determine if a judgment is valid or invalid? • From the definition of the relation • How can we define relations?

  7. Defining Relations • Enumerate • Nice if you happen to be talking about finite relations • Directly via mathematical constraints • e.g. Circle = { (x,y) | x2 + y2 = 1.0 } • Use inductive definitions • Not all relations have nice inductive definitions • Most of what we need for programming languages fortunately do

  8. Rules and Derivations • Inductive definitions consist of a set of inference rules • Inference rules are combined to form derivations trees • A valid derivation leads to a conclusion which asserts a certain judgment is valid • The set of all valid judgments for a relation implicitly defines the relation

  9. name name (y1,X,…, yn) S … (z1,X,…,zn) T premises conclusion (x1,X,…,xn) R conclusion Anatomy of a Rule proper rule axiom rule schema name schematic variable

  10. Rule Schemas • Schematic rules represent rule templates • Schematic variables can be substituted with a primitive terms or other schematic variables • All occurrences of a variable must be substituted with the same term or variable

  11. Reasoning with Rules • We can find derivations for a judgment via goal-directed search or enumeration • Both approaches will eventually find derivations for valid judgments • Neither approach knows when to stop • Invalid judgments cause our algorithm to non-terminate

  12. S Z Xnat succ(X)nat zeronat Example: Natural Numbers succ(succ(zero))nat Goal:

  13. S Z S Xnat succ(zero)nat succ(X)nat zeronat Example: Natural Numbers Substitution X = succ(zero) Goal succ(succ(zero))nat

  14. S Z S S Xnat succ(zero)nat zeronat succ(X)nat zeronat Example: Natural Numbers Substitution X = zero Goal succ(succ(zero))nat

  15. S Z S S Z Xnat succ(zero)nat zeronat succ(X)nat zeronat Example: Natural Numbers Done succ(succ(zero))nat

  16. Example: Natural Numbers Derivable Judgments: {} succ(succ(zero))nat Goal:

  17. Z Example: Natural Numbers Derivable Judgments: {zeronat} Because: zeronat succ(succ(zero))nat Goal:

  18. S Z zeronat Example: Natural Numbers Derivable Judgments: {zeronat, succ(zero)nat} Because: succ(zero)nat succ(succ(zero))nat Goal:

  19. S S Z succ(zero)nat zeronat Example: Natural Numbers Derivable Judgments: {zeronat, succ(zero)nat, succ(succ(zero))nat } Because: succ(succ(zero))nat succ(succ(zero))nat Goal:

  20. S-O Z-E S-E Xeven Xodd succ(X)odd zeroeven succ(X)even Odd and Even Numbers Derivable Judgments: {zeroeven, succ(zero)odd, succ(succ(zero))even, … }

  21. Some Theorems about Numbers • Theorems: • If Xnat then Xodd or Xeven • If Xeven then Xnat • If Xodd then Xnat • How do we prove the theorems above? • Note this is for the schematic variable X • The principal of rule inductions is what we use to show a property for any instantiation of X

  22. Rule Induction for Naturals IfXnat, P(zero), and ifP(Y) thenP(succ(Y)) thenP(X). Notice that P is a schematic variable for an arbitrary relation or proposition

  23. Proof:If Xnat then Xodd or Xeven. IfXnat, P(zero), and ifP(Y) thenP(succ(Y)) thenP(X).

  24. Proof:If Xnat then Xodd or Xeven. IfXnat, zerooddorzeroeven, and ifP(Y) thenP(succ(Y)) thenP(X). Substitution P(x) = x oddor x even

  25. Proof:If Xnat then Xoddor Xeven. IfXnat, zerooddorzeroeven, and if (YoddorYeven)thenP(succ(Y)) thenP(X). Substitution P(x) = x oddor x even

  26. Proof:If Xnat then Xoddor Xeven. IfXnat, zerooddorzeroeven, and if (YoddorYeven)then succ(Y)oddor succ(Y)even thenP(X). Substitution P(x) = x oddor x even

  27. Proof:If Xnat then Xodd or Xeven. IfXnat, zerooddorzeroeven, and if (YoddorYeven)then succ(Y)oddor succ(Y)even thenX oddorXeven. Substitution P(x) = x odd or x even

  28. Proof:If Xnat then Xoddor Xeven. Subgoal 1 IfXnat, zeroodd orzeroeven, and if (YoddorYeven)then succ(Y)oddor succ(Y)even thenXoddorXeven. Subgoal 2

  29. Proof:zerooddorzeroeven • zeroeven by axiom Z-E

  30. Proof:zerooddorzeroeven • zeroeven by axiom Z-E • zerooddorzeroeven by (1)

  31. Proof:if (YoddorYeven)thensucc(Y)oddor succ(Y)even • Yodd orYeven by assumption • succ(Y)odd or succ(Y)even from (1) case Y odd 2.1. succ(Y) even by rule S-E 2.2. succ(Y) odd or succ(Y) even by (2.1) case Y even 2.1. succ(Y) odd by rule S-O 2.2. succ(Y) odd or succ(Y) even by (2.1)

  32. Proof:if (YoddorYeven)thensucc(Y)oddor succ(Y)even • YoddorYeven by assumption • succ(Y)oddor succ(Y)even from (1) case Y odd 2.1. succ(Y) even by rule S-E 2.2. succ(Y) odd or succ(Y) even by (2.1) case Y even 2.1. succ(Y) odd by rule S-O 2.2. succ(Y) odd or succ(Y) even by (2.1)

  33. Proof:if (YoddorYeven)thensucc(Y)oddor succ(Y)even • Yodd orYeven by assumption • succ(Y)oddor succ(Y)even from (1) caseYodd 2.1. succ(Y) even by rule S-E 2.2. succ(Y) odd or succ(Y) even by (2.1) caseYeven 2.1. succ(Y) odd by rule S-O 2.2. succ(Y) odd or succ(Y) even by (2.1)

  34. Proof:if (Y oddorYeven)thensucc(Y)odd or succ(Y)even • YoddorYeven by assumption • succ(Y)oddor succ(Y)even from (1) caseYodd 2.1. succ(Y)even by rule S-E 2.2. succ(Y) odd or succ(Y)even by (2.1) caseYeven 2.1. succ(Y) odd by rule S-O 2.2. succ(Y) odd or succ(Y) even by (2.1)

  35. Proof:if (YoddorYeven)thensucc(Y)odd or succ(Y)even • YoddorYeven by assumption • succ(Y)oddor succ(Y)even from (1) caseYodd 2.1. succ(Y)even by rule S-E 2.2. succ(Y)odd or succ(Y) even by (2.1) caseYeven 2.1. succ(Y) odd by rule S-O 2.2. succ(Y)odd or succ(Y)even by (2.1)

  36. Derivable and Admissible Rules • The primitive rules Z and S define the predicate nat • Other rules may be shown to be derivable or admissible wrt the primitive rules • Derivable rules follow directly from a partial derivations of primitive rules • Admissible rules are a consequence of the primitive rules that are not derivable

  37. S-O Z-E S-E Xeven Xodd succ(X)odd zeroeven succ(X)even Reminder about Odd and Even These are the only primitive rules for odd and even judgments.

  38. S-E S-O S-S-E succ(succ(X))even succ(X)odd Xeven X even succ(succ(X))even A Derivable Rule The rule is derivable because

  39. bogus1 bogus2 X even zero odd succ(X) even Underivable Rules These rules are not derivable or admissible

  40. bogus1 bogus2 invert-S-O X even succ(X)odd zero odd succ(X) even X even Underivable Rules These rules are not derivable or admissible The rule is not derivable

  41. bogus1 bogus2 invert-S-O X even succ(X)odd zero odd succ(X) even X even Underivable Rules These rules are not derivable or admissible The rule is not derivable but is admissible

  42. invert-S-O succ(X)odd X even Admissible Rule The rule invert-S-O is admissible because because ???

  43. invert-S-O succ(X)odd X even Admissible Rule The rule invert-S-O is admissible because because any completederivation of succ(X)odd must have ??? X even

  44. invert-S-O succ(X)odd X even Admissible Rule The rule invert-S-O is admissible because because any completederivation of succ(X)odd must have used the rule S-O which requires X even as a premise

  45. Admissible Rules Caveat • Admissible rules are admissible with respect to a fixed set of primitive rules • Adding a new primitive rule can change admissibility of previous rules • Adding a new primitive rule does not effect derivability of previous rules

  46. S-N-O invert-S-O succ(X)odd succ(neg(zero))odd X even Breaking an Admissible Rule If we add this primitive rule to Z-E, S-O, and S-E The rule below is not admissible wrt Z-E,S-O,S-E, and S-N-O

  47. N-Z-E S-N-O invert-S-O succ(X)odd neg(X) even X even succ(neg(X))odd neg(zero)even Fixing an Admissible Rule If we add these primitive rules to Z-E, S-O, and S-E The rule below is admissible wrt Z-E,S-O,S-E, S-N-O, and N-Z-E

  48. Z-O invert-S-O succ(X)odd X even zero odd Be Careful! If we add this primitive rules to Z-E, S-O, and S-E The rule below is ??

  49. Z-O invert-S-O succ(X)odd X even zero odd Be Careful! If we add this primitive rules to Z-E, S-O, and S-E The rule below is still admissible wrt Z-E,S-O,S-E, and Z-O

  50. Z-O invert-S-O silly1 silly2 succ(X)odd X odd X even zero odd X even succ(one) even Be Careful! If we add this primitive rules to Z-E, S-O, and S-E The rule below is still admissible wrt Z-E,S-O,S-E, and Z-O The rules below are also admissible or derivable

More Related