32
Logic in Computer Science - Overview Sep 1, 2009 박박박

Logic in Computer Science - Overview Sep 1, 2009 박성우

Embed Size (px)

Citation preview

Page 1: Logic in Computer Science - Overview Sep 1, 2009 박성우

Logic in Computer Science - Overview

Sep 1, 2009

박성우

Page 2: Logic in Computer Science - Overview Sep 1, 2009 박성우

Introduction to Logic

Page 3: Logic in Computer Science - Overview Sep 1, 2009 박성우

3

Logic• Study of propositions and their use in argumentation

– Encyclopædia Britannica

• Propositions

(A Æ B) ¾ (B Æ A)

(A ¾ (B ¾ C)) ¾ ((A Æ B) ¾ C)

A Ç : A((A ¾ B) ¾ A) ¾ A

• Argumentation

(A Æ B) ¾ (B Æ A) is true or false?

(A Æ B) ¾ (B Æ A) is provable or not provable?

Page 4: Logic in Computer Science - Overview Sep 1, 2009 박성우

4

Different Logics• Propositional logic

A ::= P | A ¾ A | A Æ A | A Ç A | :A | T | ?

• First-order logic A ::= ... | P(x) | 8x.A | 9x.A

• Higher-order logic A ::= ... | X | 8X.A | 9X.A

• Modal logic A ::= ... | ¤A | }A – necessity ¤ and possibility }– temporal logic, lax logic, ...

• Substructural logic– linear logic, affine logic, logic of Bunched Implications, ...

Page 5: Logic in Computer Science - Overview Sep 1, 2009 박성우

5

Outline• Methodology

– Model theory ( 모델이론 )– Proof theory ( 증명이론 )

• Philosophy– Classical logic– Constructive logic

Page 6: Logic in Computer Science - Overview Sep 1, 2009 박성우

6

Model Theory vs. Proof TheoryModel theory

• Model I¼ assignment of

truth values

• I ² A• Semantic consequence

A1, ¢¢¢, An ²I CA1, ¢¢¢, An ² C

Proof theory• Inference rules

– use premisesto obtain the conclusion

