CSE321 Programming Languages Inductive Proofs POSTECH March 20

  • Slides: 27
Download presentation
CSE-321 Programming Languages Inductive Proofs 박성우 POSTECH March 20, 2006

CSE-321 Programming Languages Inductive Proofs 박성우 POSTECH March 20, 2006

Inductive Definitions of Syntactic Categories • Natural numbers • Regular binary trees 2

Inductive Definitions of Syntactic Categories • Natural numbers • Regular binary trees 2

Inductive Definitions of Judgments • Judgment • Inference rules 3

Inductive Definitions of Judgments • Judgment • Inference rules 3

Even and Odd Numbers • Judgments • Inference rules 4

Even and Odd Numbers • Judgments • Inference rules 4

Derivable Rule and Admissible Rule • Derivable rule • Admissible rule 5

Derivable Rule and Admissible Rule • Derivable rule • Admissible rule 5

But. . . • What is the point of specifying a system and doing

But. . . • What is the point of specifying a system and doing nothing else? – E. g. , why do we define the two judgments n even and n odd at all? • What if the definition is wrong? – E. g. , what if we mistakenly introduced the rule: • So we need "inductive proofs. " 6

Outline • Inductive proofs – Structural induction – Rule induction 7

Outline • Inductive proofs – Structural induction – Rule induction 7

Structural Induction • Prove a property of a syntactic category by analyzing the structure

Structural Induction • Prove a property of a syntactic category by analyzing the structure of its definition • I want to prove P(n) for every natural number n. – Examples of P(n) • n has a successor. • n is zero or has a predecessor n'. • n is a product of prime numbers. • n is even (which cannot be proven). 8

Structural Induction - Secret Revealed 9

Structural Induction - Secret Revealed 9

Structural Induction on Trees 10

Structural Induction on Trees 10

Example 11

Example 11

Here is the first theorem we prove in this course!

Here is the first theorem we prove in this course!

13

13

Outline • Inductive proofs – Structural induction V – Rule induction 14

Outline • Inductive proofs – Structural induction V – Rule induction 14

Rule Induction • Similar to structural induction but applied to derivation trees • You

Rule Induction • Similar to structural induction but applied to derivation trees • You will be using rule induction millions of times in the study of programming language theory – because programming languages themselves are defined inductively. 15

Rule Induction • A judgment J with two inference rules: 16

Rule Induction • A judgment J with two inference rules: 16

Then what? 17

Then what? 17

18

18

19

19

Are proofs by rule induction always this boring? Are proofs by rule induction always

Are proofs by rule induction always this boring? Are proofs by rule induction always about something obvious?

mparen and lparen • From • We obtain 21

mparen and lparen • From • We obtain 21

22

22

Sometimes we need a lemma if a direct proof attempt fails.

Sometimes we need a lemma if a direct proof attempt fails.

 • But it is not of the form "If J holds, then P(J)

• But it is not of the form "If J holds, then P(J) holds. " • Trick: prove instead • That is, 24

25

25

26

26

Assignments • Assignment 2 – The due date is this Friday, but finish it

Assignments • Assignment 2 – The due date is this Friday, but finish it quick! – Because. . . • Assignment 3 – Programming part • Our first attempt to implement something non-trivial – Huffman Code – Written part • About rule inductions • You are required to typeset your answers. • We accept only PS and PDF files. • Learn to use Latex. 27