Inductive Definitions with Inference Rules 1 / 27
Outline Introduction Specifying inductive definitions Inference rules in action Judgments, axioms, and rules Reasoning about inductive definitions Direct proofs Admissibility Rule induction 2 / 27
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) Mortal(x) Human(x) conclusion Introduction 3 / 27
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 / 27
Other metalanguages for specifying inductive definitions Haskell data types data Nat = Z S Nat data Exp = Add Exp Exp Neg Exp Lit Nat Recursive functions in Haskell even :: Nat -> Bool even Z = True even (S Z) = False even (S (S n)) = even n Grammars n Nat ::= Z S n e Exp ::= add e e neg e n Can also define all of these with inference rules! Specifying inductive definitions 5 / 27
Example: defining syntax by inference rules Grammars n Nat ::= Z S n e Exp ::= add e e neg e n rule schema Z Nat axiom (no premises) n Nat S n Nat n Nat n Exp e Exp neg e Exp e 1 Exp e 2 Exp add e 1 e 2 Exp Specifying inductive definitions 6 / 27
Example: defining a predicate Recursive function in Haskell even :: Nat -> Bool even Z = True even (S Z) = False even (S (S n)) = even n Option 1: Constructive judgment Even(n) Even(Z) Even(S (S 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 / 27
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 / 27
The structure of a definition How to define a concept in three parts: 1. syntax how to express the concept 2. type what kind of information does it relate? 3. content the definition itself Example: dictionary definition Syntax: e ven ēv n Type: adjective Content: (of a number) divisible by two without a remainder e Example: function definition even :: Nat -> Bool even Z = True even (S Z) = False even (S (S n)) = even n Specifying inductive definitions 9 / 27
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 / 27
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 / 27
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 / 27
Giving meaning to a judgment by inference rules 2. Write down the rules of the judgment content axioms base cases, only conclusion proper rules recursive cases, premises + conclusion Inductively defines the instances of a judgment (i.e. members of its set) Rules for: Even(n) Nat Rules for: n 1 < n 2 Nat Nat Even(Z) Even(n) Even(S (S n)) Z < S Z n 1 < n 2 n 1 < S n 2 n 1 < n 2 S n 1 < S n 2 Specifying inductive definitions 13 / 27
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: Even(n) Nat Rules for: n 1 < n 2 Nat Nat Even(Z) Even(n) Even(S (S n)) Z < S Z n 1 < n 2 n 1 < S n 2 n 1 < n 2 S n 1 < S n 2 Specifying inductive definitions 14 / 27
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 / 27
Expressing claims We can use inference rules to express claims about judgments Examples S (S Z) Nat Even(S n) Odd(n) n 1 < n 2 n 2 < n 3 n 1 < n 3 n 1 + n 2 = n 3 n 2 + n 1 = n 3 How can we prove these claims? Use definition of judgment and one of 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 / 27
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 / 27
Direct proof by derivation Definition: n Nat Succ n Nat Z Nat S n Nat Definition: n 1 < n 2 Nat Nat Z < S Z S n 1 < n 2 n 1 < S n 2 +1 n 1 < n 2 S n 1 < S n 2 Succ Z Nat S Z Nat Succ S (S Z) Nat +1 Z < S Z S Z < S (S Z) S Z < S (S (S Z)) Reasoning about inductive definitions 18 / 27
Proof trees Definition: e Exp Axioms: 0 Nat, 1 Nat, 2 Nat,... lit n Nat n Exp neg e Exp neg e Exp add e 1 Exp e 2 Exp add e 1 e 2 Exp lit 2 Nat lit 3 Nat lit 4 Nat 2 3 4 add neg add 2 3 Exp neg 4 Exp add add (add 2 3) (neg 4) Exp Reasoning about inductive definitions 19 / 27
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 n Exp neg e Exp neg e Exp add e 1 Exp e 2 Exp add e 1 e 2 Exp Reasoning about inductive definitions 20 / 27
Philosophical point: intension vs. extension Intensional definition: a description of the meaning of a judgment captured by the inference rules directly Extensional meaning: the set of all instances that satisfy the judgment derivable from the inference rules Syntax Intension: definition by grammar Extension: set of all ASTs Function (example) Intension: f (x) = x + 3 Extension: {... (1, 4), (2, 5), (3, 6),...} Reasoning about inductive definitions 21 / 27
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 22 / 27
Admissibility An alternative way to prove a claim, based on constructing proofs from assumed derivations of the premises Proof technique Assume the definition of the judgment is complete all valid judgments can be derived from axioms using only the rules in the definition Then, if the premise of a claim is satisfied, it must have a derivation key insight: use derivations to construct a proof of the conclusion Show that all derivations of premises yield a proof of the conclusion basically, apply definition rules backwards and prove for each case Reasoning about inductive definitions 23 / 27
Super simple example Definition: n Nat AST Succ n Nat Z Nat S n Nat Bold claim S (S n) Nat n Nat Proof sketch: Enumerate derivations of premise Show that each derivation proves the conclusion Only possible derivation Succ n Nat S n Nat Succ S (S n) Nat Reasoning about inductive definitions 24 / 27
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 25 / 27
Rule induction Just like structural induction on inductive data types! Definition: e Exp AST n Nat n Exp e Exp neg e Exp e 1 Exp e 2 Exp add e 1 e 2 Exp Suppose I want to prove property P on all Exps. 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 26 / 27
Example: admissibility + rule induction Def: n 1 < n 2 (Nat Nat) Claim Z Z < S n +LR n 1 < n 2 S n 1 < S n 2 +R n 1 < n 2 n 1 < S n 2 Derivation 1: Let n 1 = Z, n 2 = S n 2 Plug into claim: +R Z Z < S n 2 Z < S n 2 Z < S (S n 2 ) Direct proof with Z, n = S n 2 Derivation 2: Let n 1 = S n 1, n 2 = S n 2 Plug into claim: +R n 1 < n 2 S n 1 < S (S n 2 ) S n 1 < S n 2 S (S n 1 ) < S (S (S n 2 )) Rule +LR, then induction hypothesis Reasoning about inductive definitions 27 / 27