• Logical entailment A1, ¢¢¢, An ` C

Page 7: Logic in Computer Science - Overview Sep 1, 2009 박성우

7

Disjunction & Implication

Page 8: Logic in Computer Science - Overview Sep 1, 2009 박성우

8

) Truth of A is not affected by truth of B.

Page 9: Logic in Computer Science - Overview Sep 1, 2009 박성우

9

Page 10: Logic in Computer Science - Overview Sep 1, 2009 박성우

10

Proof Theory• Formal systems characterizing logical consequences

• Called 'Proof Theory'– concerned with 'provability'– not concerned with 'satisfiability', for example.

• Key notions– inference rules– axioms– proofs

Page 11: Logic in Computer Science - Overview Sep 1, 2009 박성우

11

• Ai are premises (1 · i · n).• A is a conclusion.• R is the name of the inference rule.

– "If A1 through An (premises) hold, then A (conclusion) holds."

• If n = 0 (no premise), the inference rule is an axiom.• A proof consists of applications of inference rules and

axioms.

Inference Rules, Axioms, Proofs

Page 12: Logic in Computer Science - Overview Sep 1, 2009 박성우

12

Examples• Inference rules

• Axioms

Page 13: Logic in Computer Science - Overview Sep 1, 2009 박성우

13

Three Types of Systems

1. Hilbert-type system (Axiomatic system)

2. Natural deduction system

3. Sequent calculus

Page 14: Logic in Computer Science - Overview Sep 1, 2009 박성우

14

1. Hilbert-type System• Consists of axioms and Modus Ponens

• Axioms

I : A ¾ A

K : A ¾ (B ¾ A)

S : (A ¾ (B ¾ C)) ¾ ((A ¾ B) ¾ (A ¾ C))

• Inference rule

Page 15: Logic in Computer Science - Overview Sep 1, 2009 박성우

15

2. Natural Deduction System• Introduced by Gentzen, 1934• For each connective Æ, Ç, ¾, ...

– introduction rule(s)– elimination rule(s)

Page 16: Logic in Computer Science - Overview Sep 1, 2009 박성우

16

Implication

Page 17: Logic in Computer Science - Overview Sep 1, 2009 박성우

17

3. Sequent Calculus• Also introduced by Gentzen, 1934• Sequent

Page 18: Logic in Computer Science - Overview Sep 1, 2009 박성우

18

Sequent Calculus for Æ, ¾

Page 19: Logic in Computer Science - Overview Sep 1, 2009 박성우

19

Outline• Methodology

– Model theory– Proof theory

• Philosophy– Classical logic ( 고전 논리 )– Constructive logic ( 건설적 논리 , 직관 논리 )

(¼ intuitionistic logic)

Page 20: Logic in Computer Science - Overview Sep 1, 2009 박성우

20

Tautology

Intuitive interpretation of

) Truth of A is not affected by truth of B.

Page 21: Logic in Computer Science - Overview Sep 1, 2009 박성우

21

Tautology

But what is an intuitive interpretation of

Page 22: Logic in Computer Science - Overview Sep 1, 2009 박성우

22

Classical Logic• Concerned with:

– "whether a given proposition is true or not."

• Logic from God's point of view– Every proposition is either true or false.

• Tautologies in classical logic

¼ Logic for mathematics

Page 23: Logic in Computer Science - Overview Sep 1, 2009 박성우

23

Constructive Logic• Concerned with:

– "how a given proposition becomes true."

• Logic from a human's point of view– we know only what we can prove.

• Not true in constructive logic (for all A and B)

¼ Logic for computer science

Page 24: Logic in Computer Science - Overview Sep 1, 2009 박성우

24

Example• Theorem:

There are two irrational numbers a and b such that ab is rational.

• Proof in classical logic:– Let c = p2p2

If c is rational, we take a = b = p2.If c is not rational, we take a = c and b = p2.

• Proof in constructive logic:– a lot more involved, but presents a procedure for

computing a and b.

Page 25: Logic in Computer Science - Overview Sep 1, 2009 박성우

This course is aboutConstructive Proof Theory.

Natural deduction

Curry-Howard isomorphism

First-order logic

Sequent calculus

Classical logic

Automated theorem proving

Page 26: Logic in Computer Science - Overview Sep 1, 2009 박성우

26

사기성 고전논리• P: 달나라에 계수나무가 있다 .• Q: 페르마의 마지막 정리는 참이다 .

• P 가 Q 를 의미하거나 Q 가 P 를 의미한다 .(P ¾ Q) Ç (Q ¾ P)

• 따라서 고전논리는 사기다 .

Page 27: Logic in Computer Science - Overview Sep 1, 2009 박성우

27

Coq• Proof assistant + theorem prover

– Calculus of (Co)inductive construction• type theory with dependent types

– Natural deduction– Constructive logic

• Application– Formalizing mathematics– Formalizing programming language metatheory– Program verification

Page 28: Logic in Computer Science - Overview Sep 1, 2009 박성우

28

Formalizing Mathematics• Ex. Formalizing 100 theorems

– http://www.cs.ru.nl/~freek/100/

– Ex. pythagorean theorem

Theorem main_thm: forall (n p : nat), n * n = double (p * p) -> p = 0.

• Four color theorem

– Proposed in 1852

– Proof formalized in Coq in 2005

5 4

Page 29: Logic in Computer Science - Overview Sep 1, 2009 박성우

29

Programming Language Metatheory

• Ex. POPLmark Challenge– type safety of System F with subtyping

• Type safetyLemma preservation : forall E e e' T,

  typing E e T -> eval e e' -> typing E e' T.

Lemma progress : forall e T,  typing nil e T -> value e \/ exists e', eval e e'.

• Theorem interp_reduces_sol : forall t, eval_many t (interp t).

Page 30: Logic in Computer Science - Overview Sep 1, 2009 박성우

30

Can you trust your compiler?• Critical software requires the correctness of

compilers.– Compilers are far from perfect, producing

unintended, erroneous code.– Unfortunately the verification of compiler is not

trivial at all.

• Formal verification of CompCert (Xavier Leroy, 2006)

– Clight to PowerPC assembly code– Verification in Coq

Page 31: Logic in Computer Science - Overview Sep 1, 2009 박성우

Most of the assignments are Coq Programming.

(+ ML programming assignments)

Page 32: Logic in Computer Science - Overview Sep 1, 2009 박성우

Welcome to the best class in Postech!

Assignment 1 will be out tonight.