inductive definitions with inference rules
play

Inductive Definitions with Inference Rules 1 / 25 Outline - PowerPoint PPT Presentation

Inductive Definitions with Inference Rules 1 / 25 Outline Introduction Specifying inductive definitions Inference rules in action Judgments, axioms, and rules Reasoning about inductive definitions Direct proofs Admissibility Rule induction


  1. Inductive Definitions with Inference Rules 1 / 25

  2. Outline Introduction Specifying inductive definitions Inference rules in action Judgments, axioms, and rules Reasoning about inductive definitions Direct proofs Admissibility Rule induction 2 / 25

  3. What are inference rules? Inference rules – a mathematical metalanguage For specifying and formally reasoning about inductive definitions Inductive definition Recursively defines something in terms of itself premises Human ( x ) → Mortal ( x ) Human ( x ) Mortal ( x ) conclusion Introduction 3 / 25

  4. Outline Introduction Specifying inductive definitions Inference rules in action Judgments, axioms, and rules Reasoning about inductive definitions Direct proofs Admissibility Rule induction Specifying inductive definitions 4 / 25

  5. Other metalanguages for inductive definitions Haskell data types Recursive functions in Haskell even :: Nat -> Bool data Nat = Z | S Nat even Z = True data Exp = Add Exp Exp | Neg Exp even (S Z) = False | Lit Nat even (S (S n)) = even n Grammars Can also define all of these with n ∈ Nat ::= Z | S n inference rules ! e ∈ Exp ::= add e e | neg e | n Specifying inductive definitions 5 / 25

  6. Example: defining syntax by inference rules rule schema Grammars n ∈ Nat n ∈ Nat ::= Z | S n Z ∈ Nat S n ∈ Nat e ∈ Exp ::= add e e axiom | neg e (no premises) | n n ∈ Nat e ∈ Exp n ∈ Exp neg e ∈ Exp e 1 ∈ Exp e 2 ∈ Exp add e 1 e 2 ∈ Exp Specifying inductive definitions 6 / 25

  7. Example: defining a predicate Option 1: Constructive judgment Recursive function in Haskell Even ( n ) Even ( Z ) even :: Nat -> Bool Even ( S (S n ) ) even Z = True even (S Z) = False even (S (S n)) = even n Option 2: Relate inputs to outputs Even ( Z , true ) Even ( S Z , false ) Even ( n , b ) Even ( S (S n ) , b ) Specifying inductive definitions 7 / 25

  8. Outline Introduction Specifying inductive definitions Inference rules in action Judgments, axioms, and rules Reasoning about inductive definitions Direct proofs Admissibility Rule induction Specifying inductive definitions 8 / 25

  9. How to define a concept (in general) Three parts of a definition: 1. syntax – how to express the concept 2. type – what kind of information is it? 3. content – the definition itself Example: dictionary definition Example: function definition e · ven | ’ ¯ even :: Nat -> Bool Syntax: ev e n | even Z = True Type: adjective even (S Z) = False Content: (of a number) divisible by even (S (S n)) = even n two without a remainder Specifying inductive definitions 9 / 25

  10. How to define a concept using inference rules 1. Define a judgment form – syntax and type States that one or more values have some property or exist in some relation to each other 2. Write down the rules for the judgment – content • axioms – base cases, only conclusion • proper rules – recursive cases, premises + conclusion Specifying inductive definitions 10 / 25

  11. Judgments 1. Define a judgment form – syntax and type States that one or more values have some property or exist in some relation to each other Syntax Type Property or relation n ∈ Nat AST n is in the syntactic category Nat Even ( n ) Nat n is an even number n 1 < n 2 Nat × Nat n 1 is less than n 2 e : T Exp × Type e has type T Γ ⊢ e : T Env × Exp × Type e has type T in environment Γ Specifying inductive definitions 11 / 25

  12. Set theoretic view of judgments A judgment is (conceptually) a predicate that indicates set membership Example: Even ( n ) ⊆ Nat Even : Nat → B = { ( Z , true ) , ( S Z , false ) , ( S (S Z) , true ) , . . . } ≡ { Z , S (S Z) , S (S (S (S Z))) , . . . } ⊆ Nat Example: n 1 < n 2 ⊆ Nat × Nat < : Nat × Nat → B = { (( 0 , 0 ) , false ) , (( 0 , 1 ) , true ) , . . . (( 5 , 3 ) , false ) , . . . (( 5 , 7 ) , true ) , . . . } ≡ { ( 0 , 1 ) , . . . ( 5 , 7 ) , . . . } ⊆ Nat × Nat Specifying inductive definitions 12 / 25

  13. Giving meaning to a judgment by inference rules Inductively defines the 2. Write down the rules of the judgment – content instances of a judgment • axioms – base cases, only conclusion (i.e. members of its set) • proper rules – recursive cases, premises + conclusion Rules for: Even ( n ) ⊆ Nat Rules for: n 1 < n 2 ⊆ Nat × Nat n 1 < n 2 n 1 < n 2 Even ( n ) Z < S Z Even ( Z ) n 1 < S n 2 S n 1 < S n 2 Even ( S (S n ) ) Specifying inductive definitions 13 / 25

  14. Exercises 1. Define the judgment: Odd ( n ) ⊆ Nat 2. Define the judgment: n 1 + n 2 = n 3 ⊆ Nat × Nat × Nat For reference: Rules for: n 1 < n 2 ⊆ Nat × Nat Rules for: Even ( n ) ⊆ Nat n 1 < n 2 n 1 < n 2 Even ( n ) Z < S Z Even ( Z ) n 1 < S n 2 S n 1 < S n 2 Even ( S (S n ) ) Specifying inductive definitions 14 / 25

  15. Outline Introduction Specifying inductive definitions Inference rules in action Judgments, axioms, and rules Reasoning about inductive definitions Direct proofs Admissibility Rule induction Reasoning about inductive definitions 15 / 25

  16. Expressing claims We can also use inference rules to express claims about judgments Examples Even ( S n ) n 1 < n 2 n 2 < n 3 n 1 + n 2 = n 3 S (S Z) ∈ Nat Odd ( n ) n 1 < n 3 n 2 + n 1 = n 3 How can we prove these claims? Three main techniques: 1. direct proof – derive conclusion from premises using the definition 2. admissibility – derive conclusion from derivations of premises 3. rule induction – reason inductively using the definition Reasoning about inductive definitions 16 / 25

  17. Outline Introduction Specifying inductive definitions Inference rules in action Judgments, axioms, and rules Reasoning about inductive definitions Direct proofs Admissibility Rule induction Reasoning about inductive definitions 17 / 25

  18. Direct proof by derivation Definition: n ∈ Nat Definition: n 1 < n 2 ⊆ Nat × Nat Succ n ∈ Nat n 1 < n 2 n 1 < n 2 S +1 Z ∈ Nat S n ∈ Nat Z < S Z n 1 < S n 2 S n 1 < S n 2 Z ∈ Nat Z < S Z Succ S S Z ∈ Nat Z < S (S Z) Succ +1 S (S Z) ∈ Nat S Z < S (S (S Z)) Reasoning about inductive definitions 18 / 25

  19. Proof trees Definition: e ∈ Exp Axioms: 0 ∈ Nat , 1 ∈ Nat , 2 ∈ Nat , . . . lit n ∈ Nat e ∈ Exp add e 1 ∈ Exp e 2 ∈ Exp neg n ∈ Exp neg e ∈ Exp add e 1 e 2 ∈ Exp 2 ∈ Nat 3 ∈ Nat 4 ∈ Nat lit lit lit 2 ∈ Exp 3 ∈ Exp 4 ∈ Exp add neg add 2 3 ∈ Exp neg 4 ∈ Exp add add (add 2 3) (neg 4) ∈ Exp Reasoning about inductive definitions 19 / 25

  20. Exercises Prove that the following expressions are valid terms in Exp 1. neg (add 5 (neg 2)) 2. add (neg (neg 3)) 4 Definition: e ∈ Exp Axioms: 0 ∈ Nat , 1 ∈ Nat , 2 ∈ Nat , . . . lit n ∈ Nat e ∈ Exp add e 1 ∈ Exp e 2 ∈ Exp neg n ∈ Exp neg e ∈ Exp add e 1 e 2 ∈ Exp Reasoning about inductive definitions 20 / 25

  21. Outline Introduction Specifying inductive definitions Inference rules in action Judgments, axioms, and rules Reasoning about inductive definitions Direct proofs Admissibility Rule induction Reasoning about inductive definitions 21 / 25

  22. Admissibility Construct proofs from assumed derivations of the premises Insights: • If the premise of a claim is satisfied, it must have a derivation • Can use information in the derivations to prove the conclusion Proof technique Show that all possible derivations of premises yield a proof of the conclusion Apply definition rules backwards on the premises, prove for each case! Reasoning about inductive definitions 22 / 25

  23. Super simple example Definition: n ∈ Nat ⊆ AST Bold claim Succ n ∈ Nat S ( S n ) ∈ Nat Z ∈ Nat S n ∈ Nat n ∈ Nat Only possible derivation Proof sketch: • Enumerate derivations of premise Succ n ∈ Nat • Show that each derivation proves S n ∈ Nat Succ the conclusion S ( S n ) ∈ Nat Reasoning about inductive definitions 23 / 25

  24. Outline Introduction Specifying inductive definitions Inference rules in action Judgments, axioms, and rules Reasoning about inductive definitions Direct proofs Admissibility Rule induction Reasoning about inductive definitions 24 / 25

  25. Rule induction Just like structural induction on inductive data types! Definition: e ∈ Exp ⊆ AST n ∈ Nat e ∈ Exp e 1 ∈ Exp e 2 ∈ Exp n ∈ Exp neg e ∈ Exp add e 1 e 2 ∈ Exp Suppose I want to prove property P on all Exp s. Just prove: • ∀ n ∈ Nat , P ( n ) • P ( e ) → P ( neg e ) • P ( e 1 ) → P ( e 2 ) → P ( add e 1 e 2 ) Reasoning about inductive definitions 25 / 25

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend