640 likes | 1.19k Views
Logic in Computer Science - Overview. 박성우. Sep 1, 2009. Introduction to Logic. 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
E N D
Logic in Computer Science - Overview 박성우 Sep 1, 2009
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?
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, ...
Outline • Methodology • Model theory (모델이론) • Proof theory (증명이론) • Philosophy • Classical logic • Constructive logic
Model theory ModelI¼ assignment of truth values I² A Semantic consequenceA1, ¢¢¢, An²I CA1, ¢¢¢, An² C Proof theory Inference rules use premisesto obtain the conclusion Logical entailment A1, ¢¢¢, An` C Model Theory vs. Proof Theory
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
Inference Rules, Axioms, Proofs • 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.
Examples • Inference rules • Axioms
Three Types of Systems • Hilbert-type system (Axiomatic system) • Natural deduction system • Sequent calculus
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
2. Natural Deduction System • Introduced by Gentzen, 1934 • For each connective Æ, Ç, ¾, ... • introduction rule(s) • elimination rule(s)
3. Sequent Calculus • Also introduced by Gentzen, 1934 • Sequent
Outline • Methodology • Model theory • Proof theory • Philosophy • Classical logic (고전 논리) • Constructive logic (건설적 논리, 직관 논리) (¼intuitionistic logic)
Tautology Intuitive interpretation of ) Truth of A is not affected by truth of B.
Tautology But what is an intuitive interpretation of
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
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
Example • Theorem:There are two irrational numbers a and b such that ab is rational. • Proof in classical logic: • Let c = p2p2If 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
사기성 고전논리 • P: 달나라에 계수나무가 있다. • Q: 페르마의 마지막 정리는 참이다. • P가 Q를 의미하거나 Q가 P를 의미한다.(P¾ Q) Ç (Q ¾ P) • 따라서 고전논리는 사기다.
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
5 4 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
Programming Language Metatheory • Ex. POPLmark Challenge • type safety of System F with subtyping • Type safety Lemma 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).
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.