1 / 10

Structural Induction

Structural Induction. CS 611. Structural Induction. Useful for proving properties about languages. Useful for proving properties about algorithms defined on languages. A generalization of the induction you know and love. Induction on the Naturals. 0. n. n+1. Example.

elliot
Télécharger la présentation

Structural Induction

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. Structural Induction CS 611

  2. Structural Induction • Useful for proving properties about languages. • Useful for proving properties about algorithms defined on languages. • A generalization of the induction you know and love.

  3. Induction on the Naturals 0 n n+1

  4. Example Prove: every natural number is odd or even. Base: 0 is even. Induction: if n is odd or even then n+1 is odd or even. Suppose n is odd, then n+1 is even Suppose n is even then n+1 is odd. 0 n n+1

  5. Induction on Aexp Suppose I want to prove a property of all arithmetic expressions. Like “eval (aexp) is finite” for some evaluation function eval. Aexp has 2 atoms and 2 constructors. So induction on Aexp has ___ base cases and ___ inductive steps? What is the induction theorem for arithmetic expressions? var const + Aexp Aexp - Aexp Aexp

  6. Induction on Aexp var const + Aexp Aexp - Aexp Aexp

  7. Example Eval (aexp a) if a = var then val(a) if a = const then a if a = (b+c) then eval(b)*eval(c) if a = (b-c) then eval(b)/eval(c) Prove: forall a:aexp. eval(a) terminates Base 1: eval(var) terminates Base 2: eval(const) terminates Ind1: suppose eval(b) and eval(c) terminate prove eval (b+c) termiantes Ind2: suppose eval(b) and eval(c) terminate prove eval(b-c) terminates

  8. Example Eval (aexp a) if a = var then val(a) if a = const then a if a = (b+c) then eval(b)*eval(c) if a = (b-c) then eval(b)/eval(c) Prove: forall a:aexp. eval(a) = correct_val(a) Base 1: eval(var) = correct_val(var) Base 2: eval(const) = correct_val(const) Ind1: suppose eval(b) = correct_eval(b) and eval(c) = correct_eval(c) prove eval(b+c) = correct_eval(b+c) Ind2: suppose eval(b) = correct_eval(b) and eval(c) = correct_eval(c) prove eval(b-c) = correct_eval(b-c)

  9. Example Eval (aexp a) if a = var then val(a) if a = const then a if a = (b+c) then eval(b)*eval(c) if a = (b-c) then eval(b)/eval(c) Prove: forall a:aexp. eval(a) is finite Base 1: eval(var) is finite Base 2: eval(const) is finite Ind1: suppose eval(b) is finite and eval(c) is finite prove eval(b+c) is finite Ind2: suppose eval(b) is finite and eval(c) is finite prove eval(b-c) is finite

  10. Reminders • Reverse engineer proof of Thm 3.1 to scratch work for Monday. • Start on proofs of Thms 3.2, 3.3, probably for Tuesday. • Thm 3.4 and Cor 3.2 likely for Friday • Paper 1 on Friday • Cancel Godel encoding part of hwk.

More Related