Top Banner
Brief Introduction to Logic
44
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Logic

Brief Introduction to Logic

Page 2: Logic

Outline

• Historical View• Propositional Logic : Syntax • Propositional Logic : Semantics• Satisfiability • Natural Deduction : Proofs.

Page 3: Logic

Historical view

• Philosophical Logic – 500 BC to 19th Century

• Symbolic Logic– Mid to late 19th Century

• Mathematical Logic– Late 19th to mid 20th Century

• Logic in Computer Science

Page 4: Logic

Philosophical Logic

• 500 B.C – 19th Century• Logic dealt with arguments in the natura

l language used by humans.• Example

– All men are motal.– Socrates is a man– Therefore, Socrates is mortal.

Page 5: Logic

Philosophical Logic

• Natural language is very ambiguous.– Eric does not believe that Mary can pass

any test.– I only borrowed your car.– Tom hates Jim and he likes Mary.

• It led to many paradoxes.– “This sentence is a lie.” (The Liar’s Paradox)

Page 6: Logic

The Sophist’s Paradox

• A Sophist is sued for his tuition by the school that educated him. He argued that he must win, since, if he loses, the school didn’t educated him well enough, and doesn’t deserve the money. The school argue that he must loss, since, if he win, he was educated well enough therefore should pay for it.

Page 7: Logic

Symbolic Logic

• Mid to late 19th Century.• Attempted to formulate logic in

terms of a mathematical language• Rules of inference were modeled

after various laws for manipulating algebraic expressions.

Page 8: Logic

Mathematical Logic

• Late 19th to mid 20th Century• Frege proposed logic as a language for mathe

matics in 1879.• With the rigor of this new foundation, Cantor w

as able to analyze the notion of infinity in ways that were previously impossible. (2N is strictly larger than N)

• Russell’s ParadoxT = { S | S S}∉

Page 9: Logic

Logic in Computer Science

• In computer science, we design and study systems through the use of formal languages that can themselves be interpreted by a formal system.– Boolean circuits– Programming languages– Design Validation and verification– AI, Security. Etc.

Page 10: Logic

Logics in Computer Science

• Propositional Logic• First Order Logic• Higher Order Logic• Theory of Construction• Real-time Logic, Temporal Logic• Process Algebras • Linear Logic

Page 11: Logic

Syntax

• The symbol of the language.• Propositional symbols: A, B, C,…• Prop: set of propositional symbols • Connectives: (and), (or), (not), (i

mplies), (is equivalent to), (false).• Parenthesis: (, ).

Page 12: Logic

Formulas

• Backus-Naur Form– Form := Prop | (Form) | (Form o Form).

• Context-Free Grammar– Form Prop,– Form ( Form),– Form (Form o Form)

Page 13: Logic

Formulas (2)

• The set of formulas, Form, is defined as the smallest set of expressions such that:

1.Prop Form2.pForm (p)Form3.p,q Form (p o q) Form

Page 14: Logic

Formulas (3)

• Examples: – (A)– ((A)) – (A (B C))– (A (B C))– Correct expressions of Propositional Logic a

re full of unnecessary parenthesis.

Page 15: Logic

Formulas (4)

• Abbreviations. Let o=, , . We write A o B o C o …

• in the place of (A o (B o (C o …)))

• Thus, we write A B C, ABC, …

• in the place of (A (B C)), (A (B C))

Page 16: Logic

Formulas (5)

• We omit parenthesis whenever we may restore them through operator precedence:

binds more strictly than , , and , bind more strictly than , .

• Thus, we write:A for ((A)), A B for ((A ) B)

A B C for ((AB) C), …

Page 17: Logic

Semantics

• Def) A truth assignment, , is an elements of 2Prop(I.e., 2Prop).

• Two ways to think of truth assignment– 1) X ⊆ Prop– 2) : Prop ↦ {0,1}

• Note : These notions are equivalence.

Page 18: Logic

Philosopher’s view

• |= p means satisfies p or is true of p or

– p holds at or is a model of p

Page 19: Logic

Satisfaction Relation

• Def 1) |= ⊆ (2Prop x Form) |= A if (A) =1 (or, A ) |= p if it is not the case |= p. |= pq if |= p and |= q |= p q if |= p or |= q |= p q if |= p implies |= q |= p q if |= p iff |= q

Page 20: Logic

Satisfaction Relation

• {A,B} |= A B– Iff {A,B} |= A and {A,B} |= B– Iff A {A,B} and B {A,B}

Page 21: Logic

Electrical Engineer’s view

• A mapping of voltages on a wire : Prop {0,1} : {0,1} {0,1}

(0) = 1 and (1) = 0

: {0,1}2 {0,1}(0,0)= (0,1)= (1,0)=0 and (1,1)=1

: {0,1}2 {0,1}(1,1)= (0,1)= (1,0)=1 and (0,0)=0

