Logic. Part I: Propositional Logic. Max Schäfer. Formosan Summer School on Logic, Language, and Computation 2010

Similar documents
Logic: Propositional Logic (Part I)

Propositional logic (revision) & semantic entailment. p. 1/34

Natural Deduction for Propositional Logic

Description Logics. Foundations of Propositional Logic. franconi. Enrico Franconi

Logic Part I: Classical Logic and Its Semantics

22c:145 Artificial Intelligence

cis32-ai lecture # 18 mon-3-apr-2006

15414/614 Optional Lecture 1: Propositional Logic

Propositional Language - Semantics

Propositional Logic: Part II - Syntax & Proofs 0-0

AI Principles, Semester 2, Week 2, Lecture 5 Propositional Logic and Predicate Logic

UNIT-I: Propositional Logic

Logic Part II: Intuitionistic Logic and Natural Deduction

Math.3336: Discrete Mathematics. Applications of Propositional Logic

Logic: Propositional Logic Truth Tables

INTRODUCTION TO LOGIC. Propositional Logic. Examples of syntactic claims

Description Logics. Deduction in Propositional Logic. franconi. Enrico Franconi

Propositional Logic: Semantics

Logical Structures in Natural Language: Propositional Logic II (Truth Tables and Reasoning

Definition 2. Conjunction of p and q

Propositional Logic Language

Chapter 4: Classical Propositional Semantics

An Introduction to Logic 1.1 ~ 1.4 6/21/04 ~ 6/23/04

Chapter 1: The Logic of Compound Statements. January 7, 2008

Ling 130 Notes: Syntax and Semantics of Propositional Logic

Logic and Proofs. Jan COT3100: Applications of Discrete Structures Jan 2007

Announcements. CS243: Discrete Structures. Propositional Logic II. Review. Operator Precedence. Operator Precedence, cont. Operator Precedence Example

Chapter Summary. Propositional Logic. Predicate Logic. Proofs. The Language of Propositions (1.1) Applications (1.2) Logical Equivalences (1.

CSC165 Mathematical Expression and Reasoning for Computer Science

Language of Propositional Logic

Natural Deduction. Formal Methods in Verification of Computer Systems Jeremy Johnson

Overview. I Review of natural deduction. I Soundness and completeness. I Semantics of propositional formulas. I Soundness proof. I Completeness proof.

Announcements CompSci 102 Discrete Math for Computer Science

COMP219: Artificial Intelligence. Lecture 19: Logic for KR

Automated Solution of the Riddle of Dracula and Other Puzzles

Lecture 2. Logic Compound Statements Conditional Statements Valid & Invalid Arguments Digital Logic Circuits. Reading (Epp s textbook)

Proofs. Joe Patten August 10, 2018

COMP9414: Artificial Intelligence Propositional Logic: Automated Reasoning

03 Propositional Logic II

Introduction to Metalogic

Intelligent Systems. Propositional Logic. Dieter Fensel and Dumitru Roman. Copyright 2008 STI INNSBRUCK

Logic and Inferences

COMP219: Artificial Intelligence. Lecture 19: Logic for KR

Propositional Logic. Testing, Quality Assurance, and Maintenance Winter Prof. Arie Gurfinkel

Announcements. CS311H: Discrete Mathematics. Propositional Logic II. Inverse of an Implication. Converse of a Implication

Overview. Knowledge-Based Agents. Introduction. COMP219: Artificial Intelligence. Lecture 19: Logic for KR

PUZZLE. You meet A, B, and C in the land of knights and knaves. A says Either B and I are both knights or we are both knaves.

Mathematical Logic Prof. Arindama Singh Department of Mathematics Indian Institute of Technology, Madras. Lecture - 15 Propositional Calculus (PC)

a. ~p : if p is T, then ~p is F, and vice versa

Mathematics for linguists

Logic for Computer Science - Week 4 Natural Deduction

Propositional Logic: Review

CHAPTER 1 - LOGIC OF COMPOUND STATEMENTS

Logical Agent & Propositional Logic

Propositional Logics and their Algebraic Equivalents

Mathematics 114L Spring 2018 D.A. Martin. Mathematical Logic

Syntax. Notation Throughout, and when not otherwise said, we assume a vocabulary V = C F P.

Propositional Logic. Logic. Propositional Logic Syntax. Propositional Logic

COM S 330 Homework 02 Solutions. Type your answers to the following questions and submit a PDF file to Blackboard. One page per problem.

Learning Goals of CS245 Logic and Computation

THE LOGIC OF COMPOUND STATEMENTS

Advanced Topics in LP and FP

Artificial Intelligence Knowledge Representation I

Knowledge base (KB) = set of sentences in a formal language Declarative approach to building an agent (or other system):

Chapter 1, Part I: Propositional Logic. With Question/Answer Animations

The Logic of Compound Statements cont.

Logical Agent & Propositional Logic

Truth-Functional Logic

Introduction to Theoretical Computer Science

Foundations of Artificial Intelligence

Foundations of Artificial Intelligence

Logical Agents. Outline

Propositional Logic and Semantics

Logical Agents. Knowledge based agents. Knowledge based agents. Knowledge based agents. The Wumpus World. Knowledge Bases 10/20/14

Logical Structures in Natural Language: First order Logic (FoL)

INTRODUCTION TO PREDICATE LOGIC HUTH AND RYAN 2.1, 2.2, 2.4

It is not the case that ϕ. p = It is not the case that it is snowing = It is not. r = It is not the case that Mary will go to the party =

2. The Logic of Compound Statements Summary. Aaron Tan August 2017

INF3170 Logikk Spring Homework #8 For Friday, March 18

7. Propositional Logic. Wolfram Burgard and Bernhard Nebel

Artificial Intelligence. Propositional Logic. Copyright 2011 Dieter Fensel and Florian Fischer

1.1 Language and Logic

Agenda. Artificial Intelligence. Reasoning in the Wumpus World. The Wumpus World

CS 2800: Logic and Computation Fall 2010 (Lecture 13)

Unit 1. Propositional Logic Reading do all quick-checks Propositional Logic: Ch. 2.intro, 2.2, 2.3, 2.4. Review 2.9

Homework assignment 1: Solutions

Propositional logic. First order logic. Alexander Clark. Autumn 2014

Comp487/587 - Boolean Formulas

Normal Forms of Propositional Logic

Artificial Intelligence. Propositional logic

Warm-Up Problem. Write a Resolution Proof for. Res 1/32

CSC Discrete Math I, Spring Propositional Logic

Discrete Structures of Computer Science Propositional Logic III Rules of Inference

Applied Logic. Lecture 1 - Propositional logic. Marcin Szczuka. Institute of Informatics, The University of Warsaw

Manual of Logical Style (fresh version 2018)

CS1021. Why logic? Logic about inference or argument. Start from assumptions or axioms. Make deductions according to rules of reasoning.

Propositional Logic Arguments (5A) Young W. Lim 10/11/16

Inference in Propositional Logic

Philosophy 220. Truth-Functional Equivalence and Consistency

1.1 Language and Logic

Transcription:

Logic Part I: Propositional Logic Max Schäfer Formosan Summer School on Logic, Language, and Computation 2010 1 / 39

Organisation Lecturer: Lectures: Homework: Exam Max Schäfer (Schaefer) max.schaefer@comlab.ox.ac.uk Monday 28th June, 2:00pm 5:00pm Wednesday 30th June, 9:30am 12:30pm Friday 2nd July, 9:30am 12:30pm after every lecture Friday 9th July, 9:30am 12:30pm material of first two lectures only 2 / 39

What Is Logic? this course is about formal logic investigate principles of reasoning, independently of particular language, mindset, or philosophy different logical systems for different kinds of reasoning three basic components of a logical system: 1. formal language 2. semantics 3. deductive system 3 / 39

Principles of Classical Logic classical logic aims to model reasoning about truth logical formulas represent statements that are either true or false proving a formula means showing that it is true sometimes this is easy 2 Q sometimes it is hard n.n > 2 ( a, b, c.a n + b n = c n ) proving a formula does not make it true, it just demonstrates its truth 4 / 39

Propositional Logic 命題邏輯 5 / 39

Principles of Propositional Logic propositional logic talks about propositions a proposition is a sentence that is either true or false some propositions are atomic; represented by capital letters P, Q, R,... other propositions are composed from simpler ones using connectives such as,,... 6 / 39

The Formal Language of Propositional Logic assume we have an alphabet R of propositional letters, assumed to contain at least the capital letters P, Q, R,... the language of formulas of propositional logic is given by the following grammar: ϕ ::= R ϕ ϕ ϕ ϕ ϕ ϕ 7 / 39

Intuitive Meaning of Propositional Logic formula reading is true if... P P the proposition represented by P is true 假, falsity, bottom never true P Q P 與 Q, conjunction P is true, and Q is also true P Q P 或 Q, disjunction P is true, or Q is true, or both P Q P 就 Q, implication it is not the case that P is true and Q is false 8 / 39

Example Formulas P, Q P P Q P; interpreted as (P Q) P not as P (Q P) P P Q; interpreted as P (P Q) not as (P P) Q Operator Precedence binds tighter than ; tighter than 9 / 39

Example Formulas (ctd.) P Q R; interpreted as (P Q) R not as P (Q R) P Q R; interpreted as (P Q) R not as P (Q R) P P Q; interpreted as P (P Q) not as (P P) Q Operator Associativity and associate to the left, to the right 10 / 39

Defined Connectives and Syntactic Equality other connectives can be defined in terms of the basic ones: ϕ := ϕ P: 非 P, negation ϕ ψ := (ϕ ψ) (ψ ϕ) P Q: P 若且唯若 Q, equivalence, bi-implication := : 真, truth, top and are not real connectives, but only abbreviations; e.g., P P (the same formula) Precedence and Associativity binds tighter than ; less tight than, associates to the left 11 / 39

Truth Value Semantics in general, to know whether a formula ϕ is true, we need to know whether its propositional letters are true need a truth value assignment (interpretation) I : R B, where B := {T, F} given an interpretation I, define the semantics ϕ I of a formula ϕ: 1. for r R: r I := I (r). 2. I := F. 3. ϕ ψ I := T if ϕ I = T and ψ I = T, else ϕ ψ I := F. 4. ϕ ψ I := F if ϕ I = F and ψ I = F, else ϕ ψ I := T. 5. ϕ ψ I := F if ϕ I = T and ψ I = F, else ϕ ψ I := T. 12 / 39

Truth Value Semantics in general, to know whether a formula ϕ is true, we need to know whether its propositional letters are true need a truth value assignment (interpretation) I : R B, where B := {T, F} given an interpretation I, define the semantics ϕ I of a formula ϕ: 1. for r R: r I := I (r). 2. I := F. 3. ϕ ψ I := T if ϕ I = T and ψ I = T, else ϕ ψ I := F. 4. ϕ ψ I := F if ϕ I = F and ψ I = F, else ϕ ψ I := T. 5. ϕ ψ I := F if ϕ I = T and ψ I = F, else ϕ ψ I := T. 12 / 39

Derived Truth Values Lemma For any interpretation I and formulas ϕ and ψ we have I = T. ϕ I = T if ϕ I = F, else ϕ I = F. ϕ ψ I = T if ϕ I = ψ I, else ϕ ψ I = F. 13 / 39

Validity and Satisfiability I = ϕ ( I is a model for ϕ ): ϕ I = T ϕ is satisfiable: there is I with I = ϕ ϕ is valid: for all I we have I = ϕ ϕ ψ ( ϕ entails ψ ): whenever I = ϕ also I = ψ ϕ ψ ( ϕ and ψ are equivalent ): both ϕ ψ and ψ ϕ 14 / 39

Examples P P is valid P P is satisfiable P Q P Q 15 / 39

Properties of Validity and Satisfiability Theorem ϕ is valid iff ϕ is unsatisfiable iff ϕ ; furthermore, ϕ ψ iff ϕ I = ψ I for every interpretation I. Example: ϕ ϕ 16 / 39

Notational Caveat ϕ ψ and ϕ ψ do not mean the same! is syntactic equality; different ways of writing, same formula (P Q) R P Q R P Q (R ) is semantic equality; different formulas, same semantics P P, but not P P 17 / 39

Propositional Letters in a Formula define set PL(ϕ) of propositional letters that occur in a formula ϕ: PL(r) = {r}, for every r R PL( ) = PL(ϕ ψ) = PL(ϕ ψ) = PL(ϕ ψ) = PL(ϕ) PL(ψ) Example PL(((P Q) P) P) = PL( ) = 18 / 39

Propositional Letters in a Formula define set PL(ϕ) of propositional letters that occur in a formula ϕ: PL(r) = {r}, for every r R PL( ) = PL(ϕ ψ) = PL(ϕ ψ) = PL(ϕ ψ) = PL(ϕ) PL(ψ) Example PL(((P Q) P) P) = {P, Q} PL( ) = 18 / 39

Propositional Letters in a Formula define set PL(ϕ) of propositional letters that occur in a formula ϕ: PL(r) = {r}, for every r R PL( ) = PL(ϕ ψ) = PL(ϕ ψ) = PL(ϕ ψ) = PL(ϕ) PL(ψ) Example PL(((P Q) P) P) = {P, Q} PL( ) = 18 / 39

Agreement Lemma Lemma For every formula ϕ and interpretations I 1, I 2 such that I 1 (P) = I 2 (P) for every P PL(ϕ), we have ϕ I1 = ϕ I2 Propositional letters that don t occur in a formula do not matter when determining its semantics. 19 / 39

Truth Tabling for every formula ϕ, PL(ϕ) is finite, say PL(ϕ) = n every one of these n variables could be either true or false; this gives 2 n combinations to know whether ϕ is valid, we only need to try them all out! 20 / 39

Example We can use truth tables to show: = P Q P Q (P Q) P Q P Q P Q P Q P Q P Q P Q P Q (P Q) F F F T T F T T P Q P Q 21 / 39

Example We can use truth tables to show: = P Q P Q (P Q) P Q P Q P Q P Q P Q P Q P Q P Q (P Q) F F F F T F T F F T T T P Q P Q 21 / 39

Example We can use truth tables to show: = P Q P Q (P Q) P Q P Q P Q P Q P Q P Q P Q P Q (P Q) F F F F F T F T T F F T T T T T P Q P Q 21 / 39

Example We can use truth tables to show: = P Q P Q (P Q) P Q P Q P Q P Q P Q P Q P Q P Q (P Q) F F F F T F T F T F T F F T F T T T T T P Q P Q 21 / 39

Example We can use truth tables to show: = P Q P Q (P Q) P Q P Q P Q P Q P Q P Q P Q P Q (P Q) F F F F T T F T F T F F T F F T F F T T T T T T P Q P Q 21 / 39

Example We can use truth tables to show: = P Q P Q (P Q) P Q P Q P Q P Q P Q P Q P Q P Q (P Q) F F F F T T T F T F T F F T T F F T F F T T T T T T T T P Q P Q 21 / 39

Some Properties of Equivalence Equivalence is reflexive: ϕ ϕ symmetric: if ϕ ψ then ψ ϕ transitive: if ϕ ψ and ψ χ then ϕ χ Connection between and = ϕ ψ iff ϕ ψ 22 / 39

Substitution for Propositional Letters We substitute a formula ϑ for all occurrences of r R in a formula ϕ, written as ϕ[ϑ/r] as follows: if ϕ is some r R, then ϕ[ϑ/r] := ϑ if r = r ϕ[ϑ/r] := r otherwise [ϑ/r] := (ψ χ)[ϑ/r] := ψ[ϑ/r] χ[ϑ/r] (ψ χ)[ϑ/r] := ψ[ϑ/r] χ[ϑ/r] (ψ χ)[ϑ/r] := ψ[ϑ/r] χ[ϑ/r]. 23 / 39

Tautologies for free! Substitution in Tautologies If = ϕ then = ϕ[ψ/r]. Once we have shown that = P P, we know that = ϕ ϕ for any ϕ. If ϕ 1 ϕ 2, then also ϕ 1 [ψ/r] ϕ 2 [ψ/r]. 24 / 39

Properties of Substitution (II) Leibniz Law If ψ 1 ψ 2 then ϕ[ψ 1 /r] ϕ[ψ 2 /r]. ϕ (ψ χ) ϕ ( ψ χ) We can eliminate from any formula! 25 / 39

Truth Functions truth function of arity n: function from B n to B formulas give rise to truth functions: for r 1,..., r n R and x 1,..., x n B, define interpretation { xi r = r I r1:=x 1,...,r n:=x n (r) := i F else for formula ϕ with PL(ϕ) = {r 1,..., r n } define truth function f ϕ : B n B by f ϕ (x 1,..., x n ) := ϕ Ir1 :=x 1,...,rn:=xn { T if x1 = x Example: f P Q (x 1, x 2 ) = 2 = T F else 26 / 39

Functional Completeness Functional Completeness A set O of operators is functionally complete if, for every f : B n B, there is a formula ϕ f using only operators from O such that f ϕf = f. {,,, } is functionally complete so are {,, } and {, } but {, } is not 27 / 39

Functional Completeness (ctd.) P Q R f F F F F F F T F F T F F F T T T T F F F T F T T T T F T T T T T ϕ f := P Q R P Q R P Q R P Q R 28 / 39

Functional Completeness (ctd.) P Q R f F F F F F F T F F T F F F T T T T F F F T F T T T T F T T T T T ϕ f := P Q R P Q R P Q R P Q R 28 / 39

Functional Completeness (ctd.) P Q R f F F F F F F T F F T F F F T T T T F F F T F T T T T F T T T T T ϕ f := P Q R P Q R P Q R P Q R 28 / 39

Functional Completeness (ctd.) P Q R f F F F F F F T F F T F F F T T T T F F F T F T T T T F T T T T T ϕ f := P Q R P Q R P Q R P Q R 28 / 39

Functional Completeness (ctd.) P Q R f F F F F F F T F F T F F F T T T T F F F T F T T T T F T T T T T ϕ f := P Q R P Q R P Q R P Q R 28 / 39

Calculational Logic 演算邏輯 29 / 39

Principles of Calculational Logic calculational logic is a deductive system for propositional logic not a new logic idea: calculate with formulas to establish their truth avoid case distinctions, truth tables make use of a set of laws: tautologies of the form ϕ ψ replace equivalent formulas 30 / 39

Example Derivation Laws: Associativity of : ((P Q) R) (P (Q R)) Symmetry of : P Q Q P Unfolding : P P Derivation: (P Q) 31 / 39

Example Derivation Laws: Associativity of : ((P Q) R) (P (Q R)) Symmetry of : P Q Q P Unfolding : (P Q) ((P Q) ) Derivation: (P Q) 31 / 39

Laws: Example Derivation Associativity of : ((P Q) R) (P (Q R)) Symmetry of : P Q Q P Unfolding : (P Q) ((P Q) ) Derivation: (P Q) { Unfolding } (P Q) 31 / 39

Laws: Example Derivation Associativity of : ((P Q) ) (P (Q )) Symmetry of : P Q Q P Unfolding : P P Derivation: (P Q) { Unfolding } (P Q) 31 / 39

Laws: Example Derivation Associativity of : ((P Q) ) (P (Q )) Symmetry of : P Q Q P Unfolding : P P Derivation: (P Q) { Unfolding } (P Q) { Associativity of } P (Q ) 31 / 39

Laws: Example Derivation Associativity of : ((P Q) R) (P (Q R)) Symmetry of : P Q Q P Unfolding : Q Q Derivation: (P Q) { Unfolding } (P Q) { Associativity of } P (Q ) 31 / 39

Laws: Example Derivation Associativity of : ((P Q) R) (P (Q R)) Symmetry of : P Q Q P Unfolding : Q Q Derivation: (P Q) { Unfolding } (P Q) { Associativity of } P (Q ) { Folding } P Q 31 / 39

Laws: Example Derivation Associativity of : ((P Q) R) (P (Q R)) Symmetry of : P Q Q P Unfolding : P P Derivation: (P Q) { Unfolding } P Q { Folding } P Q By transitivity: (P Q) P Q 31 / 39

Laws for and Unfolding : P P Idempotence of : P P P Symmetry of : P Q Q P Associativity of : P (Q R) (P Q) R Distributivity of : P (Q R) P Q P R Excluded Middle: P P Examples: P P, = P 32 / 39

Law for Golden Rule: P Q P Q P Q P Q P Q P Q P Q P Q P Q P Q P Q (P Q) F F F F T T T F T F T F F T T F F T F F T T T T T T T T P Q is true iff P Q and P Q have the same truth value. Example: P (P Q) P 33 / 39

Law for Golden Rule: P Q P Q P Q P Q P Q P Q P Q P Q P Q P Q P Q (P Q) F F F F T T T F T F T F F T T F F T F F T T T T T T T T P Q is true iff P Q and P Q have the same truth value. Example: P (P Q) P 33 / 39

Law for and Substitution Law Unfolding : P Q Q P Q Substitution: (P Q) ϕ[p/r] (P Q) ϕ[q/r] Example: P P, P (P Q) P Q 34 / 39

The Island of Knights and Knaves ( 騎士與惡棍之島 ) on an island, there are two kinds of inhabitants: knights and knaves knives always speak the truth, knaves always lie assume inhabitant A says: If you ask B, he will say he is a knight. what can we infer about A? what about B? 35 / 39

Knights and Knaves in Propositional Logic propositional letters represent identity of inhabitants let A mean A is a knight ; then A is A is a knave statements about who is a knight or knave become propositional formulas assume A says ϕ: if A is a knight, then ϕ is true if A is a knave, then ϕ is false So whenever A says ϕ, we have A ϕ! A says: B says he is a knight. is A B B 36 / 39

Statements about Knights and Knaves A says he is a knight. A says he is a knave. A and B are of the same kind. A says: I am of the same kind as B. 37 / 39

Statements about Knights and Knaves A says he is a knight. A A A says he is a knave. A and B are of the same kind. A says: I am of the same kind as B. 37 / 39

Statements about Knights and Knaves A says he is a knight. A A A says he is a knave. A A A and B are of the same kind. A says: I am of the same kind as B. 37 / 39

Statements about Knights and Knaves A says he is a knight. A A A says he is a knave. A A A and B are of the same kind. A B A says: I am of the same kind as B. 37 / 39

Statements about Knights and Knaves A says he is a knight. A A A says he is a knave. A A A and B are of the same kind. A B A says: I am of the same kind as B. A (A B) 37 / 39

Finding a Treasure on the Island Legend has it there is a treasure on the island. We want to find out whether that is true. Let the propositional letter T stand for there is a treasure. Assume we meet inhabitant A. What question Q should we ask him to find out whether T is true? A answers Q with yes : A Q A answers Q with yes iff there is a treasure: A Q T this is the same as Q (A T ) So we should ask Does there is a treasure on this island equivale that you are a knight? 38 / 39

Finding a Treasure on the Island Legend has it there is a treasure on the island. We want to find out whether that is true. Let the propositional letter T stand for there is a treasure. Assume we meet inhabitant A. What question Q should we ask him to find out whether T is true? A answers Q with yes : A Q A answers Q with yes iff there is a treasure: A Q T this is the same as Q (A T ) So we should ask Does there is a treasure on this island equivale that you are a knight? 38 / 39

Finding a Treasure on the Island Legend has it there is a treasure on the island. We want to find out whether that is true. Let the propositional letter T stand for there is a treasure. Assume we meet inhabitant A. What question Q should we ask him to find out whether T is true? A answers Q with yes : A Q A answers Q with yes iff there is a treasure: A Q T this is the same as Q (A T ) So we should ask Does there is a treasure on this island equivale that you are a knight? 38 / 39

Finding a Treasure on the Island Legend has it there is a treasure on the island. We want to find out whether that is true. Let the propositional letter T stand for there is a treasure. Assume we meet inhabitant A. What question Q should we ask him to find out whether T is true? A answers Q with yes : A Q A answers Q with yes iff there is a treasure: A Q T this is the same as Q (A T ) So we should ask Does there is a treasure on this island equivale that you are a knight? 38 / 39

Some More Logic Puzzles Assume A says any of the following things; what can you deduce about A and B? If I am a knight, then so is B. If B is a knight, then so am I. If I am a knave, then B is a knight. If I am a knight, then B is a knave. If B is a knave, then I am a knave. B says one of us is a knight. 39 / 39