Inductive Definitions Kangwon National University 임현승 Programming Languages These slides were...

33
Inductive Definitions Kangwon National University 임임임 Programming Languages These slides were originally created by Prof. Sungwoo Park at POSTECH.

description

3 Outline Inductive Definitions of Syntactic Categories Judgments and Inference Rules Derivable Rules and Admissible Rules

Transcript of Inductive Definitions Kangwon National University 임현승 Programming Languages These slides were...

Page 1: Inductive Definitions Kangwon National University 임현승 Programming Languages These slides were originally created by Prof. Sungwoo Park at POSTECH.

Inductive Definitions

Kangwon National University

임현승

Programming Languages

These slides were originally created by Prof. Sungwoo Park at POSTECH.

Page 2: Inductive Definitions Kangwon National University 임현승 Programming Languages These slides were originally created by Prof. Sungwoo Park at POSTECH.

2

Why Inductive Definitions?• Definition of Ocaml

– finite in size• Ocaml programs

– infinite in number

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

– We need inductive definitions.

Page 3: Inductive Definitions Kangwon National University 임현승 Programming Languages These slides were originally created by Prof. Sungwoo Park at POSTECH.

3

Outline• Inductive Definitions of Syntactic Categories• Judgments and Inference Rules• Derivable Rules and Admissible Rules

Page 4: Inductive Definitions Kangwon National University 임현승 Programming Languages These slides were originally created by Prof. Sungwoo Park at POSTECH.

4

Natural Numbers

Page 5: Inductive Definitions Kangwon National University 임현승 Programming Languages These slides were originally created by Prof. Sungwoo Park at POSTECH.

5

Natural Numbers - Examples

Page 6: Inductive Definitions Kangwon National University 임현승 Programming Languages These slides were originally created by Prof. Sungwoo Park at POSTECH.

6

Regular Binary Trees

Page 7: Inductive Definitions Kangwon National University 임현승 Programming Languages These slides were originally created by Prof. Sungwoo Park at POSTECH.

7

Mutual Induction

Page 8: Inductive Definitions Kangwon National University 임현승 Programming Languages These slides were originally created by Prof. Sungwoo Park at POSTECH.

8

Strings of Parentheses

Page 9: Inductive Definitions Kangwon National University 임현승 Programming Languages These slides were originally created by Prof. Sungwoo Park at POSTECH.

9

Strings of Matched Parentheses

Page 10: Inductive Definitions Kangwon National University 임현승 Programming Languages These slides were originally created by Prof. Sungwoo Park at POSTECH.

10

Strings of Matched Parentheses

Page 11: Inductive Definitions Kangwon National University 임현승 Programming Languages These slides were originally created by Prof. Sungwoo Park at POSTECH.

11

Strings of Parentheses

Page 12: Inductive Definitions Kangwon National University 임현승 Programming Languages These slides were originally created by Prof. Sungwoo Park at POSTECH.

12

Outline• Inductive Definitions of Syntactic Categories• Judgments and Inference Rules• Derivable Rules and Admissible Rules

Page 13: Inductive Definitions Kangwon National University 임현승 Programming Languages These slides were originally created by Prof. Sungwoo Park at POSTECH.

13

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."– "S S O belongs to the syntactic category nat."– ...

Page 14: Inductive Definitions Kangwon National University 임현승 Programming Languages These slides were originally created by Prof. Sungwoo Park at POSTECH.

14

Question• "1 - 1 is equal to 0" is a judgment.

• What is the meaning of "1 - 1 is equal to 0"without arithmetic rules?

• Judgments make sense only if there are inference rules for proving or refuting them.

Page 15: Inductive Definitions Kangwon National University 임현승 Programming Languages These slides were originally created by Prof. Sungwoo Park at POSTECH.

15

Inference Rules

Page 16: Inductive Definitions Kangwon National University 임현승 Programming Languages These slides were originally created by Prof. Sungwoo Park at POSTECH.

16

Examples of Inference Rules

Page 17: Inductive Definitions Kangwon National University 임현승 Programming Languages These slides were originally created by Prof. Sungwoo Park at POSTECH.

17

Examples of Axioms

Page 18: Inductive Definitions Kangwon National University 임현승 Programming Languages These slides were originally created by Prof. Sungwoo Park at POSTECH.

18

Natural Numbers using Judgments• Judgment

• Inference rules

Page 19: Inductive Definitions Kangwon National University 임현승 Programming Languages These slides were originally created by Prof. Sungwoo Park at POSTECH.

19

Metavariables

• is called a metavariable.– It is just a placeholder for a sequence of O and S.– We are not talking about " nat."– We are talking about "S S O nat."

Page 20: Inductive Definitions Kangwon National University 임현승 Programming Languages These slides were originally created by Prof. Sungwoo Park at POSTECH.

20

Derivation Tree

Page 21: Inductive Definitions Kangwon National University 임현승 Programming Languages These slides were originally created by Prof. Sungwoo Park at POSTECH.

21

Even and Odd Numbers

Page 22: Inductive Definitions Kangwon National University 임현승 Programming Languages These slides were originally created by Prof. Sungwoo Park at POSTECH.

22

Regular Binary Trees

Page 23: Inductive Definitions Kangwon National University 임현승 Programming Languages These slides were originally created by Prof. Sungwoo Park at POSTECH.

Full Regular Binary Trees• Also known as perfect binary trees

23

Page 24: Inductive Definitions Kangwon National University 임현승 Programming Languages These slides were originally created by Prof. Sungwoo Park at POSTECH.

24

A Full Regular Binary Tree

Page 25: Inductive Definitions Kangwon National University 임현승 Programming Languages These slides were originally created by Prof. Sungwoo Park at POSTECH.

25

Outline• Inductive Definitions of Syntactic Categories• Judgments and Inference Rules• Derivable Rules and Admissible Rules

Page 26: Inductive Definitions Kangwon National University 임현승 Programming Languages These slides were originally created by Prof. Sungwoo Park at POSTECH.

26

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?

Page 27: Inductive Definitions Kangwon National University 임현승 Programming Languages These slides were originally created by Prof. Sungwoo Park at POSTECH.

27

• Inference rules

• A derivation tree

• May I use the following rule?

From a Derivation Tree

Page 28: Inductive Definitions Kangwon National University 임현승 Programming Languages These slides were originally created by Prof. Sungwoo Park at POSTECH.

28

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

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

Page 29: Inductive Definitions Kangwon National University 임현승 Programming Languages These slides were originally created by Prof. Sungwoo Park at POSTECH.

29

Is this rule derivable?

• No!– no derivation tree like

Page 30: Inductive Definitions Kangwon National University 임현승 Programming Languages These slides were originally created by Prof. Sungwoo Park at POSTECH.

30

But does this rule make sense?

• Yes!

Page 31: Inductive Definitions Kangwon National University 임현승 Programming Languages These slides were originally created by Prof. Sungwoo Park at POSTECH.

31

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

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

if the system does not change.

Page 32: Inductive Definitions Kangwon National University 임현승 Programming Languages These slides were originally created by Prof. Sungwoo Park at POSTECH.

32

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

Page 33: Inductive Definitions Kangwon National University 임현승 Programming Languages These slides were originally created by Prof. Sungwoo Park at POSTECH.

33

• 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