Page 22: Logic

Semantics

• Def 2)– A() = (A)– (p)() = (p())– (p o q)() = o(p(), q())

• Lemma) Let p Form and 2Prop, then |= p iff p() = 1.

Page 23: Logic

Software Engineer’s view

• Intuition : a formula specifies a set of truth assignments.

• Def 3) Function Models : From 22Prop

– models(A) = { |(A) = 1}, A Prop– models(p) = 2Prop – models(p)– models(pq) = models(p) models(q)– models(pq) = models(p) models(q)– models(pq) = (2Prop – models(p))

models(q)

Page 24: Logic

Theorem

• Let p Form and 2Prop, then the following statements are all true:– 1. |= p– 2. p() = 1– 3. models(p)

Page 25: Logic

Relevance Lemma

• Let’s use AP(p) to denote the set of all propositional symbols occurred in p. Let 1, 2 2Prop, pForm.

• Lemma) if 1|AP(p) = 2|AP(p) , then

1|= p iff 2 |= p

Corollary) | = p iff |AP(p) |= p

Page 26: Logic

Algorithmic Perspective

• Truth Evaluation Problem– Given pForm and 2AP(p), does |=

p ? Does p() = 1 ?• Eval(p, ):

– If p A, return (A).– If p (q), return (Eval(q, ))– If p (q o r), return o(Eval(p), Eval(q))

• Eval uses polynomial time and space.

Page 27: Logic

Extension of |=

• Let T 2Prop, Form

• Def) T |= p if T models(p)– i.e., |= 22Prop X Form

• Def) T |= if T models()– models() = p models(p)– I.e., |= 22Prop X 2Form

Page 28: Logic

Extension of |=

• |= 2Form x 2Form

• Def) 1 |= 2

iff models(1) models(2)

Iff for all 2Prop

if |= 1 then |= 2

Page 29: Logic

Semantic Classification

• A formula p is called valid if models(p) = 2Prop. We denote validity of the formula p by |=p

• A formula p is called satisfiable if models(p) ≠ .

• A formula is not satisfiable is called unsatisfiable or contradiction.

Page 30: Logic

Semantic Classification(II)

• Lemma– A formula p is valid iff p is unsatifiable– p is satisfiable iff p is not valid

• Lemma– p |= q iff |= (p q)

Page 31: Logic

Satisfiability Problem

• Given a p, is p satisfiable?• SAT(p)

B:=0for all 2AP(p)

B = B Eval(p,)endreturn B

• NP-Complete

Page 32: Logic

Proofs

• Formal Proofs. We introduce a notion of formal proof of a formula p: Natural Deduction.

• A formal proof of p is a tree whose root is labeled p and whose children are assumptions p1, p2, p3, … of the rule r we used to conclude p.

Page 33: Logic

Proofs

• Natural Deduction: Rules. For each logical symbol o=, , , , and each formula p with outermost connective o, we give:

• A set of Introduction rules for o, describing under which conditions p is true;

• A set of Elimination rules for o, describing what we may infer from the truth of p.

Page 34: Logic

Proofs

• Natural Deduction: notations for proofs.• Let p be any formula, and be a set of

formulas. We use the notation…p

• abbreviated by |- p, for: • “there is a proof of p whose assumptions are

included in ”.

Page 35: Logic

Proofs

• Natural Deduction: assumptions of a proof

p1 p2 p3 …

r --------------------------------p

• are inductively defined as:

• all assumptions of proofs of p1, p2, p3, …, minus all assumptions we “crossed”.

Page 36: Logic

Proofs

• Identity Principle: The simplest proof is:p

-----p

• having 1 assumption, p, and conclusion the same p.

• We may express it by: |-p, for all p• We call this proof “The Identity

Principle” (from p we derive p).

Page 37: Logic

Proofs

• Rules for • Introduction rules: none ( is always

false).• Elimination rules: from the truth of

(a contradiction) we derive everything:

----p

If |- , then |-p, for all p

Page 38: Logic

Proofs

• Rules for • Introduction rules:

p q--------p q

• If |- p and |- q then |- p q

Page 39: Logic

Proofs

• Elimination rules:p q p q

-------- ------- p q

• If |- p q, then |- p and |- q

Page 40: Logic

Proofs

• Rules for Introduction rule: [p]…q

--------pq

• If ,p |- q, then |-pq • We may drop any number of assumptions

equal to p from the proof of q.

Page 41: Logic

Proofs

• Elimination rule: pq p

---------------- q

• If |-pq and |-p, then |- q.

Page 42: Logic

Proofs

• The only axiom not associated to a connective, nor justified by some Introduction rule, is Double Negation:

[p]….

--- p

• If , p|- , then |-p• We may drop any number of assumptions

equal to p from the proof of q.

Page 43: Logic

Soundness

|- p then |= p

Page 44: Logic

Completeness

|= p then |- p