Upload
iris-norris
View
214
Download
0
Embed Size (px)
Citation preview
Logic in Computer Science - Overview
Sep 1, 2009
박성우
Introduction to Logic
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?
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, ...
5
Outline• Methodology
– Model theory ( 모델이론 )– Proof theory ( 증명이론 )
• Philosophy– Classical logic– Constructive logic
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
7
Disjunction & Implication
8
) Truth of A is not affected by truth of B.
9
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
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
12
Examples• Inference rules
• Axioms
13
Three Types of Systems
1. Hilbert-type system (Axiomatic system)
2. Natural deduction system
3. Sequent calculus
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
15
2. Natural Deduction System• Introduced by Gentzen, 1934• For each connective Æ, Ç, ¾, ...
– introduction rule(s)– elimination rule(s)
16
Implication
17
3. Sequent Calculus• Also introduced by Gentzen, 1934• Sequent
18
Sequent Calculus for Æ, ¾
19
Outline• Methodology
– Model theory– Proof theory
• Philosophy– Classical logic ( 고전 논리 )– Constructive logic ( 건설적 논리 , 직관 논리 )
(¼ intuitionistic logic)
20
Tautology
Intuitive interpretation of
) Truth of A is not affected by truth of B.
21
Tautology
But what is an intuitive interpretation of
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
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
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.
This course is aboutConstructive Proof Theory.
Natural deduction
Curry-Howard isomorphism
First-order logic
Sequent calculus
Classical logic
Automated theorem proving
26
사기성 고전논리• P: 달나라에 계수나무가 있다 .• Q: 페르마의 마지막 정리는 참이다 .
• P 가 Q 를 의미하거나 Q 가 P 를 의미한다 .(P ¾ Q) Ç (Q ¾ P)
• 따라서 고전논리는 사기다 .
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
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
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).
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
Most of the assignments are Coq Programming.
(+ ML programming assignments)
Welcome to the best class in Postech!
Assignment 1 will be out tonight.