CSE-321 Programming Languages Inductive Definitions POSTECH March 15, 2006 박성우.

Post on 03-Jan-2016

213 views 0 download

Transcript of CSE-321 Programming Languages Inductive Definitions POSTECH March 15, 2006 박성우.

CSE-321 Programming Languages

Inductive Definitions

POSTECH

March 15, 2006

박성우

2

Why Inductive Definitions?• Definition of SML

– finite in size

• SML programs– infinite in number

• We need a mechanism by which a finite description of SML produces infinitely many SML programs.

– We need inductive definitions.

3

Outline• Inductive definitions of syntactic categories• Inductive definitions of judgments• Derivable rules and admissible rules• Inductive proofs

4

Natural Numbers

5

Natural Numbers - Examples

6

Regular Binary Trees

7

Mutual Induction

8

Strings of Parentheses

9

Outline• Inductive definitions of syntactic categories V• Inductive definitions of judgments• Derivable rules and admissible rules• Inductive proofs

10

Judgments• An object of knowledge that may or may not be

provable.• Examples

– "1 - 1 is equal to 0."– "1 + 1 is equal to 0."– "It is raining."– "succ succ zero belongs to the syntactic

category nat."– ...

11

Inference Rules

12

Examples of Inference Rules

13

Examples of Axioms

14

Remember:• Judgments make sense only if there are

inference rules for proving or refuting them.

• Example:– Without arithmetic rules, what is the meaning of:

"1 - 1 is equal to 0"?

15

Natural Numbers using Judgments

• Judgment

• Inference rules

16

Metavariables

• is called a metavariable.– It is just a placeholder for a sequence of zero

and succ.– We are not talking about " nat."– We are talking about "succ succ zero nat."

17

Derivation Tree

18

Even and Odd Numbers

19

Regular Binary Trees

20

Full Regular Binary Trees

21

A Full Regular Binary Tree

22

Proof

23

Outline• Inductive definitions of syntactic categories V• Inductive definitions of judgments V• Derivable rules and admissible rules• Inductive proofs

24

Question• We know arithmetic rules.

• But do we use arithmetic rules to calculate 4 * 9?– Why not just use 4 * 9 = 36 from the multiplication

table?

25

• Inference rules

• A derivation tree

• May I use the following rule?

From a Derivation Tree

26

Derivable Rule• There is a derivation tree from the premises to the

conclusion.• May be used as if it were an original inference rule.

27

Is this rule derivable?

• No!– because the premise is always smaller than the

conclusion in the inference rules:

28

But does this rule make sense?

• Yes!– because the only way to prove the premise is by

first proving the conclusion:

29

Admissible Rules• There is a proof that the premise implies the

conclusion.• May be used as if it were an original inference rule

if the system does not change.

30

Derivable Rules vs. Admissible Rules

• Which is stronger?– A derivable rule is an admissible rule?

• Yes• No

– An admissible rule is a derivable rule?• Yes• No

31

• A derivable rule remains valid no matter what.• An admissible rule may be invalidated

when a new inference rule is introduced.

• Now is the rule below still admissible?

Derivable Rules vs. Admissible Rules

32

Homework 1• Good News

– Everyone did a great job!– Solution and statistics will be uploaded today.

• Bad News– Everyone did such a wonderful job that

Assignment 2 will be out tonight.

– Assignment 2 will be due next Monday.

• Good or Bad News– Assignment 2 will be as much fun.– Many problems require a bit/lot of thinking:

• tail recursion• structures and signatures• functional objects