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

inductive definitions with inference rules
SMART_READER_LITE
LIVE PREVIEW

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


slide-1
SLIDE 1

Inductive Definitions with Inference Rules

1 / 25

slide-2
SLIDE 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

slide-3
SLIDE 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

slide-4
SLIDE 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

slide-5
SLIDE 5

Other metalanguages for inductive definitions

Haskell data types

data Nat = Z | S Nat data Exp = Add Exp Exp | Neg Exp | Lit Nat

Grammars

n ∈ Nat ::=

Z | S n

e ∈ Exp ::=

add e e

|

neg e

| n

Recursive functions in Haskell

even :: Nat -> Bool even Z = True even (S Z) = False even (S (S n)) = even n

Can also define all of these with inference rules!

Specifying inductive definitions 5 / 25

slide-6
SLIDE 6

Example: defining syntax by inference rules

Grammars

n ∈ Nat ::=

Z | S n

e ∈ Exp ::=

add e e

|

neg e

| n rule schema

Z ∈ Nat

n ∈ Nat

S n ∈ Nat

axiom (no premises) n ∈ Nat n ∈ Exp e ∈ Exp

neg e ∈ Exp

e1 ∈ Exp e2 ∈ Exp

add e1 e2 ∈ Exp

Specifying inductive definitions 6 / 25

slide-7
SLIDE 7

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(Z) Even(n) 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 / 25

slide-8
SLIDE 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

slide-9
SLIDE 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

Syntax: e·ven | ’¯ ev e n | Type: adjective Content: (of a number) divisible by two without a remainder

Example: function definition

even :: Nat -> Bool even Z = True even (S Z) = False even (S (S n)) = even n

Specifying inductive definitions 9 / 25

slide-10
SLIDE 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

  • r 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

slide-11
SLIDE 11

Judgments

  • 1. Define a judgment form – syntax and type

States that one or more values have some property

  • r 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 n1 < n2 Nat × Nat n1 is less than n2 e : T Exp × Type e has type T Γ ⊢ e : T Env × Exp × Type e has type T in environment Γ

Specifying inductive definitions 11 / 25

slide-12
SLIDE 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: n1 < n2 ⊆ 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

slide-13
SLIDE 13

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

Even(Z) Even(n) Even(S (S n))

Rules for: n1 < n2 ⊆ Nat × Nat

Z < S Z

n1 < n2 n1 < S n2 n1 < n2

S n1 < S n2

Specifying inductive definitions 13 / 25

slide-14
SLIDE 14

Exercises

  • 1. Define the judgment: Odd(n) ⊆ Nat
  • 2. Define the judgment: n1 + n2 = n3 ⊆ Nat × Nat × Nat

For reference:

Rules for: Even(n) ⊆ Nat

Even(Z) Even(n) Even(S (S n))

Rules for: n1 < n2 ⊆ Nat × Nat

Z < S Z

n1 < n2 n1 < S n2 n1 < n2

S n1 < S n2

Specifying inductive definitions 14 / 25

slide-15
SLIDE 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

slide-16
SLIDE 16

Expressing claims

We can also use inference rules to express claims about judgments

Examples

S (S Z) ∈ Nat

Even(S n) Odd(n) n1 < n2 n2 < n3 n1 < n3 n1 + n2 = n3 n2 + n1 = n3 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

slide-17
SLIDE 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

slide-18
SLIDE 18

Direct proof by derivation

Definition: n ∈ Nat

Z ∈ Nat Succ n ∈ Nat S n ∈ Nat Succ Succ Z ∈ Nat S Z ∈ Nat S (S Z) ∈ Nat

Definition: n1 < n2 ⊆ Nat × Nat

Z < S Z S

n1 < n2 n1 < S n2

+1

n1 < n2

S n1 < S n2 +1 S Z < S Z Z < S (S Z) S Z < S (S (S Z))

Reasoning about inductive definitions 18 / 25

slide-19
SLIDE 19

Proof trees

Definition: e ∈ Exp

Axioms: 0 ∈ Nat, 1 ∈ Nat, 2 ∈ Nat, . . .

lit n ∈ Nat

n ∈ Exp

neg

e ∈ Exp

neg e ∈ Exp add e1 ∈ Exp

e2 ∈ Exp

add e1 e2 ∈ Exp add add lit 2 ∈ Nat 2 ∈ Exp lit 3 ∈ Nat 3 ∈ Exp add 2 3 ∈ Exp neg lit 4 ∈ Nat 4 ∈ Exp neg 4 ∈ Exp add (add 2 3) (neg 4) ∈ Exp

Reasoning about inductive definitions 19 / 25

slide-20
SLIDE 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

n ∈ Exp

neg

e ∈ Exp

neg e ∈ Exp add e1 ∈ Exp

e2 ∈ Exp

add e1 e2 ∈ Exp

Reasoning about inductive definitions 20 / 25

slide-21
SLIDE 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

slide-22
SLIDE 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

slide-23
SLIDE 23

Super simple example

Definition: n ∈ Nat ⊆ AST

Z ∈ Nat Succ n ∈ 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 Succ n ∈ Nat S n ∈ Nat S (S n) ∈ Nat

Reasoning about inductive definitions 23 / 25

slide-24
SLIDE 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

slide-25
SLIDE 25

Rule induction

Just like structural induction on inductive data types!

Definition: e ∈ Exp ⊆ AST

n ∈ Nat n ∈ Exp e ∈ Exp

neg e ∈ Exp

e1 ∈ Exp e2 ∈ Exp

add e1 e2 ∈ Exp

Suppose I want to prove property P on all Exps. Just prove:

  • ∀n ∈ Nat, P(n)
  • P(e) → P(neg e)
  • P(e1) → P(e2) → P(add e1 e2)

Reasoning about inductive definitions 25 / 25